Skip to content

Commit 531e84e

Browse files
committed
v0.1.4 misc
1 parent 06c1d1f commit 531e84e

File tree

5 files changed

+189
-8
lines changed

5 files changed

+189
-8
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44
"dependencies": {},
55
"scripts": {},
66
"devDependencies": {
7-
"@stoplight/prism-cli": "5.9.0"
7+
"@stoplight/prism-cli": "5.10.0"
88
}
99
}

service/env.go

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -183,14 +183,17 @@ func (c *Env) Perform(ctx context.Context, drv *ui.Driver) error {
183183
return fmt.Errorf("Unknown method: %s. Please choose either `export` or `dotenv`.", envOutput)
184184
}
185185

186-
var lclDomain string
187-
for _, d := range attachment.Domains {
188-
if strings.HasSuffix(d, ".lcl.host") {
189-
lclDomain = d
190-
break
186+
var lclUrl string
187+
if attachment != nil {
188+
var lclDomain string
189+
for _, d := range attachment.Domains {
190+
if strings.HasSuffix(d, ".lcl.host") {
191+
lclDomain = d
192+
break
193+
}
191194
}
195+
lclUrl = fmt.Sprintf("https://%s:%d", lclDomain, *service.LocalhostPort)
192196
}
193-
lclUrl := fmt.Sprintf("https://%s:%d", lclDomain, *service.LocalhostPort)
194197

195198
drv.Activate(ctx, &models.EnvNextSteps{
196199
LclUrl: lclUrl,

service/env_test.go

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,4 +197,43 @@ func TestServiceEnv(t *testing.T) {
197197

198198
uitest.TestGolden(t, drv.Golden())
199199
})
200+
201+
t.Run("basics unattached service display", func(t *testing.T) {
202+
if srv.IsProxy() {
203+
t.Skip("service env unsupported in proxy mode")
204+
}
205+
206+
cfg.Test.Prefer = map[string]cli.ConfigTestPrefer{
207+
"/v0/orgs/org-slug/services/service-name/attachments": {
208+
Example: "empty",
209+
},
210+
}
211+
ctx = cli.ContextWithConfig(ctx, cfg)
212+
213+
drv, tm := uitest.TestTUI(ctx, t)
214+
cmd := Env{
215+
Clipboard: new(clipboard.Mock),
216+
}
217+
errc := make(chan error, 1)
218+
219+
go func() {
220+
errc <- cmd.UI().RunTUI(ctx, drv)
221+
errc <- tm.Quit()
222+
}()
223+
224+
uitest.WaitForGoldenContains(t, drv, errc,
225+
"? How would you like to manage your environment variables?",
226+
)
227+
228+
tm.Send(tea.KeyMsg{Type: tea.KeyDown})
229+
tm.Send(tea.KeyMsg{Type: tea.KeyDown})
230+
tm.Send(tea.KeyMsg{Type: tea.KeyEnter})
231+
232+
tm.WaitFinished(t, teatest.WithFinalTimeout(time.Second*3))
233+
if err := <-errc; err != nil {
234+
t.Fatal(err)
235+
}
236+
237+
uitest.TestGolden(t, drv.Golden())
238+
})
200239
}

service/models/env.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,9 @@ func (m *EnvNextSteps) View() string {
223223

224224
fmt.Fprintln(&b, ui.Header("Next Steps"))
225225
fmt.Fprintln(&b, ui.StepAlert(ui.Action("(Re)Start your server.")))
226-
fmt.Fprintln(&b, ui.StepAlert(fmt.Sprintf("%s: %s", ui.Action("Check out your encrypted site"), ui.URL(m.LclUrl))))
226+
if m.LclUrl != "" {
227+
fmt.Fprintln(&b, ui.StepAlert(fmt.Sprintf("%s: %s", ui.Action("Check out your encrypted site"), ui.URL(m.LclUrl))))
228+
}
227229
fmt.Fprintln(&b, ui.StepHint("These certificates will renew automatically, time to enjoy effortless encryption."))
228230

229231
return b.String()
Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
─── Client ─────────────────────────────────────────────────────────────────────
2+
* Checking authentication: probing credentials locally…⠋
3+
─── Client ─────────────────────────────────────────────────────────────────────
4+
* Checking authentication: testing credentials remotely…⠋
5+
─── ServiceEnvHeader ───────────────────────────────────────────────────────────
6+
7+
# Fetch Environment Variables for Service `anchor service env`
8+
─── ServiceEnvHint ─────────────────────────────────────────────────────────────
9+
10+
# Fetch Environment Variables for Service `anchor service env`
11+
| We'll set your environment variables to provide configuration and credentials.
12+
─── Fetcher[github.com/anchordotdev/cli/api.Organization] ──────────────────────
13+
14+
# Fetch Environment Variables for Service `anchor service env`
15+
| We'll set your environment variables to provide configuration and credentials.
16+
* Fetching organizations…⠋
17+
─── Fetcher[github.com/anchordotdev/cli/api.Organization] ──────────────────────
18+
19+
# Fetch Environment Variables for Service `anchor service env`
20+
| We'll set your environment variables to provide configuration and credentials.
21+
- Using org-slug, the only available organization. You can also use `--org org-slug`.
22+
─── Fetcher[github.com/anchordotdev/cli/api.Realm] ─────────────────────────────
23+
24+
# Fetch Environment Variables for Service `anchor service env`
25+
| We'll set your environment variables to provide configuration and credentials.
26+
- Using org-slug, the only available organization. You can also use `--org org-slug`.
27+
* Fetching realms…⠋
28+
─── Fetcher[github.com/anchordotdev/cli/api.Realm] ─────────────────────────────
29+
30+
# Fetch Environment Variables for Service `anchor service env`
31+
| We'll set your environment variables to provide configuration and credentials.
32+
- Using org-slug, the only available organization. You can also use `--org org-slug`.
33+
- Using realm-slug, the only available realm. You can also use `--realm realm-slug`.
34+
─── Fetcher[github.com/anchordotdev/cli/api.Service] ───────────────────────────
35+
36+
# Fetch Environment Variables for Service `anchor service env`
37+
| We'll set your environment variables to provide configuration and credentials.
38+
- Using org-slug, the only available organization. You can also use `--org org-slug`.
39+
- Using realm-slug, the only available realm. You can also use `--realm realm-slug`.
40+
* Fetching services…⠋
41+
─── Fetcher[github.com/anchordotdev/cli/api.Service] ───────────────────────────
42+
43+
# Fetch Environment Variables for Service `anchor service env`
44+
| We'll set your environment variables to provide configuration and credentials.
45+
- Using org-slug, the only available organization. You can also use `--org org-slug`.
46+
- Using realm-slug, the only available realm. You can also use `--realm realm-slug`.
47+
- Using service-name, the only available service. You can also use `--service service-name`.
48+
─── EnvFetch ───────────────────────────────────────────────────────────────────
49+
50+
# Fetch Environment Variables for Service `anchor service env`
51+
| We'll set your environment variables to provide configuration and credentials.
52+
- Using org-slug, the only available organization. You can also use `--org org-slug`.
53+
- Using realm-slug, the only available realm. You can also use `--realm realm-slug`.
54+
- Using service-name, the only available service. You can also use `--service service-name`.
55+
* Fetching service-name environment variables…⠋
56+
─── EnvFetch ───────────────────────────────────────────────────────────────────
57+
58+
# Fetch Environment Variables for Service `anchor service env`
59+
| We'll set your environment variables to provide configuration and credentials.
60+
- Using org-slug, the only available organization. You can also use `--org org-slug`.
61+
- Using realm-slug, the only available realm. You can also use `--realm realm-slug`.
62+
- Using service-name, the only available service. You can also use `--service service-name`.
63+
─── EnvMethod ──────────────────────────────────────────────────────────────────
64+
65+
# Fetch Environment Variables for Service `anchor service env`
66+
| We'll set your environment variables to provide configuration and credentials.
67+
- Using org-slug, the only available organization. You can also use `--org org-slug`.
68+
- Using realm-slug, the only available realm. You can also use `--realm realm-slug`.
69+
- Using service-name, the only available service. You can also use `--service service-name`.
70+
? How would you like to manage your environment variables?
71+
> Add export commands to your clipboard.
72+
Add dotenv contents to your clipboard.
73+
Display export commands. ! WARNING: could be observed by others.
74+
─── EnvMethod ──────────────────────────────────────────────────────────────────
75+
76+
# Fetch Environment Variables for Service `anchor service env`
77+
| We'll set your environment variables to provide configuration and credentials.
78+
- Using org-slug, the only available organization. You can also use `--org org-slug`.
79+
- Using realm-slug, the only available realm. You can also use `--realm realm-slug`.
80+
- Using service-name, the only available service. You can also use `--service service-name`.
81+
? How would you like to manage your environment variables?
82+
Add export commands to your clipboard.
83+
> Add dotenv contents to your clipboard.
84+
Display export commands. ! WARNING: could be observed by others.
85+
─── EnvMethod ──────────────────────────────────────────────────────────────────
86+
87+
# Fetch Environment Variables for Service `anchor service env`
88+
| We'll set your environment variables to provide configuration and credentials.
89+
- Using org-slug, the only available organization. You can also use `--org org-slug`.
90+
- Using realm-slug, the only available realm. You can also use `--realm realm-slug`.
91+
- Using service-name, the only available service. You can also use `--service service-name`.
92+
? How would you like to manage your environment variables?
93+
Add export commands to your clipboard.
94+
Add dotenv contents to your clipboard.
95+
> Display export commands. ! WARNING: could be observed by others.
96+
─── EnvMethod ──────────────────────────────────────────────────────────────────
97+
98+
# Fetch Environment Variables for Service `anchor service env`
99+
| We'll set your environment variables to provide configuration and credentials.
100+
- Using org-slug, the only available organization. You can also use `--org org-slug`.
101+
- Using realm-slug, the only available realm. You can also use `--realm realm-slug`.
102+
- Using service-name, the only available service. You can also use `--service service-name`.
103+
- Selected display environment variable method. You can also use `--method display`.
104+
─── EnvDisplay ─────────────────────────────────────────────────────────────────
105+
106+
# Fetch Environment Variables for Service `anchor service env`
107+
| We'll set your environment variables to provide configuration and credentials.
108+
- Using org-slug, the only available organization. You can also use `--org org-slug`.
109+
- Using realm-slug, the only available realm. You can also use `--realm realm-slug`.
110+
- Using service-name, the only available service. You can also use `--service service-name`.
111+
- Selected display environment variable method. You can also use `--method display`.
112+
113+
export ACME_CONTACT="[email protected]"
114+
export ACME_DIRECTORY_URL="http://anchor.lcl.host/org-slug/realm-slug/x509/ca/acme"
115+
export HTTPS_PORT="4433"
116+
117+
- Displayed service-name export commands.
118+
! Be sure to load these into your environment.
119+
─── EnvNextSteps ───────────────────────────────────────────────────────────────
120+
121+
# Fetch Environment Variables for Service `anchor service env`
122+
| We'll set your environment variables to provide configuration and credentials.
123+
- Using org-slug, the only available organization. You can also use `--org org-slug`.
124+
- Using realm-slug, the only available realm. You can also use `--realm realm-slug`.
125+
- Using service-name, the only available service. You can also use `--service service-name`.
126+
- Selected display environment variable method. You can also use `--method display`.
127+
128+
export ACME_CONTACT="[email protected]"
129+
export ACME_DIRECTORY_URL="http://anchor.lcl.host/org-slug/realm-slug/x509/ca/acme"
130+
export HTTPS_PORT="4433"
131+
132+
- Displayed service-name export commands.
133+
! Be sure to load these into your environment.
134+
135+
# Next Steps
136+
! (Re)Start your server.
137+
| These certificates will renew automatically, time to enjoy effortless encryption.

0 commit comments

Comments
 (0)