Skip to content

Commit e202fd3

Browse files
Add OCI source for provider ConfigMap preparation
Signed-off-by: Danil-Grigorev <[email protected]>
1 parent 7d39b00 commit e202fd3

19 files changed

+331
-24
lines changed

api/v1alpha1/provider_conversion.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ func (src *BootstrapProvider) ConvertTo(dstRaw conversion.Hub) error {
4646

4747
dst.Spec.ManifestPatches = restored.Spec.ManifestPatches
4848
dst.Spec.AdditionalDeployments = restored.Spec.AdditionalDeployments
49+
dst.Spec.FetchConfig.OCI = restored.Spec.FetchConfig.OCI
4950

5051
return nil
5152
}
@@ -108,6 +109,7 @@ func (src *ControlPlaneProvider) ConvertTo(dstRaw conversion.Hub) error {
108109

109110
dst.Spec.ManifestPatches = restored.Spec.ManifestPatches
110111
dst.Spec.AdditionalDeployments = restored.Spec.AdditionalDeployments
112+
dst.Spec.FetchConfig.OCI = restored.Spec.FetchConfig.OCI
111113

112114
return nil
113115
}
@@ -170,6 +172,7 @@ func (src *CoreProvider) ConvertTo(dstRaw conversion.Hub) error {
170172

171173
dst.Spec.ManifestPatches = restored.Spec.ManifestPatches
172174
dst.Spec.AdditionalDeployments = restored.Spec.AdditionalDeployments
175+
dst.Spec.FetchConfig.OCI = restored.Spec.FetchConfig.OCI
173176

174177
return nil
175178
}
@@ -232,6 +235,7 @@ func (src *InfrastructureProvider) ConvertTo(dstRaw conversion.Hub) error {
232235

233236
dst.Spec.ManifestPatches = restored.Spec.ManifestPatches
234237
dst.Spec.AdditionalDeployments = restored.Spec.AdditionalDeployments
238+
dst.Spec.FetchConfig.OCI = restored.Spec.FetchConfig.OCI
235239

236240
return nil
237241
}
@@ -495,6 +499,10 @@ func Convert_v1alpha2_ContainerSpec_To_v1alpha1_ContainerSpec(in *operatorv1.Con
495499
return nil
496500
}
497501

502+
func Convert_v1alpha2_FetchConfiguration_To_v1alpha1_FetchConfiguration(in *operatorv1.FetchConfiguration, out *FetchConfiguration, s apimachineryconversion.Scope) error {
503+
return autoConvert_v1alpha2_FetchConfiguration_To_v1alpha1_FetchConfiguration(in, out, s)
504+
}
505+
498506
func toImageMeta(imageURL string) *ImageMeta {
499507
im := ImageMeta{}
500508

api/v1alpha1/provider_conversion_test.go

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,28 +40,28 @@ func TestFuzzyConversion(t *testing.T) {
4040
Scheme: scheme,
4141
Hub: &operatorv1.CoreProvider{},
4242
Spoke: &CoreProvider{},
43-
FuzzerFuncs: []fuzzer.FuzzerFuncs{imageMetaFuzzFunc, imageURLFuzzFunc, secretConfigFuzzFunc},
43+
FuzzerFuncs: []fuzzer.FuzzerFuncs{imageMetaFuzzFunc, imageURLFuzzFunc, ociFuzzFunc, secretConfigFuzzFunc},
4444
}))
4545

4646
t.Run("for ControlPlaneProvider", utilconversion.FuzzTestFunc(utilconversion.FuzzTestFuncInput{
4747
Scheme: scheme,
4848
Hub: &operatorv1.ControlPlaneProvider{},
4949
Spoke: &ControlPlaneProvider{},
50-
FuzzerFuncs: []fuzzer.FuzzerFuncs{imageMetaFuzzFunc, imageURLFuzzFunc, secretConfigFuzzFunc},
50+
FuzzerFuncs: []fuzzer.FuzzerFuncs{imageMetaFuzzFunc, imageURLFuzzFunc, ociFuzzFunc, secretConfigFuzzFunc},
5151
}))
5252

5353
t.Run("for BootstrapProvider", utilconversion.FuzzTestFunc(utilconversion.FuzzTestFuncInput{
5454
Scheme: scheme,
5555
Hub: &operatorv1.BootstrapProvider{},
5656
Spoke: &BootstrapProvider{},
57-
FuzzerFuncs: []fuzzer.FuzzerFuncs{imageMetaFuzzFunc, imageURLFuzzFunc, secretConfigFuzzFunc},
57+
FuzzerFuncs: []fuzzer.FuzzerFuncs{imageMetaFuzzFunc, imageURLFuzzFunc, ociFuzzFunc, secretConfigFuzzFunc},
5858
}))
5959

6060
t.Run("for InfrastructureProvider", utilconversion.FuzzTestFunc(utilconversion.FuzzTestFuncInput{
6161
Scheme: scheme,
6262
Hub: &operatorv1.InfrastructureProvider{},
6363
Spoke: &InfrastructureProvider{},
64-
FuzzerFuncs: []fuzzer.FuzzerFuncs{imageMetaFuzzFunc, imageURLFuzzFunc, secretConfigFuzzFunc},
64+
FuzzerFuncs: []fuzzer.FuzzerFuncs{imageMetaFuzzFunc, imageURLFuzzFunc, ociFuzzFunc, secretConfigFuzzFunc},
6565
}))
6666
}
6767

@@ -80,6 +80,18 @@ func secretConfigFuzzer(in *operatorv1.SecretReference, c fuzz.Continue) {
8080
}
8181
}
8282

