Skip to content

Commit

Permalink
Refactor old DeleteData (#5279)
Browse files Browse the repository at this point in the history
  • Loading branch information
DeepikaDixit authored and Ilya Kislenko committed Mar 26, 2019
1 parent 910711e commit f62e440
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 20 deletions.
10 changes: 4 additions & 6 deletions docs/functions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -403,8 +403,8 @@ If the ActionSet `Object` is a PersistentVolumeClaim:
volume: "{{ .PVC.Name }}"
dataArtifactPrefix: s3-bucket-name/path
DeleteData
----------
LocationDelete
--------------

This function uses a new Pod to delete the specified artifact
from an S3 compatible object store.
Expand All @@ -414,7 +414,6 @@ from an S3 compatible object store.
:align: left
:widths: 5,5,5,15

`namespace`, No, `string`, namespace in which to execute
`artifact`, Yes, `string`, artifact to be deleted from the object store

.. note::
Expand All @@ -427,10 +426,9 @@ Example:
.. code-block:: yaml
:linenos:
- func: DeleteData
name: DeleteFromObjectStore
- func: LocationDelete
name: LocationDeleteFromObjectStore
args:
namespace: "{{ .Deployment.Namespace }}"
artifact: s3://bucket/path/artifact
.. _createvolumesnapshot:
Expand Down
5 changes: 2 additions & 3 deletions examples/time-log/blueprint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ actions:
inputArtifactNames:
- timeLog
phases:
- func: DeleteData
name: deleteFromS3
- func: LocationDelete
name: LocationDeleteFromS3
args:
namespace: "{{ .Deployment.Namespace }}"
artifact: "{{ .ArtifactsIn.timeLog.KeyValue.path }}"
17 changes: 6 additions & 11 deletions pkg/function/delete_data.go → pkg/function/location_delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,8 @@ import (
)

const (
// DeleteDataNamespaceArg provides the namespace
DeleteDataNamespaceArg = "namespace"
// DeleteDataArtifactArg provides the path to the artifacts on the object store
DeleteDataArtifactArg = "artifact"
// LocationDeleteArtifactArg provides the path to the artifacts on the object store
LocationDeleteArtifactArg = "artifact"
)

func init() {
Expand All @@ -26,16 +24,13 @@ var _ kanister.Func = (*deleteDataFunc)(nil)
type deleteDataFunc struct{}

func (*deleteDataFunc) Name() string {
return "DeleteData"
return "LocationDelete"
}

func (*deleteDataFunc) Exec(ctx context.Context, tp param.TemplateParams, args map[string]interface{}) (map[string]interface{}, error) {
var artifact, namespace string
var artifact string
var err error
if err = Arg(args, DeleteDataArtifactArg, &artifact); err != nil {
return nil, err
}
if err = OptArg(args, DeleteDataNamespaceArg, &namespace, ""); err != nil {
if err = Arg(args, LocationDeleteArtifactArg, &artifact); err != nil {
return nil, err
}
// Validate the Profile
Expand All @@ -47,5 +42,5 @@ func (*deleteDataFunc) Exec(ctx context.Context, tp param.TemplateParams, args m
}

func (*deleteDataFunc) RequiredArgs() []string {
return []string{DeleteDataArtifactArg}
return []string{LocationDeleteArtifactArg}
}

0 comments on commit f62e440

Please sign in to comment.