Skip to content

Commit

Permalink
Merge pull request #225 from ksimon1/delete-pvc
Browse files Browse the repository at this point in the history
feat: add delete PVC option for modify-data-object task
  • Loading branch information
ksimon1 authored Feb 20, 2023
2 parents 44b1ba3 + 5214871 commit d69f5d4
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 10 deletions.
2 changes: 1 addition & 1 deletion manifests/kubernetes/kubevirt-tekton-tasks-kubernetes.yaml

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

2 changes: 1 addition & 1 deletion manifests/okd/kubevirt-tekton-tasks-okd.yaml

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

1 change: 1 addition & 0 deletions modules/modify-data-object/pkg/constants/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const (
const (
DataVolumeKind = "DataVolume"
DataSourceKind = "DataSource"
PVCKind = "PersistentVolumeClaim"
)

// Result names
Expand Down
10 changes: 6 additions & 4 deletions modules/modify-data-object/pkg/dataobject/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,13 +154,15 @@ func NewDataObjectCreator(cliOptions *parse.CLIOptions) (*DataObjectCreator, err
}

func (d *DataObjectCreator) DeleteDataObject() error {
if d.cliOptions.DeleteObjectKind == constants.DataVolumeKind {
switch d.cliOptions.DeleteObjectKind {
case constants.DataVolumeKind:
return d.dataObjectProvider.DeleteDV(d.cliOptions.DataObjectNamespace, d.cliOptions.DeleteObjectName)
}

if d.cliOptions.DeleteObjectKind == constants.DataSourceKind {
case constants.DataSourceKind:
return d.dataObjectProvider.DeleteDS(d.cliOptions.DataObjectNamespace, d.cliOptions.DeleteObjectName)
case constants.PVCKind:
return d.dataObjectProvider.DeletePVC(d.cliOptions.DataObjectNamespace, d.cliOptions.DeleteObjectName)
}

return errors.NewBadRequest("object-kind not defined")
}

Expand Down
2 changes: 1 addition & 1 deletion modules/modify-data-object/pkg/utils/parse/clioptions.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ func (c *CLIOptions) assertValidParams() error {
return zerrors.NewMissingRequiredError("%s param has to be specified", nameOptionName)
}

if c.DeleteObjectKind != constants.DataVolumeKind && c.DeleteObjectKind != constants.DataSourceKind {
if c.DeleteObjectKind != constants.DataVolumeKind && c.DeleteObjectKind != constants.DataSourceKind && c.DeleteObjectKind != constants.PVCKind {
return zerrors.NewMissingRequiredError("%s param has to have values %s or %s", objectKindOptionName, constants.DataVolumeKind, constants.DataSourceKind)
}
return nil
Expand Down
2 changes: 1 addition & 1 deletion tasks/modify-data-object/README.md

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

2 changes: 1 addition & 1 deletion tasks/modify-data-object/manifests/modify-data-object.yaml

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

Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ spec:
type: string
default: "false"
- name: deleteObject
description: Set to `true` or `false` if task should delete the specified datavolume or datasource. If set to 'true' the ds/dv will be deleted and all other parameters are ignored.
description: Set to `true` or `false` if task should delete the specified DataVolume, DataSource or PersistentVolumeClaim. If set to 'true' the ds/dv/pvc will be deleted and all other parameters are ignored.
default: 'false'
type: string
- name: deleteObjectKind
Expand Down

0 comments on commit d69f5d4

Please sign in to comment.