Skip to content

Commit cc351df

Browse files
committed
Scaffolding tool used to create boilerplate for Share Network Controller
go run ./cmd/scaffold-controller -interactive=false \ -kind=ShareNetwork \ -gophercloud-client=NewSharedFilesystemV2 \ -gophercloud-module=github.com/gophercloud/gophercloud/v2/openstack/sharedfilesystems/v2/sharenetworks \ -gophercloud-type=ShareNetwork \ -openstack-json-object=share_network \ -optional-create-dependency=Network \ -optional-create-dependency=Subnet Signed-off-by: Daniel Lawton <dlawton@redhat.com>
1 parent 64c7a0e commit cc351df

53 files changed

Lines changed: 1806 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

api/v1alpha1/sharenetwork_types.go

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
/*
2+
Copyright The ORC Authors.
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 v1alpha1
18+
19+
// ShareNetworkResourceSpec contains the desired state of the resource.
20+
type ShareNetworkResourceSpec struct {
21+
// name will be the name of the created resource. If not specified, the
22+
// name of the ORC object will be used.
23+
// +optional
24+
Name *OpenStackName `json:"name,omitempty"`
25+
26+
// description is a human-readable description for the resource.
27+
// +kubebuilder:validation:MinLength:=1
28+
// +kubebuilder:validation:MaxLength:=255
29+
// +optional
30+
Description *string `json:"description,omitempty"`
31+
32+
// networkRef is a reference to the ORC Network which this resource is associated with.
33+
// +optional
34+
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="networkRef is immutable"
35+
NetworkRef *KubernetesNameRef `json:"networkRef,omitempty"`
36+
37+
// subnetRef is a reference to the ORC Subnet which this resource is associated with.
38+
// +optional
39+
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="subnetRef is immutable"
40+
SubnetRef *KubernetesNameRef `json:"subnetRef,omitempty"`
41+
42+
// TODO(scaffolding): Add more types.
43+
// To see what is supported, you can take inspiration from the CreateOpts structure from
44+
// github.com/gophercloud/gophercloud/v2/openstack/sharedfilesystems/v2/sharenetworks
45+
//
46+
// Until you have implemented mutability for the field, you must add a CEL validation
47+
// preventing the field being modified:
48+
// `// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="<fieldname> is immutable"`
49+
}
50+
51+
// ShareNetworkFilter defines an existing resource by its properties
52+
// +kubebuilder:validation:MinProperties:=1
53+
type ShareNetworkFilter struct {
54+
// name of the existing resource
55+
// +optional
56+
Name *OpenStackName `json:"name,omitempty"`
57+
58+
// description of the existing resource
59+
// +kubebuilder:validation:MinLength:=1
60+
// +kubebuilder:validation:MaxLength:=255
61+
// +optional
62+
Description *string `json:"description,omitempty"`
63+
64+
// TODO(scaffolding): Add more types.
65+
// To see what is supported, you can take inspiration from the ListOpts structure from
66+
// github.com/gophercloud/gophercloud/v2/openstack/sharedfilesystems/v2/sharenetworks
67+
}
68+
69+
// ShareNetworkResourceStatus represents the observed state of the resource.
70+
type ShareNetworkResourceStatus struct {
71+
// name is a Human-readable name for the resource. Might not be unique.
72+
// +kubebuilder:validation:MaxLength=1024
73+
// +optional
74+
Name string `json:"name,omitempty"`
75+
76+
// description is a human-readable description for the resource.
77+
// +kubebuilder:validation:MaxLength=1024
78+
// +optional
79+
Description string `json:"description,omitempty"`
80+
81+
// networkID is the ID of the Network to which the resource is associated.
82+
// +kubebuilder:validation:MaxLength=1024
83+
// +optional
84+
NetworkID string `json:"networkID,omitempty"`
85+
86+
// subnetID is the ID of the Subnet to which the resource is associated.
87+
// +kubebuilder:validation:MaxLength=1024
88+
// +optional
89+
SubnetID string `json:"subnetID,omitempty"`
90+
91+
// TODO(scaffolding): Add more types.
92+
// To see what is supported, you can take inspiration from the ShareNetwork structure from
93+
// github.com/gophercloud/gophercloud/v2/openstack/sharedfilesystems/v2/sharenetworks
94+
}

api/v1alpha1/zz_generated.deepcopy.go

Lines changed: 75 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cmd/models-schema/zz_generated.openapi.go

Lines changed: 112 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/rbac/role.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ rules:
3535
- servergroups
3636
- servers
3737
- services
38+
- sharenetworks
3839
- subnets
3940
- trunks
4041
- users
@@ -69,6 +70,7 @@ rules:
6970
- servergroups/status
7071
- servers/status
7172
- services/status
73+
- sharenetworks/status
7274
- subnets/status
7375
- trunks/status
7476
- users/status
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
apiVersion: openstack.k-orc.cloud/v1alpha1
3+
kind: ShareNetwork
4+
metadata:
5+
name: sharenetwork-sample
6+
spec:
7+
cloudCredentialsRef:
8+
# TODO(scaffolding): Use openstack-admin if the resource needs admin credentials to be created
9+
cloudName: openstack
10+
secretName: openstack-clouds
11+
managementPolicy: managed
12+
resource:
13+
description: Sample ShareNetwork
14+
# TODO(scaffolding): Add all fields the resource supports

0 commit comments

Comments
 (0)