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

chore: improve workspace proxy create cli flow#7907

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Emyrk merged 2 commits intomainfromstevenmasley/proxy_create_improve
Jun 8, 2023
Merged
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
50 changes: 47 additions & 3 deletionsenterprise/cli/workspaceproxy.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -208,6 +208,7 @@ func (r *RootCmd) createProxy() *clibase.Cmd {
proxyName string
displayName string
proxyIcon string
noPrompts bool
formatter = newUpdateProxyResponseFormatter()
)

Expand All@@ -221,8 +222,43 @@ func (r *RootCmd) createProxy() *clibase.Cmd {
),
Handler: func(inv *clibase.Invocation) error {
ctx := inv.Context()
var err error
if proxyName == "" && !noPrompts {
proxyName, err = cliui.Prompt(inv, cliui.PromptOptions{
Text: "Proxy Name:",
})
if err != nil {
return err
}
}
if displayName == "" && !noPrompts {
displayName, err = cliui.Prompt(inv, cliui.PromptOptions{
Text: "Display Name:",
Default: proxyName,
})
if err != nil {
return err
}
}

if proxyIcon == "" && !noPrompts {
proxyIcon, err = cliui.Prompt(inv, cliui.PromptOptions{
Text: "Icon URL:",
Default: "/emojis/1f5fa.png",
Validate: func(s string) error {
if !(strings.HasPrefix(s, "/emojis/") || strings.HasPrefix(s, "http")) {
return xerrors.New("icon must be a relative path to an emoji or a publicly hosted image URL")
}
return nil
},
})
if err != nil {
return err
}
}

if proxyName == "" {
return xerrors.Errorf("proxy name is required")
return xerrors.New("proxy name is required")
}

resp, err := client.CreateWorkspaceProxy(ctx, codersdk.CreateWorkspaceProxyRequest{
Expand DownExpand Up@@ -260,6 +296,11 @@ func (r *RootCmd) createProxy() *clibase.Cmd {
Description: "Display icon of the proxy.",
Value: clibase.StringOf(&proxyIcon),
},
clibase.Option{
Flag: "no-prompt",
Description: "Disable all input prompting, and fail if any required flags are missing.",
Value: clibase.BoolOf(&noPrompts),
},
)
return cmd
}
Expand DownExpand Up@@ -355,8 +396,11 @@ func newUpdateProxyResponseFormatter() *updateProxyResponseFormatter {
if !ok {
return nil, xerrors.Errorf("unexpected type %T", data)
}
return fmt.Sprintf("Workspace Proxy %q created successfully. Save this token, it will not be shown again."+
"\nToken: %s", response.Proxy.Name, response.ProxyToken), nil

return fmt.Sprintf("Workspace Proxy %q updated successfully.\n"+
cliui.DefaultStyles.Placeholder.Render("—————————————————————————————————————————————————")+"\n"+
"Save this authentication token, it will not be shown again.\n"+
"Token: %s\n", response.Proxy.Name, response.ProxyToken), nil
}),
cliui.JSONFormat(),
// Table formatter expects a slice, make a slice of one.
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp