Skip to content

Commit

Permalink
Merge pull request #2278 from konstructio/unused-functions
Browse files Browse the repository at this point in the history
Remove unused functions. Bump to Go 1.23. Run `gofmt` on all files.
  • Loading branch information
patrickdappollonio authored Sep 4, 2024
2 parents 1b996b7 + 62428a1 commit fd8ebb7
Show file tree
Hide file tree
Showing 14 changed files with 51 additions and 132 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/releaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ jobs:
fetch-depth: 0
-
name: Set up Go
uses: actions/setup-go@v3
uses: actions/setup-go@v5
with:
go-version: '>=1.18.0'
go-version-file: go.mod

-
name: Run GoReleaser
uses: goreleaser/goreleaser-action@v3
Expand All @@ -40,4 +40,4 @@ jobs:
version: latest
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
25 changes: 13 additions & 12 deletions cmd/akamai/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,20 @@ func createAkamai(cmd *cobra.Command, args []string) error {
cliFlags, err := utilities.GetFlags(cmd, "akamai")
if err != nil {
progress.Error(err.Error())
return nil
return fmt.Errorf("failed to get flags: %w", err)
}

progress.DisplayLogHints(25)

isValid, catalogApps, err := catalog.ValidateCatalogApps(cliFlags.InstallCatalogApps)
if !isValid {
return err
return fmt.Errorf("catalog validation failed: %w", err)
}

err = ValidateProvidedFlags(cliFlags.GitProvider)
if err != nil {
progress.Error(err.Error())
return nil
return fmt.Errorf("failed to validate provided flags: %w", err)
}

// If cluster setup is complete, return
Expand All @@ -52,7 +52,7 @@ func createAkamai(cmd *cobra.Command, args []string) error {
gitAuth, err := gitShim.ValidateGitCredentials(cliFlags.GitProvider, cliFlags.GithubOrg, cliFlags.GitlabGroup)
if err != nil {
progress.Error(err.Error())
return nil
return fmt.Errorf("failed to validate git credentials: %w", err)
}

// Validate git
Expand All @@ -72,11 +72,13 @@ func createAkamai(cmd *cobra.Command, args []string) error {
err = gitShim.InitializeGitProvider(&initGitParameters)
if err != nil {
progress.Error(err.Error())
return nil
return fmt.Errorf("failed to initialize git provider: %w", err)
}
}
viper.Set(fmt.Sprintf("kubefirst-checks.%s-credentials", cliFlags.GitProvider), true)
viper.WriteConfig()
if err := viper.WriteConfig(); err != nil {
return fmt.Errorf("failed to write viper config: %w", err)
}

k3dClusterCreationComplete := viper.GetBool("launch.deployed")
isK1Debug := strings.ToLower(os.Getenv("K1_LOCAL_DEBUG")) == "true"
Expand All @@ -88,18 +90,17 @@ func createAkamai(cmd *cobra.Command, args []string) error {
err = pkg.IsAppAvailable(fmt.Sprintf("%s/api/proxyHealth", cluster.GetConsoleIngresUrl()), "kubefirst api")
if err != nil {
progress.Error("unable to start kubefirst api")
return fmt.Errorf("failed to check kubefirst api availability: %w", err)
}

provision.CreateMgmtCluster(gitAuth, cliFlags, catalogApps)

return nil
}

func ValidateProvidedFlags(gitProvider string) error {
progress.AddStep("Validate provided flags")

if os.Getenv("LINODE_TOKEN") == "" {
// telemetryShim.Transmit(useTelemetryFlag, segmentClient, segment.MetricCloudCredentialsCheckFailed, "LINODE_TOKEN environment variable was not set")
return fmt.Errorf("your LINODE_TOKEN is not set - please set and re-run your last command")
}

Expand All @@ -114,16 +115,16 @@ func ValidateProvidedFlags(gitProvider string) error {
case "github":
key, err := internalssh.GetHostKey("github.com")
if err != nil {
return fmt.Errorf("known_hosts file does not exist - please run `ssh-keyscan github.com >> ~/.ssh/known_hosts` to remedy")
return fmt.Errorf("known_hosts file does not exist - please run `ssh-keyscan github.com >> ~/.ssh/known_hosts` to remedy: %w", err)
} else {
log.Info().Msgf("%s %s\n", "github.com", key.Type())
log.Info().Msgf("%q %s", "github.com", key.Type())
}
case "gitlab":
key, err := internalssh.GetHostKey("gitlab.com")
if err != nil {
return fmt.Errorf("known_hosts file does not exist - please run `ssh-keyscan gitlab.com >> ~/.ssh/known_hosts` to remedy")
return fmt.Errorf("known_hosts file does not exist - please run `ssh-keyscan gitlab.com >> ~/.ssh/known_hosts` to remedy: %w", err)
} else {
log.Info().Msgf("%s %s\n", "gitlab.com", key.Type())
log.Info().Msgf("%q %s", "gitlab.com", key.Type())
}
}

Expand Down
1 change: 0 additions & 1 deletion cmd/civo/quota.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ func returnCivoQuotaEvaluation(cloudRegion string) (string, int, int, error) {
if err != nil {
log.Info().Msgf("failed to fetch civo quota: %s", err)
return "", 0, 0, err

}

// Container for quota response as a map
Expand Down
29 changes: 14 additions & 15 deletions cmd/k3d/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ func runK3d(cmd *cobra.Command, args []string) error {

// todo
// Since it's possible to stop and restart, cGitOwner may need to be reset
//if cGitOwner == "" {
// if cGitOwner == "" {
// switch gitProviderFlag {
// case "github":
// cGitOwner = viper.GetString("flags.github-owner")
Expand All @@ -312,7 +312,7 @@ func runK3d(cmd *cobra.Command, args []string) error {
// }
//}
//
//model, err := presentRecap(gitProviderFlag, gitDestDescriptor, cGitOwner)
// model, err := presentRecap(gitProviderFlag, gitDestDescriptor, cGitOwner)
//if err != nil {
// return err
//}
Expand Down Expand Up @@ -520,7 +520,7 @@ func runK3d(cmd *cobra.Command, args []string) error {
gitopsDirectoryTokens.UseTelemetry = "false"
}

//* generate http credentials for git auth over https
// * generate http credentials for git auth over https
httpAuth := &githttps.BasicAuth{
Username: cGitUser,
Password: cGitToken,
Expand All @@ -530,7 +530,7 @@ func runK3d(cmd *cobra.Command, args []string) error {
log.Info().Msgf("generate public keys failed: %s\n", err.Error())
}

//* download dependencies to `$HOME/.k1/tools`
// * download dependencies to `$HOME/.k1/tools`
if !viper.GetBool("kubefirst-checks.tools-downloaded") {
log.Info().Msg("installing kubefirst dependencies")

Expand All @@ -557,7 +557,7 @@ func runK3d(cmd *cobra.Command, args []string) error {
MetaphorProductionIngressURL: fmt.Sprintf("metaphor-production.%s", k3d.DomainName),
}

//* git clone and detokenize the gitops repository
// * git clone and detokenize the gitops repository
// todo improve this logic for removing `kubefirst clean`
// if !viper.GetBool("template-repo.gitops.cloned") || viper.GetBool("template-repo.gitops.removed") {
progressPrinter.IncrementTracker("preflight-checks", 1)
Expand Down Expand Up @@ -683,7 +683,7 @@ func runK3d(cmd *cobra.Command, args []string) error {
}
}

//* push detokenized gitops-template repository content to new remote
// * push detokenized gitops-template repository content to new remote
progressPrinter.AddTracker("pushing-gitops-repos-upstream", "Pushing git repositories", 1)
progressPrinter.SetupProgress(progressPrinter.TotalOfTrackers(), false)

Expand Down Expand Up @@ -756,7 +756,7 @@ func runK3d(cmd *cobra.Command, args []string) error {
progressPrinter.IncrementTracker("pushing-gitops-repos-upstream", 1)
}

//* create k3d resources
// * create k3d resources

progressPrinter.AddTracker("creating-k3d-cluster", "Creating k3d cluster", 1)
progressPrinter.SetupProgress(progressPrinter.TotalOfTrackers(), false)
Expand Down Expand Up @@ -905,7 +905,7 @@ func runK3d(cmd *cobra.Command, args []string) error {
progressPrinter.SetupProgress(progressPrinter.TotalOfTrackers(), false)

argoCDInstallPath := fmt.Sprintf("github.com:konstructio/manifests/argocd/k3d?ref=%s", constants.KubefirstManifestRepoRef)
//* install argo
// * install argo
executionControl = viper.GetBool("kubefirst-checks.argocd-install")
if !executionControl {
telemetry.SendEvent(segClient, telemetry.ArgoCDInstallStarted, "")
Expand Down Expand Up @@ -944,7 +944,7 @@ func runK3d(cmd *cobra.Command, args []string) error {
}

var argocdPassword string
//* argocd pods are ready, get and set credentials
// * argocd pods are ready, get and set credentials
executionControl = viper.GetBool("kubefirst-checks.argocd-credentials-set")
if !executionControl {
log.Info().Msg("Setting argocd username and password credentials")
Expand Down Expand Up @@ -1024,7 +1024,7 @@ func runK3d(cmd *cobra.Command, args []string) error {
}
}

//* argocd sync registry and start sync waves
// * argocd sync registry and start sync waves
executionControl = viper.GetBool("kubefirst-checks.argocd-create-registry")
if !executionControl {
telemetry.SendEvent(segClient, telemetry.CreateRegistryStarted, "")
Expand Down Expand Up @@ -1186,8 +1186,8 @@ func runK3d(cmd *cobra.Command, args []string) error {

progressPrinter.IncrementTracker("configuring-vault", 1)

//* configure vault with terraform
//* vault port-forward
// * configure vault with terraform
// * vault port-forward
vaultStopChannel := make(chan struct{}, 1)
defer func() {
close(vaultStopChannel)
Expand Down Expand Up @@ -1227,7 +1227,7 @@ func runK3d(cmd *cobra.Command, args []string) error {
)
}

//* configure vault with terraform
// * configure vault with terraform
executionControl = viper.GetBool("kubefirst-checks.terraform-apply-vault")
if !executionControl {
telemetry.SendEvent(segClient, telemetry.VaultTerraformApplyStarted, "")
Expand All @@ -1244,7 +1244,6 @@ func runK3d(cmd *cobra.Command, args []string) error {
} else {
usernamePasswordString = fmt.Sprintf("%s:%s", cGitUser, cGitToken)
base64DockerAuth = base64.StdEncoding.EncodeToString([]byte(usernamePasswordString))

}

log.Info().Msg("configuring vault with terraform")
Expand Down Expand Up @@ -1286,7 +1285,7 @@ func runK3d(cmd *cobra.Command, args []string) error {
progressPrinter.IncrementTracker("configuring-vault", 1)
}

//* create users
// * create users
progressPrinter.AddTracker("creating-users", "Creating users", 1)
progressPrinter.SetupProgress(progressPrinter.TotalOfTrackers(), false)

Expand Down
2 changes: 1 addition & 1 deletion cmd/k3d/destroy.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ func destroyK3d(cmd *cobra.Command, args []string) error {
}
}

//* remove local content and kubefirst config file for re-execution
// * remove local content and kubefirst config file for re-execution
if !viper.GetBool(fmt.Sprintf("kubefirst-checks.terraform-apply-%s", gitProvider)) && !viper.GetBool("kubefirst-checks.create-k3d-cluster") {
log.Info().Msg("removing previous platform content")

Expand Down
6 changes: 1 addition & 5 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/konstructio/kubefirst

go 1.18
go 1.23

require (
github.com/argoproj/argo-cd/v2 v2.6.7
Expand Down Expand Up @@ -86,9 +86,6 @@ require (
github.com/digitalocean/godo v1.98.0 // indirect
github.com/dlclark/regexp2 v1.4.0 // indirect
github.com/docker/distribution v2.8.2+incompatible // indirect
github.com/docker/docker v23.0.5+incompatible // indirect
github.com/docker/go-connections v0.4.0 // indirect
github.com/docker/go-units v0.5.0 // indirect
github.com/emicklei/go-restful/v3 v3.10.1 // indirect
github.com/evanphx/json-patch v5.6.0+incompatible // indirect
github.com/exponent-io/jsonpath v0.0.0-20151013193312-d6023ce2651d // indirect
Expand Down Expand Up @@ -144,7 +141,6 @@ require (
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/olekukonko/tablewriter v0.0.5 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/image-spec v1.1.0-rc2.0.20221005185240-3a7f492d3f1b // indirect
github.com/otiai10/copy v1.7.0 // indirect
github.com/patrickmn/go-cache v2.1.0+incompatible // indirect
github.com/peterbourgon/diskv v2.0.1+incompatible // indirect
Expand Down
Loading

0 comments on commit fd8ebb7

Please sign in to comment.