Skip to content

Commit ff7717c

Browse files
committed
Update rad commands with concise output
Signed-off-by: Zach Casper <zachcasper@microsoft.com>
1 parent 210a9ec commit ff7717c

32 files changed

Lines changed: 134 additions & 421 deletions

File tree

‎pkg/cli/cmd/app/delete/delete.go‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ func (r *Runner) Run(ctx context.Context) error {
163163

164164
app, err := client.GetApplication(ctx, r.ApplicationName)
165165
if clients.Is404Error(err) {
166-
r.Output.LogInfo("Application '%s' does not exist or has already been deleted.", r.ApplicationName)
166+
r.Output.LogInfo("Applications.Core/applications/%s not found", r.ApplicationName)
167167
return nil
168168
} else if err != nil {
169169
return err
@@ -194,15 +194,15 @@ func (r *Runner) Run(ctx context.Context) error {
194194
})
195195
if err != nil {
196196
if strings.Contains(err.Error(), "not found") {
197-
r.Output.LogInfo("Application '%s' does not exist or has already been deleted.", r.ApplicationName)
197+
r.Output.LogInfo("Applications.Core/applications/%s not found", r.ApplicationName)
198198
return nil
199199
}
200200
return clierrors.Message("Failed to delete application '%s': %v", r.ApplicationName, err)
201201
}
202202
if deleted {
203-
r.Output.LogInfo("Application %s deleted successfully", r.ApplicationName)
203+
r.Output.LogInfo("Applications.Core/applications/%s deleted", r.ApplicationName)
204204
} else {
205-
r.Output.LogInfo("Application '%s' does not exist or has already been deleted.", r.ApplicationName)
205+
r.Output.LogInfo("Applications.Core/applications/%s not found", r.ApplicationName)
206206
return nil
207207
}
208208

‎pkg/cli/cmd/app/delete/delete_test.go‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ func Test_Delete(t *testing.T) {
171171

172172
expected := []any{
173173
output.LogOutput{
174-
Format: "Application %s deleted successfully",
174+
Format: "Applications.Core/applications/%s deleted",
175175
Params: []any{"test-app"},
176176
},
177177
}
@@ -240,7 +240,7 @@ func Test_Delete(t *testing.T) {
240240

241241
expected := []any{
242242
output.LogOutput{
243-
Format: "Application %s deleted successfully",
243+
Format: "Applications.Core/applications/%s deleted",
244244
Params: []any{"test-app"},
245245
},
246246
}
@@ -354,7 +354,7 @@ func Test_Delete(t *testing.T) {
354354

355355
expected := []any{
356356
output.LogOutput{
357-
Format: "Application '%s' does not exist or has already been deleted.",
357+
Format: "Applications.Core/applications/%s not found",
358358
Params: []any{"test-app"},
359359
},
360360
}
@@ -522,7 +522,7 @@ func Test_Delete(t *testing.T) {
522522

523523
expected := []any{
524524
output.LogOutput{
525-
Format: "Application '%s' does not exist or has already been deleted.",
525+
Format: "Applications.Core/applications/%s not found",
526526
Params: []any{"test-app"},
527527
},
528528
}

‎pkg/cli/cmd/env/create/create.go‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,6 @@ func (r *Runner) Validate(cmd *cobra.Command, args []string) error {
150150
// Run creates an environment in the specified resource group using the provided environment name and namespace, and
151151
// returns an error if unsuccessful.
152152
func (r *Runner) Run(ctx context.Context) error {
153-
r.Output.LogInfo("Creating Environment...")
154-
155153
client, err := r.ConnectionFactory.CreateApplicationsManagementClient(ctx, *r.Workspace)
156154
if err != nil {
157155
return err
@@ -170,7 +168,7 @@ func (r *Runner) Run(ctx context.Context) error {
170168
if err != nil {
171169
return err
172170
}
173-
r.Output.LogInfo("Successfully created environment %q in resource group %q", r.EnvironmentName, r.ResourceGroupName)
171+
r.Output.LogInfo("Applications.Core/environments/%s created", r.EnvironmentName)
174172

175173
return nil
176174
}

‎pkg/cli/cmd/env/create/create_test.go‎

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -188,13 +188,9 @@ func Test_Run(t *testing.T) {
188188

189189
expectedOutput := []any{
190190
output.LogOutput{
191-
Format: "Creating Environment...",
192-
},
193-
output.LogOutput{
194-
Format: "Successfully created environment %q in resource group %q",
191+
Format: "Applications.Core/environments/%s created",
195192
Params: []any{
196193
"default",
197-
"test-group",
198194
},
199195
},
200196
}
@@ -247,16 +243,10 @@ func Test_Run(t *testing.T) {
247243
ConfigFileInterface: configFileInterface,
248244
}
249245

250-
expectedOutput := []any{
251-
output.LogOutput{
252-
Format: "Creating Environment...",
253-
},
254-
}
255-
256246
err := runner.Run(context.Background())
257247
require.Error(t, err)
258248
require.Equal(t, expectedError, err)
259-
require.Equal(t, expectedOutput, outputSink.Writes)
249+
require.Empty(t, outputSink.Writes)
260250
})
261251
}
262252

‎pkg/cli/cmd/env/create/preview/create.go‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,6 @@ func (r *Runner) Run(ctx context.Context) error {
141141
r.RadiusCoreClientFactory = clientFactory
142142
}
143143

144-
r.Output.LogInfo("Creating Radius Core Environment...")
145-
146144
resource := &corerpv20250801.EnvironmentResource{
147145
Location: to.Ptr(v1.LocationGlobal),
148146
Properties: &corerpv20250801.EnvironmentProperties{},
@@ -153,7 +151,7 @@ func (r *Runner) Run(ctx context.Context) error {
153151
if err != nil {
154152
return err
155153
}
156-
r.Output.LogInfo("Successfully created environment %q in resource group %q", r.EnvironmentName, r.ResourceGroupName)
154+
r.Output.LogInfo("Radius.Core/environments/%s created", r.EnvironmentName)
157155

158156
return nil
159157
}

‎pkg/cli/cmd/env/create/preview/create_test.go‎

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -167,13 +167,9 @@ func Test_Run(t *testing.T) {
167167

168168
expectedOutput := []any{
169169
output.LogOutput{
170-
Format: "Creating Radius Core Environment...",
171-
},
172-
output.LogOutput{
173-
Format: "Successfully created environment %q in resource group %q",
170+
Format: "Radius.Core/environments/%s created",
174171
Params: []any{
175172
"testenv",
176-
"test-resource-group",
177173
},
178174
},
179175
}

‎pkg/cli/cmd/env/delete/delete.go‎

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,8 @@ import (
3131
)
3232

3333
const (
34-
msgEnvironmentDeleted = "Environment deleted"
35-
msgEnvironmentNotFound = "Environment '%s' does not exist or has already been deleted."
36-
msgDeletingEnvironment = "Deleting environment %s...\n"
37-
msgDeletingResourceCount = "Deleting %d resource(s) in environment %s...\n"
34+
msgEnvironmentDeleted = "Applications.Core/environments/%s deleted"
35+
msgEnvironmentNotFound = "Applications.Core/environments/%s not found"
3836
)
3937

4038
// NewCommand creates an instance of the command and runner for the `rad env delete` command.
@@ -166,24 +164,17 @@ func (r *Runner) Run(ctx context.Context) error {
166164
return err
167165
}
168166
if !confirmed {
169-
r.Output.LogInfo("Environment %q NOT deleted", r.EnvironmentName)
170167
return nil
171168
}
172169
}
173170

174-
// Show progress messages
175-
if totalResourceCount > 0 {
176-
r.Output.LogInfo(msgDeletingResourceCount, totalResourceCount, r.EnvironmentName)
177-
}
178-
r.Output.LogInfo(msgDeletingEnvironment, r.EnvironmentName)
179-
180171
deleted, err := client.DeleteEnvironment(ctx, r.EnvironmentName)
181172
if err != nil {
182173
return err
183174
}
184175

185176
if deleted {
186-
r.Output.LogInfo(msgEnvironmentDeleted)
177+
r.Output.LogInfo(msgEnvironmentDeleted, r.EnvironmentName)
187178
} else {
188179
r.Output.LogInfo(msgEnvironmentNotFound, r.EnvironmentName)
189180
}

‎pkg/cli/cmd/env/delete/delete_test.go‎

Lines changed: 6 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ func Test_CommandValidation(t *testing.T) {
3939
}
4040

4141
const (
42-
deleteConfirmationEmpty = "The environment %s is empty. Are you sure you want to delete the environment?"
42+
deleteConfirmationEmpty = "The environment %s is empty. Are you sure you want to delete the environment?"
4343
deleteConfirmationWithResources = "The environment %s contains %d deployed resource(s). Are you sure you want to delete the environment and its resources?"
4444
)
4545

@@ -145,12 +145,9 @@ func Test_Show(t *testing.T) {
145145
require.NoError(t, err)
146146

147147
expected := []any{
148-
output.LogOutput{
149-
Format: msgDeletingEnvironment,
150-
Params: []any{"test-env"},
151-
},
152148
output.LogOutput{
153149
Format: msgEnvironmentDeleted,
150+
Params: []any{"test-env"},
154151
},
155152
}
156153

@@ -201,12 +198,9 @@ func Test_Show(t *testing.T) {
201198
require.NoError(t, err)
202199

203200
expected := []any{
204-
output.LogOutput{
205-
Format: msgDeletingEnvironment,
206-
Params: []any{"test-env"},
207-
},
208201
output.LogOutput{
209202
Format: msgEnvironmentDeleted,
203+
Params: []any{"test-env"},
210204
},
211205
}
212206

@@ -260,16 +254,9 @@ func Test_Show(t *testing.T) {
260254
require.NoError(t, err)
261255

262256
expected := []any{
263-
output.LogOutput{
264-
Format: msgDeletingResourceCount,
265-
Params: []any{1, "test-env"},
266-
},
267-
output.LogOutput{
268-
Format: msgDeletingEnvironment,
269-
Params: []any{"test-env"},
270-
},
271257
output.LogOutput{
272258
Format: msgEnvironmentDeleted,
259+
Params: []any{"test-env"},
273260
},
274261
}
275262

@@ -323,16 +310,9 @@ func Test_Show(t *testing.T) {
323310
require.NoError(t, err)
324311

325312
expected := []any{
326-
output.LogOutput{
327-
Format: msgDeletingResourceCount,
328-
Params: []any{1, "test-env"},
329-
},
330-
output.LogOutput{
331-
Format: msgDeletingEnvironment,
332-
Params: []any{"test-env"},
333-
},
334313
output.LogOutput{
335314
Format: msgEnvironmentDeleted,
315+
Params: []any{"test-env"},
336316
},
337317
}
338318

@@ -376,13 +356,7 @@ func Test_Show(t *testing.T) {
376356
err := runner.Run(context.Background())
377357
require.NoError(t, err)
378358

379-
expected := []any{
380-
output.LogOutput{
381-
Format: "Environment %q NOT deleted",
382-
Params: []any{"test-env"},
383-
},
384-
}
385-
require.Equal(t, expected, outputSink.Writes)
359+
require.Empty(t, outputSink.Writes)
386360
})
387361

388362
// YES, this is a success case. Delete means "make it be gone", so if the environment is already
@@ -428,10 +402,6 @@ func Test_Show(t *testing.T) {
428402
require.NoError(t, err)
429403

430404
expected := []any{
431-
output.LogOutput{
432-
Format: msgDeletingEnvironment,
433-
Params: []any{"test-env"},
434-
},
435405
output.LogOutput{
436406
Format: msgEnvironmentNotFound,
437407
Params: []any{"test-env"},

‎pkg/cli/cmd/env/delete/preview/delete.go‎

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,8 @@ import (
3333
)
3434

3535
const (
36-
msgEnvironmentDeletedPreview = "Environment deleted"
37-
msgEnvironmentNotFoundPreview = "Environment '%s' does not exist or has already been deleted."
38-
msgDeletingEnvironmentPreview = "Deleting environment %s...\n"
39-
msgDeletingResourceCountPreview = "Deleting %d resource(s) in environment %s...\n"
36+
msgEnvironmentDeletedPreview = "Radius.Core/environments/%s deleted"
37+
msgEnvironmentNotFoundPreview = "Radius.Core/environments/%s not found"
4038
)
4139

4240
// NewCommand creates an instance of the command and runner for the `rad env delete --preview` command.
@@ -138,14 +136,10 @@ func (r *Runner) Run(ctx context.Context) error {
138136
return err
139137
}
140138
if !confirmed {
141-
r.Output.LogInfo("Environment %q NOT deleted", r.EnvironmentName)
142139
return nil
143140
}
144141
}
145142

146-
// Show progress messages (without resource count for preview, since we don't enumerate here)
147-
r.Output.LogInfo(msgDeletingEnvironmentPreview, r.EnvironmentName)
148-
149143
client := r.RadiusCoreClientFactory.NewEnvironmentsClient()
150144
_, err := client.Delete(ctx, r.EnvironmentName, &corerpv20250801.EnvironmentsClientDeleteOptions{})
151145
if err != nil {
@@ -154,7 +148,7 @@ func (r *Runner) Run(ctx context.Context) error {
154148
return err
155149
}
156150

157-
r.Output.LogInfo(msgEnvironmentDeletedPreview)
151+
r.Output.LogInfo(msgEnvironmentDeletedPreview, r.EnvironmentName)
158152

159153
return nil
160154
}

‎pkg/cli/cmd/env/delete/preview/delete_test.go‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,12 +98,9 @@ func Test_Run(t *testing.T) {
9898
name: "Success: environment deleted",
9999
serverFactory: test_client_factory.WithEnvironmentServerNoError,
100100
expectedLogs: []any{
101-
output.LogOutput{
102-
Format: msgDeletingEnvironmentPreview,
103-
Params: []any{"test-env"},
104-
},
105101
output.LogOutput{
106102
Format: msgEnvironmentDeletedPreview,
103+
Params: []any{"test-env"},
107104
},
108105
},
109106
},

0 commit comments

Comments
 (0)