Skip to content

Commit 0badce2

Browse files
committed
Generate Cluster and Machine resources
1 parent c1b42df commit 0badce2

27 files changed

+1057
-7
lines changed

PROJECT

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,23 @@ layout:
77
- go.kubebuilder.io/v4
88
projectName: cluster-api-provider-scaleway
99
repo: github.com/scaleway/cluster-api-provider-scaleway
10+
resources:
11+
- api:
12+
crdVersion: v1
13+
namespaced: true
14+
controller: true
15+
domain: cluster.x-k8s.io
16+
group: infrastructure
17+
kind: ScalewayCluster
18+
path: github.com/scaleway/cluster-api-provider-scaleway/api/v1alpha1
19+
version: v1alpha1
20+
- api:
21+
crdVersion: v1
22+
namespaced: true
23+
controller: true
24+
domain: cluster.x-k8s.io
25+
group: infrastructure
26+
kind: ScalewayMachine
27+
path: github.com/scaleway/cluster-api-provider-scaleway/api/v1alpha1
28+
version: v1alpha1
1029
version: "3"

api/v1alpha1/groupversion_info.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Package v1alpha1 contains API Schema definitions for the infrastructure v1alpha1 API group.
2+
// +kubebuilder:object:generate=true
3+
// +groupName=infrastructure.cluster.x-k8s.io
4+
package v1alpha1
5+
6+
import (
7+
"k8s.io/apimachinery/pkg/runtime/schema"
8+
"sigs.k8s.io/controller-runtime/pkg/scheme"
9+
)
10+
11+
var (
12+
// GroupVersion is group version used to register these objects.
13+
GroupVersion = schema.GroupVersion{Group: "infrastructure.cluster.x-k8s.io", Version: "v1alpha1"}
14+
15+
// SchemeBuilder is used to add go types to the GroupVersionKind scheme.
16+
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}
17+
18+
// AddToScheme adds the types in this group-version to the given scheme.
19+
AddToScheme = SchemeBuilder.AddToScheme
20+
)

api/v1alpha1/scalewaycluster_types.go

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
package v1alpha1
2+
3+
import (
4+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
5+
)
6+
7+
// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
8+
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.
9+
10+
// ScalewayClusterSpec defines the desired state of ScalewayCluster.
11+
type ScalewayClusterSpec struct {
12+
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
13+
// Important: Run "make" to regenerate code after modifying this file
14+
15+
// Foo is an example field of ScalewayCluster. Edit scalewaycluster_types.go to remove/update
16+
Foo string `json:"foo,omitempty"`
17+
}
18+
19+
// ScalewayClusterStatus defines the observed state of ScalewayCluster.
20+
type ScalewayClusterStatus struct {
21+
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
22+
// Important: Run "make" to regenerate code after modifying this file
23+
}
24+
25+
// +kubebuilder:object:root=true
26+
// +kubebuilder:subresource:status
27+
28+
// ScalewayCluster is the Schema for the scalewayclusters API.
29+
type ScalewayCluster struct {
30+
metav1.TypeMeta `json:",inline"`
31+
metav1.ObjectMeta `json:"metadata,omitempty"`
32+
33+
Spec ScalewayClusterSpec `json:"spec,omitempty"`
34+
Status ScalewayClusterStatus `json:"status,omitempty"`
35+
}
36+
37+
// +kubebuilder:object:root=true
38+
39+
// ScalewayClusterList contains a list of ScalewayCluster.
40+
type ScalewayClusterList struct {
41+
metav1.TypeMeta `json:",inline"`
42+
metav1.ListMeta `json:"metadata,omitempty"`
43+
Items []ScalewayCluster `json:"items"`
44+
}
45+
46+
func init() {
47+
SchemeBuilder.Register(&ScalewayCluster{}, &ScalewayClusterList{})
48+
}

api/v1alpha1/scalewaymachine_types.go

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
package v1alpha1
2+
3+
import (
4+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
5+
)
6+
7+
// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
8+
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.
9+
10+
// ScalewayMachineSpec defines the desired state of ScalewayMachine.
11+
type ScalewayMachineSpec struct {
12+
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
13+
// Important: Run "make" to regenerate code after modifying this file
14+
15+
// Foo is an example field of ScalewayMachine. Edit scalewaymachine_types.go to remove/update
16+
Foo string `json:"foo,omitempty"`
17+
}
18+
19+
// ScalewayMachineStatus defines the observed state of ScalewayMachine.
20+
type ScalewayMachineStatus struct {
21+
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
22+
// Important: Run "make" to regenerate code after modifying this file
23+
}
24+
25+
// +kubebuilder:object:root=true
26+
// +kubebuilder:subresource:status
27+
28+
// ScalewayMachine is the Schema for the scalewaymachines API.
29+
type ScalewayMachine struct {
30+
metav1.TypeMeta `json:",inline"`
31+
metav1.ObjectMeta `json:"metadata,omitempty"`
32+
33+
Spec ScalewayMachineSpec `json:"spec,omitempty"`
34+
Status ScalewayMachineStatus `json:"status,omitempty"`
35+
}
36+
37+
// +kubebuilder:object:root=true
38+
39+
// ScalewayMachineList contains a list of ScalewayMachine.
40+
type ScalewayMachineList struct {
41+
metav1.TypeMeta `json:",inline"`
42+
metav1.ListMeta `json:"metadata,omitempty"`
43+
Items []ScalewayMachine `json:"items"`
44+
}
45+
46+
func init() {
47+
SchemeBuilder.Register(&ScalewayMachine{}, &ScalewayMachineList{})
48+
}

api/v1alpha1/zz_generated.deepcopy.go

Lines changed: 187 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: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ import (
2020
"sigs.k8s.io/controller-runtime/pkg/metrics/filters"
2121
metricsserver "sigs.k8s.io/controller-runtime/pkg/metrics/server"
2222
"sigs.k8s.io/controller-runtime/pkg/webhook"
23+
24+
infrastructurev1alpha1 "github.com/scaleway/cluster-api-provider-scaleway/api/v1alpha1"
25+
"github.com/scaleway/cluster-api-provider-scaleway/internal/controller"
2326
// +kubebuilder:scaffold:imports
2427
)
2528

@@ -31,6 +34,7 @@ var (
3134
func init() {
3235
utilruntime.Must(clientgoscheme.AddToScheme(scheme))
3336

37+
utilruntime.Must(infrastructurev1alpha1.AddToScheme(scheme))
3438
// +kubebuilder:scaffold:scheme
3539
}
3640

@@ -182,6 +186,20 @@ func main() {
182186
os.Exit(1)
183187
}
184188

189+
if err = (&controller.ScalewayClusterReconciler{
190+
Client: mgr.GetClient(),
191+
Scheme: mgr.GetScheme(),
192+
}).SetupWithManager(mgr); err != nil {
193+
setupLog.Error(err, "unable to create controller", "controller", "ScalewayCluster")
194+
os.Exit(1)
195+
}
196+
if err = (&controller.ScalewayMachineReconciler{
197+
Client: mgr.GetClient(),
198+
Scheme: mgr.GetScheme(),
199+
}).SetupWithManager(mgr); err != nil {
200+
setupLog.Error(err, "unable to create controller", "controller", "ScalewayMachine")
201+
os.Exit(1)
202+
}
185203
// +kubebuilder:scaffold:builder
186204

187205
if metricsCertWatcher != nil {

0 commit comments

Comments
 (0)