Skip to content
This repository was archived by the owner on Aug 30, 2024. It is now read-only.

Commit 58320e4

Browse files
authored
cli: Use map for config-ssh ux State write (#199)
Context: `cliSSHConfigured` is changing data structure from `bool` -> `map[string]bool` in order to capture which environments are configured for SSH.
1 parent 1f16b2b commit 58320e4

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

internal/cmd/configssh.go

+9-3
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ func configSSH(configpath *string, remove *bool) func(cmd *cobra.Command, _ []st
135135
fmt.Printf("Your private ssh key was written to \"%s\"\n", privateKeyFilepath)
136136
}
137137

138-
writeSSHUXState(ctx, client, user.ID)
138+
writeSSHUXState(ctx, client, user.ID, envs)
139139
fmt.Printf("An auto-generated ssh config was written to \"%s\"\n", *configpath)
140140
fmt.Println("You should now be able to ssh into your environment")
141141
fmt.Printf("For example, try running\n\n\t$ ssh coder.%s\n\n", envs[0].Name)
@@ -258,10 +258,16 @@ func readStr(filename string) (string, error) {
258258
return string(contents), nil
259259
}
260260

261-
func writeSSHUXState(ctx context.Context, client *coder.Client, userID string) {
261+
func writeSSHUXState(ctx context.Context, client *coder.Client, userID string, envs []coder.Environment) {
262+
// Create a map of env.ID -> true to indicate to the web client that all
263+
// current environments have SSH configured
264+
cliSSHConfigured := make(map[string]bool)
265+
for _, env := range envs {
266+
cliSSHConfigured[env.ID] = true
267+
}
262268
// Update UXState that coder config-ssh has been run by the currently
263269
// authenticated user
264-
err := client.UpdateUXState(ctx, userID, map[string]interface{}{"cliSSHConfigured": true})
270+
err := client.UpdateUXState(ctx, userID, map[string]interface{}{"cliSSHConfigured": cliSSHConfigured})
265271
if err != nil {
266272
clog.LogWarn("The Coder web client may not recognize that you've configured SSH.")
267273
}

0 commit comments

Comments
 (0)