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

Commit db06ecc

Browse files
greyscaledcmoog
andauthored
cli: Update UXState from config-ssh (#195)
Context: In optimizing the dashboard environment experiences, tracking whether a user has run config-ssh locally enables personalized education about the feature. Co-authored-by: Charles Moog <moogcharlie@gmail.com>
1 parent 0e6ae81 commit db06ecc

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

coder-sdk/users.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,14 @@ func (c Client) UpdateUser(ctx context.Context, userID string, req UpdateUserReq
114114
return c.requestBody(ctx, http.MethodPatch, "/api/private/users/"+userID, req, nil)
115115
}
116116

117+
// UpdateUXState applies a partial update of the 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+
117125
// CreateUserReq defines the request parameters for creating a new user resource.
118126
type CreateUserReq struct {
119127
Name string `json:"name"`

internal/cmd/configssh.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ import (
1212
"strings"
1313
"time"
1414

15+
"cdr.dev/coder-cli/pkg/clog"
16+
1517
"cdr.dev/coder-cli/coder-sdk"
1618
"cdr.dev/coder-cli/internal/config"
1719
"github.com/spf13/cobra"
@@ -135,6 +137,7 @@ func configSSH(configpath *string, remove *bool) func(cmd *cobra.Command, _ []st
135137
fmt.Printf("Your private ssh key was written to \"%s\"\n", privateKeyFilepath)
136138
}
137139

140+
writeSSHUXState(ctx, client, user.ID)
138141
fmt.Printf("An auto-generated ssh config was written to \"%s\"\n", *configpath)
139142
fmt.Println("You should now be able to ssh into your environment")
140143
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) {
215218
}
216219
return string(contents), nil
217220
}
221+
222+
func writeSSHUXState(ctx context.Context, client *coder.Client, userID string) {
223+
// Update UXState that coder config-ssh has been run by the currently
224+
// authenticated user
225+
err := client.UpdateUXState(ctx, userID, map[string]interface{}{"cliSSHConfigured": true})
226+
if err != nil {
227+
clog.LogWarn("The Coder web client may not recognize that you've configured SSH.")
228+
}
229+
}

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