Skip to content

Commit

Permalink
[aidi][feat] support resource create or get
Browse files Browse the repository at this point in the history
  • Loading branch information
yangxue.chen committed Jun 16, 2021
1 parent 8059932 commit 1750e50
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion workflow/executor/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
"github.com/argoproj/argo-workflows/v3/util"
envutil "github.com/argoproj/argo-workflows/v3/util/env"
argoerr "github.com/argoproj/argo-workflows/v3/util/errors"
os_specific "github.com/argoproj/argo-workflows/v3/workflow/executor/os-specific"
"github.com/argoproj/argo-workflows/v3/workflow/executor/os-specific"
)

// ExecResource will run kubectl action against a manifest
Expand All @@ -38,6 +38,18 @@ func (we *WorkflowExecutor) ExecResource(action string, manifestPath string, fla
log.Info(strings.Join(cmd.Args, " "))

out, err := cmd.Output()
if err != nil && action == "create" {
// create支持restart,如果create err(already exists), try get
args, err = we.getKubectlArguments("get", manifestPath, flags)
if err != nil {
return "", "", "", err
}

cmd = exec.Command("kubectl", args...)
log.Info(strings.Join(cmd.Args, " "))

out, err = cmd.Output()
}
if err != nil {
if exErr, ok := err.(*exec.ExitError); ok {
errMsg := strings.TrimSpace(string(exErr.Stderr))
Expand Down

0 comments on commit 1750e50

Please sign in to comment.