Skip to content

Commit

Permalink
v0.0.37: work around for windows browser quirks
Browse files Browse the repository at this point in the history
  • Loading branch information
benburkert committed May 28, 2024
1 parent 91cc689 commit 1cd0aa1
Show file tree
Hide file tree
Showing 18 changed files with 2,083 additions and 39 deletions.
2 changes: 1 addition & 1 deletion api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ func (r responseChecker) RoundTrip(req *http.Request) (*http.Response, error) {
case http.StatusForbidden:
return nil, ErrSignedOut
case http.StatusInternalServerError:
return nil, fmt.Errorf("request [%s] failed: %w", requestId, err)
return nil, fmt.Errorf("request [%s] failed: 500 Internal Server Error", requestId)
}
if contentType := res.Header.Get("Content-Type"); !jsonMediaTypes.Matches(contentType) {
return nil, fmt.Errorf("request [%s]: %d response, expected json content-type, got: %q", requestId, res.StatusCode, contentType)
Expand Down
8 changes: 8 additions & 0 deletions auth/models/signout.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ var (
},
}

SignOutSignedOut = ui.Section{
Name: "SignOutSignedOut",
Model: ui.MessageLines{
ui.StepDone("Not signed in."),
ui.StepHint("Run `anchor auth signin` to sign in."),
},
}

