Skip to content

Commit 5ef97c7

Browse files
committed
fixup! feat: new imageRepository patch
1 parent afa9208 commit 5ef97c7

File tree

9 files changed

+36
-30
lines changed

9 files changed

+36
-30
lines changed

api/v1alpha1/clusterconfig_types.go

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ type ClusterConfigSpec struct {
2626
// Important: Run "make" to regenerate code after modifying this file
2727

2828
// +optional
29-
ImageRepository *ImageRepository `json:"imageRepository,omitempty"`
29+
KubernetesImageRepository *KubernetesImageRepository `json:"kubernetesImageRepository,omitempty"`
3030

3131
// +optional
3232
Proxy *HTTPProxy `json:"proxy,omitempty"`
@@ -41,27 +41,30 @@ func (ClusterConfigSpec) VariableSchema() clusterv1.VariableSchema {
4141
Description: "Cluster configuration",
4242
Type: "object",
4343
Properties: map[string]clusterv1.JSONSchemaProps{
44-
"imageRepository": ImageRepository("").VariableSchema().OpenAPIV3Schema,
44+
"kubernetesImageRepository": KubernetesImageRepository(
45+
"",
46+
).VariableSchema().
47+
OpenAPIV3Schema,
4548
"proxy": HTTPProxy{}.VariableSchema().OpenAPIV3Schema,
4649
"extraAPIServerCertSANs": ExtraAPIServerCertSANs{}.VariableSchema().OpenAPIV3Schema,
4750
},
4851
},
4952
}
5053
}
5154

52-
// ImageRepository required for overriding Kubernetes image repository.
53-
type ImageRepository string
55+
// KubernetesImageRepository required for overriding Kubernetes image repository.
56+
type KubernetesImageRepository string
5457

