Skip to content

Commit

Permalink
feat(oss & tests): update oss crd & add oss tests (#339)
Browse files Browse the repository at this point in the history
  • Loading branch information
maslow authored Sep 23, 2022
1 parent 135dfeb commit dde917a
Show file tree
Hide file tree
Showing 23 changed files with 1,032 additions and 98 deletions.
4 changes: 4 additions & 0 deletions controllers/oss/api/v1/bucket_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ type BucketStatus struct {

// Capacity of this bucket.
Capacity BucketCapacity `json:"capacity"`

// Conditions
// - Type: Ready
Conditions []metav1.Condition `json:"conditions,omitempty"`
}

type BucketCapacity struct {
Expand Down
21 changes: 5 additions & 16 deletions controllers/oss/api/v1/store_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,6 @@ type StoreCapacity struct {
BucketCount int64 `json:"bucketCount,omitempty"`
}

type StoreState string

const (
// StoreStateEnabled means the store is enabled.
StoreStateEnabled StoreState = "Enabled"

// StoreStateDisabled means the store is disabled.
StoreStateDisabled StoreState = "Disabled"
)

// StoreSpec defines the desired state of Store
type StoreSpec struct {
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
Expand Down Expand Up @@ -90,9 +80,9 @@ type StoreSpec struct {
Provider string `json:"provider,omitempty"`

// Endpoint is the store service endpoint.
// This is a url string, like "http://minio-service:9000"
// This is url string, like "http://minio-service:9000"
//+kubebuilder:validation:Required
Endpoint string `json:"endpoint,omitempty"`
Endpoint string `json:"endpoint"`

// UseSSL indicates whether to use ssl to connect to the store service.
//+kubebuilder:validation:Required
Expand Down Expand Up @@ -130,10 +120,9 @@ type StoreStatus struct {
//+optional
Capacity StoreCapacity `json:"capacity,omitempty"`

// The state of the store, defaults to "Pending".
//+kubebuilder:default=Pending
//+kubebuilder:validation:Enum=Pending;Enabled;Disabled
State StoreState `json:"state,omitempty"`
// Conditions
// - Type: Ready
Conditions []metav1.Condition `json:"conditions,omitempty"`
}

//+kubebuilder:object:root=true
Expand Down
8 changes: 8 additions & 0 deletions controllers/oss/api/v1/user_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ type UserSpec struct {
//+kubebuilder:validation:Required
AppId string `json:"appid"`

// Region of oss store.
//+kubebuilder:validation:Required
Region string `json:"region"`

// Password is the secret name of the user, which is used to authenticate the user.
//+kubebuilder:validation:MinLength=3
//+kubebuilder:validation:MaxLength=32
Expand Down Expand Up @@ -79,6 +83,10 @@ type UserStatus struct {

// The user's capacity observed by the controller.
Capacity UserCapacity `json:"capacity,omitempty"`

// Conditions
// - Type: Ready
Conditions []metav1.Condition `json:"conditions,omitempty"`
}

// UserCapacity is used to obtain the user's used capacity.
Expand Down
22 changes: 22 additions & 0 deletions controllers/oss/api/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

69 changes: 69 additions & 0 deletions controllers/oss/config/crd/bases/oss.laf.dev_buckets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,75 @@ spec:
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
type: object
conditions:
description: 'Conditions - Type: Ready'
items:
description: "Condition contains details for one aspect of the current
state of this API Resource. --- This struct is intended for direct
use as an array at the field path .status.conditions. For example,
\n type FooStatus struct{ // Represents the observations of a
foo's current state. // Known .status.conditions.type are: \"Available\",
\"Progressing\", and \"Degraded\" // +patchMergeKey=type // +patchStrategy=merge
// +listType=map // +listMapKey=type Conditions []metav1.Condition
`json:\"conditions,omitempty\" patchStrategy:\"merge\" patchMergeKey:\"type\"
protobuf:\"bytes,1,rep,name=conditions\"` \n // other fields }"
properties:
lastTransitionTime:
description: lastTransitionTime is the last time the condition
transitioned from one status to another. This should be when
the underlying condition changed. If that is not known, then
using the time when the API field changed is acceptable.
format: date-time
type: string
message:
description: message is a human readable message indicating
details about the transition. This may be an empty string.
maxLength: 32768
type: string
observedGeneration:
description: observedGeneration represents the .metadata.generation
that the condition was set based upon. For instance, if .metadata.generation
is currently 12, but the .status.conditions[x].observedGeneration
is 9, the condition is out of date with respect to the current
state of the instance.
format: int64
minimum: 0
type: integer
reason:
description: reason contains a programmatic identifier indicating
the reason for the condition's last transition. Producers
of specific condition types may define expected values and
meanings for this field, and whether the values are considered
a guaranteed API. The value should be a CamelCase string.
This field may not be empty.
maxLength: 1024
minLength: 1
pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$
type: string
status:
description: status of the condition, one of True, False, Unknown.
enum:
- "True"
- "False"
- Unknown
type: string
type:
description: type of condition in CamelCase or in foo.example.com/CamelCase.
--- Many .condition.type values are consistent across resources
like Available, but because arbitrary conditions can be useful
(see .node.status.conditions), the ability to deconflict is
important. The regex it matches is (dns1123SubdomainFmt/)?(qualifiedNameFmt)
maxLength: 316
pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$
type: string
required:
- lastTransitionTime
- message
- reason
- status
- type
type: object
type: array
policy:
description: Policy of bucket in oss.
type: string
Expand Down
83 changes: 73 additions & 10 deletions controllers/oss/config/crd/bases/oss.laf.dev_stores.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ spec:
type: integer
type: object
endpoint:
description: Endpoint is the store service endpoint. This is a url
string, like "http://minio-service:9000"
description: Endpoint is the store service endpoint. This is url string,
like "http://minio-service:9000"
type: string
priority:
default: 10
Expand Down Expand Up @@ -111,6 +111,8 @@ spec:
description: UseSSL indicates whether to use ssl to connect to the
store service.
type: boolean
required:
- endpoint
type: object
status:
description: StoreStatus defines the observed state of Store
Expand Down Expand Up @@ -145,14 +147,75 @@ spec:
format: int64
type: integer
type: object
state:
default: Pending
description: The state of the store, defaults to "Pending".
enum:
- Pending
- Enabled
- Disabled
type: string
conditions:
description: 'Conditions - Type: Ready'
items:
description: "Condition contains details for one aspect of the current
state of this API Resource. --- This struct is intended for direct
use as an array at the field path .status.conditions. For example,
\n type FooStatus struct{ // Represents the observations of a
foo's current state. // Known .status.conditions.type are: \"Available\",
\"Progressing\", and \"Degraded\" // +patchMergeKey=type // +patchStrategy=merge
// +listType=map // +listMapKey=type Conditions []metav1.Condition
`json:\"conditions,omitempty\" patchStrategy:\"merge\" patchMergeKey:\"type\"
protobuf:\"bytes,1,rep,name=conditions\"` \n // other fields }"
properties:
lastTransitionTime:
description: lastTransitionTime is the last time the condition
transitioned from one status to another. This should be when
the underlying condition changed. If that is not known, then
using the time when the API field changed is acceptable.
format: date-time
type: string
message:
description: message is a human readable message indicating
details about the transition. This may be an empty string.
maxLength: 32768
type: string
observedGeneration:
description: observedGeneration represents the .metadata.generation
that the condition was set based upon. For instance, if .metadata.generation
is currently 12, but the .status.conditions[x].observedGeneration
is 9, the condition is out of date with respect to the current
state of the instance.
format: int64
minimum: 0
type: integer
reason:
description: reason contains a programmatic identifier indicating
the reason for the condition's last transition. Producers
of specific condition types may define expected values and
meanings for this field, and whether the values are considered
a guaranteed API. The value should be a CamelCase string.
This field may not be empty.
maxLength: 1024
minLength: 1
pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$
type: string
status:
description: status of the condition, one of True, False, Unknown.
enum:
- "True"
- "False"
- Unknown
type: string
type:
description: type of condition in CamelCase or in foo.example.com/CamelCase.
--- Many .condition.type values are consistent across resources
like Available, but because arbitrary conditions can be useful
(see .node.status.conditions), the ability to deconflict is
important. The regex it matches is (dns1123SubdomainFmt/)?(qualifiedNameFmt)
maxLength: 316
pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$
type: string
required:
- lastTransitionTime
- message
- reason
- status
- type
type: object
type: array
type: object
type: object
served: true
Expand Down
73 changes: 73 additions & 0 deletions controllers/oss/config/crd/bases/oss.laf.dev_users.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,14 @@ spec:
The controller will create the corresponding storage resources based
on this provider.
type: string
region:
description: Region of oss store.
type: string
required:
- appid
- password
- provider
- region
type: object
status:
description: UserStatus defines the observed state of User
Expand Down Expand Up @@ -111,6 +115,75 @@ spec:
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
type: object
conditions:
description: 'Conditions - Type: Ready'
items:
description: "Condition contains details for one aspect of the current
state of this API Resource. --- This struct is intended for direct
use as an array at the field path .status.conditions. For example,
\n type FooStatus struct{ // Represents the observations of a
foo's current state. // Known .status.conditions.type are: \"Available\",
\"Progressing\", and \"Degraded\" // +patchMergeKey=type // +patchStrategy=merge
// +listType=map // +listMapKey=type Conditions []metav1.Condition
`json:\"conditions,omitempty\" patchStrategy:\"merge\" patchMergeKey:\"type\"
protobuf:\"bytes,1,rep,name=conditions\"` \n // other fields }"
properties:
lastTransitionTime:
description: lastTransitionTime is the last time the condition
transitioned from one status to another. This should be when
the underlying condition changed. If that is not known, then
using the time when the API field changed is acceptable.
format: date-time
type: string
message:
description: message is a human readable message indicating
details about the transition. This may be an empty string.
maxLength: 32768
type: string
observedGeneration:
description: observedGeneration represents the .metadata.generation
that the condition was set based upon. For instance, if .metadata.generation
is currently 12, but the .status.conditions[x].observedGeneration
is 9, the condition is out of date with respect to the current
state of the instance.
format: int64
minimum: 0
type: integer
reason:
description: reason contains a programmatic identifier indicating
the reason for the condition's last transition. Producers
of specific condition types may define expected values and
meanings for this field, and whether the values are considered
a guaranteed API. The value should be a CamelCase string.
This field may not be empty.
maxLength: 1024
minLength: 1
pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$
type: string
status:
description: status of the condition, one of True, False, Unknown.
enum:
- "True"
- "False"
- Unknown
type: string
type:
description: type of condition in CamelCase or in foo.example.com/CamelCase.
--- Many .condition.type values are consistent across resources
like Available, but because arbitrary conditions can be useful
(see .node.status.conditions), the ability to deconflict is
important. The regex it matches is (dns1123SubdomainFmt/)?(qualifiedNameFmt)
maxLength: 316
pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$
type: string
required:
- lastTransitionTime
- message
- reason
- status
- type
type: object
type: array
endpoint:
description: Endpoint is the store service endpoint.
type: string
Expand Down
Loading

0 comments on commit dde917a

Please sign in to comment.