Skip to content

Commit 28e3622

Browse files
committed
include the LC and LM templates
1 parent 463f60c commit 28e3622

8 files changed

+1914
-0
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
Copyright 2023 Akamai Technologies, Inc.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package v1beta1
18+
19+
// Hub marks LinodeClusterTemplate as a conversion hub.
20+
func (*LinodeClusterTemplate) Hub() {}
21+
22+
// Hub marks LinodeClusterTemplateList as a conversion hub.
23+
func (*LinodeClusterTemplateList) Hub() {}
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
/*
2+
Copyright 2023 Akamai Technologies, Inc.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package v1beta1
18+
19+
import (
20+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
21+
)
22+
23+
// LinodeClusterTemplateSpec defines the desired state of LinodeClusterTemplate
24+
type LinodeClusterTemplateSpec struct {
25+
// template defines the specification for a LinodeCluster.
26+
// +required
27+
Template LinodeClusterTemplateResource `json:"template,omitzero"`
28+
}
29+
30+
// LinodeClusterTemplateResource describes the data needed to create a LinodeCluster from a template.
31+
type LinodeClusterTemplateResource struct {
32+
// spec is the specification of the LinodeCluster.
33+
// +required
34+
Spec LinodeClusterSpec `json:"spec,omitzero,omitempty"`
35+
}
36+
37+
// +kubebuilder:object:root=true
38+
// +kubebuilder:resource:path=linodeclustertemplates,scope=Namespaced,categories=cluster-api,shortName=lct
39+
// +kubebuilder:storageversion
40+
41+
// LinodeClusterTemplate is the Schema for the linodeclustertemplates API
42+
type LinodeClusterTemplate struct {
43+
metav1.TypeMeta `json:",inline"`
44+
// metadata is the standard object's metadata.
45+
// +optional
46+
metav1.ObjectMeta `json:"metadata,omitempty"`
47+
48+
// spec is the desired state of the LinodeClusterTemplate.
49+
// +optional
50+
Spec LinodeClusterTemplateSpec `json:"spec,omitzero,omitempty"`
51+
}
52+
53+
// +kubebuilder:object:root=true
54+
55+
// LinodeClusterTemplateList contains a list of LinodeClusterTemplate
56+
type LinodeClusterTemplateList struct {
57+
metav1.TypeMeta `json:",inline"`
58+
// metadata is the standard object's metadata.
59+
metav1.ListMeta `json:"metadata,omitempty"`
60+
// items is a list of LinodeClusterTemplate.
61+
Items []LinodeClusterTemplate `json:"items"`
62+
}
63+
64+
func init() {
65+
SchemeBuilder.Register(&LinodeClusterTemplate{}, &LinodeClusterTemplateList{})
66+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
Copyright 2023 Akamai Technologies, Inc.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package v1beta1
18+
19+
// Hub marks LinodeMachineTemplate as a conversion hub.
20+
func (*LinodeMachineTemplate) Hub() {}
21+
22+
// Hub marks LinodeMachineTemplateList as a conversion hub.
23+
func (*LinodeMachineTemplateList) Hub() {}
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
/*
2+
Copyright 2023 Akamai Technologies, Inc.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package v1beta1
18+
19+
import (
20+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
21+
)
22+
23+
// LinodeMachineTemplateSpec defines the desired state of LinodeMachineTemplate
24+
type LinodeMachineTemplateSpec struct {
25+
// template defines the specification for a LinodeMachine.
26+
// +required
27+
Template LinodeMachineTemplateResource `json:"template,omitempty,omitzero"`
28+
}
29+
30+
// LinodeMachineTemplateStatus defines the observed state of LinodeMachineTemplate
31+
// It is used to store the status of the LinodeMachineTemplate, such as tags.
32+
type LinodeMachineTemplateStatus struct {
33+
// conditions define the current service state of the LinodeMachineTemplate
34+
// +optional
35+
// +listType=map
36+
// +listMapKey=type
37+
// +patchStrategy=merge
38+
// +patchMergeKey=type
39+
Conditions []metav1.Condition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type" protobuf:"bytes,1,rep,name=conditions"`
40+
41+
// tags that are currently applied to the LinodeMachineTemplate.
42+
// +optional
43+
// +listType=set
44+
Tags []string `json:"tags,omitempty"`
45+
46+
// firewallID that is currently applied to the LinodeMachineTemplate.
47+
// +optional
48+
FirewallID int `json:"firewallID,omitempty"`
49+
}
50+
51+
// LinodeMachineTemplateResource describes the data needed to create a LinodeMachine from a template.
52+
type LinodeMachineTemplateResource struct {
53+
// spec is the specification of the desired behavior of the machine.
54+
// +required
55+
Spec LinodeMachineSpec `json:"spec,omitempty,omitzero"`
56+
}
57+
58+
// +kubebuilder:object:root=true
59+
// +kubebuilder:storageversion
60+
// +kubebuilder:resource:path=linodemachinetemplates,scope=Namespaced,categories=cluster-api,shortName=lmt
61+
// +kubebuilder:subresource:status
62+
// +kubebuilder:metadata:labels="clusterctl.cluster.x-k8s.io/move-hierarchy=true"
63+
64+
// LinodeMachineTemplate is the Schema for the linodemachinetemplates API
65+
type LinodeMachineTemplate struct {
66+
metav1.TypeMeta `json:",inline"`
67+
// metadata is the standard object's metadata.
68+
// +optional
69+
metav1.ObjectMeta `json:"metadata,omitempty"`
70+
71+
// spec is the desired state of the LinodeMachineTemplate.
72+
// +optional
73+
Spec LinodeMachineTemplateSpec `json:"spec,omitzero,omitempty"`
74+
75+
// status is the observed state of the LinodeMachineTemplate.
76+
// +optional
77+
Status LinodeMachineTemplateStatus `json:"status,omitempty"`
78+
}
79+
80+
func (lmt *LinodeMachineTemplate) SetCondition(cond metav1.Condition) {
81+
if cond.LastTransitionTime.IsZero() {
82+
cond.LastTransitionTime = metav1.Now()
83+
}
84+
for i := range lmt.Status.Conditions {
85+
if lmt.Status.Conditions[i].Type == cond.Type {
86+
lmt.Status.Conditions[i] = cond
87+
88+
return
89+
}
90+
}
91+
lmt.Status.Conditions = append(lmt.Status.Conditions, cond)
92+
}
93+
94+
// +kubebuilder:object:root=true
95+
96+
// LinodeMachineTemplateList contains a list of LinodeMachineTemplate
97+
type LinodeMachineTemplateList struct {
98+
metav1.TypeMeta `json:",inline"`
99+
100+
// metadata is the standard object's metadata.
101+
// +optional
102+
metav1.ListMeta `json:"metadata,omitempty"`
103+
104+
// items is a list of LinodeMachineTemplate.
105+
// +optional
106+
Items []LinodeMachineTemplate `json:"items"`
107+
}
108+
109+
func init() {
110+
SchemeBuilder.Register(&LinodeMachineTemplate{}, &LinodeMachineTemplateList{})
111+
}

0 commit comments

Comments
 (0)