Skip to content

Change maintenance to string #147

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 6 additions & 11 deletions api/v1/postgres_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ type PostgresSpec struct {

// todo: add default
// Maintenance defines automatic maintenance of the database
Maintenance *Maintenance `json:"maintenance,omitempty"`
Maintenance []string `json:"maintenance,omitempty"`

// AccessList defines access restrictions
AccessList *AccessList `json:"accessList,omitempty"`
Expand All @@ -137,6 +137,7 @@ type AccessList struct {
SourceRanges []string `json:"sourceRanges,omitempty"`
}

// Todo: Add defaults
// Size defines the size aspects of the database
type Size struct {
// CPU is in the format as pod.spec.resource.request.cpu
Expand All @@ -161,14 +162,6 @@ type TimeWindow struct {
End metav1.Time `json:"end,omitempty"`
}

// Maintenance configures database maintenance
type Maintenance struct {
// Weekday defines when the operator is allowed to do maintenance
Weekday Weekday `json:"weekday,omitempty"`
// TimeWindow defines when the maintenance should happen
TimeWindow TimeWindow `json:"timeWindow,omitempty"`
}

// PostgresStatus defines the observed state of Postgres
type PostgresStatus struct {
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
Expand Down Expand Up @@ -417,8 +410,10 @@ func (p *Postgres) ToUnstructuredZalandoPostgresql(z *zalando.Postgresql) (*unst
}
jsonSpec, _ := jsonZ["spec"].(map[string]interface{})

// todo: Fix it in another branch.
// jsonSpec["maintenanceWindows"] = p.Spec.Maintenance
// In the code, zalando's `MaintenanceWindows` is a `struct`, but in the CRD
// it's an array of strings, so we can only set its `Unstructured` contents
// and deal with possible `nil`.
jsonSpec["maintenanceWindows"] = p.Spec.Maintenance
deleteIfEmpty(jsonSpec, "maintenanceWindows")

// Delete unused fields
Expand Down
20 changes: 2 additions & 18 deletions api/v1/zz_generated.deepcopy.go

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

19 changes: 3 additions & 16 deletions config/crd/bases/database.fits.cloud_postgres.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,22 +69,9 @@ spec:
maintenance:
description: 'todo: add default Maintenance defines automatic maintenance
of the database'
properties:
timeWindow:
description: TimeWindow defines when the maintenance should happen
properties:
end:
format: date-time
type: string
start:
format: date-time
type: string
type: object
weekday:
description: Weekday defines when the operator is allowed to do
maintenance
type: integer
type: object
items:
type: string
type: array
numberOfInstances:
default: 1
description: NumberOfInstances number of replicas
Expand Down
4 changes: 4 additions & 0 deletions config/samples/database_v1_postgres.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ metadata:
spec:
backup:
s3BucketURL: ""
maintenance:
- "Sun:21:00-22:00"
numberOfInstances: 2
partitionID: sample-partition
projectID: projectid-a
Expand All @@ -32,6 +34,8 @@ spec:
- 1.2.3.4/24
backup:
s3BucketURL: ""
maintenance:
- "Sun:20:00-21:00"
numberOfInstances: 2
partitionID: sample-partition
projectID: projectid-b
Expand Down