Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply gofmt, golangci-lint. #2253

Merged
merged 1 commit into from
Jul 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmd/akamai/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ 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(&installCatalogApps, "install-catalog-apps", "", "comma seperated values to install after provision")
createCmd.Flags().StringVar(&installCatalogApps, "install-catalog-apps", "", "comma separated values to install after provision")
createCmd.Flags().BoolVar(&useTelemetryFlag, "use-telemetry", true, "whether to emit telemetry")

return createCmd
Expand Down
1 change: 0 additions & 1 deletion cmd/akamai/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ func createAkamai(cmd *cobra.Command, args []string) error {
utilities.CreateK1ClusterDirectory(clusterNameFlag)

gitAuth, err := gitShim.ValidateGitCredentials(cliFlags.GitProvider, cliFlags.GithubOrg, cliFlags.GitlabGroup)

if err != nil {
progress.Error(err.Error())
return nil
Expand Down
8 changes: 1 addition & 7 deletions cmd/aws/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,6 @@ var (
installCatalogApps string
installKubefirstProFlag bool

// RootCredentials
copyArgoCDPasswordToClipboardFlag bool
copyKbotPasswordToClipboardFlag bool
copyVaultPasswordToClipboardFlag bool

patrickdappollonio marked this conversation as resolved.
Show resolved Hide resolved
// Supported argument arrays
supportedDNSProviders = []string{"aws", "cloudflare"}
supportedGitProviders = []string{"github", "gitlab"}
Expand Down Expand Up @@ -100,7 +95,7 @@ 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(&installCatalogApps, "install-catalog-apps", "", "comma seperated values to install after provision")
createCmd.Flags().StringVar(&installCatalogApps, "install-catalog-apps", "", "comma separated 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")
createCmd.Flags().BoolVar(&installKubefirstProFlag, "install-kubefirst-pro", true, "whether or not to install kubefirst pro")
Expand All @@ -118,7 +113,6 @@ func Destroy() *cobra.Command {
}

return destroyCmd

}

func Quota() *cobra.Command {
Expand Down
2 changes: 0 additions & 2 deletions cmd/aws/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ func createAws(cmd *cobra.Command, args []string) error {
Config: awsinternal.NewAwsV2(cloudRegionFlag),
}
creds, err := awsClient.Config.Credentials.Retrieve(aws.BackgroundContext())

if err != nil {
progress.Error(err.Error())
return nil
Expand All @@ -80,7 +79,6 @@ func createAws(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
Expand Down
3 changes: 1 addition & 2 deletions cmd/aws/quota.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ func printAwsQuotaWarning(messageHeader string, output map[string][]awsinternal.

// Write to logs, but also output to stdout
return createAwsQuotaWarning.String()

}

// evalAwsQuota provides an interface to the command-line
Expand All @@ -53,7 +52,7 @@ func evalAwsQuota(cmd *cobra.Command, args []string) error {
return err
}

var messageHeader = fmt.Sprintf(
messageHeader := fmt.Sprintf(
"AWS Quota Health\nRegion: %s\n\nIf you encounter issues deploying your kubefirst cluster, check these quotas and determine if you need to request a limit increase.",
cloudRegionFlag,
)
Expand Down
2 changes: 1 addition & 1 deletion cmd/civo/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ 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(&installCatalogApps, "install-catalog-apps", "", "comma seperated values to install after provision")
createCmd.Flags().StringVar(&installCatalogApps, "install-catalog-apps", "", "comma separated 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
1 change: 0 additions & 1 deletion cmd/civo/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ func createCivo(cmd *cobra.Command, args []string) error {
utilities.CreateK1ClusterDirectory(clusterNameFlag)

gitAuth, err := gitShim.ValidateGitCredentials(cliFlags.GitProvider, cliFlags.GithubOrg, cliFlags.GitlabGroup)

if err != nil {
progress.Error(err.Error())
return nil
Expand Down
3 changes: 1 addition & 2 deletions cmd/civo/quota.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ func returnCivoQuotaEvaluation(cloudRegion string) (string, int, int, error) {
}

// Parse the entire message
var messageHeader = fmt.Sprintf("Civo Quota Health\nRegion: %s\n\nNote that if any of these are approaching their limits, you may want to increase them.", cloudRegion)
messageHeader := fmt.Sprintf("Civo Quota Health\nRegion: %s\n\nNote that if any of these are approaching their limits, you may want to increase them.", cloudRegion)
sort.Strings(output)
result := printCivoQuotaWarning(messageHeader, output)

Expand Down Expand Up @@ -164,7 +164,6 @@ func printCivoQuotaWarning(messageHeader string, output []string) string {

// Write to logs, but also output to stdout
return createCivoQuotaWarning.String()

}

// evalCivoQuota provides an interface to the command-line
Expand Down
2 changes: 1 addition & 1 deletion cmd/digitalocean/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ 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(&installCatalogApps, "install-catalog-apps", "", "comma seperated values to install after provision")
createCmd.Flags().StringVar(&installCatalogApps, "install-catalog-apps", "", "comma separated 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
1 change: 0 additions & 1 deletion cmd/digitalocean/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ func createDigitalocean(cmd *cobra.Command, args []string) error {
utilities.CreateK1ClusterDirectory(clusterNameFlag)

gitAuth, err := gitShim.ValidateGitCredentials(cliFlags.GitProvider, cliFlags.GithubOrg, cliFlags.GitlabGroup)

if err != nil {
progress.Error(err.Error())
return nil
Expand Down
2 changes: 1 addition & 1 deletion cmd/google/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ 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(&installCatalogApps, "install-catalog-apps", "", "comma seperated values to install after provision")
createCmd.Flags().StringVar(&installCatalogApps, "install-catalog-apps", "", "comma separated 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)")
createCmd.Flags().BoolVar(&installKubefirstProFlag, "install-kubefirst-pro", true, "whether or not to install kubefirst pro")
Expand Down
1 change: 0 additions & 1 deletion cmd/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ var infoCmd = &cobra.Command{
Short: "provides general Kubefirst setup data",
Long: `Provides machine data, files and folders paths`,
Run: func(cmd *cobra.Command, args []string) {

config := configs.ReadConfig()

content := `
Expand Down
2 changes: 1 addition & 1 deletion cmd/k3d/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ 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(&installCatalogApps, "install-catalog-apps", "", "comma seperated values of catalog apps to install after provision")
createCmd.Flags().StringVar(&installCatalogApps, "install-catalog-apps", "", "comma separated values of catalog apps to install after provision")
createCmd.Flags().BoolVar(&useTelemetryFlag, "use-telemetry", true, "whether to emit telemetry")

return createCmd
Expand Down
31 changes: 14 additions & 17 deletions cmd/k3d/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ package k3d
import (
"context"
"encoding/base64"
"errors"
"fmt"
"net/http"
"os"
Expand Down Expand Up @@ -54,10 +55,6 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

var (
cancelContext context.CancelFunc
patrickdappollonio marked this conversation as resolved.
Show resolved Hide resolved
)

func runK3d(cmd *cobra.Command, args []string) error {
ciFlag, err := cmd.Flags().GetBool("ci")
if err != nil {
Expand Down Expand Up @@ -137,22 +134,22 @@ func runK3d(cmd *cobra.Command, args []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 errors.New("known_hosts file does not exist - please run `ssh-keyscan github.com >> ~/.ssh/known_hosts` to remedy")
patrickdappollonio marked this conversation as resolved.
Show resolved Hide resolved
} else {
log.Info().Msgf("%s %s\n", "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 errors.New("known_hosts file does not exist - please run `ssh-keyscan gitlab.com >> ~/.ssh/known_hosts` to remedy")
} else {
log.Info().Msgf("%s %s\n", "gitlab.com", key.Type())
}
}

// Either user or org can be specified for github, not both
if githubOrgFlag != "" && githubUserFlag != "" {
return fmt.Errorf("only one of --github-user or --github-org can be supplied")
return errors.New("only one of --github-user or --github-org can be supplied")
}

// Check for existing port forwards before continuing
Expand All @@ -171,8 +168,8 @@ func runK3d(cmd *cobra.Command, args []string) error {
// }

// Global context
var ctx context.Context
ctx, cancelContext = context.WithCancel(context.Background())
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
patrickdappollonio marked this conversation as resolved.
Show resolved Hide resolved

// Clients
httpClient := http.DefaultClient
Expand Down Expand Up @@ -357,7 +354,7 @@ func runK3d(cmd *cobra.Command, args []string) error {
}
default:
switch gitopsTemplateURLFlag {
case "https://github.com/kubefirst/gitops-template.git": //default value
case "https://github.com/kubefirst/gitops-template.git": // default value
if gitopsTemplateBranchFlag == "" {
gitopsTemplateBranchFlag = configs.K1Version
}
Expand All @@ -366,7 +363,7 @@ func runK3d(cmd *cobra.Command, args []string) error {
gitopsTemplateBranchFlag = configs.K1Version
}
default: // not equal to our defaults
if gitopsTemplateBranchFlag == "" { //didn't supply the branch flag but they did supply the repo flag
if gitopsTemplateBranchFlag == "" { // didn't supply the branch flag but they did supply the repo flag
return fmt.Errorf("must supply gitops-template-branch flag when gitops-template-url is overridden")
}
}
Expand Down Expand Up @@ -575,11 +572,11 @@ func runK3d(cmd *cobra.Command, args []string) error {
config.GitProvider,
clusterNameFlag,
clusterTypeFlag,
config.DestinationGitopsRepoURL, //default to https for git interactions when creating remotes
config.DestinationGitopsRepoURL, // default to https for git interactions when creating remotes
config.GitopsDir,
gitopsTemplateBranchFlag,
gitopsTemplateURLFlag,
config.DestinationMetaphorRepoURL, //default to https for git interactions when creating remotes
config.DestinationMetaphorRepoURL, // default to https for git interactions when creating remotes
config.K1Dir,
&gitopsDirectoryTokens,
config.MetaphorDir,
Expand Down Expand Up @@ -714,7 +711,7 @@ func runK3d(cmd *cobra.Command, args []string) error {
return err
}

//Push to remotes and use https
// Push to remotes and use https
// Push gitops repo to remote
err = gitopsRepo.Push(
&git.PushOptions{
Expand Down Expand Up @@ -1142,7 +1139,7 @@ func runK3d(cmd *cobra.Command, args []string) error {
log.Info().Msgf("Error creating Minio client: %s", err)
}

//define upload object
// define upload object
objectName := fmt.Sprintf("terraform/%s/terraform.tfstate", config.GitProvider)
filePath := config.K1Dir + fmt.Sprintf("/gitops/%s", objectName)
contentType := "xl.meta"
Expand Down Expand Up @@ -1301,7 +1298,7 @@ func runK3d(cmd *cobra.Command, args []string) error {
progressPrinter.IncrementTracker("creating-users", 1)
}

//PostRun string replacement
// PostRun string replacement
progressPrinter.AddTracker("wrapping-up", "Wrapping up", 2)
progressPrinter.SetupProgress(progressPrinter.TotalOfTrackers(), false)

Expand All @@ -1316,7 +1313,7 @@ func runK3d(cmd *cobra.Command, args []string) error {
if err != nil {
log.Info().Msgf("error opening repo at: %s", config.GitopsDir)
}
//check if file exists before rename
// check if file exists before rename
_, err = os.Stat(fmt.Sprintf("%s/terraform/%s/remote-backend.md", config.GitopsDir, config.GitProvider))
if err == nil {
err = os.Rename(fmt.Sprintf("%s/terraform/%s/remote-backend.md", config.GitopsDir, config.GitProvider), fmt.Sprintf("%s/terraform/%s/remote-backend.tf", config.GitopsDir, config.GitProvider))
Expand Down
4 changes: 2 additions & 2 deletions cmd/k3d/destroy.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ func destroyK3d(cmd *cobra.Command, args []string) error {

// Before removing Terraform resources, remove any container registry repositories
// since failing to remove them beforehand will result in an apply failure
var projectsForDeletion = []string{"gitops", "metaphor"}
projectsForDeletion := []string{"gitops", "metaphor"}
for _, project := range projectsForDeletion {
projectExists, err := gitlabClient.CheckProjectExists(project)
if err != nil {
Expand Down Expand Up @@ -250,7 +250,7 @@ func destroyK3d(cmd *cobra.Command, args []string) error {
if _, err := os.Stat(config.K1Dir + "/kubeconfig"); !os.IsNotExist(err) {
err = os.Remove(config.K1Dir + "/kubeconfig")
if err != nil {
return fmt.Errorf("unable to delete %q folder, error: %s", config.K1Dir+"/kubeconfig", err)
return fmt.Errorf("unable to delete %q folder, error: %w", config.K1Dir+"/kubeconfig", err)
}
}
time.Sleep(time.Millisecond * 200) // allows progress bars to finish
Expand Down
2 changes: 1 addition & 1 deletion cmd/k3d/mkcert.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func mkCert(cmd *cobra.Command, args []string) error {

err = k3d.GenerateSingleTLSSecret(kcfg.Clientset, *config, appNameFlag, appNamespaceFlag)
if err != nil {
return fmt.Errorf("error generating certificate for %s/%s: %s", appNameFlag, appNamespaceFlag, err)
return fmt.Errorf("error generating certificate for %s/%s: %w", appNameFlag, appNamespaceFlag, err)
patrickdappollonio marked this conversation as resolved.
Show resolved Hide resolved
}

log.Infof("Certificate generated. You can use it with an app by setting `tls.secretName: %s-tls` on a Traefik IngressRoute.", appNameFlag)
Expand Down
4 changes: 2 additions & 2 deletions cmd/k3d/vault.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func unsealVault(cmd *cobra.Command, args []string) error {
}
}
if i == 5 {
return fmt.Errorf("error passing unseal shard %v to %s: %s", i+1, node, err)
return fmt.Errorf("error passing unseal shard %v to %s: %w", i+1, node, err)
}
}
// Wait for key acceptance
Expand All @@ -99,7 +99,7 @@ func unsealVault(cmd *cobra.Command, args []string) error {
}
if sealStatus.Progress > sealStatusTracking || !sealStatus.Sealed {
log.Info().Msgf("shard accepted")
sealStatusTracking += 1
sealStatusTracking++
break
}
log.Info().Msgf("waiting for node %s to accept unseal shard", node)
Expand Down
2 changes: 1 addition & 1 deletion cmd/k3s/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ 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(&installCatalogApps, "install-catalog-apps", "", "comma seperated values to install after provision")
createCmd.Flags().StringVar(&installCatalogApps, "install-catalog-apps", "", "comma separated 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)")
createCmd.Flags().BoolVar(&installKubefirstProFlag, "install-kubefirst-pro", true, "whether or not to install kubefirst pro")
Expand Down
6 changes: 2 additions & 4 deletions cmd/launch.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,8 @@ import (
"github.com/spf13/cobra"
)

var (
// additionalHelmFlags can optionally pass user-supplied flags to helm
additionalHelmFlags []string
)
// additionalHelmFlags can optionally pass user-supplied flags to helm
var additionalHelmFlags []string

func LaunchCommand() *cobra.Command {
launchCommand := &cobra.Command{
Expand Down
6 changes: 2 additions & 4 deletions cmd/letsencrypt.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,8 @@ import (
"github.com/spf13/cobra"
)

var (
// Certificate check
domainNameFlag string
)
// Certificate check
var domainNameFlag string

func LetsEncryptCommand() *cobra.Command {
letsEncryptCommand := &cobra.Command{
Expand Down
Loading
Loading