From 7702b691992df8cfd35336a0accf3bbb6061c008 Mon Sep 17 00:00:00 2001 From: Jean-Marc Andre Date: Thu, 31 Dec 2020 15:11:24 +0100 Subject: [PATCH] More refined status --- api/v1alpha1/backupconfiguration_types.go | 8 +++--- api/v1alpha1/backupsession_types.go | 27 ++++++++++++------ api/v1alpha1/zz_generated.deepcopy.go | 34 ++++++++++++++++++++--- 3 files changed, 52 insertions(+), 17 deletions(-) diff --git a/api/v1alpha1/backupconfiguration_types.go b/api/v1alpha1/backupconfiguration_types.go index 9d86a0d..e7c3866 100644 --- a/api/v1alpha1/backupconfiguration_types.go +++ b/api/v1alpha1/backupconfiguration_types.go @@ -30,17 +30,17 @@ type Repository struct { } type Step struct { - Name string `json:"name"` - Env []corev1.EnvVar `json:"env"` + Name string `json:"name"` + Namespace string `json:"namespace"` + Env []corev1.EnvVar `json:"env"` } type Target struct { Kind string `json:"kind"` + Name string `json:"name"` // +optional ApiVersion string `json:"apiVersion,omitempty"` // +optional - Name string `json:"name,omitempty"` - // +optional VolumeMounts []corev1.VolumeMount `json:"volumeMounts,omitempty"` // +optional Paths []string `json:"paths,omitempty"` diff --git a/api/v1alpha1/backupsession_types.go b/api/v1alpha1/backupsession_types.go index 7afd557..c91a3c3 100644 --- a/api/v1alpha1/backupsession_types.go +++ b/api/v1alpha1/backupsession_types.go @@ -23,12 +23,12 @@ import ( // EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN! // NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized. -type BackupSessionState string +type BackupState string const ( - Running BackupSessionState = "Running" - Success BackupSessionState = "Success" - Failure BackupSessionState = "Failure" + Running BackupState = "Running" + Success BackupState = "Success" + Failure BackupState = "Failure" ) type Ref struct { @@ -44,12 +44,9 @@ type BackupSessionSpec struct { Ref `json:"ref"` } -// BackupSessionStatus defines the observed state of BackupSession -type BackupSessionStatus struct { - // INSERT ADDITIONAL STATUS FIELD - define observed state of cluster - // Important: Run "make" to regenerate code after modifying this file +type TargetStatus struct { // +optional - BackupSessionState `json:"state,omitempty"` + BackupState `json:"state,omitempty"` // +optional SnapshotId string `json:"snapshotId,omitempty"` // +optional @@ -58,6 +55,18 @@ type BackupSessionStatus struct { Duration *metav1.Duration `json:"duration,omitempty"` } +// BackupSessionStatus defines the observed state of BackupSession +type BackupSessionStatus struct { + // INSERT ADDITIONAL STATUS FIELD - define observed state of cluster + // Important: Run "make" to regenerate code after modifying this file + // +optional + BackupState `json:"state,omitempty"` + // +optional + StartTime *metav1.Time `json:"startTime,omitempty"` + // +optional + Targets []TargetStatus `json:"target,omitempty"` +} + // +kubebuilder:object:root=true // +kubebuilder:subresource:status diff --git a/api/v1alpha1/zz_generated.deepcopy.go b/api/v1alpha1/zz_generated.deepcopy.go index 0d97fe3..a8b6de9 100644 --- a/api/v1alpha1/zz_generated.deepcopy.go +++ b/api/v1alpha1/zz_generated.deepcopy.go @@ -226,10 +226,12 @@ func (in *BackupSessionStatus) DeepCopyInto(out *BackupSessionStatus) { in, out := &in.StartTime, &out.StartTime *out = (*in).DeepCopy() } - if in.Duration != nil { - in, out := &in.Duration, &out.Duration - *out = new(metav1.Duration) - **out = **in + if in.Targets != nil { + in, out := &in.Targets, &out.Targets + *out = make([]TargetStatus, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } } } @@ -506,3 +508,27 @@ func (in *Target) DeepCopy() *Target { in.DeepCopyInto(out) return out } + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *TargetStatus) DeepCopyInto(out *TargetStatus) { + *out = *in + if in.StartTime != nil { + in, out := &in.StartTime, &out.StartTime + *out = (*in).DeepCopy() + } + if in.Duration != nil { + in, out := &in.Duration, &out.Duration + *out = new(metav1.Duration) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TargetStatus. +func (in *TargetStatus) DeepCopy() *TargetStatus { + if in == nil { + return nil + } + out := new(TargetStatus) + in.DeepCopyInto(out) + return out +}