From 6aeca04f49b0c8d3522dcb45fee8f3619694ad85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89tienne=20Michon?= Date: Tue, 5 Mar 2024 15:29:03 +0100 Subject: [PATCH 1/4] fix(domains): missing err check --- cmd/domains.go | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/cmd/domains.go b/cmd/domains.go index fb727b964..7cb5ffc2d 100644 --- a/cmd/domains.go +++ b/cmd/domains.go @@ -22,14 +22,16 @@ var ( }.Render(), Action: func(c *cli.Context) error { - currentApp := detect.CurrentApp(c) - var err error - if c.Args().Len() == 0 { - err = domains.List(c.Context, currentApp) - } else { - cli.ShowCommandHelp(c, "domains") + if c.Args().Len() > 0 { + err := cli.ShowCommandHelp(c, "domains") + if err != nil { + errorQuit(c.Context, err) + } + return nil } + currentApp := detect.CurrentApp(c) + err := domains.List(c.Context, currentApp) if err != nil { errorQuit(c.Context, err) } From 0cd34f1ad71c79fd1f89d0faea9c64f29f526560 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89tienne=20Michon?= Date: Tue, 5 Mar 2024 15:32:25 +0100 Subject: [PATCH 2/4] fix(domains): replace errgo with errors --- domains/list.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/domains/list.go b/domains/list.go index 6e804f520..81099e5ba 100644 --- a/domains/list.go +++ b/domains/list.go @@ -6,10 +6,10 @@ import ( "os" "github.com/olekukonko/tablewriter" - "gopkg.in/errgo.v1" "github.com/Scalingo/cli/config" scalingo "github.com/Scalingo/go-scalingo/v6" + "github.com/Scalingo/go-utils/errors/v2" ) var letsencryptStatusString = map[string]string{ @@ -23,11 +23,12 @@ var letsencryptStatusString = map[string]string{ func List(ctx context.Context, app string) error { c, err := config.ScalingoClient(ctx) if err != nil { - return errgo.Notef(err, "fail to get Scalingo client") + return errors.Wrapf(ctx, err, "get Scalingo client to list domains") } + domains, err := c.DomainsList(ctx, app) if err != nil { - return errgo.Mask(err) + return errors.Wrapf(ctx, err, "list domains") } t := tablewriter.NewWriter(os.Stdout) From 2a872cc93d9d6f66912f65ee12a8cdea4557f2a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89tienne=20Michon?= Date: Tue, 5 Mar 2024 15:38:00 +0100 Subject: [PATCH 3/4] fix(domains): printf perf --- domains/list.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/domains/list.go b/domains/list.go index 81099e5ba..d6bfcd505 100644 --- a/domains/list.go +++ b/domains/list.go @@ -49,7 +49,7 @@ func List(ctx context.Context, app string) error { if !ok { letsencryptStatus = string(domain.LetsEncryptStatus) } - row = append(row, fmt.Sprintf("Let's Encrypt: %s", letsencryptStatus)) + row = append(row, "Let's Encrypt "+letsencryptStatus) } else { row = append(row, fmt.Sprintf("Valid until %v", domain.Validity)) } From c9593b722fd8ac5aa1152fd1e3c79b339186b42b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89tienne=20Michon?= Date: Wed, 6 Mar 2024 10:49:42 +0100 Subject: [PATCH 4/4] feat(domains): add 'Manual Action' column if needed --- domains/list.go | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/domains/list.go b/domains/list.go index d6bfcd505..3457e41d9 100644 --- a/domains/list.go +++ b/domains/list.go @@ -4,6 +4,7 @@ import ( "context" "fmt" "os" + "slices" "github.com/olekukonko/tablewriter" @@ -32,8 +33,8 @@ func List(ctx context.Context, app string) error { } t := tablewriter.NewWriter(os.Stdout) - t.SetHeader([]string{"Domain", "TLS/SSL"}) hasCanonical := false + headers := []string{"Domain", "TLS/SSL"} for _, domain := range domains { domainName := domain.Name @@ -42,6 +43,7 @@ func List(ctx context.Context, app string) error { domainName += " (*)" } row := []string{domainName} + if !domain.SSL { row = append(row, "-") } else if domain.LetsEncrypt { @@ -53,8 +55,18 @@ func List(ctx context.Context, app string) error { } else { row = append(row, fmt.Sprintf("Valid until %v", domain.Validity)) } + + if domain.LetsEncryptStatus == scalingo.LetsEncryptStatusDNSRequired { + if !slices.Contains(headers, "Manual Action") { + headers = append(headers, "Manual Action") + } + row = append(row, fmt.Sprintf("%v \n%v", domain.AcmeDNSFqdn, domain.AcmeDNSValue)) + } + t.Append(row) } + + t.SetHeader(headers) t.Render() if hasCanonical {