Skip to content

Commit

Permalink
Update API fields with regards to:
Browse files Browse the repository at this point in the history
- Unify pointer and omitempty JSON tag usage
- Add all default fields for struct with default values.
With the exception of HZ anc MC spec. The change is done due to the
issue in  kubernetes-sigs/controller-tools#622
- WanReplication Queue , Batch and Acknowledgment fields did not have
struct default values but they were not pointers so those fields acted
like they had default values. Added explicit struct default values.
- Add enum kubebuilder tags
- Add optional comment for forgotten fields
- Add explicit required comment for required field
  • Loading branch information
Muhammet Yazici committed Dec 16, 2022
1 parent 6f71771 commit 6c090db
Show file tree
Hide file tree
Showing 54 changed files with 550 additions and 467 deletions.
7 changes: 5 additions & 2 deletions api/v1alpha1/cache_types.go
Expand Up @@ -40,10 +40,13 @@ type CacheStatus struct {

// Cache is the Schema for the caches API
type Cache struct {
metav1.TypeMeta `json:",inline"`
metav1.TypeMeta `json:",inline"`
// +optional
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec CacheSpec `json:"spec,omitempty"`
// +required
Spec CacheSpec `json:"spec"`
// +optional
Status CacheStatus `json:"status,omitempty"`
}

Expand Down
18 changes: 12 additions & 6 deletions api/v1alpha1/cronhotbackup_types.go
Expand Up @@ -19,36 +19,39 @@ type CronHotBackupSpec struct {
// @daily (or @midnight) | Run once a day, midnight | 0 0 * * *
// @hourly | Run once an hour, beginning of hour | 0 * * * *
// +kubebuilder:validation:MinLength:=1
// +required
Schedule string `json:"schedule"`

// Specifies the hot backup that will be created when executing a CronHotBackup.
// +required
HotBackupTemplate HotBackupTemplateSpec `json:"hotBackupTemplate"`

// The number of successful finished hot backups to retain.
// This is a pointer to distinguish between explicit zero and not specified.
// +kubebuilder:validation:Minimum=0
// +kubebuilder:default:=5
// +optional
SuccessfulHotBackupsHistoryLimit *int32 `json:"successfulHotBackupsHistoryLimit,omitempty"`

// The number of failed finished hot backups to retain.
// This is a pointer to distinguish between explicit zero and not specified.
// +kubebuilder:validation:Minimum=0
// +kubebuilder:default:=3
// +optional
FailedHotBackupsHistoryLimit *int32 `json:"failedHotBackupsHistoryLimit,omitempty"`

// When true, CronHotBackup will stop creating HotBackup CRs until it is disabled
// +kubebuilder:default:=false
// +optional
Suspend bool `json:"suspend,omitempty"`
Suspend bool `json:"suspend"`
}

type HotBackupTemplateSpec struct {
// Standard object's metadata of the hot backups created from this template.
// +optional
// +kubebuilder:validation:XPreserveUnknownFields
// +optional
metav1.ObjectMeta `json:"metadata,omitempty"`

// Specification of the desired behavior of the hot backup.
// +required
Spec HotBackupSpec `json:"spec"`
}

Expand All @@ -61,10 +64,13 @@ type CronHotBackupStatus struct{}
// CronHotBackup is the Schema for the cronhotbackups API
// +kubebuilder:printcolumn:name="SUSPENDED",type="boolean",JSONPath=".spec.suspend",description="Suspention status of the CronHotBackup"
type CronHotBackup struct {
metav1.TypeMeta `json:",inline"`
metav1.TypeMeta `json:",inline"`
// +optional
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec CronHotBackupSpec `json:"spec"`
// +required
Spec CronHotBackupSpec `json:"spec"`
// +optional
Status CronHotBackupStatus `json:"status,omitempty"`
}

Expand Down
12 changes: 9 additions & 3 deletions api/v1alpha1/data_structure.go
Expand Up @@ -8,22 +8,28 @@ type DataStructureSpec struct {

// HazelcastResourceName defines the name of the Hazelcast resource.
// +kubebuilder:validation:MinLength:=1
// +required
HazelcastResourceName string `json:"hazelcastResourceName"`

// Number of synchronous backups.
// +kubebuilder:validation:Minimum=0
// +kubebuilder:default:=1
// +optional
BackupCount *int32 `json:"backupCount,omitempty"`

// Number of asynchronous backups.
// +kubebuilder:validation:Minimum=0
// +kubebuilder:default:=0
// +optional
AsyncBackupCount *int32 `json:"asyncBackupCount,omitempty"`
AsyncBackupCount int32 `json:"asyncBackupCount"`
}

type DataStructureStatus struct {
State DataStructureConfigState `json:"state,omitempty"`
Message string `json:"message,omitempty"`
// +optional
State DataStructureConfigState `json:"state,omitempty"`
// +optional
Message string `json:"message,omitempty"`
// +optional
MemberStatuses map[string]DataStructureConfigState `json:"memberStatuses,omitempty"`
}

Expand Down

0 comments on commit 6c090db

Please sign in to comment.