Skip to content

Commit

Permalink
Fixed : CLI Does Not Honor metadata.namespace #1288 (#1352)
Browse files Browse the repository at this point in the history
  • Loading branch information
sarabala1979 authored May 10, 2019
1 parent e58859d commit 810949d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 2 additions & 2 deletions cmd/argo/commands/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ var (
wfClient v1alpha1.WorkflowInterface
jobStatusIconMap map[wfv1.NodePhase]string
noColor bool
namespace string
)

func init() {
Expand Down Expand Up @@ -80,11 +81,10 @@ func initKubeClient() *kubernetes.Clientset {

// InitWorkflowClient creates a new client for the Kubernetes Workflow CRD.
func InitWorkflowClient(ns ...string) v1alpha1.WorkflowInterface {
if wfClient != nil {
if wfClient != nil && (len(ns) == 0 || ns[0] == namespace) {
return wfClient
}
initKubeClient()
var namespace string
var err error
if len(ns) > 0 {
namespace = ns[0]
Expand Down
6 changes: 5 additions & 1 deletion cmd/argo/commands/submit.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func SubmitWorkflows(filePaths []string, submitOpts *util.SubmitOpts, cliOpts *c
if cliOpts == nil {
cliOpts = &cliSubmitOpts{}
}
InitWorkflowClient()
defaultWFClient := InitWorkflowClient()
var workflows []wfv1.Workflow
if len(filePaths) == 1 && filePaths[0] == "-" {
reader := bufio.NewReader(os.Stdin)
Expand Down Expand Up @@ -114,6 +114,10 @@ func SubmitWorkflows(filePaths []string, submitOpts *util.SubmitOpts, cliOpts *c
var workflowNames []string
for _, wf := range workflows {
wf.Spec.Priority = cliOpts.priority
wfClient := defaultWFClient
if wf.Namespace != "" {
wfClient = InitWorkflowClient(wf.Namespace)
}
created, err := util.SubmitWorkflow(wfClient, &wf, submitOpts)
if err != nil {
log.Fatalf("Failed to submit workflow: %v", err)
Expand Down

0 comments on commit 810949d

Please sign in to comment.