From e581f02f39fc12b3697c4b05a2f633b38e286967 Mon Sep 17 00:00:00 2001 From: G r e y Date: Wed, 2 Dec 2020 18:27:10 +0000 Subject: [PATCH] cli: Update UXState from config-ssh 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 --- coder-sdk/users.go | 8 ++++++++ internal/cmd/configssh.go | 12 ++++++++++++ 2 files changed, 20 insertions(+) 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.") + } +} 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