Skip to content

Commit

Permalink
Allow Storage resource to be manually edited in testing mode (#192)
Browse files Browse the repository at this point in the history
Add a Spec.Mode value to the Storage resource to indicate whether the resource
is "live" and is being updated by the reconciler or whether it is in "testing"
mode and is being updated manually.

Signed-off-by: Dean Roehrich <[email protected]>
  • Loading branch information
roehrich-hpe authored Apr 8, 2024
1 parent 53e8a9e commit 6e87ba9
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 8 deletions.
6 changes: 6 additions & 0 deletions api/v1alpha1/conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,8 @@ func (src *Storage) ConvertTo(dstRaw conversion.Hub) error {
// hub-specific then copy it into 'dst' from 'restored'.
// Otherwise, you may comment out UnmarshalData() until it's needed.

dst.Spec.Mode = restored.Spec.Mode

return nil
}

Expand Down Expand Up @@ -551,3 +553,7 @@ func Convert_v1alpha1_SystemConfigurationSpec_To_v1alpha2_SystemConfigurationSpe
func Convert_v1alpha2_SystemConfigurationSpec_To_v1alpha1_SystemConfigurationSpec(in *dwsv1alpha2.SystemConfigurationSpec, out *SystemConfigurationSpec, s apiconversion.Scope) error {
return autoConvert_v1alpha2_SystemConfigurationSpec_To_v1alpha1_SystemConfigurationSpec(in, out, s)
}

func Convert_v1alpha2_StorageSpec_To_v1alpha1_StorageSpec(in *dwsv1alpha2.StorageSpec, out *StorageSpec, s apiconversion.Scope) error {
return autoConvert_v1alpha2_StorageSpec_To_v1alpha1_StorageSpec(in, out, s)
}
30 changes: 23 additions & 7 deletions api/v1alpha1/zz_generated.conversion.go

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

10 changes: 9 additions & 1 deletion api/v1alpha2/storage_types.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2021-2023 Hewlett Packard Enterprise Development LP
* Copyright 2021-2024 Hewlett Packard Enterprise Development LP
* Other additional copyright holders may be indicated within.
*
* The entirety of this work is licensed under the Apache License,
Expand Down Expand Up @@ -35,6 +35,13 @@ type StorageSpec struct {
// State describes the desired state of the Storage resource.
// +kubebuilder:default:=Enabled
State ResourceState `json:"state,omitempty"`

// Mode indicates whether the resource is live and is being updated
// by the reconcilers or whether it is in testing mode and is being
// updated manually.
// +kubebuilder:validation:Enum:=Live;Testing
// +kubebuilder:default:=Live
Mode string `json:"mode,omitempty"`
}

// StorageDevice contains the details of the storage hardware
Expand Down Expand Up @@ -133,6 +140,7 @@ type StorageStatus struct {
//+kubebuilder:subresource:status
//+kubebuilder:printcolumn:name="State",type="string",JSONPath=".spec.state",description="State of the storage resource"
//+kubebuilder:printcolumn:name="Status",type="string",JSONPath=".status.status",description="Status of the storage resource"
//+kubebuilder:printcolumn:name="Mode",type="string",JSONPath=".spec.mode",description="State of live updates"
//+kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp"

// Storage is the Schema for the storages API
Expand Down
14 changes: 14 additions & 0 deletions config/crd/bases/dataworkflowservices.github.io_storages.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,10 @@ spec:
jsonPath: .status.status
name: Status
type: string
- description: State of live updates
jsonPath: .spec.mode
name: Mode
type: string
- jsonPath: .metadata.creationTimestamp
name: Age
type: date
Expand Down Expand Up @@ -248,6 +252,16 @@ spec:
description: StorageSpec defines the desired specifications of Storage
resource
properties:
mode:
default: Live
description: |-
Mode indicates whether the resource is live and is being updated
by the reconcilers or whether it is in testing mode and is being
updated manually.
enum:
- Live
- Testing
type: string
state:
default: Enabled
description: State describes the desired state of the Storage resource.
Expand Down

0 comments on commit 6e87ba9

Please sign in to comment.