/
talosconfig_types.go
112 lines (90 loc) · 3.81 KB
/
talosconfig_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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
package v1alpha3
import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
capiv1 "sigs.k8s.io/cluster-api/api/v1beta1"
)
const (
// ConfigFinalizer allows us to clean up resources before deletion
ConfigFinalizer = "talosconfig.bootstrap.cluster.x-k8s.io"
)
// TalosConfigSpec defines the desired state of TalosConfig
type TalosConfigSpec struct {
TalosVersion string `json:"talosVersion,omitempty"` //talos version formatted like v0.8. used for backwards compatibility
GenerateType string `json:"generateType"` //none,init,controlplane,worker mutually exclusive w/ data
Data string `json:"data,omitempty"`
ConfigPatches []ConfigPatches `json:"configPatches,omitempty"`
// Talos Linux machine configuration strategic merge patch list.
StrategicPatches []string `json:"strategicPatches,omitempty"`
// Set hostname in the machine configuration to some value.
Hostname HostnameSpec `json:"hostname,omitempty"`
// Important: Run "make" to regenerate code after modifying this file
}
// HostnameSource is the definition of hostname source.
type HostnameSource string
// HostnameSourceMachineName sets the hostname in the generated configuration to the machine name.
const HostnameSourceMachineName HostnameSource = "MachineName"
// HostnameSpec defines the hostname source.
type HostnameSpec struct {
// Source of the hostname.
//
// Allowed values: "MachineName" (use linked Machine's Name).
Source HostnameSource `json:"source,omitempty"`
}
// TalosConfigStatus defines the observed state of TalosConfig
type TalosConfigStatus struct {
// Ready indicates the BootstrapData field is ready to be consumed
Ready bool `json:"ready,omitempty"`
// DataSecretName is the name of the secret that stores the bootstrap data script.
// +optional
DataSecretName *string `json:"dataSecretName,omitempty"`
// Talos config will be a string containing the config for download.
//
// Deprecated: please use `<cluster>-talosconfig` secret.
//
// +optional
TalosConfig string `json:"talosConfig,omitempty"`
// FailureReason will be set on non-retryable errors
// +optional
FailureReason string `json:"failureReason,omitempty"`
// FailureMessage will be set on non-retryable errors
// +optional
FailureMessage string `json:"failureMessage,omitempty"`
// ObservedGeneration is the latest generation observed by the controller.
// +optional
ObservedGeneration int64 `json:"observedGeneration,omitempty"`
// Conditions defines current service state of the TalosConfig.
// +optional
Conditions capiv1.Conditions `json:"conditions,omitempty"`
}
// +kubebuilder:object:root=true
// +kubebuilder:resource:path=talosconfigs,scope=Namespaced,categories=cluster-api
// +kubebuilder:storageversion
// +kubebuilder:subresource:status
// TalosConfig is the Schema for the talosconfigs API
type TalosConfig struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Spec TalosConfigSpec `json:"spec,omitempty"`
Status TalosConfigStatus `json:"status,omitempty"`
}
// GetConditions returns the set of conditions for this object.
func (c *TalosConfig) GetConditions() capiv1.Conditions {
return c.Status.Conditions
}
// SetConditions sets the conditions on this object.
func (c *TalosConfig) SetConditions(conditions capiv1.Conditions) {
c.Status.Conditions = conditions
}
// +kubebuilder:object:root=true
// TalosConfigList contains a list of TalosConfig
type TalosConfigList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []TalosConfig `json:"items"`
}
func init() {
SchemeBuilder.Register(&TalosConfig{}, &TalosConfigList{})
}