Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Aug 30, 2024. It is now read-only.
/coder-v1-cliPublic archive

Commitdb06ecc

Browse files
greyscaledcmoog
andauthored
cli: Update UXState from config-ssh (#195)
Context:In optimizing the dashboard environment experiences, tracking whether auser has run config-ssh locally enables personalized education about thefeature.Co-authored-by: Charles Moog <moogcharlie@gmail.com>
1 parent0e6ae81 commitdb06ecc

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
returnc.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 (cClient)UpdateUXState(ctx context.Context,userIDstring,uxsPartialmap[string]interface{})error {
119+
iferr:=c.requestBody(ctx,http.MethodPut,"/api/private/users/"+userID+"/ux-state",uxsPartial,nil);err!=nil {
120+
returnerr
121+
}
122+
returnnil
123+
}
124+
117125
// CreateUserReq defines the request parameters for creating a new user resource.
118126
typeCreateUserReqstruct {
119127
Namestring`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
returnstring(contents),nil
217220
}
221+
222+
funcwriteSSHUXState(ctx context.Context,client*coder.Client,userIDstring) {
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+
iferr!=nil {
227+
clog.LogWarn("The Coder web client may not recognize that you've configured SSH.")
228+
}
229+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp