@@ -19,6 +19,7 @@ import (
19
19
20
20
var templateUrl string
21
21
var scm string
22
+ var runiacGitHubOrg = "github.com/runiac"
22
23
23
24
func init () {
24
25
newCmd .Flags ().StringVarP (& templateUrl , "url" , "" , "" , "URL to download project template" )
@@ -183,6 +184,16 @@ func initializeGit(name string, fs afero.Fs) error {
183
184
return err
184
185
}
185
186
187
+ // check if a git repository has already been initialized
188
+ exists , err := afero .Exists (fs , fmt .Sprintf ("%s/.git" , name ))
189
+ if err != nil {
190
+ return err
191
+ }
192
+
193
+ if exists {
194
+ return nil
195
+ }
196
+
186
197
// initialize the repository
187
198
cmd := exec .Command ("git" , "init" , "-b" , "main" )
188
199
cmd .Dir = name
@@ -345,19 +356,20 @@ func processUrl(name string, templateUrl string) error {
345
356
}
346
357
347
358
func processPredefined (name string , template string ) error {
348
- subdir := ""
359
+ source := ""
349
360
switch template {
350
361
case "azure-arm" :
351
- subdir = " arm-azure-hello-world"
362
+ source = fmt . Sprintf ( "%s/runiac-starter- arm-azure-hello-world", runiacGitHubOrg )
352
363
case "azure-terraform" :
353
- subdir = "terraform-azure-hello-world"
364
+ source = fmt .Sprintf ("%s/runiac-starter-terraform-azure-hello-world" , runiacGitHubOrg )
365
+ case "aws-terraform" :
366
+ source = fmt .Sprintf ("%s/runiac-starter-terraform-aws-hello-world" , runiacGitHubOrg )
354
367
case "gcp-terraform" :
355
- subdir = " terraform-gcp-hello-world"
368
+ source = fmt . Sprintf ( "%s/runiac-starter- terraform-gcp-hello-world", runiacGitHubOrg )
356
369
case "kitchen-sink" :
357
- subdir = "kitchen-sink"
370
+ source = "github.com/optum/runiac.git//examples/ kitchen-sink"
358
371
}
359
372
360
- source := fmt .Sprintf ("github.com/optum/runiac.git//examples/%s" , subdir )
361
373
err := getter .Get (name , source )
362
374
if err != nil {
363
375
return err
0 commit comments