From 940670c07ceaf4cf017d6b01f6c96d50bfc4f07e Mon Sep 17 00:00:00 2001 From: Marc Campbell Date: Wed, 17 Dec 2025 06:07:50 -0800 Subject: [PATCH] run go fmt --- cli/cmd/app_hostname_ls.go | 14 +++++------ cli/cmd/cluster_upgrade.go | 2 +- cli/cmd/image_extraction_test.go | 2 -- cli/cmd/lint.go | 4 +-- cli/cmd/lint_types.go | 20 +++++++-------- cli/cmd/release_create.go | 16 ++++++------ cli/cmd/release_download.go | 42 ++++++++++++++++---------------- cli/cmd/release_image_ls.go | 4 +-- cli/cmd/version.go | 8 +++--- cli/print/channel_images.go | 8 +++--- cli/print/clusters.go | 2 +- cli/print/vms.go | 4 +-- client/channel.go | 12 ++++----- pkg/lint2/gitignore.go | 1 + pkg/tools/config_test.go | 4 +-- pkg/tools/init.go | 4 +-- pkg/types/channel.go | 38 ++++++++++++++--------------- pkg/types/customer.go | 42 ++++++++++++++++---------------- pkg/types/network.go | 6 ++--- pkg/util/ssh.go | 6 ++--- pkg/version/updatecache.go | 26 ++++++++++---------- pkg/version/updateinfo.go | 4 +-- pkg/version/version.go | 4 +-- 23 files changed, 135 insertions(+), 138 deletions(-) diff --git a/cli/cmd/app_hostname_ls.go b/cli/cmd/app_hostname_ls.go index 8404923bd..7e755e425 100644 --- a/cli/cmd/app_hostname_ls.go +++ b/cli/cmd/app_hostname_ls.go @@ -187,23 +187,23 @@ func extractHostnameStrings(merged *types.KotsAppCustomHostnames) map[string]str // printHostnamesTable prints hostnames in a table format func printHostnamesTable(w *tabwriter.Writer, hostnames map[string]string) error { fmt.Fprintln(w, "TYPE\tHOSTNAME") - + if registry, ok := hostnames["registry"]; ok && registry != "" { fmt.Fprintf(w, "Registry\t%s\n", registry) } - + if proxy, ok := hostnames["proxy"]; ok && proxy != "" { fmt.Fprintf(w, "Proxy\t%s\n", proxy) } - + if downloadPortal, ok := hostnames["downloadPortal"]; ok && downloadPortal != "" { fmt.Fprintf(w, "Download Portal\t%s\n", downloadPortal) } - + if replicatedApp, ok := hostnames["replicatedApp"]; ok && replicatedApp != "" { fmt.Fprintf(w, "Replicated App\t%s\n", replicatedApp) } - + w.Flush() return nil } @@ -215,11 +215,11 @@ func mergeHostnames(defaults *types.DefaultHostnames, custom *types.KotsAppCusto if custom == nil && defaults == nil { return &types.KotsAppCustomHostnames{} } - + if custom == nil { custom = &types.KotsAppCustomHostnames{} } - + if defaults == nil { return custom } diff --git a/cli/cmd/cluster_upgrade.go b/cli/cmd/cluster_upgrade.go index 735178ff5..045579d6b 100644 --- a/cli/cmd/cluster_upgrade.go +++ b/cli/cmd/cluster_upgrade.go @@ -47,7 +47,7 @@ func (r *runners) upgradeCluster(cmd *cobra.Command, args []string) error { if len(args) < 1 { return errors.New("cluster id or name is required") } - + clusterID, err := r.getClusterIDFromArg(args[0]) if err != nil { return errors.Wrap(err, "get cluster id from arg") diff --git a/cli/cmd/image_extraction_test.go b/cli/cmd/image_extraction_test.go index ca9962431..4c3322bd4 100644 --- a/cli/cmd/image_extraction_test.go +++ b/cli/cmd/image_extraction_test.go @@ -117,7 +117,6 @@ func TestExtractImagesFromConfig_ChartWithRequiredValues_NoHelmChartManifest(t * // This tests only the discovery layer behavior } - func TestExtractImagesFromConfig_NonMatchingHelmChart_FailsToRender(t *testing.T) { // Test that HelmChart manifest must match chart name:version exactly chartPath := getAbsTestDataPath(t, filepath.Join("testdata", "image-extraction", "non-matching-helmchart-test", "chart")) @@ -275,7 +274,6 @@ func TestExtractImagesFromConfig_NoManifests_ReturnsError(t *testing.T) { // This tests only the discovery layer behavior (which is now lenient) } - func TestExtractImagesFromConfig_EmptyBuilder_FailsToRender(t *testing.T) { // Test that HelmChart manifest with empty builder section doesn't provide values chartPath := getAbsTestDataPath(t, filepath.Join("testdata", "image-extraction", "empty-builder-test", "chart")) diff --git a/cli/cmd/lint.go b/cli/cmd/lint.go index 910f126a7..fad664a1c 100644 --- a/cli/cmd/lint.go +++ b/cli/cmd/lint.go @@ -730,8 +730,8 @@ func (r *runners) calculateOverallSummary(output *JSONLintOutput) LintSummary { // This eliminates duplication across chart, preflight, and support bundle display functions. func (r *runners) displayLintResults( sectionTitle string, - itemName string, // e.g., "chart", "preflight spec", "support bundle spec" - pluralName string, // e.g., "charts", "preflight specs", "support bundle specs" + itemName string, // e.g., "chart", "preflight spec", "support bundle spec" + pluralName string, // e.g., "charts", "preflight specs", "support bundle specs" results []LintableResult, ) error { if len(results) == 0 { diff --git a/cli/cmd/lint_types.go b/cli/cmd/lint_types.go index 4a3571b6a..7f58f8334 100644 --- a/cli/cmd/lint_types.go +++ b/cli/cmd/lint_types.go @@ -57,7 +57,7 @@ type PreflightLintResult struct { // SupportBundleLintResults contains all Support Bundle spec lint results type SupportBundleLintResults struct { - Enabled bool `json:"enabled"` + Enabled bool `json:"enabled"` Specs []SupportBundleLintResult `json:"specs"` } @@ -144,21 +144,21 @@ type LintableResult interface { } // Implement LintableResult interface for ChartLintResult -func (c ChartLintResult) GetPath() string { return c.Path } -func (c ChartLintResult) GetSuccess() bool { return c.Success } -func (c ChartLintResult) GetMessages() []LintMessage { return c.Messages } +func (c ChartLintResult) GetPath() string { return c.Path } +func (c ChartLintResult) GetSuccess() bool { return c.Success } +func (c ChartLintResult) GetMessages() []LintMessage { return c.Messages } func (c ChartLintResult) GetSummary() ResourceSummary { return c.Summary } // Implement LintableResult interface for PreflightLintResult -func (p PreflightLintResult) GetPath() string { return p.Path } -func (p PreflightLintResult) GetSuccess() bool { return p.Success } -func (p PreflightLintResult) GetMessages() []LintMessage { return p.Messages } +func (p PreflightLintResult) GetPath() string { return p.Path } +func (p PreflightLintResult) GetSuccess() bool { return p.Success } +func (p PreflightLintResult) GetMessages() []LintMessage { return p.Messages } func (p PreflightLintResult) GetSummary() ResourceSummary { return p.Summary } // Implement LintableResult interface for SupportBundleLintResult -func (s SupportBundleLintResult) GetPath() string { return s.Path } -func (s SupportBundleLintResult) GetSuccess() bool { return s.Success } -func (s SupportBundleLintResult) GetMessages() []LintMessage { return s.Messages } +func (s SupportBundleLintResult) GetPath() string { return s.Path } +func (s SupportBundleLintResult) GetSuccess() bool { return s.Success } +func (s SupportBundleLintResult) GetMessages() []LintMessage { return s.Messages } func (s SupportBundleLintResult) GetSummary() ResourceSummary { return s.Summary } // Helper functions to convert between types diff --git a/cli/cmd/release_create.go b/cli/cmd/release_create.go index b6e4dd29a..4863b3700 100644 --- a/cli/cmd/release_create.go +++ b/cli/cmd/release_create.go @@ -100,11 +100,11 @@ func (r *runners) InitReleaseCreate(parent *cobra.Command) error { savedAppID := r.appID savedAppSlug := r.appSlug savedAppType := r.appType - + r.appID = "" r.appSlug = "" r.appType = "" - + // Call parent prerun (will setup APIs but skip app resolution since app is empty) if originalPreRun != nil { if err := originalPreRun(cmd, args); err != nil { @@ -115,7 +115,7 @@ func (r *runners) InitReleaseCreate(parent *cobra.Command) error { return err } } - + // Keep app cleared - we'll load from config in releaseCreate return nil } @@ -891,17 +891,17 @@ func (r *runners) validateAppFromConfig(config *tools.Config) error { // This handles cases where user passes appId and config has appSlug (or vice versa) // as long as they refer to the same app cliMatchesConfig := false - + // Check if CLI appID matches config appId if r.appID != "" && configAppId != "" && r.appID == configAppId { cliMatchesConfig = true } - + // Check if CLI appSlug matches config appSlug if r.appSlug != "" && configAppSlug != "" && r.appSlug == configAppSlug { cliMatchesConfig = true } - + // Check if CLI appID matches config appSlug (or vice versa) // We need to resolve this via API to check if they're the same app if r.appID != "" && configAppSlug != "" && !cliMatchesConfig { @@ -909,13 +909,13 @@ func (r *runners) validateAppFromConfig(config *tools.Config) error { // We'll allow this and let the API resolve it cliMatchesConfig = true } - + if r.appSlug != "" && configAppId != "" && !cliMatchesConfig { // The appSlug from CLI might be the slug for the ID in config // We'll allow this and let the API resolve it cliMatchesConfig = true } - + // If we couldn't match, show error with both values if !cliMatchesConfig { configValue := configAppSlug diff --git a/cli/cmd/release_download.go b/cli/cmd/release_download.go index a071d7a75..80e81cc11 100644 --- a/cli/cmd/release_download.go +++ b/cli/cmd/release_download.go @@ -43,17 +43,17 @@ replicated release download --channel Unstable # Download to directory (KOTS only with sequence) replicated release download 1 --dest ./manifests`, - Args: cobra.MaximumNArgs(1), + Args: cobra.MaximumNArgs(1), } parent.AddCommand(cmd) - + // Similar to release create, handle config-based flow in PreRunE cmd.PreRunE = func(cmd *cobra.Command, args []string) error { // Check if --app flag was explicitly provided by the user appFlagProvided := cmd.Flags().Changed("app") - + // Check if we should use config-based flow (no --app flag was provided) - // Note: Parent's PersistentPreRunE runs BEFORE our PreRunE, so appID/appSlug + // Note: Parent's PersistentPreRunE runs BEFORE our PreRunE, so appID/appSlug // may already be set from cache/env even if user didn't provide --app flag usingConfigFlow := false if !appFlagProvided { @@ -69,28 +69,28 @@ replicated release download 1 --dest ./manifests`, } } } - + if usingConfigFlow { // The parent's PersistentPreRunE already ran and may have set wrong app from cache // We need to override it with the app from config and re-resolve - + // Clear the wrong app state that parent set r.appID = "" r.appType = "" // r.appSlug is already set from config above - + // Resolve the app using the correct profile's API if err := r.resolveAppTypeForDownload(); err != nil { return errors.Wrap(err, "resolve app type from config") } - + return nil } - + // Normal flow - --app flag was provided, parent prerun already handled it return nil } - + cmd.RunE = r.releaseDownload cmd.Flags().StringVarP(&r.args.releaseDownloadDest, "dest", "d", "", "File or directory to which release should be downloaded. Auto-generated if not specified.") cmd.Flags().StringVarP(&r.args.releaseDownloadChannel, "channel", "c", "", "Download the current release from this channel (case sensitive)") @@ -110,25 +110,25 @@ func (r *runners) releaseDownload(command *cobra.Command, args []string) error { // Determine sequence to download var seq int64 var err error - + if r.args.releaseDownloadChannel != "" { // Download from channel if len(args) > 0 { return errors.New("cannot specify both sequence and --channel flag") } - + log.ActionWithSpinner("Finding channel %q", r.args.releaseDownloadChannel) channel, err := r.api.GetChannelByName(r.appID, r.appType, r.args.releaseDownloadChannel) if err != nil { log.FinishSpinnerWithError() return errors.Wrapf(err, "get channel %q", r.args.releaseDownloadChannel) } - + if channel.ReleaseSequence == 0 { log.FinishSpinnerWithError() return errors.Errorf("channel %q has no releases", r.args.releaseDownloadChannel) } - + seq = channel.ReleaseSequence log.FinishSpinner() log.ActionWithoutSpinner("Channel %q is at sequence %d", r.args.releaseDownloadChannel, seq) @@ -146,19 +146,19 @@ func (r *runners) releaseDownload(command *cobra.Command, args []string) error { log.FinishSpinnerWithError() return errors.Wrap(err, "list channels to find latest release") } - + var latestSeq int64 for _, channel := range channels { if channel.ReleaseSequence > latestSeq { latestSeq = channel.ReleaseSequence } } - + if latestSeq == 0 { log.FinishSpinnerWithError() return errors.New("no releases found") } - + seq = latestSeq log.FinishSpinner() log.ActionWithoutSpinner("Latest release is sequence %d", seq) @@ -167,7 +167,7 @@ func (r *runners) releaseDownload(command *cobra.Command, args []string) error { // Determine destination and whether to save as file or directory dest := r.args.releaseDownloadDest saveAsFile := false - + if dest == "" { // Auto-generate filename for .tgz dest = r.generateDownloadFilename() @@ -247,7 +247,7 @@ func (r *runners) generateDownloadFilename() string { if base == "" { base = r.appID } - + filename := fmt.Sprintf("%s.tgz", base) if _, err := os.Stat(filename); err == nil { // File exists, try with incrementing number @@ -258,7 +258,7 @@ func (r *runners) generateDownloadFilename() string { } } } - + return filename } @@ -273,7 +273,7 @@ func (r *runners) downloadReleaseArchive(seq int64, dest string) error { // The release config is base64 encoded JSON, we need to get the raw archive // For now, we'll use the kotsrelease.Save to a temp dir then tar it up // TODO: Look for a direct archive download endpoint - + tempDir, err := os.MkdirTemp("", "replicated-download-*") if err != nil { return errors.Wrap(err, "create temp directory") diff --git a/cli/cmd/release_image_ls.go b/cli/cmd/release_image_ls.go index 8656a0f5a..8f5e4db15 100644 --- a/cli/cmd/release_image_ls.go +++ b/cli/cmd/release_image_ls.go @@ -107,7 +107,7 @@ func (r *runners) releaseImageLS(cmd *cobra.Command, args []string) error { // Extract and clean up image names images := make([]string, 0) - + for _, image := range targetRelease.AirgapBundleImages { // Remove registry prefixes and clean up image names var cleanProxyDomain string @@ -207,5 +207,3 @@ func findTargetRelease(releases []*types.ChannelRelease, requestedVersion string return targetRelease, nil } - - diff --git a/cli/cmd/version.go b/cli/cmd/version.go index 6179285ca..9f68ea5da 100644 --- a/cli/cmd/version.go +++ b/cli/cmd/version.go @@ -18,9 +18,9 @@ func Version() *cobra.Command { Long: `Print the current version and exit`, RunE: func(cmd *cobra.Command, args []string) error { currentVersion := version.Version() - + // For version command, do a synchronous update check - updateChecker, err := version.NewUpdateChecker(currentVersion, "replicatedhq/replicated/cli") + updateChecker, err := version.NewUpdateChecker(currentVersion, "replicatedhq/replicated/cli") if err == nil { // If we're in a development build or unknown version, still try to get latest // version info but don't compare versions @@ -32,7 +32,7 @@ func Version() *cobra.Command { version.SaveUpdateCache(currentVersion, updateInfo) } } - + // Now get the (potentially updated) build info build := version.GetBuild() @@ -68,4 +68,4 @@ func Version() *cobra.Command { cmd.AddCommand(versionUpgradeCmd()) return cmd -} \ No newline at end of file +} diff --git a/cli/print/channel_images.go b/cli/print/channel_images.go index 38b7acd99..4116b76c4 100644 --- a/cli/print/channel_images.go +++ b/cli/print/channel_images.go @@ -9,14 +9,14 @@ import ( func ChannelImages(w *tabwriter.Writer, images []string) error { // Sort images for consistent output sort.Strings(images) - + // Print header fmt.Fprintln(w, "IMAGE") - + // Print each image for _, image := range images { fmt.Fprintln(w, image) } - + return w.Flush() -} \ No newline at end of file +} diff --git a/cli/print/clusters.go b/cli/print/clusters.go index 5949af5ae..6151173ad 100644 --- a/cli/print/clusters.go +++ b/cli/print/clusters.go @@ -25,7 +25,7 @@ var clustersTmplTableNoHeader = template.Must(template.New("clusters").Funcs(clu // Wide table formatting var clustersTmplWideHeaderSrc = `ID NAME DISTRIBUTION VERSION STATUS LAST SCHEDULING STATUS NETWORK CREATED EXPIRES COST TOTAL NODES NODEGROUPS TAGS` -var clustersTmplWideRowSrc = `{{ range . -}} +var clustersTmplWideRowSrc = `{{ range . -}} {{ .ID }} {{ padding .Name 27 }} {{ padding .KubernetesDistribution 12 }} {{ padding .KubernetesVersion 10 }} {{ padding (printf "%s" .Status) 12 }} {{ if .LastSchedulingStatus }}{{ padding .LastSchedulingStatus 29 }}{{ else }}{{ padding "-" 29 }}{{ end }} {{ if .Network }}{{ padding (printf "%.8s" .Network) 8 }}{{else}}{{ padding "-" 8 }}{{end}} {{ padding (printf "%s" (localeTime .CreatedAt)) 30 }} {{if .ExpiresAt.IsZero}}{{ padding "-" 30 }}{{else}}{{ padding (printf "%s" (localeTime .ExpiresAt)) 30 }}{{end}} {{ padding (CreditsToDollarsDisplay .EstimatedCost) 11 }} {{$nodecount:=0}}{{ range $index, $ng := .NodeGroups}}{{$nodecount = add $nodecount $ng.NodeCount}}{{ end }}{{ padding (printf "%d" $nodecount) 11 }} {{ len .NodeGroups}} {{ if eq (len .Tags) 0 }}{{ padding "-" 11 }}{{ else }}{{ range $index, $tag := .Tags }}{{if $index}}, {{end}}{{ $tag.Key }}={{ $tag.Value }}{{ end }}{{ end }} {{ end }}` var clustersTmplWideSrc = fmt.Sprintln(clustersTmplWideHeaderSrc) + clustersTmplWideRowSrc diff --git a/cli/print/vms.go b/cli/print/vms.go index b92e8ff7f..e4e42e9f9 100644 --- a/cli/print/vms.go +++ b/cli/print/vms.go @@ -16,7 +16,7 @@ var vmFuncs = template.FuncMap{ // Table formatting var vmsTmplTableHeaderSrc = `ID NAME DISTRIBUTION VERSION STATUS NETWORK CREATED EXPIRES COST` -var vmsTmplTableRowSrc = `{{ range . -}} +var vmsTmplTableRowSrc = `{{ range . -}} {{ .ID }} {{ padding .Name 27 }} {{ padding .Distribution 12 }} {{ padding .Version 10 }} {{ padding (printf "%s" .Status) 12 }} {{ if .Network }}{{ padding (printf "%.8s" .Network) 8 }}{{else}}{{ padding "-" 8 }}{{end}} {{ padding (printf "%s" (localeTime .CreatedAt)) 30 }} {{if .ExpiresAt.IsZero}}{{ padding "-" 30 }}{{else}}{{ padding (printf "%s" (localeTime .ExpiresAt)) 30 }}{{end}} {{ padding (CreditsToDollarsDisplay .EstimatedCost) 11 }} {{ end }}` var vmsTmplTableSrc = fmt.Sprintln(vmsTmplTableHeaderSrc) + vmsTmplTableRowSrc @@ -25,7 +25,7 @@ var vmsTmplTableNoHeader = template.Must(template.New("vms").Funcs(vmFuncs).Func // Wide table formatting var vmsTmplWideHeaderSrc = `ID NAME DISTRIBUTION VERSION INSTANCE TYPE STATUS LAST SCHEDULING STATUS NETWORK CREATED EXPIRES COST TAGS` -var vmsTmplWideRowSrc = `{{ range . -}} +var vmsTmplWideRowSrc = `{{ range . -}} {{ .ID }} {{ padding .Name 27 }} {{ padding .Distribution 12 }} {{ padding .Version 10 }} {{ if .InstanceType }}{{ padding .InstanceType 13 }}{{ else }}{{ padding "-" 13 }}{{ end }} {{ padding (printf "%s" .Status) 12 }} {{ if .LastSchedulingStatus }}{{ padding .LastSchedulingStatus 29 }}{{ else }}{{ padding "-" 29 }}{{ end }} {{ if .Network }}{{ padding (printf "%.8s" .Network) 8 }}{{else}}{{ padding "-" 8 }}{{end}} {{ padding (printf "%s" (localeTime .CreatedAt)) 30 }} {{if .ExpiresAt.IsZero}}{{ padding "-" 30 }}{{else}}{{ padding (printf "%s" (localeTime .ExpiresAt)) 30 }}{{end}} {{ padding (CreditsToDollarsDisplay .EstimatedCost) 11 }} {{ if eq (len .Tags) 0 }}{{ padding "-" 11 }}{{ else }}{{ range $index, $tag := .Tags }}{{if $index}}, {{end}}{{ $tag.Key }}={{ $tag.Value }}{{ end }}{{ end }} {{ end }}` var vmsTmplWideSrc = fmt.Sprintln(vmsTmplWideHeaderSrc) + vmsTmplWideRowSrc diff --git a/client/channel.go b/client/channel.go index 3b6375cfd..b5b8c68a3 100644 --- a/client/channel.go +++ b/client/channel.go @@ -218,7 +218,7 @@ func (c *Client) GetCurrentChannelRelease(appID string, appType string, channelI if err != nil { return nil, "", err } - + // If the channel has releases data, find the current one if len(kotsChannel.Releases) > 0 { var currentRelease *types.ChannelRelease @@ -249,24 +249,24 @@ func (c *Client) GetCurrentChannelRelease(appID string, appType string, channelI return currentRelease, proxyDomain, nil } } - + // Fallback to the existing approach if releases aren't included releases, err := c.KotsClient.ListChannelReleases(appID, channelID) if err != nil { return nil, "", err } - + if len(releases) == 0 { return nil, "", errors.New("no releases found in channel") } - + var currentRelease *types.ChannelRelease for _, release := range releases { if currentRelease == nil || release.ChannelSequence > currentRelease.ChannelSequence { currentRelease = release } } - + proxyDomain := currentRelease.ProxyRegistryDomain if proxyDomain == "" && kotsChannel.CustomHostNameOverrides.Proxy.Hostname != "" { proxyDomain = kotsChannel.CustomHostNameOverrides.Proxy.Hostname @@ -285,7 +285,7 @@ func (c *Client) GetCurrentChannelRelease(appID string, appType string, channelI proxyDomain = "proxy.replicated.com" } } - + return currentRelease, proxyDomain, nil } return nil, "", errors.Errorf("unknown app type %q", appType) diff --git a/pkg/lint2/gitignore.go b/pkg/lint2/gitignore.go index 6fac9e2ff..e72bf8925 100644 --- a/pkg/lint2/gitignore.go +++ b/pkg/lint2/gitignore.go @@ -181,6 +181,7 @@ func loadGitInfoExcludeMatcher(repoRoot string) (gitignore.IgnoreMatcher, []stri // - Parse ~/.gitconfig directly (no command execution) // - Validate paths to prevent traversal attacks // - Add comprehensive input validation +// // See: https://github.com/replicatedhq/replicated/pull/634 func loadGlobalGitignoreMatcher() (gitignore.IgnoreMatcher, []string, error) { // Disabled for security - will re-enable with proper validation in future PR diff --git a/pkg/tools/config_test.go b/pkg/tools/config_test.go index 615942bc5..dbe09d4b9 100644 --- a/pkg/tools/config_test.go +++ b/pkg/tools/config_test.go @@ -377,8 +377,8 @@ func TestConfigParser_MergeConfigs(t *testing.T) { PromoteToChannelNames: []string{"stable"}, } child := &Config{ - AppId: "", // Empty - should not override - PromoteToChannelIds: nil, // Nil - should not override + AppId: "", // Empty - should not override + PromoteToChannelIds: nil, // Nil - should not override PromoteToChannelNames: []string{}, // Empty slice - should not override } diff --git a/pkg/tools/init.go b/pkg/tools/init.go index 7baeacfd2..12aacffa7 100644 --- a/pkg/tools/init.go +++ b/pkg/tools/init.go @@ -62,8 +62,8 @@ func AutoDetectResources(startPath string) (*DetectedResources, error) { // Check if this is a manifest directory dirName := strings.ToLower(name) if dirName == "manifests" || dirName == "replicated" || - dirName == "kustomize" || dirName == "k8s" || - dirName == "kubernetes" || dirName == "yaml" { + dirName == "kustomize" || dirName == "k8s" || + dirName == "kubernetes" || dirName == "yaml" { relPath, err := filepath.Rel(absStartPath, path) if err == nil && relPath != "." { manifestDirs[relPath] = true diff --git a/pkg/types/channel.go b/pkg/types/channel.go index 70ec1be0f..894f4372b 100644 --- a/pkg/types/channel.go +++ b/pkg/types/channel.go @@ -63,22 +63,22 @@ type CustomerAdoption struct { } type ChannelRelease struct { - AirgapBuildError string `json:"airgapBuildError,omitempty"` - AirgapBuildStatus string `json:"airgapBuildStatus,omitempty"` - AirgapBundleImages []string `json:"airgapBundleImages,omitempty"` - ChannelIcon string `json:"channelIcon,omitempty"` - ChannelId string `json:"channelId,omitempty"` - ChannelName string `json:"channelName,omitempty"` - ChannelSequence int32 `json:"channelSequence,omitempty"` - Created time.Time `json:"created,omitempty"` - ProxyRegistryDomain string `json:"proxyRegistryDomain,omitempty"` - RegistrySecret string `json:"registrySecret,omitempty"` - ReleaseNotes string `json:"releaseNotes,omitempty"` - ReleasedAt time.Time `json:"releasedAt,omitempty"` - Semver string `json:"semver,omitempty"` - Sequence int32 `json:"sequence,omitempty"` - Updated time.Time `json:"updated,omitempty"` - InstallationTypes InstallationTypes `json:"installationTypes,omitempty"` + AirgapBuildError string `json:"airgapBuildError,omitempty"` + AirgapBuildStatus string `json:"airgapBuildStatus,omitempty"` + AirgapBundleImages []string `json:"airgapBundleImages,omitempty"` + ChannelIcon string `json:"channelIcon,omitempty"` + ChannelId string `json:"channelId,omitempty"` + ChannelName string `json:"channelName,omitempty"` + ChannelSequence int32 `json:"channelSequence,omitempty"` + Created time.Time `json:"created,omitempty"` + ProxyRegistryDomain string `json:"proxyRegistryDomain,omitempty"` + RegistrySecret string `json:"registrySecret,omitempty"` + ReleaseNotes string `json:"releaseNotes,omitempty"` + ReleasedAt time.Time `json:"releasedAt,omitempty"` + Semver string `json:"semver,omitempty"` + Sequence int32 `json:"sequence,omitempty"` + Updated time.Time `json:"updated,omitempty"` + InstallationTypes InstallationTypes `json:"installationTypes,omitempty"` } type CreateChannelRequest struct { @@ -129,7 +129,7 @@ type InstallationTypes struct { } type EmbeddedCluster struct { - Version string `json:"version,omitempty"` - ReplicatedAppDomain string `json:"replicatedAppDomain,omitempty"` - ProxyRegistryDomain string `json:"proxyRegistryDomain,omitempty"` + Version string `json:"version,omitempty"` + ReplicatedAppDomain string `json:"replicatedAppDomain,omitempty"` + ProxyRegistryDomain string `json:"proxyRegistryDomain,omitempty"` } diff --git a/pkg/types/customer.go b/pkg/types/customer.go index aa662cf72..c81fedf5d 100644 --- a/pkg/types/customer.go +++ b/pkg/types/customer.go @@ -6,27 +6,27 @@ import ( ) type Customer struct { - ID string `json:"id"` - CustomID string `json:"customId"` - Name string `json:"name"` - Email string `json:"email"` - Channels []Channel `json:"channels"` - Type string `json:"type"` - Expires *util.Time `json:"expiresAt"` - Instances []Instance `json:"instances"` - InstallationID string `json:"installationId"` - Entitlements []Entitlement `json:"entitlements"` - IsAirgapEnabled bool `json:"airgap"` - IsEmbeddedClusterDownloadEnabled bool `json:"isEmbeddedClusterDownloadEnabled"` - IsEmbeddedClusterMultinodeEnabled bool `json:"isEmbeddedClusterMultinodeEnabled"` - IsGeoaxisSupported bool `json:"isGeoaxisSupported"` - IsHelmVMDownloadEnabled bool `json:"isHelmVmDownloadEnabled"` - IsIdentityServiceSupported bool `json:"isIdentityServiceSupported"` - IsInstallerSupportEnabled bool `json:"isInstallerSupportEnabled"` - IsKotsInstallEnabled bool `json:"isKotsInstallEnabled"` - IsSnapshotSupported bool `json:"isSnapshotSupported"` - IsSupportBundleUploadEnabled bool `json:"isSupportBundleUploadEnabled"` - IsGitopsSupported bool `json:"isGitopsSupported"` + ID string `json:"id"` + CustomID string `json:"customId"` + Name string `json:"name"` + Email string `json:"email"` + Channels []Channel `json:"channels"` + Type string `json:"type"` + Expires *util.Time `json:"expiresAt"` + Instances []Instance `json:"instances"` + InstallationID string `json:"installationId"` + Entitlements []Entitlement `json:"entitlements"` + IsAirgapEnabled bool `json:"airgap"` + IsEmbeddedClusterDownloadEnabled bool `json:"isEmbeddedClusterDownloadEnabled"` + IsEmbeddedClusterMultinodeEnabled bool `json:"isEmbeddedClusterMultinodeEnabled"` + IsGeoaxisSupported bool `json:"isGeoaxisSupported"` + IsHelmVMDownloadEnabled bool `json:"isHelmVmDownloadEnabled"` + IsIdentityServiceSupported bool `json:"isIdentityServiceSupported"` + IsInstallerSupportEnabled bool `json:"isInstallerSupportEnabled"` + IsKotsInstallEnabled bool `json:"isKotsInstallEnabled"` + IsSnapshotSupported bool `json:"isSnapshotSupported"` + IsSupportBundleUploadEnabled bool `json:"isSupportBundleUploadEnabled"` + IsGitopsSupported bool `json:"isGitopsSupported"` } func (c Customer) WithExpiryTime(expiryTime string) (Customer, error) { diff --git a/pkg/types/network.go b/pkg/types/network.go index fe7a20bdb..64eac7fd8 100644 --- a/pkg/types/network.go +++ b/pkg/types/network.go @@ -17,9 +17,9 @@ type Network struct { OverlayEndpoint string `json:"overlay_endpoint,omitempty"` OverlayToken string `json:"overlay_token,omitempty"` - Policy string `json:"policy,omitempty"` - CollectReport bool `json:"collect_report,omitempty"` - HasReport bool `json:"has_report,omitempty"` + Policy string `json:"policy,omitempty"` + CollectReport bool `json:"collect_report,omitempty"` + HasReport bool `json:"has_report,omitempty"` Resources []*NetworkResource `json:"resources,omitempty"` } diff --git a/pkg/util/ssh.go b/pkg/util/ssh.go index 5882fe1cb..12dd6f3b8 100644 --- a/pkg/util/ssh.go +++ b/pkg/util/ssh.go @@ -30,7 +30,7 @@ func ReadAndValidatePublicKey(path string) (string, error) { parts := strings.Fields(keyContent) if len(parts) > 2 { comment := strings.Join(parts[2:], " ") - + dangerousPattern := regexp.MustCompile(`[;&|<>$\\\(\)\[\]\{\}\*\?]`) if dangerousPattern.MatchString(comment) { return "", fmt.Errorf("SSH public key comment contains potentially dangerous characters: %s", path) @@ -38,8 +38,8 @@ func ReadAndValidatePublicKey(path string) (string, error) { } keyType := pubKey.Type() - if keyType != "ssh-rsa" && keyType != "ssh-ed25519" && - !strings.HasPrefix(keyType, "ecdsa-sha2-nistp") && keyType != "ssh-dss" { + if keyType != "ssh-rsa" && keyType != "ssh-ed25519" && + !strings.HasPrefix(keyType, "ecdsa-sha2-nistp") && keyType != "ssh-dss" { return "", fmt.Errorf("unsupported SSH public key type %s in file: %s", keyType, path) } diff --git a/pkg/version/updatecache.go b/pkg/version/updatecache.go index aee87ab9f..01006d226 100644 --- a/pkg/version/updatecache.go +++ b/pkg/version/updatecache.go @@ -27,9 +27,9 @@ func debugLog(format string, args ...interface{}) { // UpdateCache represents the cached update information type UpdateCache struct { - Version string `json:"cachedVersion"` - UpdateInfo UpdateInfo `json:"updateCheckerInfo"` - LastCheckedAt time.Time `json:"lastCheckedAt"` + Version string `json:"cachedVersion"` + UpdateInfo UpdateInfo `json:"updateCheckerInfo"` + LastCheckedAt time.Time `json:"lastCheckedAt"` } // getCacheDir returns the directory where the cache file is stored @@ -79,7 +79,7 @@ func LoadUpdateCache() (*UpdateCache, error) { return nil, nil // Invalid cache, silently return nil } - debugLog("Successfully loaded cache: version=%s, latest=%s, checked=%s", + debugLog("Successfully loaded cache: version=%s, latest=%s, checked=%s", cache.Version, cache.UpdateInfo.LatestVersion, cache.LastCheckedAt.Format(time.RFC3339)) return &cache, nil } @@ -92,7 +92,7 @@ func ClearUpdateCache() { debugLog("Failed to get cache path: %v", err) return } - + // Check if file exists first _, err = os.Stat(cachePath) if err != nil { @@ -103,7 +103,7 @@ func ClearUpdateCache() { debugLog("Error checking cache file: %v", err) return } - + debugLog("Clearing update cache at %s", cachePath) err = os.Remove(cachePath) if err != nil { @@ -121,7 +121,7 @@ func SaveUpdateCache(currentVersion string, updateInfo *UpdateInfo) { return } - debugLog("Saving update cache for version %s, latest version %s", + debugLog("Saving update cache for version %s, latest version %s", currentVersion, updateInfo.LatestVersion) cacheDir, err := getCacheDir() @@ -167,9 +167,9 @@ func SaveUpdateCache(currentVersion string, updateInfo *UpdateInfo) { if err := os.Rename(tmpFile, cachePath); err != nil { debugLog("Failed to rename temporary file: %v", err) os.Remove(tmpFile) // Clean up temp file if rename fails - return // Silently fail + return // Silently fail } - + debugLog("Successfully saved update cache") } @@ -178,7 +178,7 @@ func SaveUpdateCache(currentVersion string, updateInfo *UpdateInfo) { // handles all errors. func CheckForUpdatesInBackground(currentVersion string, homebrewFormula string) { debugLog("Starting background update check for version %s", currentVersion) - + go func() { // Create update checker with shorter timeout for background checks debugLog("Creating update checker with formula %s", homebrewFormula) @@ -187,7 +187,7 @@ func CheckForUpdatesInBackground(currentVersion string, homebrewFormula string) debugLog("Failed to create update checker: %v", err) return // Silently fail } - + // Use a shorter timeout for background checks updateChecker.httpTimeout = 1 * time.Second @@ -205,8 +205,8 @@ func CheckForUpdatesInBackground(currentVersion string, homebrewFormula string) } debugLog("Update check complete, latest version: %s", updateInfo.LatestVersion) - + // Save to cache SaveUpdateCache(currentVersion, updateInfo) }() -} \ No newline at end of file +} diff --git a/pkg/version/updateinfo.go b/pkg/version/updateinfo.go index d4f208dbf..50d5c53f8 100644 --- a/pkg/version/updateinfo.go +++ b/pkg/version/updateinfo.go @@ -63,7 +63,7 @@ type ClientVersions struct { func getLatestVersion(timeout time.Duration) (*VersionInfo, error) { startTime := time.Now() debugLog("Making HTTP request to %s with timeout %v", latestVersionURI, timeout) - + client := &http.Client{ Timeout: timeout, } @@ -149,7 +149,7 @@ func UpdateInfoFromVersions(currentVersion string, latestVersion *VersionInfo) ( // Compare versions and only return update info if a newer version is available if latestSemver.LessThan(currentSemver) || latestSemver.Equal(currentSemver) { - debugLog("Current version %s is equal to or newer than latest %s, no update needed", + debugLog("Current version %s is equal to or newer than latest %s, no update needed", currentVersion, latestVersion.Version) return nil, nil } diff --git a/pkg/version/version.go b/pkg/version/version.go index 6c8bd8a4e..7fb859f7a 100644 --- a/pkg/version/version.go +++ b/pkg/version/version.go @@ -32,7 +32,7 @@ func initBuild() { debugLog("Using cached update info for version %s", build.Version) build.UpdateInfo = &updateCache.UpdateInfo } else { - debugLog("Cached update info is for version %s, current version is %s - clearing cache", + debugLog("Cached update info is for version %s, current version is %s - clearing cache", updateCache.Version, build.Version) // Clear the cache when CLI version has changed ClearUpdateCache() @@ -79,4 +79,4 @@ func PrintIfUpgradeAvailable() { fmt.Fprintf(os.Stderr, "To upgrade, run \"%s\"\n", build.UpdateInfo.ExternalUpgradeCommand) } } -} \ No newline at end of file +}