This repository has been archived by the owner on Apr 11, 2024. It is now read-only.
/
node_types.go
71 lines (58 loc) · 1.71 KB
/
node_types.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
// Copyright 2023 D2iQ, Inc. All rights reserved.
// SPDX-License-Identifier: Apache-2.0
package v1alpha1
import (
"maps"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
)
//+kubebuilder:object:root=true
// NodeConfig is the Schema for the workerconfigs API.
type NodeConfig struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
//+optional
Spec NodeConfigSpec `json:"spec,omitempty"`
}
// NodeConfigSpec defines the desired state of NodeConfig.
// Place any configuration that can be applied to individual Nodes here.
// Otherwise, it should go into the ClusterConfigSpec.
type NodeConfigSpec struct {
// +optional
AWS *AWSNodeSpec `json:"aws,omitempty"`
// +optional
Docker *DockerNodeSpec `json:"docker,omitempty"`
}
func (s NodeConfigSpec) VariableSchema() clusterv1.VariableSchema {
nodeConfigProps := GenericNodeConfig{}.VariableSchema()
switch {
case s.AWS != nil:
maps.Copy(
nodeConfigProps.OpenAPIV3Schema.Properties,
map[string]clusterv1.JSONSchemaProps{
AWSVariableName: AWSNodeSpec{}.VariableSchema().OpenAPIV3Schema,
},
)
case s.Docker != nil:
maps.Copy(
nodeConfigProps.OpenAPIV3Schema.Properties,
map[string]clusterv1.JSONSchemaProps{
"docker": DockerNodeSpec{}.VariableSchema().OpenAPIV3Schema,
},
)
}
return nodeConfigProps
}
type GenericNodeConfig struct{}
func (GenericNodeConfig) VariableSchema() clusterv1.VariableSchema {
return clusterv1.VariableSchema{
OpenAPIV3Schema: clusterv1.JSONSchemaProps{
Description: "Node configuration",
Type: "object",
Properties: map[string]clusterv1.JSONSchemaProps{},
},
}
}
func init() {
SchemeBuilder.Register(&NodeConfig{})
}