-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
feat: add artifact delete to argoexec CLI Signed-off-by: Dillen Padhiar <dillen_padhiar@intuit.com>
- Loading branch information
Showing
4 changed files
with
66 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package artifact | ||
|
||
import ( | ||
"context" | ||
"encoding/json" | ||
"fmt" | ||
"os" | ||
"path/filepath" | ||
|
||
"github.com/spf13/cobra" | ||
|
||
wfv1 "github.com/argoproj/argo-workflows/v3/pkg/apis/workflow/v1alpha1" | ||
executor "github.com/argoproj/argo-workflows/v3/workflow/artifacts" | ||
"github.com/argoproj/argo-workflows/v3/workflow/common" | ||
) | ||
|
||
func NewArtifactDeleteCommand() *cobra.Command { | ||
return &cobra.Command{ | ||
Use: "delete", | ||
SilenceUsage: true, | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
a := &wfv1.Artifact{} | ||
if err := json.Unmarshal([]byte(os.Getenv(common.EnvVarArtifact)), a); err != nil { | ||
return fmt.Errorf("failed to unmarshal artifact: %w", err) | ||
} | ||
|
||
drv, err := executor.NewDriver(cmd.Context(), a, &resources{}) | ||
if err != nil { | ||
return fmt.Errorf("failed to create driver: %w", err) | ||
} | ||
|
||
if err := drv.Delete(a); err != nil { | ||
return fmt.Errorf("failed to delete artifact: %w", err) | ||
} | ||
return nil | ||
}, | ||
} | ||
} | ||
|
||
type resources struct{} | ||
|
||
func (r resources) GetSecret(ctx context.Context, name, key string) (string, error) { | ||
file, err := os.ReadFile(filepath.Join(common.SecretVolMountPath, name, key)) | ||
return string(file), err | ||
|
||
} | ||
|
||
func (r resources) GetConfigMapKey(ctx context.Context, name, key string) (string, error) { | ||
return "", fmt.Errorf("not supported") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package artifact | ||
|
||
import ( | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
func NewArtifactCommand() *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: "artifact", | ||
} | ||
cmd.AddCommand(NewArtifactDeleteCommand()) | ||
return cmd | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters