Skip to content

Commit

Permalink
Fix ctx writing kubeconfig to stdout with current path (#608)
Browse files Browse the repository at this point in the history
  • Loading branch information
RedbackThomson authored Aug 22, 2024
1 parent ac8675e commit dc53958
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions cmd/up/ctx/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ func (c *Cmd) RunNonInteractive(ctx context.Context, upCtx *upbound.Context, nav

// final step if we moved: accept the state
msg := fmt.Sprintf("Kubeconfig context %q: %s\n", c.KubeContext, withUpboundPrefix(m.state.Breadcrumbs()))
if m.state.Breadcrumbs() != initialState.Breadcrumbs() {
if m.state.Breadcrumbs() != initialState.Breadcrumbs() || c.File == "-" {
accepting, ok := m.state.(Accepting)
if !ok {
return fmt.Errorf("cannot move context to: %s", m.state.Breadcrumbs())
Expand All @@ -334,11 +334,14 @@ func (c *Cmd) RunNonInteractive(ctx context.Context, upCtx *upbound.Context, nav
}
}

// don't print anything else or we are going to pollute stdout
if c.Short {
fmt.Println(m.state.Breadcrumbs())
} else {
fmt.Print(msg)
// if printing the kubeconfig to stdout, don't print anything els
if c.File != "-" {
// don't print anything else or we are going to pollute stdout
if c.Short {
fmt.Println(m.state.Breadcrumbs())
} else {
fmt.Print(msg)
}
}

return nil
Expand Down

0 comments on commit dc53958

Please sign in to comment.