Skip to content

Commit 81413e7

Browse files
committed
added placeholders for nutanix related clusterConfig
1 parent e150be4 commit 81413e7

22 files changed

+1818
-2
lines changed

api/v1alpha1/clusterconfig_types.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ type ClusterConfigSpec struct {
4040
AWS *AWSSpec `json:"aws,omitempty"`
4141
// +optional
4242
Docker *DockerSpec `json:"docker,omitempty"`
43+
// +optional
44+
Nutanix *NutanixSpec `json:"nutanix,omitempty"`
4345

4446
GenericClusterConfig `json:",inline"`
4547

@@ -71,6 +73,16 @@ func (s ClusterConfigSpec) VariableSchema() clusterv1.VariableSchema { //nolint:
7173
}.VariableSchema().OpenAPIV3Schema,
7274
},
7375
)
76+
case s.Nutanix != nil:
77+
maps.Copy(
78+
clusterConfigProps.OpenAPIV3Schema.Properties,
79+
map[string]clusterv1.JSONSchemaProps{
80+
"nutanix": NutanixSpec{}.VariableSchema().OpenAPIV3Schema,
81+
"controlPlane": NodeConfigSpec{
82+
Nutanix: &NutanixNodeSpec{},
83+
}.VariableSchema().OpenAPIV3Schema,
84+
},
85+
)
7486
}
7587

7688
return clusterConfigProps

api/v1alpha1/node_types.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ type NodeConfigSpec struct {
2929
AWS *AWSNodeSpec `json:"aws,omitempty"`
3030
// +optional
3131
Docker *DockerNodeSpec `json:"docker,omitempty"`
32+
// +optional
33+
Nutanix *NutanixNodeSpec `json:"nutanix,omitempty"`
3234
}
3335

3436
func (s NodeConfigSpec) VariableSchema() clusterv1.VariableSchema {
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Copyright 2023 D2iQ, Inc. All rights reserved.
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
package v1alpha1
5+
6+
import (
7+
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
8+
)
9+
10+
type NutanixSpec struct{}
11+
12+
func (NutanixSpec) VariableSchema() clusterv1.VariableSchema {
13+
return clusterv1.VariableSchema{
14+
OpenAPIV3Schema: clusterv1.JSONSchemaProps{
15+
Description: "Nutanix cluster configuration",
16+
Type: "object",
17+
Properties: map[string]clusterv1.JSONSchemaProps{},
18+
},
19+
}
20+
}

api/v1alpha1/nutanix_node_types.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// Copyright 2023 D2iQ, Inc. All rights reserved.
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
package v1alpha1
5+
6+
import (
7+
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
8+
)
9+
10+
type NutanixNodeSpec struct {
11+
// +optional
12+
CustomImage *OCIImage `json:"customImage,omitempty"`
13+
}
14+
15+
func (NutanixNodeSpec) VariableSchema() clusterv1.VariableSchema {
16+
return clusterv1.VariableSchema{
17+
OpenAPIV3Schema: clusterv1.JSONSchemaProps{
18+
Description: "Nutanix Node configuration",
19+
Type: "object",
20+
Properties: map[string]clusterv1.JSONSchemaProps{
21+
"customImage": OCIImage("").VariableSchema().OpenAPIV3Schema,
22+
},
23+
},
24+
}
25+
}

api/v1alpha1/zz_generated.deepcopy.go

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

cmd/main.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ import (
3333
dockerclusterconfig "github.com/d2iq-labs/capi-runtime-extensions/pkg/handlers/docker/clusterconfig"
3434
dockermutation "github.com/d2iq-labs/capi-runtime-extensions/pkg/handlers/docker/mutation"
3535
dockerworkerconfig "github.com/d2iq-labs/capi-runtime-extensions/pkg/handlers/docker/workerconfig"
36+
nutanixclusterconfig "github.com/d2iq-labs/capi-runtime-extensions/pkg/handlers/nutanix/clusterconfig"
37+
nutanixmutation "github.com/d2iq-labs/capi-runtime-extensions/pkg/handlers/nutanix/mutation"
38+
nutanixworkerconfig "github.com/d2iq-labs/capi-runtime-extensions/pkg/handlers/nutanix/workerconfig"
3639
"github.com/d2iq-labs/capi-runtime-extensions/pkg/handlers/generic/lifecycle"
3740
)
3841

@@ -132,10 +135,20 @@ func main() {
132135
dockermutation.MetaWorkerPatchHandler(),
133136
}
134137

138+
// dnutanixMetaHandlers combines all Nutanix patch and variable handlers under a single handler.
139+
// It allows to specify configuration under a single variable.
140+
nutanixMetaHandlers := []handlers.Named{
141+
nutanixclusterconfig.NewVariable(),
142+
nutanixworkerconfig.NewVariable(),
143+
nutanixmutation.MetaPatchHandler(mgr),
144+
nutanixmutation.MetaWorkerPatchHandler(),
145+
}
146+
135147
var allHandlers []handlers.Named
136148
allHandlers = append(allHandlers, genericLifecycleHandlers.AllHandlers(mgr)...)
137149
allHandlers = append(allHandlers, awsMetaHandlers...)
138150
allHandlers = append(allHandlers, dockerMetaHandlers...)
151+
allHandlers = append(allHandlers, nutanixMetaHandlers...)
139152

140153
runtimeWebhookServer := server.NewServer(runtimeWebhookServerOpts, allHandlers...)
141154

common/go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ require (
5454
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
5555
github.com/modern-go/reflect2 v1.0.2 // indirect
5656
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
57+
github.com/nutanix-cloud-native/prism-go-client v0.3.4 // indirect
5758
github.com/pkg/errors v0.9.1 // indirect
5859
github.com/pmezard/go-difflib v1.0.0 // indirect
5960
github.com/prometheus/client_golang v1.18.0 // indirect

0 commit comments

Comments
 (0)