SignOutSuccess = ui.Section{
Name: "SignOutSuccess",
Model: ui.MessageLines{
Expand Down
19 changes: 16 additions & 3 deletions auth/models/whoami.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ var WhoAmIHeader = ui.Section{
}

type WhoAmIChecker struct {
whoami string
signedout bool
whoami string

spinner spinner.Model
}
Expand All @@ -29,12 +30,16 @@ func (m *WhoAmIChecker) Init() tea.Cmd {
}

type UserWhoAmIMsg string
type UserWhoAmISignedOutMsg bool

func (m *WhoAmIChecker) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
switch msg := msg.(type) {
case UserWhoAmIMsg:
m.whoami = string(msg)
return m, nil
case UserWhoAmISignedOutMsg:
m.signedout = bool(msg)
return m, nil
}

var cmd tea.Cmd
Expand All @@ -44,10 +49,18 @@ func (m *WhoAmIChecker) Update(msg tea.Msg) (tea.Model, tea.Cmd) {

func (m *WhoAmIChecker) View() string {
var b strings.Builder

if m.signedout {
fmt.Fprintln(&b, ui.StepDone("Identified Anchor.dev account: not signed in."))
fmt.Fprintln(&b, ui.StepHint("Run `anchor auth signin` to sign in."))
return b.String()
}

if m.whoami == "" {
fmt.Fprintln(&b, ui.StepInProgress(fmt.Sprintf("Identifying Anchor.dev account… %s", m.spinner.View())))
} else {
fmt.Fprintln(&b, ui.StepDone(fmt.Sprintf("Identified Anchor.dev account: %s", ui.Emphasize(m.whoami))))
return b.String()
}

fmt.Fprintln(&b, ui.StepDone(fmt.Sprintf("Identified Anchor.dev account: %s", ui.Emphasize(m.whoami))))
return b.String()
}
6 changes: 6 additions & 0 deletions auth/signout.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package auth

import (
"context"
"errors"

"github.com/anchordotdev/cli"
"github.com/anchordotdev/cli/auth/models"
Expand All @@ -28,6 +29,11 @@ func (s *SignOut) runTUI(ctx context.Context, drv *ui.Driver) error {
kr := keyring.Keyring{Config: cfg}
err := kr.Delete(keyring.APIToken)

if errors.Is(err, keyring.ErrNotFound) {
drv.Activate(ctx, models.SignOutSignedOut)
return nil
}

if err == nil {
drv.Activate(ctx, models.SignOutSuccess)
}
Expand Down
4 changes: 3 additions & 1 deletion auth/signout_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ func TestSignout(t *testing.T) {
ctx = cli.ContextWithConfig(ctx, cfg)

t.Run("signed-out", func(t *testing.T) {
uitest.TestTUIError(ctx, t, new(SignOut).UI(), "secret not found in keyring")
cmd := SignOut{}

uitest.TestTUIOutput(ctx, t, cmd.UI())
})

t.Run("signed-in", func(t *testing.T) {
Expand Down
6 changes: 6 additions & 0 deletions auth/testdata/TestSignout/signed-out.golden
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
─── SignOutHeader ──────────────────────────────────────────────────────────────
# Signout from Anchor.dev `anchor auth signout`
─── SignOutSignedOut ───────────────────────────────────────────────────────────
# Signout from Anchor.dev `anchor auth signout`
- Not signed in.
| Run `anchor auth signin` to sign in.
9 changes: 9 additions & 0 deletions auth/testdata/TestWhoAmI/signed-out.golden
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
─── WhoAmIHeader ───────────────────────────────────────────────────────────────
# Identify Current Anchor.dev Account `anchor auth whoami`
─── WhoAmIChecker ──────────────────────────────────────────────────────────────
# Identify Current Anchor.dev Account `anchor auth whoami`
* Identifying Anchor.dev account… ⠋
─── WhoAmIChecker ──────────────────────────────────────────────────────────────
# Identify Current Anchor.dev Account `anchor auth whoami`
- Identified Anchor.dev account: not signed in.
| Run `anchor auth signin` to sign in.
4 changes: 4 additions & 0 deletions auth/whoami.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ func (c *WhoAmI) runTUI(ctx context.Context, drv *ui.Driver) error {
drv.Activate(ctx, &models.WhoAmIChecker{})

anc, err := api.NewClient(cfg)
if errors.Is(err, api.ErrSignedOut) {
drv.Send(models.UserWhoAmISignedOutMsg(true))
return nil
}
if err != nil {
return err
}
Expand Down
5 changes: 3 additions & 2 deletions auth/whoami_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"testing"

"github.com/anchordotdev/cli"
"github.com/anchordotdev/cli/api"
"github.com/anchordotdev/cli/cmdtest"
"github.com/anchordotdev/cli/ui/uitest"
)
Expand All @@ -27,7 +26,9 @@ func TestWhoAmI(t *testing.T) {
ctx = cli.ContextWithConfig(ctx, cfg)

t.Run("signed-out", func(t *testing.T) {
uitest.TestTUIError(ctx, t, new(WhoAmI).UI(), api.ErrSignedOut)
cmd := WhoAmI{}

uitest.TestTUIOutput(ctx, t, cmd.UI())
})

t.Run("signed-in", func(t *testing.T) {
Expand Down
17 changes: 16 additions & 1 deletion diagnostic/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ type Server struct {

rchanmu sync.Mutex
rchan chan string

tlso sync.Once
tlsc chan struct{}
}

func (s *Server) Start(ctx context.Context) error {
Expand Down Expand Up @@ -69,12 +72,18 @@ func (s *Server) Start(ctx context.Context) error {
go s.server.Serve(lnHTTP)
go s.server.Serve(tls.NewListener(lnTLS, &tls.Config{
NextProtos: []string{"h2", "http/1.1"},
GetCertificate: s.GetCertificate,
GetCertificate: s.getCertificate,
}))

s.tlsc = make(chan struct{})

return s.proxy.Start()
}

func (s *Server) EnableTLS() {
s.tlso.Do(func() { close(s.tlsc) })
}

func (s *Server) Close() error {
if err := s.ln.Close(); err != nil {
return err
Expand All @@ -91,6 +100,12 @@ func (s *Server) Close() error {
return s.proxy.Wait()
}

func (s *Server) getCertificate(chi *tls.ClientHelloInfo) (*tls.Certificate, error) {
<-s.tlsc

return s.GetCertificate(chi)
}

func (s *Server) RequestChan() <-chan string {
s.rchanmu.Lock()
defer s.rchanmu.Unlock()
Expand Down
2 changes: 2 additions & 0 deletions diagnostic/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ func TestServerSupportsDualProtocols(t *testing.T) {
}
defer srv.Close()

srv.EnableTLS()

_, port, err := net.SplitHostPort(srv.Addr)
if err != nil {
t.Fatal(err)
Expand Down
14 changes: 7 additions & 7 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ require (
github.com/atotto/clipboard v0.1.4
github.com/aymanbagabas/go-udiff v0.2.0
github.com/charmbracelet/bubbles v0.18.0
github.com/charmbracelet/bubbletea v0.25.0
github.com/charmbracelet/bubbletea v0.26.2
github.com/charmbracelet/lipgloss v0.10.0
github.com/charmbracelet/x/exp/teatest v0.0.0-20240222131549-03ee51df8bea
github.com/cli/browser v1.3.0
Expand All @@ -23,10 +23,10 @@ require (
github.com/spf13/pflag v1.0.5
github.com/stretchr/testify v1.9.0
github.com/zalando/go-keyring v0.2.4
golang.org/x/crypto v0.22.0
golang.org/x/crypto v0.23.0
golang.org/x/exp v0.0.0-20240318143956-a85f2c67cd81
golang.org/x/sync v0.7.0
golang.org/x/sys v0.19.0
golang.org/x/sys v0.20.0
howett.net/plist v1.0.1
)

Expand All @@ -36,9 +36,9 @@ require (
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
github.com/charmbracelet/x/exp/golden v0.0.0-20240222125807-0344fda748f8 // indirect
github.com/cloudflare/circl v1.3.7 // indirect
github.com/containerd/console v1.0.4-0.20230313162750-1ae8d489ac81 // indirect
github.com/danieljoos/wincred v1.2.0 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f // indirect
github.com/getkin/kin-openapi v0.118.0 // indirect
github.com/go-openapi/jsonpointer v0.20.0 // indirect
github.com/go-openapi/swag v0.22.4 // indirect
Expand All @@ -65,10 +65,10 @@ require (
github.com/rogpeppe/go-internal v1.10.0 // indirect
github.com/sahilm/fuzzy v0.1.1-0.20230530133925-c48e322e2a8f // indirect
golang.org/x/mod v0.17.0 // indirect
golang.org/x/net v0.24.0 // indirect
golang.org/x/net v0.25.0 // indirect
golang.org/x/oauth2 v0.16.0 // indirect
golang.org/x/term v0.19.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/term v0.20.0 // indirect
golang.org/x/text v0.15.0 // indirect
golang.org/x/tools v0.19.0 // indirect
google.golang.org/appengine v1.6.8 // indirect
google.golang.org/protobuf v1.33.0 // indirect
Expand Down
30 changes: 15 additions & 15 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ github.com/aymanbagabas/go-udiff v0.2.0/go.mod h1:RE4Ex0qsGkTAJoQdQQCA0uG+nAzJO/
github.com/bwesterb/go-ristretto v1.2.0/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7NFEuV9ekS419A0=
github.com/charmbracelet/bubbles v0.18.0 h1:PYv1A036luoBGroX6VWjQIE9Syf2Wby2oOl/39KLfy0=
github.com/charmbracelet/bubbles v0.18.0/go.mod h1:08qhZhtIwzgrtBjAcJnij1t1H0ZRjwHyGsy6AL11PSw=
github.com/charmbracelet/bubbletea v0.25.0 h1:bAfwk7jRz7FKFl9RzlIULPkStffg5k6pNt5dywy4TcM=
github.com/charmbracelet/bubbletea v0.25.0/go.mod h1:EN3QDR1T5ZdWmdfDzYcqOCAps45+QIJbLOBxmVNWNNg=
github.com/charmbracelet/bubbletea v0.26.2 h1:Eeb+n75Om9gQ+I6YpbCXQRKHt5Pn4vMwusQpwLiEgJQ=
github.com/charmbracelet/bubbletea v0.26.2/go.mod h1:6I0nZ3YHUrQj7YHIHlM8RySX4ZIthTliMY+W8X8b+Gs=
github.com/charmbracelet/lipgloss v0.10.0 h1:KWeXFSexGcfahHX+54URiZGkBFazf70JNMtwg/AFW3s=
github.com/charmbracelet/lipgloss v0.10.0/go.mod h1:Wig9DSfvANsxqkRsqj6x87irdy123SR4dOXlKa91ciE=
github.com/charmbracelet/x/exp/golden v0.0.0-20240222125807-0344fda748f8 h1:kyT+aGp1z5jwlus3OY0cP6FuT05jYeeExx/4TYxnyrs=
Expand All @@ -27,8 +27,6 @@ github.com/cli/browser v1.3.0/go.mod h1:HH8s+fOAxjhQoBUAsKuPCbqUuxZDhQ2/aD+SzsEf
github.com/cloudflare/circl v1.1.0/go.mod h1:prBCrKB9DV4poKZY1l9zBXg2QJY7mvgRvtMxxK7fi4I=
github.com/cloudflare/circl v1.3.7 h1:qlCDlTPz2n9fu58M0Nh1J/JzcFpfgkFHHX3O35r5vcU=
github.com/cloudflare/circl v1.3.7/go.mod h1:sRTcRWXGLrKw6yIGJ+l7amYJFfAXbZG0kBSc8r4zxgA=
github.com/containerd/console v1.0.4-0.20230313162750-1ae8d489ac81 h1:q2hJAaP1k2wIvVRd/hEHD7lacgqrCPS+k8g1MndzfWY=
github.com/containerd/console v1.0.4-0.20230313162750-1ae8d489ac81/go.mod h1:YynlIjWYF8myEu6sdkwKIvGQq+cOckRm6So2avqoYAk=
github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/danieljoos/wincred v1.2.0 h1:ozqKHaLK0W/ii4KVbbvluM91W2H3Sh0BncbUNPS7jLE=
github.com/danieljoos/wincred v1.2.0/go.mod h1:FzQLLMKBFdvu+osBrnFODiv32YGwCfx0SkRa/eYHgec=
Expand All @@ -38,6 +36,8 @@ github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/deepmap/oapi-codegen v1.16.2 h1:xGHx0dNqYfy9gE8a7AVgVM8Sd5oF9SEgePzP+UPAUXI=
github.com/deepmap/oapi-codegen v1.16.2/go.mod h1:rdYoEA2GE+riuZ91DvpmBX9hJbQpuY9wchXpfQ3n+ho=
github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f h1:Y/CXytFA4m6baUTXGLOoWe4PQhGxaX0KpnayAqC48p4=
github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f/go.mod h1:vw97MGsxSvLiUE2X8qFplwetxpGLQrlU1Q9AUEIzCaM=
github.com/getkin/kin-openapi v0.118.0 h1:z43njxPmJ7TaPpMSCQb7PN0dEYno4tyBPQcrFdHoLuM=
github.com/getkin/kin-openapi v0.118.0/go.mod h1:l5e9PaFUo9fyLJCPGQeXI2ML8c3P8BHOEV2VaAVf/pc=
github.com/go-openapi/jsonpointer v0.19.5/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg=
Expand Down Expand Up @@ -154,8 +154,8 @@ github.com/zalando/go-keyring v0.2.4 h1:wi2xxTqdiwMKbM6TWwi+uJCG/Tum2UV0jqaQhCa9
github.com/zalando/go-keyring v0.2.4/go.mod h1:HL4k+OXQfJUWaMnqyuSOc0drfGPX2b51Du6K+MRgZMk=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.22.0 h1:g1v0xeRhjcugydODzvb3mEM9SQ0HGp9s/nh3COQ/C30=
golang.org/x/crypto v0.22.0/go.mod h1:vr6Su+7cTlO45qkww3VDJlzDn0ctJvRgYbC2NvXHt+M=
golang.org/x/crypto v0.23.0 h1:dIJU/v2J8Mdglj/8rJ6UUOM3Zc9zLZxVZwwxMooUSAI=
golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8=
golang.org/x/exp v0.0.0-20240318143956-a85f2c67cd81 h1:6R2FC06FonbXQ8pK11/PDFY6N6LWlf9KlzibaCapmqc=
golang.org/x/exp v0.0.0-20240318143956-a85f2c67cd81/go.mod h1:CQ1k9gNrJ50XIzaKCRR2hssIjF07kZFEiieALBM/ARQ=
golang.org/x/lint v0.0.0-20210508222113-6edffad5e616 h1:VLliZ0d+/avPrXXH+OakdXhpJuEoBZuwh1m2j7U6Iug=
Expand All @@ -166,8 +166,8 @@ golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/net v0.24.0 h1:1PcaxkF854Fu3+lvBIx5SYn9wRlBzzcnHZSiaFFAb0w=
golang.org/x/net v0.24.0/go.mod h1:2Q7sJY5mzlzWjKtYUEXSlBWCdyaioyXzRB2RtU8KVE8=
golang.org/x/net v0.25.0 h1:d/OCCoBEUq33pjydKrGQhw7IlUPI2Oylr+8qLx49kac=
golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM=
golang.org/x/oauth2 v0.16.0 h1:aDkGMBSYxElaoP81NpoUoz2oo2R2wHdZpGToUxfyQrQ=
golang.org/x/oauth2 v0.16.0/go.mod h1:hqZ+0LWXsiVoZpeld6jVt06P3adbS2Uu911W1SsJv2o=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
Expand All @@ -177,23 +177,23 @@ golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.19.0 h1:q5f1RH2jigJ1MoAWp2KTp3gm5zAGFUTarQZ5U386+4o=
golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y=
golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.19.0 h1:+ThwsDv+tYfnJFhF4L8jITxu1tdTWRTZpdsWgEgjL6Q=
golang.org/x/term v0.19.0/go.mod h1:2CuTdWZ7KHSQwUzKva0cbMg6q2DMI3Mmxp+gKJbskEk=
golang.org/x/term v0.20.0 h1:VnkxpohqXaOBYJtBmEppKUG6mXpi+4O6purfc2+sMhw=
golang.org/x/term v0.20.0/go.mod h1:8UkIAJTvZgivsXaD6/pH6U9ecQzZ45awqEOzuCvwpFY=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ=
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
golang.org/x/text v0.15.0 h1:h1V/4gjBv8v9cjcR6+AR5+/cIYK5N/WAgiv4xlsEtAk=
golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
Expand Down
6 changes: 5 additions & 1 deletion lcl/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,8 @@ func (c LclConfig) perform(ctx context.Context, drv *ui.Driver) error {
}
}

srvDiag.EnableTLS()

httpsURL, err := url.Parse("https://" + domain + ":" + diagPort)
if err != nil {
return err
Expand Down Expand Up @@ -261,7 +263,9 @@ func (c LclConfig) perform(ctx context.Context, drv *ui.Driver) error {
}
}

drv.Activate(ctx, new(models.LclConfigSuccess))
drv.Activate(ctx, &models.LclConfigSuccess{
URL: httpsURL,
})

return nil
}
13 changes: 6 additions & 7 deletions lcl/models/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package models

import (
"fmt"
"net/url"
"strings"

"github.com/anchordotdev/cli/ui"
Expand Down Expand Up @@ -106,16 +107,11 @@ func (m LclConfig) View() string {
return b.String()
}

fmt.Fprintln(&b, ui.StepDone(fmt.Sprintf("Success! %s works as expected (%s).",
ui.URL(m.url),
ui.Accentuate("encrypted with HTTPS"),
)))

return b.String()
}

type LclConfigSuccess struct {
Org, Realm, CA string
URL *url.URL
}

func (LclConfigSuccess) Init() tea.Cmd { return nil }
Expand All @@ -125,7 +121,10 @@ func (m LclConfigSuccess) Update(tea.Msg) (tea.Model, tea.Cmd) { return m, nil }
func (m LclConfigSuccess) View() string {
var b strings.Builder

// TODO: move success part of Diagnostic to here
fmt.Fprintln(&b, ui.StepDone(fmt.Sprintf("Success! %s works as expected (%s).",
ui.URL(m.URL.String()),
ui.Accentuate("encrypted with HTTPS"),
)))

return b.String()
}
Loading

0 comments on commit 1cd0aa1

Please sign in to comment.