Skip to content

Commit 5f03d71

Browse files
committed
fix: resolve linting errors for CI
- Remove unnecessary nil check in host_kernel_configs.go (len() for nil slices is zero) - Remove unnecessary fmt.Sprintf() calls in ceph.go for static strings - Apply go fmt formatting fixes Fixes failing lint CI check
1 parent 6a75463 commit 5f03d71

5 files changed

Lines changed: 33 additions & 33 deletions

File tree

cmd/analyze/cli/root.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ import (
1616
// validateArgs allows certain flags to run without requiring bundle arguments
1717
func validateArgs(cmd *cobra.Command, args []string) error {
1818
// Special flags that don't require bundle arguments
19-
if cmd.Flags().Changed("check-ollama") || cmd.Flags().Changed("setup-ollama") ||
20-
cmd.Flags().Changed("list-models") || cmd.Flags().Changed("pull-model") {
19+
if cmd.Flags().Changed("check-ollama") || cmd.Flags().Changed("setup-ollama") ||
20+
cmd.Flags().Changed("list-models") || cmd.Flags().Changed("pull-model") {
2121
return nil
2222
}
2323

cmd/analyze/cli/run.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,11 @@ func runAnalyzers(v *viper.Viper, bundlePath string) error {
3535
if v.GetBool("check-ollama") {
3636
return handleOllamaStatus(v)
3737
}
38-
38+
3939
if v.GetBool("list-models") {
4040
return handleListModels(v)
4141
}
42-
42+
4343
if v.GetBool("pull-model") {
4444
return handlePullModel(v)
4545
}
@@ -50,11 +50,11 @@ func runAnalyzers(v *viper.Viper, bundlePath string) error {
5050
}
5151

5252
// Check if advanced analysis is requested
53-
useAdvanced := v.GetBool("advanced-analysis") ||
54-
v.GetBool("enable-ollama") ||
55-
v.GetBool("disable-ollama") || // ← FIX: disable-ollama should still use advanced engine
56-
(len(v.GetStringSlice("agents")) > 1 ||
57-
(len(v.GetStringSlice("agents")) == 1 && v.GetStringSlice("agents")[0] != "local"))
53+
useAdvanced := v.GetBool("advanced-analysis") ||
54+
v.GetBool("enable-ollama") ||
55+
v.GetBool("disable-ollama") || // ← FIX: disable-ollama should still use advanced engine
56+
(len(v.GetStringSlice("agents")) > 1 ||
57+
(len(v.GetStringSlice("agents")) == 1 && v.GetStringSlice("agents")[0] != "local"))
5858

5959
if useAdvanced {
6060
return runAdvancedAnalysis(v, bundlePath)
@@ -485,7 +485,7 @@ func loadSupportBundle(bundlePath string) (*analyzer.SupportBundle, error) {
485485

486486
// Create bundle structure
487487
bundle := &analyzer.SupportBundle{
488-
Files: make(map[string][]byte),
488+
Files: make(map[string][]byte),
489489
Metadata: &analyzer.SupportBundleMetadata{
490490
CreatedAt: time.Now(),
491491
Version: "1.0.0",
@@ -526,7 +526,7 @@ func loadSupportBundle(bundlePath string) (*analyzer.SupportBundle, error) {
526526
}
527527

528528
klog.Infof("Successfully loaded support bundle with %d files", len(bundle.Files))
529-
529+
530530
return bundle, nil
531531
}
532532

pkg/analyze/agents/ollama/ollama_agent.go

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -714,29 +714,29 @@ func (a *OllamaAgent) autoDetectFileForAnalyzer(bundle *analyzer.SupportBundle,
714714
}
715715
}
716716
}
717-
717+
718718
case "crd", "customResourceDefinition":
719719
// CRD analyzers - look for custom resource files
720720
if traditionalAnalyzer, ok := spec.Config["analyzer"]; ok {
721721
if crdAnalyzer, ok := traditionalAnalyzer.(*troubleshootv1beta2.CustomResourceDefinition); ok {
722722
// Look for specific CRD name in custom-resources directory
723723
crdName := crdAnalyzer.CustomResourceDefinitionName
724724
for path, data := range bundle.Files {
725-
if strings.Contains(path, "custom-resources") &&
726-
(strings.Contains(strings.ToLower(path), strings.ToLower(crdName)) ||
727-
strings.Contains(strings.ToLower(path), "crd")) {
725+
if strings.Contains(path, "custom-resources") &&
726+
(strings.Contains(strings.ToLower(path), strings.ToLower(crdName)) ||
727+
strings.Contains(strings.ToLower(path), "crd")) {
728728
return path, data, true
729729
}
730730
}
731731
}
732732
}
733-
733+
734734
case "container-runtime":
735735
// Container runtime analyzers - look for node information
736736
if data, exists := bundle.Files["cluster-resources/nodes.json"]; exists {
737737
return "cluster-resources/nodes.json", data, true
738738
}
739-
739+
740740
case "distribution":
741741
// Distribution analyzers - primarily use node information
742742
if data, exists := bundle.Files["cluster-resources/nodes.json"]; exists {
@@ -746,103 +746,103 @@ func (a *OllamaAgent) autoDetectFileForAnalyzer(bundle *analyzer.SupportBundle,
746746
if data, exists := bundle.Files["cluster-info/cluster_version.json"]; exists {
747747
return "cluster-info/cluster_version.json", data, true
748748
}
749-
749+
750750
case "storage-class":
751751
// Storage class analyzers - look for storage class resources
752752
for path, data := range bundle.Files {
753753
if strings.Contains(path, "storage") && strings.HasSuffix(path, ".json") {
754754
return path, data, true
755755
}
756756
}
757-
757+
758758
case "ingress":
759759
// Ingress analyzers - look for ingress resources
760760
for path, data := range bundle.Files {
761761
if strings.Contains(path, "ingress") && strings.HasSuffix(path, ".json") {
762762
return path, data, true
763763
}
764764
}
765-
765+
766766
case "http":
767767
// HTTP analyzers can work with any network-related data
768768
for path, data := range bundle.Files {
769769
if strings.Contains(path, "services") || strings.Contains(path, "ingress") {
770770
return path, data, true
771771
}
772772
}
773-
773+
774774
case "job-status":
775775
// Job analyzers - look for job resources
776776
for path, data := range bundle.Files {
777777
if strings.Contains(path, "jobs") && strings.HasSuffix(path, ".json") {
778778
return path, data, true
779779
}
780780
}
781-
781+
782782
case "statefulset-status":
783783
// StatefulSet analyzers
784784
for path, data := range bundle.Files {
785785
if strings.Contains(path, "statefulsets") && strings.HasSuffix(path, ".json") {
786786
return path, data, true
787787
}
788788
}
789-
789+
790790
case "replicaset-status":
791791
// ReplicaSet analyzers
792792
for path, data := range bundle.Files {
793793
if strings.Contains(path, "replicasets") && strings.HasSuffix(path, ".json") {
794794
return path, data, true
795795
}
796796
}
797-
797+
798798
case "cluster-pod-statuses":
799799
// Pod status analyzers
800800
for path, data := range bundle.Files {
801801
if strings.Contains(path, "pods") && strings.HasSuffix(path, ".json") {
802802
return path, data, true
803803
}
804804
}
805-
805+
806806
case "image-pull-secret":
807807
// Image pull secret analyzers
808808
for path, data := range bundle.Files {
809809
if strings.Contains(path, "secrets") && strings.HasSuffix(path, ".json") {
810810
return path, data, true
811811
}
812812
}
813-
813+
814814
case "yaml-compare", "json-compare":
815815
// Comparison analyzers - can work with any structured data
816816
for path, data := range bundle.Files {
817817
if strings.HasSuffix(path, ".json") || strings.HasSuffix(path, ".yaml") {
818818
return path, data, true
819819
}
820820
}
821-
821+
822822
case "certificates":
823823
// Certificate analyzers
824824
for path, data := range bundle.Files {
825825
if strings.Contains(path, "cert") || strings.Contains(path, "tls") {
826826
return path, data, true
827827
}
828828
}
829-
829+
830830
case "velero", "longhorn", "ceph-status":
831831
// Storage system analyzers
832832
for path, data := range bundle.Files {
833833
if strings.Contains(strings.ToLower(path), spec.Name) {
834834
return path, data, true
835835
}
836836
}
837-
837+
838838
case "sysctl", "goldpinger", "weave-report", "registry-images":
839839
// Infrastructure analyzers
840840
for path, data := range bundle.Files {
841841
if strings.Contains(strings.ToLower(path), strings.ToLower(spec.Name)) {
842842
return path, data, true
843843
}
844844
}
845-
845+
846846
case "cluster-resource":
847847
// Generic cluster resource analyzer - can work with any cluster data
848848
if data, exists := bundle.Files["cluster-resources/nodes.json"]; exists {

pkg/analyze/ceph.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,9 +249,9 @@ func detailedCephMessage(outcomeMessage string, status CephStatus) string {
249249
}
250250

251251
if status.OsdMap.OsdMap.Full {
252-
msg = append(msg, fmt.Sprintf("OSD disk is full"))
252+
msg = append(msg, "OSD disk is full")
253253
} else if status.OsdMap.OsdMap.NearFull {
254-
msg = append(msg, fmt.Sprintf("OSD disk is nearly full"))
254+
msg = append(msg, "OSD disk is nearly full")
255255
}
256256

257257
if status.PgMap.TotalBytes > 0 {

pkg/analyze/host_kernel_configs.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ func (a *AnalyzeHostKernelConfigs) analyzeSingleNode(content collectedContent, c
7777
for _, config := range hostAnalyzer.SelectedConfigs {
7878
matches := kConfigRegex.FindStringSubmatch(config)
7979
// zero tolerance for invalid kernel config
80-
if matches == nil || len(matches) < 3 {
80+
if len(matches) < 3 {
8181
return nil, errors.Errorf("invalid kernel config: %s", config)
8282
}
8383

0 commit comments

Comments
 (0)