Skip to content

Commit

Permalink
feat(domains): add 'Manual Action' column if needed
Browse files Browse the repository at this point in the history
  • Loading branch information
EtienneM committed Mar 6, 2024
1 parent 2a872cc commit c9593b7
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion domains/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"fmt"
"os"
"slices"

Check failure on line 7 in domains/list.go

View workflow job for this annotation

GitHub Actions / Unit Tests

package slices is not in GOROOT (/opt/hostedtoolcache/go/1.20.14/x64/src/slices)

"github.com/olekukonko/tablewriter"

Expand Down Expand Up @@ -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
Expand All @@ -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 {
Expand All @@ -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 {
Expand Down

0 comments on commit c9593b7

Please sign in to comment.