Skip to content

Commit 26f425e

Browse files
committed
operator-sdk create api --group assistant --version v1beta1 --kind OpenStackAssistant
1 parent 79cd52d commit 26f425e

16 files changed

Lines changed: 601 additions & 1 deletion

PROJECT

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,4 +111,13 @@ resources:
111111
webhooks:
112112
validation: true
113113
webhookVersion: v1
114+
- api:
115+
crdVersion: v1
116+
namespaced: true
117+
controller: true
118+
domain: openstack.org
119+
group: assistant
120+
kind: OpenStackAssistant
121+
path: github.com/openstack-k8s-operators/openstack-operator/api/assistant/v1beta1
122+
version: v1beta1
114123
version: "3"
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
Copyright 2022.
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 contains API Schema definitions for the assistant v1beta1 API group.
18+
// +kubebuilder:object:generate=true
19+
// +groupName=assistant.openstack.org
20+
package v1beta1
21+
22+
import (
23+
"k8s.io/apimachinery/pkg/runtime/schema"
24+
"sigs.k8s.io/controller-runtime/pkg/scheme"
25+
)
26+
27+
var (
28+
// GroupVersion is group version used to register these objects.
29+
GroupVersion = schema.GroupVersion{Group: "assistant.openstack.org", Version: "v1beta1"}
30+
31+
// SchemeBuilder is used to add go types to the GroupVersionKind scheme.
32+
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}
33+
34+
// AddToScheme adds the types in this group-version to the given scheme.
35+
AddToScheme = SchemeBuilder.AddToScheme
36+
)
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/*
2+
Copyright 2022.
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+
// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
24+
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.
25+
26+
// OpenStackAssistantSpec defines the desired state of OpenStackAssistant.
27+
type OpenStackAssistantSpec struct {
28+
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
29+
// Important: Run "make" to regenerate code after modifying this file
30+
31+
// Foo is an example field of OpenStackAssistant. Edit openstackassistant_types.go to remove/update
32+
Foo string `json:"foo,omitempty"`
33+
}
34+
35+
// OpenStackAssistantStatus defines the observed state of OpenStackAssistant.
36+
type OpenStackAssistantStatus struct {
37+
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
38+
// Important: Run "make" to regenerate code after modifying this file
39+
}
40+
41+
// +kubebuilder:object:root=true
42+
// +kubebuilder:subresource:status
43+
44+
// OpenStackAssistant is the Schema for the openstackassistants API.
45+
type OpenStackAssistant struct {
46+
metav1.TypeMeta `json:",inline"`
47+
metav1.ObjectMeta `json:"metadata,omitempty"`
48+
49+
Spec OpenStackAssistantSpec `json:"spec,omitempty"`
50+
Status OpenStackAssistantStatus `json:"status,omitempty"`
51+
}
52+
53+
// +kubebuilder:object:root=true
54+
55+
// OpenStackAssistantList contains a list of OpenStackAssistant.
56+
type OpenStackAssistantList struct {
57+
metav1.TypeMeta `json:",inline"`
58+
metav1.ListMeta `json:"metadata,omitempty"`
59+
Items []OpenStackAssistant `json:"items"`
60+
}
61+
62+
func init() {
63+
SchemeBuilder.Register(&OpenStackAssistant{}, &OpenStackAssistantList{})
64+
}

api/assistant/v1beta1/zz_generated.deepcopy.go

Lines changed: 114 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: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ import (
5151
backupcontroller "github.com/openstack-k8s-operators/openstack-operator/internal/controller/backup"
5252

5353
webhookbackupv1beta1 "github.com/openstack-k8s-operators/openstack-operator/internal/webhook/backup/v1beta1"
54+
assistantv1beta1 "github.com/openstack-k8s-operators/openstack-operator/api/assistant/v1beta1"
55+
assistantcontroller "github.com/openstack-k8s-operators/openstack-operator/internal/controller/assistant"
56+
5457
// +kubebuilder:scaffold:imports
5558
certmgrv1 "github.com/cert-manager/cert-manager/pkg/apis/certmanager/v1"
5659
k8s_networkv1 "github.com/k8snetworkplumbingwg/network-attachment-definition-client/pkg/apis/k8s.cni.cncf.io/v1"
@@ -136,6 +139,7 @@ func init() {
136139
utilruntime.Must(topologyv1.AddToScheme(scheme))
137140
utilruntime.Must(watcherv1.AddToScheme(scheme))
138141
utilruntime.Must(backupv1beta1.AddToScheme(scheme))
142+
utilruntime.Must(assistantv1beta1.AddToScheme(scheme))
139143
// +kubebuilder:scaffold:scheme
140144
}
141145

@@ -431,6 +435,13 @@ func main() {
431435
}
432436
checker = mgr.GetWebhookServer().StartedChecker()
433437
}
438+
if err := (&assistantcontroller.OpenStackAssistantReconciler{
439+
Client: mgr.GetClient(),
440+
Scheme: mgr.GetScheme(),
441+
}).SetupWithManager(mgr); err != nil {
442+
setupLog.Error(err, "unable to create controller", "controller", "OpenStackAssistant")
443+
os.Exit(1)
444+
}
434445
// +kubebuilder:scaffold:builder
435446

436447
if metricsCertWatcher != nil {

config/crd/kustomization.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ resources:
1010
- bases/dataplane.openstack.org_openstackdataplanedeployments.yaml
1111
#- bases/operator.openstack.org_openstacks.yaml
1212
- bases/backup.openstack.org_openstackbackupconfigs.yaml
13+
- bases/assistant.openstack.org_openstackassistants.yaml
1314
# +kubebuilder:scaffold:crdkustomizeresource
1415

1516
patches:

config/default/kustomization.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ namePrefix: openstack-operator-
1515
# someName: someValue
1616

1717
resources:
18-
#- ../crd
18+
- ../crd
1919
#- ../rbac
2020
- ../manager
2121
# [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix including the one in
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# This rule is not used by the project openstack-operator itself.
2+
# It is provided to allow the cluster admin to help manage permissions for users.
3+
#
4+
# Grants full permissions ('*') over assistant.openstack.org.
5+
# This role is intended for users authorized to modify roles and bindings within the cluster,
6+
# enabling them to delegate specific permissions to other users or groups as needed.
7+
8+
apiVersion: rbac.authorization.k8s.io/v1
9+
kind: ClusterRole
10+
metadata:
11+
labels:
12+
app.kubernetes.io/name: openstack-operator
13+
app.kubernetes.io/managed-by: kustomize
14+
name: assistant-openstackassistant-admin-role
15+
rules:
16+
- apiGroups:
17+
- assistant.openstack.org
18+
resources:
19+
- openstackassistants
20+
verbs:
21+
- '*'
22+
- apiGroups:
23+
- assistant.openstack.org
24+
resources:
25+
- openstackassistants/status
26+
verbs:
27+
- get
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# This rule is not used by the project openstack-operator itself.
2+
# It is provided to allow the cluster admin to help manage permissions for users.
3+
#
4+
# Grants permissions to create, update, and delete resources within the assistant.openstack.org.
5+
# This role is intended for users who need to manage these resources
6+
# but should not control RBAC or manage permissions for others.
7+
8+
apiVersion: rbac.authorization.k8s.io/v1
9+
kind: ClusterRole
10+
metadata:
11+
labels:
12+
app.kubernetes.io/name: openstack-operator
13+
app.kubernetes.io/managed-by: kustomize
14+
name: assistant-openstackassistant-editor-role
15+
rules:
16+
- apiGroups:
17+
- assistant.openstack.org
18+
resources:
19+
- openstackassistants
20+
verbs:
21+
- create
22+
- delete
23+
- get
24+
- list
25+
- patch
26+
- update
27+
- watch
28+
- apiGroups:
29+
- assistant.openstack.org
30+
resources:
31+
- openstackassistants/status
32+
verbs:
33+
- get
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# This rule is not used by the project openstack-operator itself.
2+
# It is provided to allow the cluster admin to help manage permissions for users.
3+
#
4+
# Grants read-only access to assistant.openstack.org resources.
5+
# This role is intended for users who need visibility into these resources
6+
# without permissions to modify them. It is ideal for monitoring purposes and limited-access viewing.
7+
8+
apiVersion: rbac.authorization.k8s.io/v1
9+
kind: ClusterRole
10+
metadata:
11+
labels:
12+
app.kubernetes.io/name: openstack-operator
13+
app.kubernetes.io/managed-by: kustomize
14+
name: assistant-openstackassistant-viewer-role
15+
rules:
16+
- apiGroups:
17+
- assistant.openstack.org
18+
resources:
19+
- openstackassistants
20+
verbs:
21+
- get
22+
- list
23+
- watch
24+
- apiGroups:
25+
- assistant.openstack.org
26+
resources:
27+
- openstackassistants/status
28+
verbs:
29+
- get

0 commit comments

Comments
 (0)