Skip to content

Commit c6f9c4a

Browse files
committed
Scaffold org.openstack.operator.OpenStack
operator-sdk create api --group operator --version v1beta1 --kind OpenStack Jira: OSPRH-11244
1 parent dfc0ead commit c6f9c4a

17 files changed

+578
-0
lines changed

PROJECT

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,4 +77,13 @@ resources:
7777
kind: OpenStackDataPlaneDeployment
7878
path: github.com/openstack-k8s-operators/openstack-operator/apis/dataplane/v1beta1
7979
version: v1beta1
80+
- api:
81+
crdVersion: v1
82+
namespaced: true
83+
controller: true
84+
domain: openstack.org
85+
group: operator
86+
kind: OpenStack
87+
path: github.com/openstack-k8s-operators/openstack-operator/apis/operator/v1beta1
88+
version: v1beta1
8089
version: "3"
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
---
2+
apiVersion: apiextensions.k8s.io/v1
3+
kind: CustomResourceDefinition
4+
metadata:
5+
annotations:
6+
controller-gen.kubebuilder.io/version: v0.11.1
7+
creationTimestamp: null
8+
name: openstacks.operator.openstack.org
9+
spec:
10+
group: operator.openstack.org
11+
names:
12+
kind: OpenStack
13+
listKind: OpenStackList
14+
plural: openstacks
15+
singular: openstack
16+
scope: Namespaced
17+
versions:
18+
- name: v1beta1
19+
schema:
20+
openAPIV3Schema:
21+
properties:
22+
apiVersion:
23+
type: string
24+
kind:
25+
type: string
26+
metadata:
27+
type: object
28+
spec:
29+
properties:
30+
foo:
31+
type: string
32+
type: object
33+
status:
34+
type: object
35+
type: object
36+
served: true
37+
storage: true
38+
subresources:
39+
status: {}
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 operator v1beta1 API group
18+
// +kubebuilder:object:generate=true
19+
// +groupName=operator.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: "operator.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+
// OpenStackSpec defines the desired state of OpenStack
27+
type OpenStackSpec 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 OpenStack. Edit openstack_types.go to remove/update
32+
Foo string `json:"foo,omitempty"`
33+
}
34+
35+
// OpenStackStatus defines the observed state of OpenStack
36+
type OpenStackStatus 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+
// OpenStack is the Schema for the openstacks API
45+
type OpenStack struct {
46+
metav1.TypeMeta `json:",inline"`
47+
metav1.ObjectMeta `json:"metadata,omitempty"`
48+
49+
Spec OpenStackSpec `json:"spec,omitempty"`
50+
Status OpenStackStatus `json:"status,omitempty"`
51+
}
52+
53+
//+kubebuilder:object:root=true
54+
55+
// OpenStackList contains a list of OpenStack
56+
type OpenStackList struct {
57+
metav1.TypeMeta `json:",inline"`
58+
metav1.ListMeta `json:"metadata,omitempty"`
59+
Items []OpenStack `json:"items"`
60+
}
61+
62+
func init() {
63+
SchemeBuilder.Register(&OpenStack{}, &OpenStackList{})
64+
}

apis/operator/v1beta1/zz_generated.deepcopy.go

Lines changed: 115 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
---
2+
apiVersion: apiextensions.k8s.io/v1
3+
kind: CustomResourceDefinition
4+
metadata:
5+
annotations:
6+
controller-gen.kubebuilder.io/version: v0.11.1
7+
creationTimestamp: null
8+
name: openstacks.operator.openstack.org
9+
spec:
10+
group: operator.openstack.org
11+
names:
12+
kind: OpenStack
13+
listKind: OpenStackList
14+
plural: openstacks
15+
singular: openstack
16+
scope: Namespaced
17+
versions:
18+
- name: v1beta1
19+
schema:
20+
openAPIV3Schema:
21+
properties:
22+
apiVersion:
23+
type: string
24+
kind:
25+
type: string
26+
metadata:
27+
type: object
28+
spec:
29+
properties:
30+
foo:
31+
type: string
32+
type: object
33+
status:
34+
type: object
35+
type: object
36+
served: true
37+
storage: true
38+
subresources:
39+
status: {}

config/crd/kustomization.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ resources:
88
- bases/dataplane.openstack.org_openstackdataplanenodesets.yaml
99
- bases/dataplane.openstack.org_openstackdataplaneservices.yaml
1010
- bases/dataplane.openstack.org_openstackdataplanedeployments.yaml
11+
- bases/operator.openstack.org_openstacks.yaml
1112
#+kubebuilder:scaffold:crdkustomizeresource
1213

1314
patchesStrategicMerge:
@@ -16,13 +17,15 @@ patchesStrategicMerge:
1617
#- patches/webhook_in_core_openstackcontrolplanes.yaml
1718
#- patches/webhook_in_openstackclients.yaml
1819
#- patches/webhook_in_openstackversions.yaml
20+
#- patches/webhook_in_openstacks.yaml
1921
#+kubebuilder:scaffold:crdkustomizewebhookpatch
2022

2123
# [CERTMANAGER] To enable cert-manager, uncomment all the sections with [CERTMANAGER] prefix.
2224
# patches here are for enabling the CA injection for each CRD
2325
- patches/cainjection_in_core_openstackcontrolplanes.yaml
2426
#- patches/cainjection_in_openstackclients.yaml
2527
#- patches/cainjection_in_openstackversions.yaml
28+
#- patches/cainjection_in_openstacks.yaml
2629
#+kubebuilder:scaffold:crdkustomizecainjectionpatch
2730

2831
# the following config is for teaching kustomize how to do kustomization for CRDs.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# The following patch adds a directive for certmanager to inject CA into the CRD
2+
apiVersion: apiextensions.k8s.io/v1
3+
kind: CustomResourceDefinition
4+
metadata:
5+
annotations:
6+
cert-manager.io/inject-ca-from: $(CERTIFICATE_NAMESPACE)/$(CERTIFICATE_NAME)
7+
name: openstacks.operator.openstack.org
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# The following patch enables a conversion webhook for the CRD
2+
apiVersion: apiextensions.k8s.io/v1
3+
kind: CustomResourceDefinition
4+
metadata:
5+
name: openstacks.operator.openstack.org
6+
spec:
7+
conversion:
8+
strategy: Webhook
9+
webhook:
10+
clientConfig:
11+
service:
12+
namespace: system
13+
name: webhook-service
14+
path: /convert
15+
conversionReviewVersions:
16+
- v1
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# permissions for end users to edit openstacks.
2+
apiVersion: rbac.authorization.k8s.io/v1
3+
kind: ClusterRole
4+
metadata:
5+
labels:
6+
app.kubernetes.io/name: clusterrole
7+
app.kubernetes.io/instance: openstack-editor-role
8+
app.kubernetes.io/component: rbac
9+
app.kubernetes.io/created-by: openstack-operator
10+
app.kubernetes.io/part-of: openstack-operator
11+
app.kubernetes.io/managed-by: kustomize
12+
name: openstack-editor-role
13+
rules:
14+
- apiGroups:
15+
- operator.openstack.org
16+
resources:
17+
- openstacks
18+
verbs:
19+
- create
20+
- delete
21+
- get
22+
- list
23+
- patch
24+
- update
25+
- watch
26+
- apiGroups:
27+
- operator.openstack.org
28+
resources:
29+
- openstacks/status
30+
verbs:
31+
- get

0 commit comments

Comments
 (0)