83+
func ociFuzzFunc(_ runtimeserializer.CodecFactory) []interface{} {
84+
return []interface{}{
85+
ociFuzzer,
86+
}
87+
}
88+
89+
func ociFuzzer(in *operatorv1.FetchConfiguration, c fuzz.Continue) {
90+
c.FuzzNoCustom(in)
91+
92+
in.OCI = ""
93+
}
94+
8395
func imageURLFuzzFunc(_ runtimeserializer.CodecFactory) []interface{} {
8496
return []interface{}{
8597
imageURLFuzzer,

api/v1alpha1/zz_generated.conversion.go

Lines changed: 24 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/v1alpha2/provider_types.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,12 @@ type FetchConfiguration struct {
218218
// +optional
219219
URL string `json:"url,omitempty"`
220220

221+
// OCI to be used for fetching the provider’s components and metadata from an OCI artifact.
222+
// You must set `providerSpec.Version` field for operator to pick up desired version of the release from GitHub.
223+
// If the providerSpec.Version is missing, latest provider version from clusterctl defaults is used.
224+
// +optional
225+
OCI string `json:"oci,omitempty"`
226+
221227
// Selector to be used for fetching provider’s components and metadata from
222228
// ConfigMaps stored inside the cluster. Each ConfigMap is expected to contain
223229
// components and metadata for a specific version only.

config/crd/bases/operator.cluster.x-k8s.io_addonproviders.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2750,6 +2750,12 @@ spec:
27502750
For example, the infrastructure name `aws` will fetch artifacts from
27512751
https://github.com/kubernetes-sigs/cluster-api-provider-aws/releases.
27522752
properties:
2753+
oci:
2754+
description: |-
2755+
OCI to be used for fetching the provider’s components and metadata from an OCI artifact.
2756+
You must set `providerSpec.Version` field for operator to pick up desired version of the release from GitHub.
2757+
If the providerSpec.Version is missing, latest provider version from clusterctl defaults is used.
2758+
type: string
27532759
selector:
27542760
description: |-
27552761
Selector to be used for fetching provider’s components and metadata from

config/crd/bases/operator.cluster.x-k8s.io_bootstrapproviders.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4380,6 +4380,12 @@ spec:
43804380
For example, the infrastructure name `aws` will fetch artifacts from
43814381
https://github.com/kubernetes-sigs/cluster-api-provider-aws/releases.
43824382
properties:
4383+
oci:
4384+
description: |-
4385+
OCI to be used for fetching the provider’s components and metadata from an OCI artifact.
4386+
You must set `providerSpec.Version` field for operator to pick up desired version of the release from GitHub.
4387+
If the providerSpec.Version is missing, latest provider version from clusterctl defaults is used.
4388+
type: string
43834389
selector:
43844390
description: |-
43854391
Selector to be used for fetching provider’s components and metadata from

config/crd/bases/operator.cluster.x-k8s.io_controlplaneproviders.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4382,6 +4382,12 @@ spec:
43824382
For example, the infrastructure name `aws` will fetch artifacts from
43834383
https://github.com/kubernetes-sigs/cluster-api-provider-aws/releases.
43844384
properties:
4385+
oci:
4386+
description: |-
4387+
OCI to be used for fetching the provider’s components and metadata from an OCI artifact.
4388+
You must set `providerSpec.Version` field for operator to pick up desired version of the release from GitHub.
4389+
If the providerSpec.Version is missing, latest provider version from clusterctl defaults is used.
4390+
type: string
43854391
selector:
43864392
description: |-
43874393
Selector to be used for fetching provider’s components and metadata from

config/crd/bases/operator.cluster.x-k8s.io_coreproviders.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4380,6 +4380,12 @@ spec:
43804380
For example, the infrastructure name `aws` will fetch artifacts from
43814381
https://github.com/kubernetes-sigs/cluster-api-provider-aws/releases.
43824382
properties:
4383+
oci:
4384+
description: |-
4385+
OCI to be used for fetching the provider’s components and metadata from an OCI artifact.
4386+
You must set `providerSpec.Version` field for operator to pick up desired version of the release from GitHub.
4387+
If the providerSpec.Version is missing, latest provider version from clusterctl defaults is used.
4388+
type: string
43834389
selector:
43844390
description: |-
43854391
Selector to be used for fetching provider’s components and metadata from

config/crd/bases/operator.cluster.x-k8s.io_infrastructureproviders.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4382,6 +4382,12 @@ spec:
43824382
For example, the infrastructure name `aws` will fetch artifacts from
43834383
https://github.com/kubernetes-sigs/cluster-api-provider-aws/releases.
43844384
properties:
4385+
oci:
4386+
description: |-
4387+
OCI to be used for fetching the provider’s components and metadata from an OCI artifact.
4388+
You must set `providerSpec.Version` field for operator to pick up desired version of the release from GitHub.
4389+
If the providerSpec.Version is missing, latest provider version from clusterctl defaults is used.
4390+
type: string
43854391
selector:
43864392
description: |-
43874393
Selector to be used for fetching provider’s components and metadata from

config/crd/bases/operator.cluster.x-k8s.io_ipamproviders.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2750,6 +2750,12 @@ spec:
27502750
For example, the infrastructure name `aws` will fetch artifacts from
27512751
https://github.com/kubernetes-sigs/cluster-api-provider-aws/releases.
27522752
properties:
2753+
oci:
2754+
description: |-
2755+
OCI to be used for fetching the provider’s components and metadata from an OCI artifact.
2756+
You must set `providerSpec.Version` field for operator to pick up desired version of the release from GitHub.
2757+
If the providerSpec.Version is missing, latest provider version from clusterctl defaults is used.
2758+
type: string
27532759
selector:
27542760
description: |-
27552761
Selector to be used for fetching provider’s components and metadata from

0 commit comments

Comments
 (0)