Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Aug 30, 2024. It is now read-only.
/coder-v1-cliPublic archive

Commite76a60e

Browse files
committed
fixup! Add coder envs rm command for removing environments
1 parent0d0c495 commite76a60e

File tree

1 file changed

+19
-22
lines changed

1 file changed

+19
-22
lines changed

‎internal/cmd/envs.go

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import (
1212
"github.com/manifoldco/promptui"
1313
"github.com/spf13/cobra"
1414
"golang.org/x/sync/errgroup"
15-
"golang.org/x/sync/semaphore"
1615
"golang.org/x/xerrors"
1716
)
1817

@@ -198,7 +197,7 @@ coder envs create --cpu 4 --disk 100 --memory 8 --image 5f443b16-30652892427b955
198197
clog.LogSuccess(
199198
"creating environment...",
200199
clog.BlankLine,
201-
clog.Tipf(`run "coder envs watch-build %q" to trail the build logs`,args[0]),
200+
clog.Tipf(`run "coder envs watch-build %s" to trail the build logs`,env.Name),
202201
)
203202

204203
iffollow {
@@ -335,45 +334,43 @@ func rmEnvsCommand(user *string) *cobra.Command {
335334
iferr!=nil {
336335
returnerr
337336
}
338-
339-
// only show one confirmation dialogue at a time
340-
confirmLimiter:=semaphore.NewWeighted(1)
337+
if!force {
338+
confirm:= promptui.Prompt{
339+
Label:fmt.Sprintf("Delete environments %q? (all data will be lost)",args),
340+
IsConfirm:true,
341+
}
342+
if_,err:=confirm.Run();err!=nil {
343+
returnerr
344+
}
345+
}
341346

342347
varegroup errgroup.Group
348+
varfailuresint32
343349
for_,envName:=rangeargs {
344350
envName:=envName
345351
egroup.Go(func()error {
346352
env,err:=findEnv(ctx,client,envName,*user)
347353
iferr!=nil {
354+
atomic.AddInt32(&failures,1)
348355
clog.Log(err)
349356
returnerr
350357
}
351-
if!force {
352-
confirm:= promptui.Prompt{
353-
Label:fmt.Sprintf("Delete environment\"%s\"? (all data will be lost)",env.Name),
354-
IsConfirm:true,
355-
}
356-
iferr:=confirmLimiter.Acquire(ctx,1);err!=nil {
357-
returnerr
358-
}
359-
360-
if_,err=confirm.Run();err!=nil {
361-
confirmLimiter.Release(1)
362-
returnxerrors.Errorf("confirm deletion of environment\"%s\"",env.Name)
363-
}
364-
confirmLimiter.Release(1)
365-
}
366358
iferr=client.DeleteEnvironment(cmd.Context(),env.ID);err!=nil {
367-
err=clog.Error(fmt.Sprintf(`failed to delete environment "%s"`,env.Name),clog.Cause(err.Error()))
359+
atomic.AddInt32(&failures,1)
360+
err=clog.Error(
361+
fmt.Sprintf(`failed to delete environment "%s"`,env.Name),
362+
clog.Causef(err.Error()),
363+
)
368364
clog.Log(err)
369365
returnerr
370366
}
367+
clog.LogSuccess(fmt.Sprintf("deleted environment %q",env.Name))
371368
returnnil
372369
})
373370
}
374371

375372
iferr=egroup.Wait();err!=nil {
376-
returnxerrors.Errorf("some environment remove operations failed")
373+
returnxerrors.Errorf("%d failures emitted",failures)
377374
}
378375
returnnil
379376
},

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp