Skip to content

Commit 38e540e

Browse files
Remove flags from audit command and remove auth command (#1138)
* update libs * Remove unused authentication code and dependencies from the Polaris project, streamlining the audit process by eliminating the upload insights feature and related flags. * remove insights reporter * remove lingering libs * update docs * INS-1251: Polaris: upgrade github.com/qri-io/jsonschema to v0.2.1 (#1135) * Bump lins * Code refactoring * Fixign issues * Fixing issues * Fixing issues * Fixing issues * [WIP] * [WIP] * [WIP] * Trying to fix tests * Trying to fix tests * Fixing issues * Fixing issues * Fixing issues * Fixing issues * Fixing issues * Fixing issues * Revert go mod * Revert go mod * Revert go mod * Revert go mod * Fixing issues * Fixing issue * Code refactoring * Updating json schema version * Updating json schema version * fix go mod * fix go sum --------- Co-authored-by: jdesouza <james@fairwinds.com>
1 parent 2b17c31 commit 38e540e

13 files changed

Lines changed: 3 additions & 980 deletions

File tree

cmd/polaris/audit.go

Lines changed: 1 addition & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,8 @@ import (
2424
"net/http"
2525
"os"
2626
"os/exec"
27-
"strings"
2827

29-
workloads "github.com/fairwindsops/insights-plugins/plugins/workloads"
30-
workloadsPkg "github.com/fairwindsops/insights-plugins/plugins/workloads/pkg"
31-
32-
"github.com/fairwindsops/polaris/pkg/auth"
3328
cfg "github.com/fairwindsops/polaris/pkg/config"
34-
"github.com/fairwindsops/polaris/pkg/insights"
3529
"github.com/fairwindsops/polaris/pkg/kube"
3630
"github.com/fairwindsops/polaris/pkg/validator"
3731
"github.com/sirupsen/logrus"
@@ -55,9 +49,6 @@ var (
5549
auditNamespace string
5650
severityLevel string
5751
skipSslValidation bool
58-
uploadInsights bool
59-
clusterName string
60-
quiet bool
6152
)
6253

6354
func init() {
@@ -79,9 +70,6 @@ func init() {
7970
auditCmd.PersistentFlags().StringVar(&auditNamespace, "namespace", "", "Namespace to audit. Only applies to in-cluster audits")
8071
auditCmd.PersistentFlags().StringVar(&severityLevel, "severity", "", "Severity level used to filter results. Behaves like log levels. 'danger' is the least verbose (warning, danger)")
8172
auditCmd.PersistentFlags().BoolVar(&skipSslValidation, "skip-ssl-validation", false, "Skip https certificate verification")
82-
auditCmd.PersistentFlags().BoolVar(&uploadInsights, "upload-insights", false, "Upload scan results to Fairwinds Insights")
83-
auditCmd.PersistentFlags().StringVar(&clusterName, "cluster-name", "", "Set --cluster-name to a descriptive name for the cluster you're auditing")
84-
auditCmd.PersistentFlags().BoolVar(&quiet, "quiet", false, "Suppress the 'upload to Insights' prompt.")
8573
}
8674

8775
var auditCmd = &cobra.Command{
@@ -120,23 +108,6 @@ var auditCmd = &cobra.Command{
120108
os.Exit(1)
121109
}
122110
}
123-
if uploadInsights && len(clusterName) == 0 {
124-
logrus.Error("cluster-name is required when using --upload-insights")
125-
os.Exit(1)
126-
}
127-
if uploadInsights {
128-
if auditPath != "" {
129-
logrus.Errorf("upload-insights and audit-path are not supported when used simultaneously")
130-
os.Exit(1)
131-
}
132-
if !auth.IsLoggedIn() {
133-
err := auth.HandleLogin(insightsHost)
134-
if err != nil {
135-
logrus.Errorf("error handling logging: %v", err)
136-
os.Exit(1)
137-
}
138-
}
139-
}
140111

141112
ctx := context.TODO()
142113
k, err := kube.CreateResourceProvider(ctx, auditPath, resourceToAudit, config)
@@ -151,43 +122,7 @@ var auditCmd = &cobra.Command{
151122
os.Exit(1)
152123
}
153124

154-
if uploadInsights {
155-
auth, err := auth.GetAuth(insightsHost)
156-
if err != nil {
157-
logrus.Errorf("getting auth: %v", err)
158-
os.Exit(1)
159-
}
160-
// fetch workloads using workload plugin... or should we adapt the workloads from above?
161-
dynamicClient, restMapper, clientSet, host, err := kube.GetKubeClient(ctx, "")
162-
if err != nil {
163-
logrus.Errorf("getting the kubernetes client: %v", err)
164-
os.Exit(1)
165-
}
166-
k8sResources, err := workloadsPkg.CreateResourceProviderFromAPI(ctx, dynamicClient, restMapper, clientSet, host)
167-
if err != nil {
168-
logrus.Errorf("creating resource provider: %v", err)
169-
os.Exit(1)
170-
}
171-
172-
insightsClient := insights.NewHTTPClient(insightsHost, auth.Organization, auth.Token)
173-
insightsReporter := insights.NewInsightsReporter(insightsClient)
174-
wr := insights.WorkloadsReport{Version: workloads.Version, Payload: *k8sResources}
175-
pr := insights.PolarisReport{Version: version, Payload: auditData}
176-
logrus.Infof("Uploading to Fairwinds Insights organization '%s/%s'...", auth.Organization, clusterName)
177-
err = insightsReporter.ReportAuditToFairwindsInsights(clusterName, wr, pr)
178-
if err != nil {
179-
logrus.Errorf("reporting audit file to insights: %v", err)
180-
os.Exit(1)
181-
}
182-
os.Stderr.WriteString("\n\nSuccess! You can see your results at:")
183-
os.Stderr.WriteString(fmt.Sprintf("\n\n%s/orgs/%s/clusters/%s/action-items\n\n", insightsHost, auth.Organization, clusterName))
184-
} else {
185-
outputAudit(auditData, auditOutputFile, auditOutputURL, auditOutputFormat, useColor, onlyShowFailedTests, severityLevel)
186-
if !quiet {
187-
os.Stderr.WriteString("\n\n🚀 Upload your Polaris findings to Fairwinds Insights to see remediation advice, add teammates, integrate with Slack or Jira, and more:")
188-
os.Stderr.WriteString("\n\n❯ polaris " + strings.Join(os.Args[1:], " ") + " --upload-insights --cluster-name=my-cluster\n\n")
189-
}
190-
}
125+
outputAudit(auditData, auditOutputFile, auditOutputURL, auditOutputFormat, useColor, onlyShowFailedTests, severityLevel)
191126

192127
summary := auditData.GetSummary()
193128
score := summary.GetScore()

cmd/polaris/auth.go

Lines changed: 0 additions & 81 deletions
This file was deleted.

docs/cli.md

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ meta:
99
# top-level commands
1010
audit
1111
Runs a one-time audit.
12-
auth
13-
Authenticate polaris with Fairwinds Insights
1412
dashboard
1513
Runs the webserver for Polaris dashboard.
1614
fix
@@ -44,7 +42,6 @@ webhook
4442
# audit flags
4543
--audit-path string If specified, audits one or more YAML files instead of a cluster.
4644
--checks strings Optional flag to specify specific checks to check
47-
--cluster-name string Set --cluster-name to a descriptive name for the cluster you're auditing
4845
--color Whether to use color in pretty format. (default true)
4946
--display-name string An optional identifier for the audit.
5047
-f, --format string Output format for results - json, yaml, pretty, or score. (default "json")
@@ -56,13 +53,11 @@ webhook
5653
--only-show-failed-tests If specified, audit output will only show failed tests.
5754
--output-file string Destination file for audit results.
5855
--output-url string Destination URL to send audit results.
59-
--quiet Suppress the 'upload to Insights' prompt.
6056
--resource string Audit a specific resource, in the format namespace/kind/version/name, e.g. nginx-ingress/Deployment.apps/v1/default-backend.
6157
--set-exit-code-below-score int Set an exit code of 4 when the score is below this threshold (1-100).
6258
--set-exit-code-on-danger Set an exit code of 3 when the audit contains danger-level issues.
6359
--severity string Severity level used to filter results. Behaves like log levels. 'danger' is the least verbose (warning, danger)
6460
--skip-ssl-validation Skip https certificate verification
65-
--upload-insights Upload scan results to Fairwinds Insights
6661
6762
# fix flags
6863
--checks strings Optional flag to specify specific checks to fix eg. checks=hostIPCSet,hostPIDSet and checks=all applies fix to all defined checks mutations
@@ -76,15 +71,4 @@ webhook
7671
-h, --help help for webhook
7772
-p, --port int Port for the dashboard webserver. (default 9876)
7873
79-
# auth sub-commands
80-
login Authenticate polaris with Fairwinds Insights.
81-
logout Log out of a Fairwinds Insights.
82-
status View authentication status.
83-
token Print the auth token gh is configured to use.
8474
```
85-
86-
#### Suppressing 'upload to Insights' output
87-
88-
When running the `polaris audit` subcommand, you can suppress the following output using the `--quiet flag`:
89-
90-
> 🚀 Upload your Polaris findings to Fairwinds Insights to see remediation advice, add teammates, integrate with Slack or Jira, and more:

go.mod

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@ module github.com/fairwindsops/polaris
33
go 1.24.4
44

55
require (
6-
github.com/AlecAivazis/survey/v2 v2.3.7
76
github.com/fairwindsops/controller-utils v0.3.4
8-
github.com/fairwindsops/insights-plugins/plugins/workloads v0.0.0-20250613143236-883a20aaf1f1
97
github.com/fatih/color v1.18.0
108
github.com/gorilla/mux v1.8.1
119
github.com/pkg/errors v0.9.1
@@ -29,6 +27,7 @@ require (
2927
github.com/cespare/xxhash/v2 v2.3.0 // indirect
3028
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
3129
github.com/emicklei/go-restful/v3 v3.12.2 // indirect
30+
github.com/evanphx/json-patch v5.9.0+incompatible // indirect
3231
github.com/evanphx/json-patch/v5 v5.9.11 // indirect
3332
github.com/fsnotify/fsnotify v1.9.0 // indirect
3433
github.com/fxamacker/cbor/v2 v2.8.0 // indirect
@@ -44,11 +43,9 @@ require (
4443
github.com/inconshreveable/mousetrap v1.1.0 // indirect
4544
github.com/josharian/intern v1.0.0 // indirect
4645
github.com/json-iterator/go v1.1.12 // indirect
47-
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect
4846
github.com/mailru/easyjson v0.9.0 // indirect
4947
github.com/mattn/go-colorable v0.1.14 // indirect
5048
github.com/mattn/go-isatty v0.0.20 // indirect
51-
github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d // indirect
5249
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
5350
github.com/modern-go/reflect2 v1.0.2 // indirect
5451
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
@@ -69,6 +66,7 @@ require (
6966
google.golang.org/protobuf v1.36.6 // indirect
7067
gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect
7168
gopkg.in/inf.v0 v0.9.1 // indirect
69+
k8s.io/apiextensions-apiserver v0.33.1 // indirect
7270
k8s.io/klog/v2 v2.130.1 // indirect
7371
k8s.io/kube-openapi v0.0.0-20250610211856-8b98d1ed966a // indirect
7472
k8s.io/utils v0.0.0-20250604170112-4c0f3b243397 // indirect

0 commit comments

Comments
 (0)