Skip to content

Commit 802aa0e

Browse files
authored
feat(app): impl creation form crd, update app crds (#317)
1 parent b3cb361 commit 802aa0e

31 files changed

+858
-340
lines changed

controllers/application/PROJECT

+10-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,16 @@ resources:
1919
controller: true
2020
domain: laf.dev
2121
group: application
22-
kind: Specification
22+
kind: Bundle
23+
path: github.com/labring/laf/controllers/application/api/v1
24+
version: v1
25+
- api:
26+
crdVersion: v1
27+
namespaced: true
28+
controller: true
29+
domain: laf.dev
30+
group: application
31+
kind: CreationForm
2332
path: github.com/labring/laf/controllers/application/api/v1
2433
version: v1
2534
version: "3"

controllers/application/api/v1/application_types.go

+34-25
Original file line numberDiff line numberDiff line change
@@ -28,34 +28,28 @@ import (
2828
type ApplicationState string
2929

3030
const (
31-
ApplicationStateCreated ApplicationState = "Created"
32-
ApplicationStateStarted ApplicationState = "Started"
33-
ApplicationStateStopped ApplicationState = "Stopped"
34-
ApplicationStateRunning ApplicationState = "Running"
35-
ApplicationStateRestarted ApplicationState = "Restarted"
36-
ApplicationStateDeleted ApplicationState = "Deleted"
31+
ApplicationStateInitializing ApplicationState = "Initializing"
32+
ApplicationStateInitialized ApplicationState = "Initialized"
33+
ApplicationStateStarting ApplicationState = "Starting"
34+
ApplicationStateRunning ApplicationState = "Running"
35+
ApplicationStateStopping ApplicationState = "Stopping"
36+
ApplicationStateStopped ApplicationState = "Stopped"
3737
)
3838

3939
// ApplicationSpec defines the desired state of Application
4040
type ApplicationSpec struct {
4141
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
4242
// Important: Run "make" to regenerate code after modifying this file
4343

44-
// DisplayName for the application
45-
//+kubebuilder:validation:MinLength=3
46-
//+kubebuilder:validation:MaxLength=63
47-
//+kubebuilder:validation:Required
48-
DisplayName string `json:"displayName"`
49-
5044
// State of the application
51-
//+kubebuilder:validation:Enum=Created;Started;Stopped;Running;Restarted;Deleted
45+
//+kubebuilder:validation:Enum=Running;Stopped;
5246
//+kubebuilder:validation:Required
53-
//+kubebuilder:default:=Created
54-
State ApplicationState `json:"state"`
47+
//+kubebuilder:default:=Running
48+
State ApplicationState `json:"state,omitempty"`
5549

56-
// Specification Name for the application
50+
// Bundle Name for the application
5751
//+kubebuilder:validation:Required
58-
SpecificationName string `json:"specificationName"`
52+
BundleName string `json:"bundleName"`
5953

6054
// Runtime Name of the application
6155
//+kubebuilder:validation:Required
@@ -69,18 +63,33 @@ type ApplicationStatus struct {
6963

7064
// AppId
7165
//+kubebuilder:validation:MinLength=3
72-
//+kubebuilder:validation:MaxLength=16
66+
//+kubebuilder:validation:MaxLength=24
7367
//+kubebuilder:validation:Required
7468
AppId string `json:"appid"`
7569

76-
// Specification for the application
77-
Specification SpecificationSpec `json:"specification"`
78-
7970
// State of the application
80-
State ApplicationState `json:"state"`
81-
82-
// Runtime for the application
83-
Runtime v1.RuntimeSpec `json:"runtime"`
71+
Phase ApplicationState `json:"state,omitempty"`
72+
73+
// Bundle of the application
74+
Bundle BundleSpec `json:"bundle,omitempty"`
75+
76+
// Runtime of the application
77+
Runtime v1.RuntimeSpec `json:"runtime,omitempty"`
78+
79+
// Conditions:
80+
// - type: DatabaseCreated
81+
// status: True | False | Unknown
82+
// reason: "DatabaseCreated" | "InsufficientResources" | "Unknown"
83+
// message: "Database created Successfully" | "Insufficient resources to create database" | "Unknown error"
84+
// - type: ObjectStorageCreated
85+
// - type: GatewayCreated
86+
// - type: InstanceCreated
87+
// - type: InstanceReady
88+
// - type: InstanceDeleted
89+
// - type: DatabaseDeleted
90+
// - type: ObjectStorageDeleted
91+
// - type: GatewayDeleted
92+
Conditions []metav1.Condition `json:"conditions,omitempty"`
8493
}
8594

8695
//+kubebuilder:object:root=true

controllers/application/api/v1/specification_types.go renamed to controllers/application/api/v1/bundle_types.go

+24-24
Original file line numberDiff line numberDiff line change
@@ -24,76 +24,76 @@ import (
2424
// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
2525
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.
2626

27-
// SpecificationSpec defines the desired state of Specification
28-
type SpecificationSpec struct {
27+
// BundleSpec defines the desired state of Bundle
28+
type BundleSpec struct {
2929
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
3030
// Important: Run "make" to regenerate code after modifying this file
3131

32-
// DisplayName for the specification
32+
// DisplayName for the bundle
3333
DisplayName string `json:"displayName"`
3434

35-
// Request CPU for the specification
35+
// Request CPU for the bundle
3636
RequestCPU resource.Quantity `json:"requestCPU"`
3737

38-
// Request Memory for the specification
38+
// Request Memory for the bundle
3939
RequestMemory resource.Quantity `json:"requestMemory"`
4040

41-
// Limit CPU for the specification
41+
// Limit CPU for the bundle
4242
LimitCPU resource.Quantity `json:"limitCPU"`
4343

44-
// Limit Memory for the specification
44+
// Limit Memory for the bundle
4545
LimitMemory resource.Quantity `json:"limitMemory"`
4646

47-
// Database capacity for the specification
47+
// Database capacity for the bundle
4848
DatabaseCapacity resource.Quantity `json:"databaseCapacity"`
4949

50-
// Storage capacity for the specification
50+
// Storage capacity for the bundle
5151
StorageCapacity resource.Quantity `json:"storageCapacity"`
5252

53-
// Network Bandwidth Outbound for the specification
53+
// Network Bandwidth Outbound for the bundle
5454
NetworkBandwidthOutbound resource.Quantity `json:"networkBandwidthOutbound,omitempty"`
5555

56-
// Network Bandwidth Inbound for the specification
56+
// Network Bandwidth Inbound for the bundle
5757
NetworkBandwidthInbound resource.Quantity `json:"networkBandwidthInbound,omitempty"`
5858

59-
// Network Traffic Outbound for the specification
59+
// Network Traffic Outbound for the bundle
6060
NetworkTrafficOutbound resource.Quantity `json:"networkTrafficOutbound"`
6161

62-
// Priority for the specification.
63-
// The default value is 0, which means that the specification is not currently available for creating new applications.
62+
// Priority for the bundle.
63+
// The default value is 0, which means that the bundle is not currently available for creating new applications.
6464
//+kubebuilder:validation:Minimum=0
6565
//+kubebuilder:validation:Maximum=1000
6666
//+kubebuilder:validation:Default=10
6767
Priority int32 `json:"priority"`
6868
}
6969

70-
// SpecificationStatus defines the observed state of Specification
71-
type SpecificationStatus struct {
70+
// BundleStatus defines the observed state of Bundle
71+
type BundleStatus struct {
7272
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
7373
// Important: Run "make" to regenerate code after modifying this file
7474
}
7575

7676
//+kubebuilder:object:root=true
7777
//+kubebuilder:subresource:status
7878

79-
// Specification is the Schema for the specifications API
80-
type Specification struct {
79+
// Bundle is the Schema for the bundles API
80+
type Bundle struct {
8181
metav1.TypeMeta `json:",inline"`
8282
metav1.ObjectMeta `json:"metadata,omitempty"`
8383

84-
Spec SpecificationSpec `json:"spec,omitempty"`
85-
Status SpecificationStatus `json:"status,omitempty"`
84+
Spec BundleSpec `json:"spec,omitempty"`
85+
Status BundleStatus `json:"status,omitempty"`
8686
}
8787

8888
//+kubebuilder:object:root=true
8989

90-
// SpecificationList contains a list of Specification
91-
type SpecificationList struct {
90+
// BundleList contains a list of Bundle
91+
type BundleList struct {
9292
metav1.TypeMeta `json:",inline"`
9393
metav1.ListMeta `json:"metadata,omitempty"`
94-
Items []Specification `json:"items"`
94+
Items []Bundle `json:"items"`
9595
}
9696

9797
func init() {
98-
SchemeBuilder.Register(&Specification{}, &SpecificationList{})
98+
SchemeBuilder.Register(&Bundle{}, &BundleList{})
9999
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
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 v1
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+
// CreationFormSpec defines the desired state of CreationForm
27+
type CreationFormSpec struct {
28+
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
29+
// Important: Run "make" to regenerate code after modifying this file
30+
31+
// DisplayName for the application
32+
//+kubebuilder:validation:MinLength=3
33+
//+kubebuilder:validation:MaxLength=63
34+
//+kubebuilder:validation:Required
35+
DisplayName string `json:"displayName"`
36+
37+
// Bundle Name for the application
38+
//+kubebuilder:validation:Required
39+
BundleName string `json:"bundleName"`
40+
41+
// Runtime Name of the application
42+
//+kubebuilder:validation:Required
43+
RuntimeName string `json:"runtimeName"`
44+
}
45+
46+
// CreationFormStatus defines the observed state of CreationForm
47+
type CreationFormStatus struct {
48+
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
49+
// Important: Run "make" to regenerate code after modifying this file
50+
51+
AppId string `json:"appid,omitempty"`
52+
53+
Namespace string `json:"namespace,omitempty"`
54+
55+
Created bool `json:"created,omitempty"`
56+
}
57+
58+
//+kubebuilder:object:root=true
59+
//+kubebuilder:subresource:status
60+
61+
// CreationForm is the Schema for the creationforms API
62+
type CreationForm struct {
63+
metav1.TypeMeta `json:",inline"`
64+
metav1.ObjectMeta `json:"metadata,omitempty"`
65+
66+
Spec CreationFormSpec `json:"spec,omitempty"`
67+
Status CreationFormStatus `json:"status,omitempty"`
68+
}
69+
70+
//+kubebuilder:object:root=true
71+
72+
// CreationFormList contains a list of CreationForm
73+
type CreationFormList struct {
74+
metav1.TypeMeta `json:",inline"`
75+
metav1.ListMeta `json:"metadata,omitempty"`
76+
Items []CreationForm `json:"items"`
77+
}
78+
79+
func init() {
80+
SchemeBuilder.Register(&CreationForm{}, &CreationFormList{})
81+
}

0 commit comments

Comments
 (0)