Skip to content

Commit

Permalink
Dxcdt 393 ensure status and progress indicator (#949)
Browse files Browse the repository at this point in the history
* Bump github.com/auth0/go-auth0 from 1.2.0 to 1.3.0 (#908)

Bumps [github.com/auth0/go-auth0](https://github.com/auth0/go-auth0) from 1.2.0 to 1.3.0.
- [Release notes](https://github.com/auth0/go-auth0/releases)
- [Changelog](https://github.com/auth0/go-auth0/blob/main/CHANGELOG.md)
- [Commits](auth0/go-auth0@v1.2.0...v1.3.0)

---
updated-dependencies:
- dependency-name: github.com/auth0/go-auth0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* dxcdt-615-goreleaser-upgrade (#909)

* Fix: Remove or replace deprecations for GoReleaser config

Remove deprecated replacements
Replace deprecated brews tap
Replace deprecated scoop entries
Fix name_template to reflect exact current naming conventions

* DXCDT-582: Convert audience into a drop down in interactive mode in test token cmd (#906)

Convert audience into a drop down in interactive mode in test token cmd

* Bump github.com/auth0/go-auth0 from 1.2.0 to 1.3.0 (#908)

Bumps [github.com/auth0/go-auth0](https://github.com/auth0/go-auth0) from 1.2.0 to 1.3.0.
- [Release notes](https://github.com/auth0/go-auth0/releases)
- [Changelog](https://github.com/auth0/go-auth0/blob/main/CHANGELOG.md)
- [Commits](auth0/go-auth0@v1.2.0...v1.3.0)

---
updated-dependencies:
- dependency-name: github.com/auth0/go-auth0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: Sergiu Ghitea <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* DXCDT-582: Convert audience into a drop down in interactive mode in test token cmd (#906)

Convert audience into a drop down in interactive mode in test token cmd

Title Os for final release name fit

* Bump goreleaser version

* Use progress bars for long multistep processes

Create generic ProgressBar
Ensure 1 or less items behaves like Spinner
Add progress bars to possibly longer processes

* Bump github.com/google/uuid from 1.4.0 to 1.5.0 (#942)

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Dxcdt 578 increase results amount in lists (#940)

* Bump github.com/auth0/go-auth0 from 1.2.0 to 1.3.0 (#908)

Bumps [github.com/auth0/go-auth0](https://github.com/auth0/go-auth0) from 1.2.0 to 1.3.0.
- [Release notes](https://github.com/auth0/go-auth0/releases)
- [Changelog](https://github.com/auth0/go-auth0/blob/main/CHANGELOG.md)
- [Commits](auth0/go-auth0@v1.2.0...v1.3.0)

---
updated-dependencies:
- dependency-name: github.com/auth0/go-auth0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* dxcdt-615-goreleaser-upgrade (#909)

* Fix: Remove or replace deprecations for GoReleaser config

Remove deprecated replacements
Replace deprecated brews tap
Replace deprecated scoop entries
Fix name_template to reflect exact current naming conventions

* DXCDT-582: Convert audience into a drop down in interactive mode in test token cmd (#906)

Convert audience into a drop down in interactive mode in test token cmd

* Bump github.com/auth0/go-auth0 from 1.2.0 to 1.3.0 (#908)

Bumps [github.com/auth0/go-auth0](https://github.com/auth0/go-auth0) from 1.2.0 to 1.3.0.
- [Release notes](https://github.com/auth0/go-auth0/releases)
- [Changelog](https://github.com/auth0/go-auth0/blob/main/CHANGELOG.md)
- [Commits](auth0/go-auth0@v1.2.0...v1.3.0)

---
updated-dependencies:
- dependency-name: github.com/auth0/go-auth0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: Sergiu Ghitea <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* DXCDT-582: Convert audience into a drop down in interactive mode in test token cmd (#906)

Convert audience into a drop down in interactive mode in test token cmd

Title Os for final release name fit

* Bump goreleaser version

* Increase default page amount to 100 results per page

* Updated docs for defalut list limit

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Sergiu Ghitea <[email protected]>

* Bump github.com/auth0/go-auth0 from 1.3.1 to 1.4.0 (#944)

* DXCDT-396: Standardize error messages (#943)

* Bump golang.org/x/crypto from 0.16.0 to 0.17.0 (#947)

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Ignore err for adding steps to the ProgressBar

This is a specific error, internal to the developer and not of use to the user

* Organize imports

* Improve error messages in APIs

* Add documentation comment for ProgressBar

Co-authored-by: Sergiu Ghitea <[email protected]>

* Normalize delete error messages

* Discard duplicate path escape

* Revert data file

* Return nil on 0 case

* Ensure ID isn't empty when deleting an organization

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Sergiu Ghitea <[email protected]>
  • Loading branch information
3 people authored Dec 21, 2023
1 parent 76f97dd commit 5620e50
Show file tree
Hide file tree
Showing 16 changed files with 135 additions and 140 deletions.
4 changes: 3 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ require (
github.com/olekukonko/tablewriter v0.0.5
github.com/pkg/browser v0.0.0-20210706143420-7d21f8c997e2
github.com/pkg/errors v0.9.1
github.com/schollz/progressbar/v3 v3.14.1
github.com/spf13/cobra v1.8.0
github.com/spf13/pflag v1.0.5
github.com/stretchr/testify v1.8.4
Expand Down Expand Up @@ -76,12 +77,13 @@ require (
github.com/mattn/go-runewidth v0.0.14 // indirect
github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d // indirect
github.com/microcosm-cc/bluemonday v1.0.23 // indirect
github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db // indirect
github.com/muesli/reflow v0.3.0 // indirect
github.com/muesli/termenv v0.13.0 // indirect
github.com/nwaples/rardecode v1.1.0 // indirect
github.com/pierrec/lz4/v4 v4.1.3 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/rivo/uniseg v0.2.0 // indirect
github.com/rivo/uniseg v0.4.4 // indirect
github.com/ulikunitz/xz v0.5.10 // indirect
github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 // indirect
github.com/yuin/goldmark v1.5.2 // indirect
Expand Down
11 changes: 10 additions & 1 deletion go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOl
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo=
github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
github.com/k0kubun/go-ansi v0.0.0-20180517002512-3bf9e2903213/go.mod h1:vNUNkEQ1e29fT/6vq2aBdFsgNPmy8qMdSay1npru+Sw=
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 h1:Z9n2FFNUXsshfwJMBgNA0RU6/i7WVaAegv3PtuIHPMs=
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51/go.mod h1:CzGEWj7cYgsdH8dAjBGEr58BoE7ScuLd+fwFZ44+/x8=
github.com/kevinburke/ssh_config v1.2.0 h1:x584FjTGwHzMwvHx18PXxbBVzfnxogHaAReU4gf13a4=
Expand Down Expand Up @@ -171,6 +172,8 @@ github.com/mholt/archiver/v3 v3.5.1/go.mod h1:e3dqJ7H78uzsRSEACH1joayhuSyhnonssn
github.com/microcosm-cc/bluemonday v1.0.21/go.mod h1:ytNkv4RrDrLJ2pqlsSI46O6IVXmZOBBD4SaJyDwwTkM=
github.com/microcosm-cc/bluemonday v1.0.23 h1:SMZe2IGa0NuHvnVNAZ+6B38gsTbi5e4sViiWJyDDqFY=
github.com/microcosm-cc/bluemonday v1.0.23/go.mod h1:mN70sk7UkkF8TUr2IGBpNN0jAgStuPzlK76QuruE/z4=
github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db h1:62I3jR2EmQ4l5rM/4FEfDWcRD+abF5XlKShorW5LRoQ=
github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db/go.mod h1:l0dey0ia/Uv7NcFFVbCLtqEBQbrT4OCwCSKTEv6enCw=
github.com/muesli/reflow v0.3.0 h1:IFsN6K9NfGtjeggFP+68I4chLZV2yIKsXJFNZ+eWh6s=
github.com/muesli/reflow v0.3.0/go.mod h1:pbwTDkVPibjO2kyvBQRBxTWEEGDGq0FlB1BIKtnHY/8=
github.com/muesli/termenv v0.13.0 h1:wK20DRpJdDX8b7Ek2QfhvqhRQFZ237RGRO0RQ/Iqdy0=
Expand All @@ -193,11 +196,14 @@ github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY=
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/rivo/uniseg v0.4.4 h1:8TfxU8dW6PdqD27gjM8MVNuicgxIjxpm4K7x4jp8sis=
github.com/rivo/uniseg v0.4.4/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
github.com/rogpeppe/go-internal v1.6.1 h1:/FiVV8dS/e+YqF2JvO3yXRFbBLTIuSDkuC7aBOAvL+k=
github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/schollz/progressbar/v3 v3.14.1 h1:VD+MJPCr4s3wdhTc7OEJ/Z3dAeBzJ7yKH/P4lC5yRTI=
github.com/schollz/progressbar/v3 v3.14.1/go.mod h1:Zc9xXneTzWXF81TGoqL71u0sBPjULtEHYtj/WVgVy8E=
github.com/sergi/go-diff v1.2.0 h1:XU+rvMAioB0UC3q1MFrIQy4Vo5/4VsRDQQXHsEya6xQ=
github.com/sergi/go-diff v1.2.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM=
github.com/skeema/knownhosts v1.2.1 h1:SHWdIUa82uGZz+F+47k8SY4QhhI291cXCpopT1lK2AQ=
Expand All @@ -210,6 +216,7 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/objx v0.5.0 h1:1zr/of2m5FGMsad5YfcqgdqdWrIhu+EBEJRhR1U7z/c=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
Expand Down Expand Up @@ -295,6 +302,7 @@ golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc=
golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
Expand All @@ -303,6 +311,7 @@ golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc=
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U=
golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo=
golang.org/x/term v0.14.0/go.mod h1:TySc+nGkYR6qt8km8wUhuFRTVSMIX3XPR58y2lC8vww=
golang.org/x/term v0.15.0 h1:y/Oo/a/q3IXu26lQgl04j/gjuBDOBlx7X6Om1j2CPW4=
golang.org/x/term v0.15.0/go.mod h1:BDl952bC7+uMoWR75FIrCDx79TPU9oHkTZ9yRbYOrX0=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
Expand Down
29 changes: 29 additions & 0 deletions internal/ansi/progress.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package ansi

import (
"errors"

"github.com/schollz/progressbar/v3"
)

// ProgressBar will display progress indication for the given items.
func ProgressBar[T comparable](desc string, items []T, fn func(int, T) error) error {
switch len(items) {
case 0:
return nil
case 1:
return Spinner(desc, func() error {
return fn(1, items[0])
})
default:
bar := progressbar.Default(int64(len(items)), desc)
var errs []error
for i, item := range items {
_ = bar.Add(1)
if err := fn(i, item); err != nil {
errs = append(errs, err)
}
}
return errors.Join(errs...)
}
}
2 changes: 1 addition & 1 deletion internal/auth/authutil/browser.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func WaitForBrowserCallback(addr string) (code string, state string, err error)

if cb.code == "" {
_, _ = w.Write([]byte(resultPage("Login Failed",
"Unable to extract code from request, please try authenticating again.",
"Failed to extract code from request, please try authenticating again.",
"error-denied")))
} else {
_, _ = w.Write([]byte(resultPage("Login Successful",
Expand Down
2 changes: 1 addition & 1 deletion internal/auth/authutil/browser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func TestWaitForBrowserCallback(t *testing.T) {
_ = resp.Body.Close()
}()

assert.Contains(t, body, "Unable to extract code from request, please try authenticating again")
assert.Contains(t, body, "Failed to extract code from request, please try authenticating again")
})

code, state, callbackErr := WaitForBrowserCallback("localhost:1234")
Expand Down
13 changes: 5 additions & 8 deletions internal/cli/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -391,16 +391,13 @@ func deleteActionCmd(cli *cli) *cobra.Command {
}
}

return ansi.Spinner("Deleting action(s)", func() error {
var errs []error
for _, id := range ids {
if id != "" {
if err := cli.api.Action.Delete(cmd.Context(), id); err != nil {
errs = append(errs, fmt.Errorf("failed to delete action with ID %q: %w", id, err))
}
return ansi.ProgressBar("Deleting action(s)", ids, func(i int, id string) error {
if id != "" {
if err := cli.api.Action.Delete(cmd.Context(), id); err != nil {
return fmt.Errorf("failed to delete Action with ID %q: %w", id, err)
}
}
return errors.Join(errs...)
return nil
})
},
}
Expand Down
22 changes: 8 additions & 14 deletions internal/cli/apis.go
Original file line number Diff line number Diff line change
Expand Up @@ -445,21 +445,15 @@ func deleteAPICmd(cli *cli) *cobra.Command {
}
}

return ansi.Spinner("Deleting API(s)", func() error {
var errs []error
for _, id := range ids {
if id != "" {
if _, err := cli.api.ResourceServer.Read(cmd.Context(), id); err != nil {
errs = append(errs, fmt.Errorf("failed to delete API with ID %q: %w", id, err))
continue
}

if err := cli.api.ResourceServer.Delete(cmd.Context(), id); err != nil {
errs = append(errs, fmt.Errorf("failed to delete API with ID %q: %w", id, err))
}
}
return ansi.ProgressBar("Deleting API(s)", ids, func(_ int, id string) error {
if _, err := cli.api.ResourceServer.Read(cmd.Context(), id); err != nil {
return fmt.Errorf("failed to delete API with ID %q: %w", id, err)
}

if err := cli.api.ResourceServer.Delete(cmd.Context(), id); err != nil {
return fmt.Errorf("failed to delete API with ID %q: %w", id, err)
}
return errors.Join(errs...)
return nil
})
},
}
Expand Down
22 changes: 9 additions & 13 deletions internal/cli/apps.go
Original file line number Diff line number Diff line change
Expand Up @@ -347,21 +347,17 @@ func deleteAppCmd(cli *cli) *cobra.Command {
}
}

return ansi.Spinner("Deleting Application(s)", func() error {
var errs []error
for _, id := range ids {
if id != "" {
if _, err := cli.api.Client.Read(cmd.Context(), id); err != nil {
errs = append(errs, fmt.Errorf("failed to delete application with ID %q: %w", id, err))
continue
}

if err := cli.api.Client.Delete(cmd.Context(), id); err != nil {
errs = append(errs, fmt.Errorf("failed to delete application with ID %q: %w", id, err))
}
return ansi.ProgressBar("Deleting Application(s)", ids, func(_ int, id string) error {
if id != "" {
if _, err := cli.api.Client.Read(cmd.Context(), id); err != nil {
return fmt.Errorf("failed to delete application with ID %q: %w", id, err)
}

if err := cli.api.Client.Delete(cmd.Context(), id); err != nil {
return fmt.Errorf("failed to delete application with ID %q: %w", id, err)
}
}
return errors.Join(errs...)
return nil
})
},
}
Expand Down
23 changes: 9 additions & 14 deletions internal/cli/custom_domains.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package cli

import (
"context"
"errors"
"fmt"
"net/url"

Expand Down Expand Up @@ -348,21 +347,17 @@ func deleteCustomDomainCmd(cli *cli) *cobra.Command {
}
}

return ansi.Spinner("Deleting custom domain", func() error {
var errs []error
for _, id := range ids {
if id != "" {
if _, err := cli.api.CustomDomain.Read(cmd.Context(), url.PathEscape(id)); err != nil {
return fmt.Errorf("failed to delete custom domain with ID %q: %w", id, err)
}

if err := cli.api.CustomDomain.Delete(cmd.Context(), url.PathEscape(id)); err != nil {
return fmt.Errorf("failed to delete custom domain with ID %q: %w", id, err)
}
return ansi.ProgressBar("Deleting custom domain", ids, func(_ int, id string) error {
if id != "" {
if _, err := cli.api.CustomDomain.Read(cmd.Context(), url.PathEscape(id)); err != nil {
return fmt.Errorf("failed to delete custom domain with ID %q: %w", id, err)
}
}

return errors.Join(errs...)
if err := cli.api.CustomDomain.Delete(cmd.Context(), url.PathEscape(id)); err != nil {
return fmt.Errorf("failed to delete custom domain with ID %q: %w", id, err)
}
}
return nil
})
},
}
Expand Down
21 changes: 8 additions & 13 deletions internal/cli/log_streams.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,21 +199,16 @@ func deleteLogStreamCmd(cli *cli) *cobra.Command {
}
}

return ansi.Spinner("Deleting Log Stream(s)", func() error {
var errs []error
for _, id := range ids {
if id != "" {
if _, err := cli.api.LogStream.Read(cmd.Context(), id); err != nil {
errs = append(errs, fmt.Errorf("failed to delete log stream with ID %q: %w", id, err))
continue
}
if err := cli.api.LogStream.Delete(cmd.Context(), id); err != nil {
errs = append(errs, fmt.Errorf("failed to delete log stream with ID %q: %w", id, err))
}
return ansi.ProgressBar("Deleting Log Stream(s)", ids, func(_ int, id string) error {
if id != "" {
if _, err := cli.api.LogStream.Read(cmd.Context(), id); err != nil {
return fmt.Errorf("failed to delete log stream with ID %q: %w", id, err)
}
if err := cli.api.LogStream.Delete(cmd.Context(), id); err != nil {
return fmt.Errorf("failed to delete log stream with ID %q: %w", id, err)
}
}

return errors.Join(errs...)
return nil
})
},
}
Expand Down
23 changes: 9 additions & 14 deletions internal/cli/organizations.go
Original file line number Diff line number Diff line change
Expand Up @@ -437,21 +437,17 @@ func deleteOrganizationCmd(cli *cli) *cobra.Command {
}
}

return ansi.Spinner("Deleting organization(s)", func() error {
var errs []error
for _, id := range ids {
if id != "" {
if _, err := cli.api.Organization.Read(cmd.Context(), id); err != nil {
errs = append(errs, fmt.Errorf("failed to delete organization with ID %q: %w", id, err))
continue
}

if err := cli.api.Organization.Delete(cmd.Context(), id); err != nil {
errs = append(errs, fmt.Errorf("failed to delete organization with ID %q: %w", id, err))
}
return ansi.ProgressBar("Deleting organization(s)", ids, func(_ int, id string) error {
if id != "" {
if _, err := cli.api.Organization.Read(cmd.Context(), id); err != nil {
return fmt.Errorf("failed to delete organization with ID %q: %w", id, err)
}

if err := cli.api.Organization.Delete(cmd.Context(), id); err != nil {
return fmt.Errorf("failed to delete organization with ID %q: %w", id, err)
}
}
return errors.Join(errs...)
return nil
})
},
}
Expand Down Expand Up @@ -597,7 +593,6 @@ func listRolesOrganizationCmd(cli *cli) *cobra.Command {
} else {
inputs.OrgID = args[0]
}

members, err := cli.getOrgMembersWithSpinner(cmd.Context(), inputs.OrgID, inputs.Number)
if err != nil {
return err
Expand Down
22 changes: 9 additions & 13 deletions internal/cli/roles.go
Original file line number Diff line number Diff line change
Expand Up @@ -306,21 +306,17 @@ func deleteRoleCmd(cli *cli) *cobra.Command {
}
}

return ansi.Spinner("Deleting Role(s)", func() error {
var errs []error
for _, id := range ids {
if id != "" {
if _, err := cli.api.Role.Read(cmd.Context(), id); err != nil {
errs = append(errs, fmt.Errorf("failed to delete role with ID %q: %w", id, err))
continue
}

if err := cli.api.Role.Delete(cmd.Context(), id); err != nil {
errs = append(errs, fmt.Errorf("failed to delete role with ID %q: %w", id, err))
}
return ansi.ProgressBar("Deleting Role(s)", ids, func(_ int, id string) error {
if id != "" {
if _, err := cli.api.Role.Read(cmd.Context(), id); err != nil {
return fmt.Errorf("failed to delete role with ID %q: %w", id, err)
}

if err := cli.api.Role.Delete(cmd.Context(), id); err != nil {
return fmt.Errorf("failed to delete role with ID %q: %w", id, err)
}
}
return errors.Join(errs...)
return nil
})
},
}
Expand Down
22 changes: 9 additions & 13 deletions internal/cli/rules.go
Original file line number Diff line number Diff line change
Expand Up @@ -281,21 +281,17 @@ func deleteRuleCmd(cli *cli) *cobra.Command {
}
}

return ansi.Spinner("Deleting Rule(s)", func() error {
var errs []error
for _, id := range ids {
if id != "" {
if _, err := cli.api.Rule.Read(cmd.Context(), id); err != nil {
errs = append(errs, fmt.Errorf("failed to delete rule with ID %q: %w", id, err))
continue
}

if err := cli.api.Rule.Delete(cmd.Context(), id); err != nil {
errs = append(errs, fmt.Errorf("failed to delete rule with ID %q: %w", id, err))
}
return ansi.ProgressBar("Deleting Rule(s)", ids, func(_ int, id string) error {
if id != "" {
if _, err := cli.api.Rule.Read(cmd.Context(), id); err != nil {
return fmt.Errorf("failed to delete rule with ID %q: %w", id, err)
}

if err := cli.api.Rule.Delete(cmd.Context(), id); err != nil {
return fmt.Errorf("failed to delete rule with ID %q: %w", id, err)
}
}
return errors.Join(errs...)
return nil
})
},
}
Expand Down
Loading

0 comments on commit 5620e50

Please sign in to comment.