Skip to content

Commit

Permalink
feat: sync domains/list.go with master
Browse files Browse the repository at this point in the history
  • Loading branch information
SCedricThomas committed Aug 20, 2024
1 parent 5b8bb6c commit c2e0b2c
Showing 1 changed file with 26 additions and 13 deletions.
39 changes: 26 additions & 13 deletions domains/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ import (
"gopkg.in/errgo.v1"

"github.com/Scalingo/cli/config"
scalingo "github.com/Scalingo/go-scalingo/v6"
"github.com/Scalingo/go-scalingo/v7"

Check failure on line 12 in domains/list.go

View workflow job for this annotation

GitHub Actions / Unit Tests

cannot find module providing package github.com/Scalingo/go-scalingo/v7: import lookup disabled by -mod=vendor
)

var letsencryptStatusString = map[string]string{
string(scalingo.LetsEncryptStatusPendingDNS): "Pending DNS",

Check failure on line 16 in domains/list.go

View workflow job for this annotation

GitHub Actions / golangci-lint on a PR or from a tag

undefined: scalingo (typecheck)
string(scalingo.LetsEncryptStatusNew): "Creating",

Check failure on line 17 in domains/list.go

View workflow job for this annotation

GitHub Actions / golangci-lint on a PR or from a tag

undefined: scalingo (typecheck)
string(scalingo.LetsEncryptStatusCreated): "In use",
string(scalingo.LetsEncryptStatusCreated): "Created",

Check failure on line 18 in domains/list.go

View workflow job for this annotation

GitHub Actions / golangci-lint on a PR or from a tag

undefined: scalingo (typecheck)
string(scalingo.LetsEncryptStatusDNSRequired): "DNS required",
string(scalingo.LetsEncryptStatusError): "Error",
}
Expand All @@ -31,7 +31,7 @@ func List(ctx context.Context, app string) error {
}

t := tablewriter.NewWriter(os.Stdout)
t.SetHeader([]string{"Domain", "TLS/SSL"})
t.SetHeader([]string{"Domain", "TLS/SSL", "TLS Subject", "Let's Encrypt Certificate"})
hasCanonical := false

for _, domain := range domains {
Expand All @@ -40,19 +40,32 @@ func List(ctx context.Context, app string) error {
hasCanonical = true
domainName += " (*)"
}
row := []string{domainName}
switch {
case !domain.SSL:
row = append(row, "-")
case domain.LetsEncrypt:
letsencryptStatus, ok := letsencryptStatusString[string(domain.LetsEncryptStatus)]

tls := "-"
letsEncrypt := "Disabled"
if domain.LetsEncryptEnabled {

Check failure on line 46 in domains/list.go

View workflow job for this annotation

GitHub Actions / golangci-lint on a PR or from a tag

domain.LetsEncryptEnabled undefined (type scalingo.Domain has no field or method LetsEncryptEnabled) (typecheck)
// If the domain is using Let's Encrypt (and not a custom cert), we mention it
if domain.LetsEncrypt {
tls = "Let's Encrypt"
}
// In any case we display the state of creation of the Let's Encrypt certificate
// So if a customer certification is used, it is still mentioned we have it
var ok bool
letsEncrypt, ok = letsencryptStatusString[string(domain.LetsEncryptStatus)]
if !ok {
letsencryptStatus = string(domain.LetsEncryptStatus)
letsEncrypt = string(domain.LetsEncryptStatus)
}

if !domain.LetsEncrypt && domain.LetsEncryptStatus == scalingo.LetsEncryptStatusCreated {
letsEncrypt = "Created, Not in use"
}
row = append(row, "Let's Encrypt: "+letsencryptStatus)
default:
row = append(row, fmt.Sprintf("Valid until %v", domain.Validity))
}

if domain.SSL && !domain.LetsEncrypt {
tls = fmt.Sprintf("Valid until %v", domain.Validity)
}

row := []string{domainName, tls, domain.TLSCert, letsEncrypt}
t.Append(row)
}
t.Render()
Expand Down

0 comments on commit c2e0b2c

Please sign in to comment.