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

cli: Update UXState from config-ssh#195

Merged
greyscaled merged 1 commit intomasterfromvapurrmaid/ch2889/config-ssh-ux
Dec 2, 2020
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletionscoder-sdk/users.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -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"`
Expand Down
12 changes: 12 additions & 0 deletionsinternal/cmd/configssh.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -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"
Expand DownExpand Up@@ -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)
Expand DownExpand Up@@ -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.")
}
}

[8]ページ先頭

©2009-2025 Movatter.jp