55-
func (ImageRepository) VariableSchema() clusterv1.VariableSchema {
58+
func (KubernetesImageRepository) VariableSchema() clusterv1.VariableSchema {
5659
return clusterv1.VariableSchema{
5760
OpenAPIV3Schema: clusterv1.JSONSchemaProps{
58-
Description: "Sets the imageRepository used for the KubeadmControlPlane.",
61+
Description: "Sets the Kubernetes imageRepository used for the KubeadmControlPlane.",
5962
Type: "string",
6063
},
6164
}
6265
}
6366

64-
func (v ImageRepository) String() string {
67+
func (v KubernetesImageRepository) String() string {
6568
return string(v)
6669
}
6770

api/v1alpha1/zz_generated.deepcopy.go

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

cmd/main.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import (
3131
"github.com/d2iq-labs/capi-runtime-extensions/pkg/handlers/cni/calico"
3232
"github.com/d2iq-labs/capi-runtime-extensions/pkg/handlers/extraapiservercertsans"
3333
"github.com/d2iq-labs/capi-runtime-extensions/pkg/handlers/httpproxy"
34-
"github.com/d2iq-labs/capi-runtime-extensions/pkg/handlers/imagerepository"
34+
"github.com/d2iq-labs/capi-runtime-extensions/pkg/handlers/kubernetesimagerepository"
3535
"github.com/d2iq-labs/capi-runtime-extensions/pkg/handlers/servicelbgc"
3636
)
3737

@@ -126,8 +126,8 @@ func main() {
126126

127127
auditpolicy.NewPatch(),
128128

129-
imagerepository.NewVariable(),
130-
imagerepository.NewPatch(imagerepository.VariableName),
129+
kubernetesimagerepository.NewVariable(),
130+
kubernetesimagerepository.NewPatch(kubernetesimagerepository.VariableName),
131131

132132
clusterconfig.NewVariable(),
133133
mutation.NewMetaGeneratePatchesHandler(
@@ -138,7 +138,10 @@ func main() {
138138
extraapiservercertsans.VariableName,
139139
),
140140
auditpolicy.NewPatch(),
141-
imagerepository.NewPatch(clusterconfig.VariableName, imagerepository.VariableName),
141+
kubernetesimagerepository.NewPatch(
142+
clusterconfig.VariableName,
143+
kubernetesimagerepository.VariableName,
144+
),
142145
),
143146
)
144147
if err := mgr.Add(runtimeWebhookServer); err != nil {

docs/content/cluster-config.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ spec:
3535
variables:
3636
- name: clusterConfig
3737
value:
38-
imageRepository: "my-registry.io/my-org/my-repo"
38+
kubernetesImageRepository: "my-registry.io/my-org/my-repo"
3939
extraAPIServerCertSANs:
4040
- a.b.c.example.com
4141
- d.e.f.example.com

docs/content/image-repository.md renamed to docs/content/kubernetes-image-repository.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: "Image Repository"
2+
title: "Kubernete Image Repository"
33
---
44

55
Override the container image repository used when pulling Kubernetes images.
@@ -19,7 +19,7 @@ spec:
1919
discoverVariablesExtension: "imagerepositoryvars.capi-runtime-extensions"
2020
```
2121
22-
On the cluster resource then specify desired image repository value:
22+
On the cluster resource then specify desired Kubernetes image repository value:
2323
2424
```yaml
2525
apiVersion: cluster.x-k8s.io/v1beta1
@@ -29,7 +29,7 @@ metadata:
2929
spec:
3030
topology:
3131
variables:
32-
- name: imageRepository
32+
- name: kubernetesImageRepository
3333
value: "my-registry.io/my-org/my-repo"
3434
```
3535

pkg/handlers/imagerepository/inject.go renamed to pkg/handlers/kubernetesimagerepository/inject.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright 2023 D2iQ, Inc. All rights reserved.
22
// SPDX-License-Identifier: Apache-2.0
33

4-
package imagerepository
4+
package kubernetesimagerepository
55

66
import (
77
"context"
@@ -82,7 +82,7 @@ func (h *imageRepositoryPatchHandler) GeneratePatches(
8282
"holderRef", holderRef,
8383
)
8484

85-
imageRepositoryVar, found, err := variables.Get[v1alpha1.ImageRepository](
85+
imageRepositoryVar, found, err := variables.Get[v1alpha1.KubernetesImageRepository](
8686
vars,
8787
h.variableName,
8888
h.variableFieldPath...,
@@ -91,7 +91,7 @@ func (h *imageRepositoryPatchHandler) GeneratePatches(
9191
return err
9292
}
9393
if !found {
94-
log.V(5).Info("imageRepository variable not defined")
94+
log.V(5).Info("kubernetesImageRepository variable not defined")
9595
return nil
9696
}
9797

@@ -110,7 +110,7 @@ func (h *imageRepositoryPatchHandler) GeneratePatches(
110110
log.WithValues(
111111
"patchedObjectKind", obj.GetObjectKind().GroupVersionKind().String(),
112112
"patchedObjectName", client.ObjectKeyFromObject(obj),
113-
).Info("setting imageRepository in kubeadm config spec")
113+
).Info("setting kubernetesImageRepository in kubeadm config spec")
114114

115115
if obj.Spec.Template.Spec.KubeadmConfigSpec.ClusterConfiguration == nil {
116116
obj.Spec.Template.Spec.KubeadmConfigSpec.ClusterConfiguration = &bootstrapv1.ClusterConfiguration{}

pkg/handlers/imagerepository/inject_test.go renamed to pkg/handlers/kubernetesimagerepository/inject_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright 2023 D2iQ, Inc. All rights reserved.
22
// SPDX-License-Identifier: Apache-2.0
33

4-
package imagerepository
4+
package kubernetesimagerepository
55

66
import (
77
"testing"
@@ -22,11 +22,11 @@ func TestGeneratePatches(t *testing.T) {
2222
Name: "unset variable",
2323
},
2424
capitest.PatchTestDef{
25-
Name: "imageRepository set",
25+
Name: "kubernetesImageRepository set",
2626
Vars: []runtimehooksv1.Variable{
2727
capitest.VariableWithValue(
2828
VariableName,
29-
v1alpha1.ImageRepository("my-registry.io/my-org/my-repo"),
29+
v1alpha1.KubernetesImageRepository("my-registry.io/my-org/my-repo"),
3030
),
3131
},
3232
RequestItem: capitest.NewKubeadmControlPlaneTemplateRequestItem(),

pkg/handlers/imagerepository/variables.go renamed to pkg/handlers/kubernetesimagerepository/variables.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright 2023 D2iQ, Inc. All rights reserved.
22
// SPDX-License-Identifier: Apache-2.0
33

4-
package imagerepository
4+
package kubernetesimagerepository
55

66
import (
77
"context"
@@ -21,7 +21,7 @@ var (
2121

2222
const (
2323
// VariableName is http proxy external patch variable name.
24-
VariableName = "imageRepository"
24+
VariableName = "kubernetesImageRepository"
2525

2626
// HandlerNameVariable is the name of the variable handler.
2727
HandlerNameVariable = "ImageRepositoryVars"
@@ -45,7 +45,7 @@ func (h *imageRepositoryVariableHandler) DiscoverVariables(
4545
resp.Variables = append(resp.Variables, clusterv1.ClusterClassVariable{
4646
Name: VariableName,
4747
Required: false,
48-
Schema: v1alpha1.ImageRepository("").VariableSchema(),
48+
Schema: v1alpha1.KubernetesImageRepository("").VariableSchema(),
4949
})
5050
resp.SetStatus(runtimehooksv1.ResponseStatusSuccess)
5151
}

pkg/handlers/imagerepository/variables_test.go renamed to pkg/handlers/kubernetesimagerepository/variables_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright 2023 D2iQ, Inc. All rights reserved.
22
// SPDX-License-Identifier: Apache-2.0
33

4-
package imagerepository
4+
package kubernetesimagerepository
55

66
import (
77
"testing"
@@ -16,7 +16,7 @@ func TestVariableValidation(t *testing.T) {
1616
capitest.ValidateDiscoverVariables(
1717
t,
1818
VariableName,
19-
ptr.To(v1alpha1.ImageRepository("").VariableSchema()),
19+
ptr.To(v1alpha1.KubernetesImageRepository("").VariableSchema()),
2020
NewVariable,
2121
capitest.VariableTestDef{
2222
Name: "set",

0 commit comments

Comments
 (0)