mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
chore: Remove url and wildcard url from moon create (#7224)
* chore: Remove url and wildcard url from moon create
This commit is contained in:
@@ -55,13 +55,11 @@ func (r *RootCmd) deleteProxy() *clibase.Cmd {
|
||||
|
||||
func (r *RootCmd) createProxy() *clibase.Cmd {
|
||||
var (
|
||||
proxyName string
|
||||
displayName string
|
||||
proxyIcon string
|
||||
proxyURL string
|
||||
proxyWildcardHostname string
|
||||
onlyToken bool
|
||||
formatter = cliui.NewOutputFormatter(
|
||||
proxyName string
|
||||
displayName string
|
||||
proxyIcon string
|
||||
onlyToken bool
|
||||
formatter = cliui.NewOutputFormatter(
|
||||
// Text formatter should be human readable.
|
||||
cliui.ChangeFormatterData(cliui.TextFormat(), func(data any) (any, error) {
|
||||
response, ok := data.(codersdk.CreateWorkspaceProxyResponse)
|
||||
@@ -94,11 +92,9 @@ func (r *RootCmd) createProxy() *clibase.Cmd {
|
||||
Handler: func(inv *clibase.Invocation) error {
|
||||
ctx := inv.Context()
|
||||
resp, err := client.CreateWorkspaceProxy(ctx, codersdk.CreateWorkspaceProxyRequest{
|
||||
Name: proxyName,
|
||||
DisplayName: displayName,
|
||||
Icon: proxyIcon,
|
||||
URL: proxyURL,
|
||||
WildcardHostname: proxyWildcardHostname,
|
||||
Name: proxyName,
|
||||
DisplayName: displayName,
|
||||
Icon: proxyIcon,
|
||||
})
|
||||
if err != nil {
|
||||
return xerrors.Errorf("create workspace proxy: %w", err)
|
||||
@@ -136,16 +132,6 @@ func (r *RootCmd) createProxy() *clibase.Cmd {
|
||||
Description: "Display icon of the proxy.",
|
||||
Value: clibase.StringOf(&proxyIcon),
|
||||
},
|
||||
clibase.Option{
|
||||
Flag: "access-url",
|
||||
Description: "Access URL of the proxy.",
|
||||
Value: clibase.StringOf(&proxyURL),
|
||||
},
|
||||
clibase.Option{
|
||||
Flag: "wildcard-access-url",
|
||||
Description: "(Optional) Access url of the proxy for subdomain based apps.",
|
||||
Value: clibase.StringOf(&proxyWildcardHostname),
|
||||
},
|
||||
clibase.Option{
|
||||
Flag: "only-token",
|
||||
Description: "Only print the token. This is useful for scripting.",
|
||||
|
||||
@@ -49,7 +49,6 @@ func Test_ProxyCRUD(t *testing.T) {
|
||||
"--name", expectedName,
|
||||
"--display-name", "Test Proxy",
|
||||
"--icon", "/emojis/1f4bb.png",
|
||||
"--access-url", "http://localhost:3010",
|
||||
"--only-token",
|
||||
)
|
||||
|
||||
@@ -99,7 +98,6 @@ func Test_ProxyCRUD(t *testing.T) {
|
||||
Name: expectedName,
|
||||
DisplayName: "Test Proxy",
|
||||
Icon: "/emojis/us.png",
|
||||
URL: "http://localhost:3010",
|
||||
})
|
||||
require.NoError(t, err, "failed to create workspace proxy")
|
||||
|
||||
|
||||
@@ -108,10 +108,8 @@ func NewWorkspaceProxy(t *testing.T, coderdAPI *coderd.API, owner *codersdk.Clie
|
||||
}
|
||||
|
||||
proxyRes, err := owner.CreateWorkspaceProxy(ctx, codersdk.CreateWorkspaceProxyRequest{
|
||||
Name: options.Name,
|
||||
Icon: "/emojis/flag.png",
|
||||
URL: accessURL.String(),
|
||||
WildcardHostname: options.AppHostname,
|
||||
Name: options.Name,
|
||||
Icon: "/emojis/flag.png",
|
||||
})
|
||||
require.NoError(t, err, "failed to create workspace proxy")
|
||||
|
||||
|
||||
@@ -91,24 +91,6 @@ func (api *API) postWorkspaceProxy(rw http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
if err := validateProxyURL(req.URL); err != nil {
|
||||
httpapi.Write(ctx, rw, http.StatusBadRequest, codersdk.Response{
|
||||
Message: "URL is invalid.",
|
||||
Detail: err.Error(),
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
if req.WildcardHostname != "" {
|
||||
if _, err := httpapi.CompileHostnamePattern(req.WildcardHostname); err != nil {
|
||||
httpapi.Write(ctx, rw, http.StatusBadRequest, codersdk.Response{
|
||||
Message: "Wildcard URL is invalid.",
|
||||
Detail: err.Error(),
|
||||
})
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
id := uuid.New()
|
||||
secret, err := cryptorand.HexString(64)
|
||||
if err != nil {
|
||||
@@ -123,8 +105,6 @@ func (api *API) postWorkspaceProxy(rw http.ResponseWriter, r *http.Request) {
|
||||
Name: req.Name,
|
||||
DisplayName: req.DisplayName,
|
||||
Icon: req.Icon,
|
||||
Url: req.URL,
|
||||
WildcardHostname: req.WildcardHostname,
|
||||
TokenHashedSecret: hashedSecret[:],
|
||||
CreatedAt: database.Now(),
|
||||
UpdatedAt: database.Now(),
|
||||
|
||||
@@ -52,10 +52,8 @@ func TestWorkspaceProxyCRUD(t *testing.T) {
|
||||
})
|
||||
ctx := testutil.Context(t, testutil.WaitLong)
|
||||
proxyRes, err := client.CreateWorkspaceProxy(ctx, codersdk.CreateWorkspaceProxyRequest{
|
||||
Name: namesgenerator.GetRandomName(1),
|
||||
Icon: "/emojis/flag.png",
|
||||
URL: "https://" + namesgenerator.GetRandomName(1) + ".com",
|
||||
WildcardHostname: "*.sub.example.com",
|
||||
Name: namesgenerator.GetRandomName(1),
|
||||
Icon: "/emojis/flag.png",
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
@@ -87,10 +85,8 @@ func TestWorkspaceProxyCRUD(t *testing.T) {
|
||||
})
|
||||
ctx := testutil.Context(t, testutil.WaitLong)
|
||||
proxyRes, err := client.CreateWorkspaceProxy(ctx, codersdk.CreateWorkspaceProxyRequest{
|
||||
Name: namesgenerator.GetRandomName(1),
|
||||
Icon: "/emojis/flag.png",
|
||||
URL: "https://" + namesgenerator.GetRandomName(1) + ".com",
|
||||
WildcardHostname: "*.sub.example.com",
|
||||
Name: namesgenerator.GetRandomName(1),
|
||||
Icon: "/emojis/flag.png",
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
@@ -156,10 +152,8 @@ func TestIssueSignedAppToken(t *testing.T) {
|
||||
|
||||
createProxyCtx := testutil.Context(t, testutil.WaitLong)
|
||||
proxyRes, err := client.CreateWorkspaceProxy(createProxyCtx, codersdk.CreateWorkspaceProxyRequest{
|
||||
Name: namesgenerator.GetRandomName(1),
|
||||
Icon: "/emojis/flag.png",
|
||||
URL: "https://" + namesgenerator.GetRandomName(1) + ".com",
|
||||
WildcardHostname: "*.sub.example.com",
|
||||
Name: namesgenerator.GetRandomName(1),
|
||||
Icon: "/emojis/flag.png",
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user