diff --git a/coder-sdk/users.go b/coder-sdk/users.go index 26e48afd..ce2beee5 100644 --- a/coder-sdk/users.go +++ b/coder-sdk/users.go @@ -114,6 +114,14 @@ func (c Client) UpdateUser(ctx context.Context, userID string, req UpdateUserReq return c.requestBody(ctx, http.MethodPatch, "/api/private/users/"+userID, req, nil) } +// UpdateUXState applies a partial update of the user's UX State. +func (c Client) UpdateUXState(ctx context.Context, userID string, uxsPartial map[string]interface{}) error { + if err := c.requestBody(ctx, http.MethodPut, "/api/private/users/"+userID+"/ux-state", uxsPartial, nil); err != nil { + return err + } + return nil +} + // CreateUserReq defines the request parameters for creating a new user resource. type CreateUserReq struct { Name string `json:"name"` diff --git a/internal/cmd/configssh.go b/internal/cmd/configssh.go index 50f6c3bd..db879602 100644 --- a/internal/cmd/configssh.go +++ b/internal/cmd/configssh.go @@ -12,6 +12,8 @@ import ( "strings" "time" + "cdr.dev/coder-cli/pkg/clog" + "cdr.dev/coder-cli/coder-sdk" "cdr.dev/coder-cli/internal/config" "github.com/spf13/cobra" @@ -135,6 +137,7 @@ func configSSH(configpath *string, remove *bool) func(cmd *cobra.Command, _ []st fmt.Printf("Your private ssh key was written to \"%s\"\n", privateKeyFilepath) } + writeSSHUXState(ctx, client, user.ID) fmt.Printf("An auto-generated ssh config was written to \"%s\"\n", *configpath) fmt.Println("You should now be able to ssh into your environment") fmt.Printf("For example, try running\n\n\t$ ssh coder.%s\n\n", envs[0].Name) @@ -215,3 +218,12 @@ func readStr(filename string) (string, error) { } return string(contents), nil } + +func writeSSHUXState(ctx context.Context, client *coder.Client, userID string) { + // Update UXState that coder config-ssh has been run by the currently + // authenticated user + err := client.UpdateUXState(ctx, userID, map[string]interface{}{"cliSSHConfigured": true}) + if err != nil { + clog.LogWarn("The Coder web client may not recognize that you've configured SSH.") + } +}
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies: