Skip to content

Commit

Permalink
Merge pull request #37 from Optum/maint/cli-fixes
Browse files Browse the repository at this point in the history
Update CLI starter templates
  • Loading branch information
mbpolan committed Oct 6, 2021
2 parents 9095961 + 25d9fff commit 8d69b4c
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions cmd/cli/cmd/new.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (

var templateUrl string
var scm string
var runiacGitHubOrg = "github.com/runiac"

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

// check if a git repository has already been initialized
exists, err := afero.Exists(fs, fmt.Sprintf("%s/.git", name))
if err != nil {
return err
}

if exists {
return nil
}

// initialize the repository
cmd := exec.Command("git", "init", "-b", "main")
cmd.Dir = name
Expand Down Expand Up @@ -345,19 +356,20 @@ func processUrl(name string, templateUrl string) error {
}

func processPredefined(name string, template string) error {
subdir := ""
source := ""
switch template {
case "azure-arm":
subdir = "arm-azure-hello-world"
source = fmt.Sprintf("%s/runiac-starter-arm-azure-hello-world", runiacGitHubOrg)
case "azure-terraform":
subdir = "terraform-azure-hello-world"
source = fmt.Sprintf("%s/runiac-starter-terraform-azure-hello-world", runiacGitHubOrg)
case "aws-terraform":
source = fmt.Sprintf("%s/runiac-starter-terraform-aws-hello-world", runiacGitHubOrg)
case "gcp-terraform":
subdir = "terraform-gcp-hello-world"
source = fmt.Sprintf("%s/runiac-starter-terraform-gcp-hello-world", runiacGitHubOrg)
case "kitchen-sink":
subdir = "kitchen-sink"
source = "github.com/optum/runiac.git//examples/kitchen-sink"
}

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

0 comments on commit 8d69b4c

Please sign in to comment.