7
7
"fmt"
8
8
"io"
9
9
"io/ioutil"
10
- "net/url"
11
10
12
11
"cdr.dev/coder-cli/coder-sdk"
13
12
"cdr.dev/coder-cli/internal/coderutil"
@@ -300,6 +299,7 @@ func createEnvFromRepoCmd() *cobra.Command {
300
299
filepath string
301
300
org string
302
301
providerName string
302
+ envName string
303
303
)
304
304
305
305
cmd := & cobra.Command {
@@ -308,23 +308,23 @@ func createEnvFromRepoCmd() *cobra.Command {
308
308
Long : "Create a new Coder environment from a config file." ,
309
309
Hidden : true ,
310
310
Example : `# create a new environment from git repository template
311
- coder envs create-from-config --repo-url github.com/cdr/m --branch my-branch
312
- coder envs create-from-config -f coder.yaml` ,
311
+ coder envs create-from-config --name="dev-env" -- repo-url github.com/cdr/m --ref my-branch
312
+ coder envs create-from-config --name="dev-env" - f coder.yaml` ,
313
313
RunE : func (cmd * cobra.Command , args []string ) error {
314
314
ctx := cmd .Context ()
315
315
316
+ if envName == "" {
317
+ return clog .Error ("Must provide a environment name." ,
318
+ clog .BlankLine ,
319
+ clog .Tipf ("Use --name=<env-name> to name your environment" ),
320
+ )
321
+ }
322
+
316
323
client , err := newClient (ctx )
317
324
if err != nil {
318
325
return err
319
326
}
320
327
321
- if repo != "" {
322
- _ , err = url .Parse (repo )
323
- if err != nil {
324
- return xerrors .Errorf ("'repo' must be a valid url: %w" , err )
325
- }
326
- }
327
-
328
328
orgs , err := getUserOrgs (ctx , client , coder .Me )
329
329
if err != nil {
330
330
return err
@@ -388,6 +388,7 @@ coder envs create-from-config -f coder.yaml`,
388
388
TemplateID : version .TemplateID ,
389
389
ResourcePoolID : provider .ID ,
390
390
Namespace : provider .DefaultNamespace ,
391
+ Name : envName ,
391
392
})
392
393
if err != nil {
393
394
return handleAPIError (err )
@@ -414,6 +415,7 @@ coder envs create-from-config -f coder.yaml`,
414
415
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'." )
415
416
cmd .Flags ().BoolVar (& follow , "follow" , false , "follow buildlog after initiating rebuild" )
416
417
cmd .Flags ().StringVar (& providerName , "provider" , "" , "name of Workspace Provider with which to create the environment" )
418
+ cmd .Flags ().StringVar (& envName , "name" , "" , "name of the environment to be created" )
417
419
return cmd
418
420
}
419
421
0 commit comments