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

Commit e13657f

Browse files
committed
fixup! cli: Update UXState from config-ssh
1 parent a727c6b commit e13657f

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

coder-sdk/users.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,6 @@ func (c Client) Me(ctx context.Context) (*User, error) {
4646
return c.UserByID(ctx, Me)
4747
}
4848

49-
// MyUXState updates the authenticated user's UX State.
50-
func (c Client) MyUXState(ctx context.Context, uxsPartial map[string]interface{}) error {
51-
if err := c.requestBody(ctx, http.MethodPut, "/api/private/users/me/ux-state", uxsPartial, nil); err != nil {
52-
return err
53-
}
54-
return nil
55-
}
56-
5749
// UserByID get the details of a user by their id.
5850
func (c Client) UserByID(ctx context.Context, id string) (*User, error) {
5951
var u User
@@ -122,6 +114,14 @@ func (c Client) UpdateUser(ctx context.Context, userID string, req UpdateUserReq
122114
return c.requestBody(ctx, http.MethodPatch, "/api/private/users/"+userID, req, nil)
123115
}
124116

117+
// UpdateUXState updates the authenticated user's UX State.
118+
func (c Client) UpdateUXState(ctx context.Context, userID string, uxsPartial map[string]interface{}) error {
119+
if err := c.requestBody(ctx, http.MethodPut, "/api/private/users/"+userID+"/ux-state", uxsPartial, nil); err != nil {
120+
return err
121+
}
122+
return nil
123+
}
124+
125125
// CreateUserReq defines the request parameters for creating a new user resource.
126126
type CreateUserReq struct {
127127
Name string `json:"name"`

internal/cmd/configssh.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package cmd
22

33
import (
4+
"cdr.dev/coder-cli/pkg/clog"
45
"context"
56
"fmt"
67
"io/ioutil"
@@ -135,7 +136,7 @@ func configSSH(configpath *string, remove *bool) func(cmd *cobra.Command, _ []st
135136
fmt.Printf("Your private ssh key was written to \"%s\"\n", privateKeyFilepath)
136137
}
137138

138-
writeSSHUXState(ctx, client)
139+
writeSSHUXState(ctx, client, user.ID)
139140
fmt.Printf("An auto-generated ssh config was written to \"%s\"\n", *configpath)
140141
fmt.Println("You should now be able to ssh into your environment")
141142
fmt.Printf("For example, try running\n\n\t$ ssh coder.%s\n\n", envs[0].Name)
@@ -217,11 +218,11 @@ func readStr(filename string) (string, error) {
217218
return string(contents), nil
218219
}
219220

220-
func writeSSHUXState(ctx context.Context, client *coder.Client) {
221+
func writeSSHUXState(ctx context.Context, client *coder.Client, userID string) {
221222
// Update UXState that coder config-ssh has been run by the currently
222223
// authenticated user
223-
err := client.MyUXState(ctx, map[string]interface{}{"cliSSHConfigured": true})
224+
err := client.UpdateUXState(ctx, userID, map[string]interface{}{"cliSSHConfigured": true})
224225
if err != nil {
225-
fmt.Println("⚠ The Coder web client may not recognize that you've configured SSH.")
226+
clog.LogWarn("The Coder web client may not recognize that you've configured SSH.")
226227
}
227228
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

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:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy