Skip to content

Commit 8d69b4c

Browse files
authored
Merge pull request #37 from Optum/maint/cli-fixes
Update CLI starter templates
2 parents 9095961 + 25d9fff commit 8d69b4c

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

cmd/cli/cmd/new.go

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import (
1919

2020
var templateUrl string
2121
var scm string
22+
var runiacGitHubOrg = "github.com/runiac"
2223

2324
func init() {
2425
newCmd.Flags().StringVarP(&templateUrl, "url", "", "", "URL to download project template")
@@ -183,6 +184,16 @@ func initializeGit(name string, fs afero.Fs) error {
183184
return err
184185
}
185186

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+
186197
// initialize the repository
187198
cmd := exec.Command("git", "init", "-b", "main")
188199
cmd.Dir = name
@@ -345,19 +356,20 @@ func processUrl(name string, templateUrl string) error {
345356
}
346357

347358
func processPredefined(name string, template string) error {
348-
subdir := ""
359+
source := ""
349360
switch template {
350361
case "azure-arm":
351-
subdir = "arm-azure-hello-world"
362+
source = fmt.Sprintf("%s/runiac-starter-arm-azure-hello-world", runiacGitHubOrg)
352363
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)
354367
case "gcp-terraform":
355-
subdir = "terraform-gcp-hello-world"
368+
source = fmt.Sprintf("%s/runiac-starter-terraform-gcp-hello-world", runiacGitHubOrg)
356369
case "kitchen-sink":
357-
subdir = "kitchen-sink"
370+
source = "github.com/optum/runiac.git//examples/kitchen-sink"
358371
}
359372

360-
source := fmt.Sprintf("github.com/optum/runiac.git//examples/%s", subdir)
361373
err := getter.Get(name, source)
362374
if err != nil {
363375
return err

0 commit comments

Comments
 (0)