Skip to content

Commit 547d392

Browse files
committed
Fix duplicated output for create-workspace
Signed-off-by: Nelo-T. Wallus <[email protected]> Signed-off-by: Nelo-T. Wallus <[email protected]>
1 parent 9e899fe commit 547d392

File tree

2 files changed

+7
-13
lines changed

2 files changed

+7
-13
lines changed

cli/pkg/workspace/plugin/context.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -144,14 +144,15 @@ func (o *CreateContextOptions) Run(ctx context.Context) error {
144144
return err
145145
}
146146

147+
verb := "Created"
147148
if existedBefore {
148-
if o.startingConfig.CurrentContext == o.Name {
149-
_, err = fmt.Fprintf(o.Out, "Updated context %q.\n", o.Name)
150-
} else {
151-
_, err = fmt.Fprintf(o.Out, "Updated context %q and switched to it.\n", o.Name)
152-
}
149+
verb = "Updated"
150+
}
151+
152+
if o.KeepCurrent || o.startingConfig.CurrentContext == o.Name {
153+
_, err = fmt.Fprintf(o.Out, "%s context %q.\n", verb, o.Name)
153154
} else {
154-
_, err = fmt.Fprintf(o.Out, "Created context %q and switched to it.\n", o.Name)
155+
_, err = fmt.Fprintf(o.Out, "%s context %q and switched to it.\n", verb, o.Name)
155156
}
156157

157158
return err

cli/pkg/workspace/plugin/create.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -268,13 +268,6 @@ func (o *CreateWorkspaceOptions) Run(ctx context.Context) error {
268268
return fmt.Errorf("failed to create context: %w", err)
269269
}
270270

271-
// Print output
272-
if o.EnterAfterCreate {
273-
fmt.Fprintf(o.Out, "Created context %q and switched to it.\n", o.CreateContextName)
274-
} else {
275-
fmt.Fprintf(o.Out, "Created context %q.\n", o.CreateContextName)
276-
}
277-
278271
return nil
279272
}
280273

0 commit comments

Comments
 (0)