Skip to content

Commit

Permalink
#210 fix
Browse files Browse the repository at this point in the history
Signed-off-by: 6za <53096417+6za@users.noreply.github.com>
  • Loading branch information
6za committed Aug 10, 2022
1 parent 7185873 commit 066f73c
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 25 deletions.
12 changes: 6 additions & 6 deletions cmd/createGithub.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,20 +70,20 @@ var createGithubCmd = &cobra.Command{
return err
}

directory := fmt.Sprintf("%s/gitops/terraform/base", config.K1FolderPath)
informUser("Creating K8S Cluster")
terraform.ApplyBaseTerraform(dryRun, directory)

informUser("populating gitops/metaphor repos")
err = githubPopulateCmd.RunE(cmd, args)
if err != nil {
return err
}

directory := fmt.Sprintf("%s/gitops/terraform/base", config.K1FolderPath)
informUser("Creating K8S Cluster")
terraform.ApplyBaseTerraform(dryRun, directory)

//progressPrinter.IncrementTracker("step-terraform", 1)

//informUser("Attempt to recycle certs")
//restoreSSLCmd.Run(cmd, args)
informUser("Attempt to recycle certs")
restoreSSLCmd.Run(cmd, args)

/*
Expand Down
19 changes: 19 additions & 0 deletions cmd/githubAdd.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import (
"fmt"
"log"

"github.com/kubefirst/kubefirst/configs"
"github.com/kubefirst/kubefirst/internal/gitClient"
"github.com/kubefirst/kubefirst/internal/githubWrapper"
"github.com/spf13/cobra"
"github.com/spf13/viper"
Expand All @@ -20,6 +22,14 @@ var githubAddCmd = &cobra.Command{
Long: `TBD`,
RunE: func(cmd *cobra.Command, args []string) error {
fmt.Println("githubAddCmd called")
config := configs.ReadConfig()
owner, err := cmd.Flags().GetString("github-owner")
if err != nil {
return err
}
viper.Set("github.owner", owner)
viper.WriteConfig()

org, err := cmd.Flags().GetString("github-org")
if err != nil {
return err
Expand Down Expand Up @@ -52,6 +62,15 @@ var githubAddCmd = &cobra.Command{
return err
}
}

_, err = gitClient.CloneRepoAndDetokenize(config.GitopsTemplateURL, "gitops", "main")
if err != nil {
return err
}
_, err = gitClient.CloneRepoAndDetokenize(config.MetaphorTemplateURL, "metaphor", "main")
if err != nil {
return err
}
viper.Set("github.enabled", true)
viper.Set("github.repo.added", true)
viper.WriteConfig()
Expand Down
24 changes: 6 additions & 18 deletions cmd/githubPopulate.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,6 @@ to quickly create a Cobra application.`,
RunE: func(cmd *cobra.Command, args []string) error {
fmt.Println("githubPopulate called")
config := configs.ReadConfig()
owner, err := cmd.Flags().GetString("github-owner")
if err != nil {
return err
}

githubHost, err := cmd.Flags().GetString("github-host")
if err != nil {
Expand All @@ -40,8 +36,6 @@ to quickly create a Cobra application.`,
if err != nil {
return err
}
viper.Set("github.owner", owner)
viper.WriteConfig()

log.Println("dry-run:", dryrun)

Expand All @@ -54,19 +48,13 @@ to quickly create a Cobra application.`,
return nil
}

owner := viper.GetString("github.owner")
//sourceFolder := fmt.Sprintf("%s/sample", config.K1FolderPath)
sourceFolder, err := gitClient.CloneRepoAndDetokenize(config.GitopsTemplateURL, "gitops", "main")
if err != nil {
return err
}
fmt.Println("githubPopulate:", sourceFolder)
gitClient.PopulateRepoWithToken(owner, "gitops", sourceFolder, githubHost)
sourceFolder, err = gitClient.CloneRepoAndDetokenize(config.MetaphorTemplateURL, "metaphor", "main")
if err != nil {
return err
}
fmt.Println("githubPopulate:", sourceFolder)
gitClient.PopulateRepoWithToken(owner, "metaphor", sourceFolder, githubHost)
fmt.Println("githubPopulate: gitops")
gitClient.PopulateRepoWithToken(owner, "gitops", fmt.Sprintf("%s/%s", config.K1FolderPath, "gitops"), githubHost)

fmt.Println("githubPopulate: metaphor")
gitClient.PopulateRepoWithToken(owner, "metaphor", fmt.Sprintf("%s/%s", config.K1FolderPath, "metaphor"), githubHost)
viper.Set("github.metaphor-pushed", true)

viper.Set("github.repo.populated", true)
Expand Down
2 changes: 1 addition & 1 deletion pkg/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func DetokenizeDirectory(path string, fi os.FileInfo, err error) error {
if gitlabConfigured {
newContents = strings.Replace(string(read), "ssh://soft-serve.soft-serve.svc.cluster.local:22/gitops", fmt.Sprintf("https://gitlab.%s/kubefirst/gitops.git", viper.GetString("aws.hostedzonename")), -1)
} else if githubConfigured {
newContents = strings.Replace(string(read), "https://gitlab.<AWS_HOSTED_ZONE_NAME>/kubefirst/gitops.git", "git@github.com:"+githubRepoOwner+"/"+"gitops.git", -1)
newContents = strings.Replace(string(read), "https://gitlab.<AWS_HOSTED_ZONE_NAME>/kubefirst/gitops", "git@github.com:"+githubRepoOwner+"/"+"gitops", -1)
} else {
newContents = strings.Replace(string(read), "https://gitlab.<AWS_HOSTED_ZONE_NAME>/kubefirst/gitops.git", "ssh://soft-serve.soft-serve.svc.cluster.local:22/gitops", -1)
}
Expand Down

0 comments on commit 066f73c

Please sign in to comment.