Skip to content

Commit 7efb0f7

Browse files
committed
fixup! refactor: provider an entrypoint to the infra provider meta handlers
1 parent f7ea208 commit 7efb0f7

File tree

4 files changed

+8
-25
lines changed

4 files changed

+8
-25
lines changed

pkg/handlers/nutanix/handlers.go

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,30 +10,23 @@ import (
1010
"github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/common/pkg/capi/clustertopology/handlers"
1111
nutanixclusterconfig "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/pkg/handlers/nutanix/clusterconfig"
1212
nutanixmutation "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/pkg/handlers/nutanix/mutation"
13-
"github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/pkg/handlers/nutanix/mutation/controlplaneendpoint"
1413
nutanixworkerconfig "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/pkg/handlers/nutanix/workerconfig"
1514
"github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/pkg/handlers/options"
1615
)
1716

18-
type Handlers struct {
19-
nutanixControlPlaneEndpointConfig *controlplaneendpoint.Config
20-
}
17+
type Handlers struct{}
2118

2219
func New(
23-
globalOptions *options.GlobalOptions,
20+
_ *options.GlobalOptions,
2421
) *Handlers {
25-
return &Handlers{
26-
nutanixControlPlaneEndpointConfig: &controlplaneendpoint.Config{
27-
GlobalOptions: globalOptions,
28-
},
29-
}
22+
return &Handlers{}
3023
}
3124

3225
func (h *Handlers) AllHandlers(mgr manager.Manager) []handlers.Named {
3326
return []handlers.Named{
3427
nutanixclusterconfig.NewVariable(),
3528
nutanixworkerconfig.NewVariable(),
36-
nutanixmutation.MetaPatchHandler(mgr, h.nutanixControlPlaneEndpointConfig),
29+
nutanixmutation.MetaPatchHandler(mgr),
3730
nutanixmutation.MetaWorkerPatchHandler(mgr),
3831
}
3932
}

pkg/handlers/nutanix/mutation/controlplaneendpoint/inject.go

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,41 +22,31 @@ import (
2222
"github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/common/pkg/capi/clustertopology/patches/selectors"
2323
"github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/common/pkg/capi/clustertopology/variables"
2424
"github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/pkg/handlers/generic/clusterconfig"
25-
"github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/pkg/handlers/options"
2625
)
2726

2827
const (
2928
// VariableName is the external patch variable name.
3029
VariableName = "controlPlaneEndpoint"
3130
)
3231

33-
type Config struct {
34-
*options.GlobalOptions
35-
}
36-
3732
type nutanixControlPlaneEndpoint struct {
38-
config *Config
39-
4033
variableName string
4134
variableFieldPath []string
4235
}
4336

44-
func NewPatch(cfg *Config) *nutanixControlPlaneEndpoint {
37+
func NewPatch() *nutanixControlPlaneEndpoint {
4538
return newNutanixControlPlaneEndpoint(
46-
cfg,
4739
clusterconfig.MetaVariableName,
4840
v1alpha1.NutanixVariableName,
4941
VariableName,
5042
)
5143
}
5244

5345
func newNutanixControlPlaneEndpoint(
54-
cfg *Config,
5546
variableName string,
5647
variableFieldPath ...string,
5748
) *nutanixControlPlaneEndpoint {
5849
return &nutanixControlPlaneEndpoint{
59-
config: cfg,
6050
variableName: variableName,
6151
variableFieldPath: variableFieldPath,
6252
}

pkg/handlers/nutanix/mutation/controlplaneendpoint/inject_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ func TestControlPlaneEndpointPatch(t *testing.T) {
2626

2727
var _ = Describe("Generate Nutanix ControlPlane endpoint patches", func() {
2828
patchGenerator := func() mutation.GeneratePatches {
29-
return mutation.NewMetaGeneratePatchesHandler("", helpers.TestEnv.Client, NewPatch(nil)).(mutation.GeneratePatches)
29+
return mutation.NewMetaGeneratePatchesHandler("", helpers.TestEnv.Client, NewPatch()).(mutation.GeneratePatches)
3030
}
3131

3232
testDefs := []capitest.PatchTestDef{

pkg/handlers/nutanix/mutation/metapatch_handler.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ import (
1515
)
1616

1717
// MetaPatchHandler returns a meta patch handler for mutating CAPX clusters.
18-
func MetaPatchHandler(mgr manager.Manager, cfg *controlplaneendpoint.Config) handlers.Named {
18+
func MetaPatchHandler(mgr manager.Manager) handlers.Named {
1919
patchHandlers := append(
2020
[]mutation.MetaMutator{
21-
controlplaneendpoint.NewPatch(cfg),
21+
controlplaneendpoint.NewPatch(),
2222
prismcentralendpoint.NewPatch(),
2323
machinedetails.NewControlPlanePatch(),
2424
},

0 commit comments

Comments
 (0)