Skip to content

Commit

Permalink
Merge pull request #334 from patrickpichler/fix/various-linter-report…
Browse files Browse the repository at this point in the history
…ed-issues

fix: various linter reported issues
  • Loading branch information
matthisholleville committed Apr 25, 2023
2 parents d4dcc7a + c29860d commit 10f49e6
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 24 deletions.
1 change: 0 additions & 1 deletion cmd/serve/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import (
var (
port string
backend string
token string
)

var ServeCmd = &cobra.Command{
Expand Down
3 changes: 0 additions & 3 deletions pkg/ai/prompts.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,4 @@ package ai

const (
default_prompt = "Simplify the following Kubernetes error message and provide a solution in %s: %s"
prompt_a = "Read the following input %s and provide possible scenarios for remediation in %s"
prompt_b = "Considering the following input from the Kubernetes resource %s and the error message %s, provide possible scenarios for remediation in %s"
prompt_c = "Reading the following %s error message and it's accompanying log message %s, how would you simplify this message?"
)
6 changes: 2 additions & 4 deletions pkg/analyzer/cronjob.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,9 @@ func (analyzer CronJobAnalyzer) Analyze(a common.Analyzer) ([]common.Result, err
"analyzer_name": kind,
})

var results []common.Result

cronJobList, err := a.Client.GetClient().BatchV1().CronJobs(a.Namespace).List(a.Context, v1.ListOptions{})
if err != nil {
return results, err
return nil, err
}

var preAnalysis = map[string]common.PreAnalysis{}
Expand Down Expand Up @@ -114,7 +112,7 @@ func (analyzer CronJobAnalyzer) Analyze(a common.Analyzer) ([]common.Result, err
Name: key,
Error: value.FailureDetails,
}
a.Results = append(results, currentAnalysis)
a.Results = append(a.Results, currentAnalysis)
}
}

Expand Down
32 changes: 16 additions & 16 deletions pkg/analyzer/netpol.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,23 +54,23 @@ func (NetworkPolicyAnalyzer) Analyze(a common.Analyzer) ([]common.Result, error)
},
},
})
continue
}
// Check if policy is not applied to any pods
podList, err := util.GetPodListByLabels(a.Client.GetClient(), a.Namespace, policy.Spec.PodSelector.MatchLabels)
if err != nil {
return nil, err
}
if len(podList.Items) == 0 {
failures = append(failures, common.Failure{
Text: fmt.Sprintf("Network policy is not applied to any pods: %s", policy.Name),
Sensitive: []common.Sensitive{
{
Unmasked: policy.Name,
Masked: util.MaskString(policy.Name),
} else {
// Check if policy is not applied to any pods
podList, err := util.GetPodListByLabels(a.Client.GetClient(), a.Namespace, policy.Spec.PodSelector.MatchLabels)
if err != nil {
return nil, err
}
if len(podList.Items) == 0 {
failures = append(failures, common.Failure{
Text: fmt.Sprintf("Network policy is not applied to any pods: %s", policy.Name),
Sensitive: []common.Sensitive{
{
Unmasked: policy.Name,
Masked: util.MaskString(policy.Name),
},
},
},
})
})
}
}

if len(failures) > 0 {
Expand Down

0 comments on commit 10f49e6

Please sign in to comment.