Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Aug 30, 2024. It is now read-only.

Removing Name from Wac templates #303

Merged
merged 3 commits into from
Mar 29, 2021
Merged
Changes from all 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
22 changes: 12 additions & 10 deletions internal/cmd/envs.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"fmt"
"io"
"io/ioutil"
"net/url"

"cdr.dev/coder-cli/coder-sdk"
"cdr.dev/coder-cli/internal/coderutil"
Expand Down Expand Up @@ -300,6 +299,7 @@ func createEnvFromRepoCmd() *cobra.Command {
filepath string
org string
providerName string
envName string
)

cmd := &cobra.Command{
Expand All @@ -308,23 +308,23 @@ func createEnvFromRepoCmd() *cobra.Command {
Long: "Create a new Coder environment from a config file.",
Hidden: true,
Example: `# create a new environment from git repository template
coder envs create-from-config --repo-url github.com/cdr/m --branch my-branch
coder envs create-from-config -f coder.yaml`,
coder envs create-from-config --name="dev-env" --repo-url github.com/cdr/m --ref my-branch
coder envs create-from-config --name="dev-env" -f coder.yaml`,
RunE: func(cmd *cobra.Command, args []string) error {
ctx := cmd.Context()

if envName == "" {
return clog.Error("Must provide a environment name.",
clog.BlankLine,
clog.Tipf("Use --name=<env-name> to name your environment"),
)
}

client, err := newClient(ctx)
if err != nil {
return err
}

if repo != "" {
_, err = url.Parse(repo)
if err != nil {
return xerrors.Errorf("'repo' must be a valid url: %w", err)
}
}

orgs, err := getUserOrgs(ctx, client, coder.Me)
if err != nil {
return err
Expand Down Expand Up @@ -388,6 +388,7 @@ coder envs create-from-config -f coder.yaml`,
TemplateID: version.TemplateID,
ResourcePoolID: provider.ID,
Namespace: provider.DefaultNamespace,
Name: envName,
})
if err != nil {
return handleAPIError(err)
Expand All @@ -414,6 +415,7 @@ coder envs create-from-config -f coder.yaml`,
cmd.Flags().StringVarP(&repo, "repo-url", "r", "", "URL of the git repository to pull the config from. Config file must live in '.coder/coder.yaml'.")
cmd.Flags().BoolVar(&follow, "follow", false, "follow buildlog after initiating rebuild")
cmd.Flags().StringVar(&providerName, "provider", "", "name of Workspace Provider with which to create the environment")
cmd.Flags().StringVar(&envName, "name", "", "name of the environment to be created")
return cmd
}

Expand Down