Skip to content

Commit

Permalink
Added helm version in the nova output (#25)
Browse files Browse the repository at this point in the history
* added helm version in the nova output

* update readme and file_test
  • Loading branch information
makoscafee authored Dec 3, 2020
1 parent 725b6da commit 2a8eae4
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 8 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ nova find --helm-version=auto --wide

### Options
* `--helm-version` - which version of Helm to use. Options are `2`, `3`, and `auto` (default is `3`)
* `--wide` - show `Chart Name` and `Namespace`
* `--wide` - show `Chart Name`, `Namespace` and `HelmVersion`
* `--output-file` - output JSON to a file
* `--url strings`, `-u` - URL for a helm chart repo (default [https://charts.fairwinds.com/stable,https://charts.fairwinds.com/incubator,https://kubernetes-charts.storage.googleapis.com,https://kubernetes-charts-incubator.storage.googleapis.com,https://charts.jetstack.io])
* `--poll-helm-hub` - When true, polls all helm repos that publish to helm hub (Default is true).
Expand Down Expand Up @@ -106,6 +106,7 @@ nginx-ingress 1.25.0 1.40.3 true false
"version": "v0.16.0",
"appVersion": "v0.16.0"
},
"helmVersion": "v3",
"outdated": true,
"deprecated": false
}
Expand Down
10 changes: 6 additions & 4 deletions pkg/helm/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,9 @@ func (h *Helm) GetHelmReleasesVersion3(helmRepos []*Repo) ([]output.ReleaseOutpu
Version: newest.Version,
AppVersion: newest.AppVersion,
},
Deprecated: chart.Chart.Metadata.Deprecated,
IsOld: version.Compare(newest.Version, chart.Chart.Metadata.Version, ">"),
HelmVersion: "v3",
Deprecated: chart.Chart.Metadata.Deprecated,
IsOld: version.Compare(newest.Version, chart.Chart.Metadata.Version, ">"),
}
outputObjects = append(outputObjects, rls)
}
Expand Down Expand Up @@ -113,8 +114,9 @@ func (h *Helm) GetHelmReleasesVersion2(helmRepos []*Repo) ([]output.ReleaseOutpu
Version: newest.Version,
AppVersion: newest.AppVersion,
},
Deprecated: chart.Chart.Metadata.Deprecated,
IsOld: version.Compare(newest.Version, chart.Chart.Metadata.Version, ">"),
HelmVersion: "v2",
Deprecated: chart.Chart.Metadata.Deprecated,
IsOld: version.Compare(newest.Version, chart.Chart.Metadata.Version, ">"),
}
outputObjects = append(outputObjects, rls)
}
Expand Down
1 change: 1 addition & 0 deletions pkg/output/file_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ func TestFileOutput_Send(t *testing.T) {
Version: "1.0",
AppVersion: "2.0.0",
},
HelmVersion: "v3",
Home: "https://wiki.example.com",
Deprecated: false,
Description: "Test description for foo chart",
Expand Down
8 changes: 5 additions & 3 deletions pkg/output/output.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,9 @@ type ReleaseOutput struct {
Icon string `json:"icon,omitempty"`
Installed VersionInfo
Latest VersionInfo
IsOld bool `json:"outdated"`
Deprecated bool `json:"deprecated"`
IsOld bool `json:"outdated"`
Deprecated bool `json:"deprecated"`
HelmVersion string `json:"helmVersion"`
}

// VersionInfo contains both a chart version and an app version
Expand Down Expand Up @@ -72,7 +73,7 @@ func (output Output) Print(wide bool) {
w := tabwriter.NewWriter(os.Stdout, 0, 4, 4, ' ', 0)
header := "Release Name\t"
if wide {
header += "Chart Name\tNamespace\t"
header += "Chart Name\tNamespace\tHelmVersion\t"
}
header += "Installed\tLatest\tOld\tDeprecated"
fmt.Fprintln(w, header)
Expand All @@ -82,6 +83,7 @@ func (output Output) Print(wide bool) {
if wide {
line += release.ChartName + "\t"
line += release.Namespace + "\t"
line += release.HelmVersion + "\t"
}
line += release.Installed.Version + "\t"
line += release.Latest.Version + "\t"
Expand Down

0 comments on commit 2a8eae4

Please sign in to comment.