Skip to content

Commit

Permalink
Merge pull request #6 from pluralsh/master
Browse files Browse the repository at this point in the history
add conditions
  • Loading branch information
zreigz authored Oct 28, 2022
2 parents 5dbd1f2 + 50c02c4 commit b7ed725
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 2 deletions.
25 changes: 25 additions & 0 deletions apis/database/v1alpha1/database_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ limitations under the License.
package v1alpha1

import (
crhelperTypes "github.com/pluralsh/controller-reconcile-helper/pkg/types"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
Expand All @@ -25,6 +26,14 @@ func init() {
SchemeBuilder.Register(&Database{}, &DatabaseList{})
}

const (
// DatabaseReadyCondition used when database is ready.
DatabaseReadyCondition crhelperTypes.ConditionType = "DatabaseReady"

// FailedToCreateDatabaseReason used when grpc method for database creation failed.
FailedToCreateDatabaseReason = "FailedToCreateDatabase"
)

type DatabaseSpec struct {
// DriverName is the name of driver associated with this database
DriverName string `json:"driverName"`
Expand Down Expand Up @@ -62,11 +71,27 @@ type DatabaseStatus struct {
// DatabaseID is the unique id of the database
// +optional
DatabaseID string `json:"databaseID,omitempty"`

// Conditions defines current state.
// +optional
Conditions crhelperTypes.Conditions `json:"conditions,omitempty"`
}

// GetConditions returns the list of conditions for a WireGuardServer API object.
func (db *Database) GetConditions() crhelperTypes.Conditions {
return db.Status.Conditions
}

// SetConditions will set the given conditions on a WireGuardServer object.
func (db *Database) SetConditions(conditions crhelperTypes.Conditions) {
db.Status.Conditions = conditions
}

// +kubebuilder:object:root=true
// +kubebuilder:resource:scope=Cluster
// +kubebuilder:subresource:status
// +kubebuilder:printcolumn:name="Ready",type="string",JSONPath=".status.ready",description="Database ready status"

type Database struct {
metav1.TypeMeta `json:",inline"`
// +optional
Expand Down
10 changes: 9 additions & 1 deletion apis/database/v1alpha1/zz_generated.deepcopy.go

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

50 changes: 49 additions & 1 deletion config/crd/bases/database.plural.sh_databases.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@ spec:
singular: database
scope: Cluster
versions:
- name: v1alpha1
- additionalPrinterColumns:
- description: Database ready status
jsonPath: .status.ready
name: Ready
type: string
name: v1alpha1
schema:
openAPIV3Schema:
properties:
Expand Down Expand Up @@ -103,6 +108,49 @@ spec:
type: object
status:
properties:
conditions:
description: Conditions defines current state.
items:
properties:
lastTransitionTime:
description: 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: A human readable message indicating details about
the transition. This field may be empty.
type: string
reason:
description: The reason for the condition's last transition
in CamelCase. The specific API may choose whether or not this
field is considered a guaranteed API. This field may not be
empty.
type: string
severity:
description: Severity provides an explicit classification of
Reason code, so the users or machines can immediately understand
the current situation and act accordingly. The Severity field
MUST be set only when Status=False.
type: string
status:
description: Status of the condition, one of 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.
type: string
required:
- lastTransitionTime
- status
- type
type: object
type: array
databaseID:
description: DatabaseID is the unique id of the database
type: string
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ go 1.18

require (
github.com/golang/protobuf v1.5.2
github.com/pluralsh/controller-reconcile-helper v0.0.4
google.golang.org/grpc v1.50.0
google.golang.org/protobuf v1.28.0
k8s.io/api v0.25.0
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWb
github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE=
github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE=
github.com/onsi/gomega v1.20.1 h1:PA/3qinGoukvymdIDV8pii6tiZgC8kbmJO6Z5+b002Q=
github.com/pluralsh/controller-reconcile-helper v0.0.4 h1:1o+7qYSyoeqKFjx+WgQTxDz4Q2VMpzprJIIKShxqG0E=
github.com/pluralsh/controller-reconcile-helper v0.0.4/go.mod h1:AfY0gtteD6veBjmB6jiRx/aR4yevEf6K0M13/pGan/s=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
Expand Down

0 comments on commit b7ed725

Please sign in to comment.