Skip to content

Commit

Permalink
resolved the suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
M R Rishi authored and M R Rishi committed Aug 1, 2024
1 parent 8b519fd commit e5cac33
Show file tree
Hide file tree
Showing 22 changed files with 148 additions and 144 deletions.
16 changes: 8 additions & 8 deletions cmd/akamai/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ var (
gitProtocolFlag string
gitopsTemplateURLFlag string
gitopsTemplateBranchFlag string
gitopsRepoName string
metaphorRepoName string
adminTeamName string
developerTeamName string
gitopsRepoName string
metaphorRepoName string
adminTeamName string
developerTeamName string
useTelemetryFlag bool
nodeTypeFlag string
nodeCountFlag string
Expand Down Expand Up @@ -102,10 +102,10 @@ func Create() *cobra.Command {
createCmd.Flags().StringVar(&gitlabGroupFlag, "gitlab-group", "", "the GitLab group for the new gitops and metaphor projects - required if using gitlab")
createCmd.Flags().StringVar(&gitopsTemplateBranchFlag, "gitops-template-branch", "", "the branch to clone for the gitops-template repository")
createCmd.Flags().StringVar(&gitopsTemplateURLFlag, "gitops-template-url", "https://github.com/kubefirst/gitops-template.git", "the fully qualified url to the gitops-template repository to clone")
createCmd.Flags().StringVar(&gitopsRepoName,"gitopsRepoName","gitops","the custom gitops name")
createCmd.Flags().StringVar(&metaphorRepoName,"metaphorRepoName","metaphor","the custom metpahor name")
createCmd.Flags().StringVar(&adminTeamName,"adminTeamName","admins","admin team name for this repo ")
createCmd.Flags().StringVar(&developerTeamName,"developerTeamName","developers"," developer team name for this repo")
createCmd.Flags().StringVar(&gitopsRepoName, "gitopsRepoName", "gitops", "the custom gitops name")
createCmd.Flags().StringVar(&metaphorRepoName, "metaphorRepoName", "metaphor", "the custom metpahor name")
createCmd.Flags().StringVar(&adminTeamName, "adminTeamName", "admins", "admin team name for this repo ")
createCmd.Flags().StringVar(&developerTeamName, "developerTeamName", "developers", " developer team name for this repo")
createCmd.Flags().StringVar(&installCatalogApps, "install-catalog-apps", "", "comma seperated values to install after provision")
createCmd.Flags().BoolVar(&useTelemetryFlag, "use-telemetry", true, "whether to emit telemetry")

Expand Down
16 changes: 8 additions & 8 deletions cmd/aws/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ var (
gitProtocolFlag string
gitopsTemplateURLFlag string
gitopsTemplateBranchFlag string
gitopsRepoName string
metaphorRepoName string
adminTeamName string
developerTeamName string
gitopsRepoName string
metaphorRepoName string
adminTeamName string
developerTeamName string
domainNameFlag string
subdomainNameFlag string
useTelemetryFlag bool
Expand Down Expand Up @@ -104,10 +104,10 @@ func Create() *cobra.Command {
createCmd.Flags().StringVar(&gitlabGroupFlag, "gitlab-group", "", "the GitLab group for the new gitops and metaphor projects - required if using gitlab")
createCmd.Flags().StringVar(&gitopsTemplateBranchFlag, "gitops-template-branch", "", "the branch to clone for the gitops-template repository")
createCmd.Flags().StringVar(&gitopsTemplateURLFlag, "gitops-template-url", "https://github.com/kubefirst/gitops-template.git", "the fully qualified url to the gitops-template repository to clone")
createCmd.Flags().StringVar(&gitopsRepoName,"gitopsRepoName","gitops","the custom gitops name")
createCmd.Flags().StringVar(&metaphorRepoName,"metaphorRepoName","metaphor","the custom metpahor name")
createCmd.Flags().StringVar(&adminTeamName,"adminTeamName","admins","admin team name for this repo ")
createCmd.Flags().StringVar(&developerTeamName,"developerTeamName","developers"," developer team name for this repo")
createCmd.Flags().StringVar(&gitopsRepoName, "gitopsRepoName", "gitops", "the custom gitops name")
createCmd.Flags().StringVar(&metaphorRepoName, "metaphorRepoName", "metaphor", "the custom metpahor name")
createCmd.Flags().StringVar(&adminTeamName, "adminTeamName", "admins", "admin team name for this repo ")
createCmd.Flags().StringVar(&developerTeamName, "developerTeamName", "developers", " developer team name for this repo")
createCmd.Flags().StringVar(&installCatalogApps, "install-catalog-apps", "", "comma seperated values to install after provision")
createCmd.Flags().BoolVar(&useTelemetryFlag, "use-telemetry", true, "whether to emit telemetry")
createCmd.Flags().BoolVar(&ecrFlag, "ecr", false, "whether or not to use ecr vs the git provider")
Expand Down
3 changes: 1 addition & 2 deletions cmd/civo/backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func backupCivoSSL(cmd *cobra.Command, args []string) error {
default:
log.Panic().Msgf("invalid git provider option")
}

gitopsRepoName, err := cmd.Flags().GetString("gitopRepoName")
if err != nil {
return err
Expand All @@ -46,7 +46,6 @@ func backupCivoSSL(cmd *cobra.Command, args []string) error {
return err
}


config := providerConfigs.GetConfig(
clusterName,
domainName,
Expand Down
16 changes: 8 additions & 8 deletions cmd/civo/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ var (
nodeCountFlag string
installCatalogApps string
installKubefirstProFlag bool
gitopsRepoName string
metaphorRepoName string
adminTeamName string
developerTeamName string
gitopsRepoName string
metaphorRepoName string
adminTeamName string
developerTeamName string

// RootCredentials
copyArgoCDPasswordToClipboardFlag bool
Expand Down Expand Up @@ -109,10 +109,10 @@ func Create() *cobra.Command {
createCmd.Flags().StringVar(&subdomainNameFlag, "subdomain", "", "the subdomain to use for DNS records (Cloudflare)")
createCmd.Flags().StringVar(&domainNameFlag, "domain-name", "", "the Civo DNS Name to use for DNS records (i.e. your-domain.com|subdomain.your-domain.com) (required)")
createCmd.MarkFlagRequired("domain-name")
createCmd.Flags().StringVar(&gitopsRepoName,"gitopsRepoName","gitops","the custom gitops name")
createCmd.Flags().StringVar(&metaphorRepoName,"metaphorRepoName","metaphor","the custom metaphor name")
createCmd.Flags().StringVar(&adminTeamName,"adminTeamName","admins","admin team name for this repo")
createCmd.Flags().StringVar(&developerTeamName,"developerTeamName","developers","developer team name for this repo")
createCmd.Flags().StringVar(&gitopsRepoName, "gitopsRepoName", "gitops", "the custom gitops name")
createCmd.Flags().StringVar(&metaphorRepoName, "metaphorRepoName", "metaphor", "the custom metaphor name")
createCmd.Flags().StringVar(&adminTeamName, "adminTeamName", "admins", "admin team name for this repo")
createCmd.Flags().StringVar(&developerTeamName, "developerTeamName", "developers", "developer team name for this repo")
createCmd.Flags().StringVar(&gitProviderFlag, "git-provider", "github", fmt.Sprintf("the git provider - one of: %s", supportedGitProviders))
createCmd.Flags().StringVar(&gitProtocolFlag, "git-protocol", "ssh", fmt.Sprintf("the git protocol - one of: %s", supportedGitProtocolOverride))
createCmd.Flags().StringVar(&githubOrgFlag, "github-org", "", "the GitHub organization for the new gitops and metaphor repositories - required if using github")
Expand Down
6 changes: 3 additions & 3 deletions cmd/civo/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ func createCivo(cmd *cobra.Command, args []string) error {
// Validate git
executionControl := viper.GetBool(fmt.Sprintf("kubefirst-checks.%s-credentials", cliFlags.GitProvider))
if !executionControl {
newRepositoryNames := []string{cliFlags.GitopsRepoName,cliFlags.MetaphorRepoName}
newTeamNames := []string{cliFlags.AdminTeamName,cliFlags.DeveloperTeamName}
newRepositoryNames := []string{cliFlags.GitopsRepoName, cliFlags.MetaphorRepoName}
newTeamNames := []string{cliFlags.AdminTeamName, cliFlags.DeveloperTeamName}

initGitParameters := gitShim.GitInitParameters{
GitProvider: cliFlags.GitProvider,
Expand All @@ -79,7 +79,7 @@ func createCivo(cmd *cobra.Command, args []string) error {

viper.Set(fmt.Sprintf("kubefirst-checks.%s-credentials", cliFlags.GitProvider), true)
viper.WriteConfig()

k3dClusterCreationComplete := viper.GetBool("launch.deployed")
isK1Debug := strings.ToLower(os.Getenv("K1_LOCAL_DEBUG")) == "true"

Expand Down
16 changes: 8 additions & 8 deletions cmd/digitalocean/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ var (
gitProtocolFlag string
gitopsTemplateURLFlag string
gitopsTemplateBranchFlag string
gitopsRepoName string
metaphorRepoName string
adminTeamName string
developerTeamName string
gitopsRepoName string
metaphorRepoName string
adminTeamName string
developerTeamName string
useTelemetryFlag bool
nodeTypeFlag string
nodeCountFlag string
Expand Down Expand Up @@ -108,10 +108,10 @@ func Create() *cobra.Command {
createCmd.Flags().StringVar(&gitlabGroupFlag, "gitlab-group", "", "the GitLab group for the new gitops and metaphor projects - required if using gitlab")
createCmd.Flags().StringVar(&gitopsTemplateBranchFlag, "gitops-template-branch", "", "the branch to clone for the gitops-template repository")
createCmd.Flags().StringVar(&gitopsTemplateURLFlag, "gitops-template-url", "https://github.com/kubefirst/gitops-template.git", "the fully qualified url to the gitops-template repository to clone")
createCmd.Flags().StringVar(&gitopsRepoName,"gitopsRepoName","gitops","the custom gitops name")
createCmd.Flags().StringVar(&metaphorRepoName,"metaphorRepoName","metaphor","the custom metpahor name")
createCmd.Flags().StringVar(&adminTeamName,"adminTeamName","admins","admin team name for this repo ")
createCmd.Flags().StringVar(&developerTeamName,"developerTeamName","developers"," developer team name for this repo")
createCmd.Flags().StringVar(&gitopsRepoName, "gitopsRepoName", "gitops", "the custom gitops name")
createCmd.Flags().StringVar(&metaphorRepoName, "metaphorRepoName", "metaphor", "the custom metpahor name")
createCmd.Flags().StringVar(&adminTeamName, "adminTeamName", "admins", "admin team name for this repo ")
createCmd.Flags().StringVar(&developerTeamName, "developerTeamName", "developers", " developer team name for this repo")
createCmd.Flags().StringVar(&installCatalogApps, "install-catalog-apps", "", "comma seperated values to install after provision")
createCmd.Flags().BoolVar(&useTelemetryFlag, "use-telemetry", true, "whether to emit telemetry")
createCmd.Flags().BoolVar(&installKubefirstProFlag, "install-kubefirst-pro", true, "whether or not to install kubefirst pro")
Expand Down
16 changes: 8 additions & 8 deletions cmd/google/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ var (
gitProtocolFlag string
gitopsTemplateURLFlag string
gitopsTemplateBranchFlag string
gitopsRepoName string
metaphorRepoName string
adminTeamName string
developerTeamName string
gitopsRepoName string
metaphorRepoName string
adminTeamName string
developerTeamName string
useTelemetryFlag bool
forceDestroyFlag bool
nodeTypeFlag string
Expand Down Expand Up @@ -112,10 +112,10 @@ func Create() *cobra.Command {
createCmd.Flags().StringVar(&gitlabGroupFlag, "gitlab-group", "", "the GitLab group for the new gitops and metaphor projects - required if using gitlab")
createCmd.Flags().StringVar(&gitopsTemplateBranchFlag, "gitops-template-branch", "", "the branch to clone for the gitops-template repository")
createCmd.Flags().StringVar(&gitopsTemplateURLFlag, "gitops-template-url", "https://github.com/kubefirst/gitops-template.git", "the fully qualified url to the gitops-template repository to clone")
createCmd.Flags().StringVar(&gitopsRepoName,"gitopsRepoName","gitops","the custom gitops name")
createCmd.Flags().StringVar(&metaphorRepoName,"metaphorRepoName","metaphor","the custom metpahor name")
createCmd.Flags().StringVar(&adminTeamName,"adminTeamName","admins","admin team name for this repo ")
createCmd.Flags().StringVar(&developerTeamName,"developerTeamName","developers"," developer team name for this repo")
createCmd.Flags().StringVar(&gitopsRepoName, "gitopsRepoName", "gitops", "the custom gitops name")
createCmd.Flags().StringVar(&metaphorRepoName, "metaphorRepoName", "metaphor", "the custom metpahor name")
createCmd.Flags().StringVar(&adminTeamName, "adminTeamName", "admins", "admin team name for this repo ")
createCmd.Flags().StringVar(&developerTeamName, "developerTeamName", "developers", " developer team name for this repo")
createCmd.Flags().StringVar(&installCatalogApps, "install-catalog-apps", "", "comma seperated values to install after provision")
createCmd.Flags().BoolVar(&useTelemetryFlag, "use-telemetry", true, "whether to emit telemetry")
createCmd.Flags().BoolVar(&forceDestroyFlag, "force-destroy", false, "allows force destruction on objects (helpful for test environments, defaults to false)")
Expand Down
12 changes: 6 additions & 6 deletions cmd/k3d/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ var (
gitopsTemplateBranchFlag string
useTelemetryFlag bool
installCatalogApps string
gitopsRepoName string
metaphorRepoName string
gitopsRepoName string
metaphorRepoName string
adminTeamName string
developerTeamName string

Expand Down Expand Up @@ -102,10 +102,10 @@ func Create() *cobra.Command {
createCmd.Flags().StringVar(&gitopsTemplateURLFlag, "gitops-template-url", "https://github.com/kubefirst/gitops-template.git", "the fully qualified url to the gitops-template repository to clone")
createCmd.Flags().StringVar(&installCatalogApps, "install-catalog-apps", "", "comma seperated values of catalog apps to install after provision")
createCmd.Flags().BoolVar(&useTelemetryFlag, "use-telemetry", true, "whether to emit telemetry")
createCmd.Flags().StringVar(&gitopsRepoName,"gitopsRepoName","gitops","the custom gitops name")
createCmd.Flags().StringVar(&metaphorRepoName,"metaphorRepoName","metaphor","the custom metaphor name")
createCmd.Flags().StringVar(&adminTeamName,"adminTeamName","admins","admin team name for this repo")
createCmd.Flags().StringVar(&developerTeamName,"developerTeamName","developers","developer team name for this repo")
createCmd.Flags().StringVar(&gitopsRepoName, "gitopsRepoName", "gitops", "the custom gitops name")
createCmd.Flags().StringVar(&metaphorRepoName, "metaphorRepoName", "metaphor", "the custom metaphor name")
createCmd.Flags().StringVar(&adminTeamName, "adminTeamName", "admins", "admin team name for this repo")
createCmd.Flags().StringVar(&developerTeamName, "developerTeamName", "developers", "developer team name for this repo")

return createCmd
}
Expand Down
31 changes: 12 additions & 19 deletions cmd/k3d/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
"fmt"
"net/http"
"os"
"os/exec"
"strconv"
"strings"
"time"
Expand Down Expand Up @@ -344,7 +343,7 @@ func runK3d(cmd *cobra.Command, args []string) error {
//}

// Instantiate K3d config
config := k3d.GetConfig(clusterNameFlag, gitProviderFlag, cGitOwner, gitProtocolFlag, gitopsRepoName,metaphorRepoName,adminTeamName,developerTeamName)
config := k3d.GetConfig(clusterNameFlag, gitProviderFlag, cGitOwner, gitProtocolFlag, gitopsRepoName, metaphorRepoName, adminTeamName, developerTeamName)
switch gitProviderFlag {
case "github":
config.GithubToken = cGitToken
Expand Down Expand Up @@ -396,7 +395,7 @@ func runK3d(cmd *cobra.Command, args []string) error {
log.Info().Msgf("kubefirst version configs.K1Version: %s ", configs.K1Version)
log.Info().Msgf("cloning gitops-template repo url: %s ", gitopsTemplateURLFlag)
log.Info().Msgf("cloning gitops-template repo branch: %s ", gitopsTemplateBranchFlag)
log.Info().Msgf("branch %s\b",gitopsTemplateBranchFlag)
log.Info().Msgf("branch %s\b", gitopsTemplateBranchFlag)
atlantisWebhookSecret := viper.GetString("secrets.atlantis-webhook")
if atlantisWebhookSecret == "" {
atlantisWebhookSecret = utils.Random(20)
Expand Down Expand Up @@ -556,7 +555,7 @@ func runK3d(cmd *cobra.Command, args []string) error {
if !viper.GetBool("kubefirst-checks.tools-downloaded") {
log.Info().Msg("installing kubefirst dependencies")

err := k3d.DownloadTools(clusterNameFlag, config.GitProvider, cGitOwner, config.ToolsDir, config.GitProtocol,config.GitopsRepoName,config.MetaphorRepoName,config.AdminTeamName,config.DeveloperTeamName)
err := k3d.DownloadTools(clusterNameFlag, config.GitProvider, cGitOwner, config.ToolsDir, config.GitProtocol, config.GitopsRepoName, config.MetaphorRepoName, config.AdminTeamName, config.DeveloperTeamName)
if err != nil {
return err
}
Expand All @@ -572,7 +571,7 @@ func runK3d(cmd *cobra.Command, args []string) error {
metaphorTemplateTokens := k3d.MetaphorTokenValues{
ClusterName: clusterNameFlag,
CloudRegion: cloudRegionFlag,
ContainerRegistryURL: fmt.Sprintf("%s/%s/%s", containerRegistryHost, cGitOwner,config.MetaphorRepoName),
ContainerRegistryURL: fmt.Sprintf("%s/%s/%s", containerRegistryHost, cGitOwner, config.MetaphorRepoName),
DomainName: k3d.DomainName,
MetaphorDevelopmentIngressURL: fmt.Sprintf("metaphor-development.%s", k3d.DomainName),
MetaphorStagingIngressURL: fmt.Sprintf("metaphor-staging.%s", k3d.DomainName),
Expand Down Expand Up @@ -614,8 +613,8 @@ func runK3d(cmd *cobra.Command, args []string) error {
if err != nil {
return err
}
viper.Set("adminTeamName",config.AdminTeamName)
viper.Set("developerTeamName",config.DeveloperTeamName)
viper.Set("adminTeamName", config.AdminTeamName)
viper.Set("developerTeamName", config.DeveloperTeamName)

// todo emit init telemetry end
viper.Set("kubefirst-checks.gitops-ready-to-push", true)
Expand Down Expand Up @@ -1070,16 +1069,10 @@ func runK3d(cmd *cobra.Command, args []string) error {
log.Info().Msg("applying the registry application to argocd")
registryApplicationObject := argocd.GetArgoCDApplicationObject(gitopsRepoURL, fmt.Sprintf("registry/%s", clusterNameFlag))

cmdStr := fmt.Sprintf("kubectl --kubeconfig=%s rollout restart -n argocd deploy/argocd-applicationset-controller", config.Kubeconfig)

cmd := exec.Command("/bin/sh", "-c", cmdStr)

err = cmd.Run()
err = k3d.Restart(config.Kubeconfig)
if err != nil {
log.Info().Msgf("Error executing kubectl command: %v\n", err)
return err
return fmt.Errorf("Error in Restarting argocd controller %w", err)
}

retryAttempts := 2
for attempt := 1; attempt <= retryAttempts; attempt++ {
log.Info().Msgf("Attempt #%d to create Argo CD application...\n", attempt)
Expand All @@ -1091,11 +1084,11 @@ func runK3d(cmd *cobra.Command, args []string) error {
}
log.Info().Msgf("Error creating Argo CD application on attempt number #%d: %v\n", attempt, err)
time.Sleep(5 * time.Second)
continue
continue
}

log.Info().Msgf("Argo CD application created successfully on attempt #%d: %s\n", attempt, app.Name)
break
break
}

viper.Set("kubefirst-checks.argocd-create-registry", true)
Expand Down Expand Up @@ -1203,7 +1196,7 @@ func runK3d(cmd *cobra.Command, args []string) error {

//define upload object
objectName := fmt.Sprintf("terraform/%s/terraform.tfstate", config.GitProvider)
filePath := config.K1Dir + fmt.Sprintf("/%s/%s", objectName,config.GitopsRepoName)
filePath := config.K1Dir + fmt.Sprintf("/%s/%s", objectName, config.GitopsRepoName)
contentType := "xl.meta"
bucketName := "kubefirst-state-store"
log.Info().Msgf("BucketName: %s", bucketName)
Expand Down Expand Up @@ -1472,4 +1465,4 @@ func runK3d(cmd *cobra.Command, args []string) error {
}

return nil
}
}
Loading

0 comments on commit e5cac33

Please sign in to comment.