Improve get-values-overrides help

Change-Id: I59b763b6109ad7af63c3d5484a03773915b23493
This commit is contained in:
Vladimir Kozhukalov 2024-05-09 11:55:28 -05:00
parent 611f0cefdc
commit 5b1bcd99ab
3 changed files with 47 additions and 18 deletions

View File

@ -1,6 +1,6 @@
# Install
```
helm plugin install https://github.com/kubepro/helm-plugin-osh.git
helm plugin install https://opendev.org/openstack/openstack-helm-plugin.git
```
# Uninstall
@ -11,25 +11,38 @@ helm plugin uninstall osh
# Usage
## get-values-overrides
Get Helm values overrides for a set of features.
If 3 features are passed, then the overrides will be looked
up in the following order:
```
helm osh get-values-overrides [-d/--download] [-p/--path <lookup_path>] [-u/--url <base_url>] <chart> <feature-1> <feature-2> ...
<overrides_path>/<chart>/values_overrides/<feature-3>.yaml
<overrides_path>/<chart>/values_overrides/<feature-2>.yaml
<overrides_path>/<chart>/values_overrides/<feature-2>-<feature-3>.yaml
<overrides_path>/<chart>/values_overrides/<feature-1>.yaml
<overrides_path>/<chart>/values_overrides/<feature-1>-<feature-3>.yaml
<overrides_path>/<chart>/values_overrides/<feature-1>-<feature-2>.yaml
<overrides_path>/<chart>/values_overrides/<feature-1>-<feature-2>-<feature-3>.yaml
```
- `-d/--download` download overrides if not found locally in the path
- `-u/--url <base_url>` the base url from where the plugin tries to download overrides. The resulting url is `<base_url>/<chart>/values_overrides/<override_candidate>`
- `-p/--path <lookup_path>` the path where the plugin tries to find override files and puts downloaded override files. The resulting path is `<lookup_path>/<chart>/values_overrides/<override_candidate>`
- `<chart>` the chart name for which the plugin tries to find overrides
- `<feature-X>` features in the beginning of the list are of higher priority
If you think of the features as bits of a binary number where <feature3> is
the least significant bit, then the order corresponds to all numbers from 001
to 111 in binary representation.
If there are 3 features in the list, then the order of override candidates will be like follows:
Usage:
```
<lookup_path>/<chart>/values_overrides/<feature-3>.yaml
<lookup_path>/<chart>/values_overrides/<feature-2>.yaml
<lookup_path>/<chart>/values_overrides/<feature-2>-<feature-3>.yaml
<lookup_path>/<chart>/values_overrides/<feature-1>.yaml
<lookup_path>/<chart>/values_overrides/<feature-1>-<feature-3>.yaml
<lookup_path>/<chart>/values_overrides/<feature-1>-<feature-2>.yaml
<lookup_path>/<chart>/values_overrides/<feature-1>-<feature-2>-<feature-3>.yaml
get-values-overrides <feature1> <feature2> ... [flags]
```
Flags:
```
-c, --chart string Chart to get the overrides for
-d, --download Download the overrides from the internet if not found in the path (default: false)
-h, --help help for get-values-overrides
-p, --path string Path to the overrides (default "$(pwd)")
-s, --subchart string Subchart to get the overrides for
-u, --url string Base url to download overrides (default "https://opendev.org/openstack/openstack-helm/raw/branch/master")
```
## wait-for-pods

Binary file not shown.

22
main.go
View File

@ -39,7 +39,23 @@ func newRootCommand() *cobra.Command {
cwd, _ = os.Getwd()
rootCmd := &cobra.Command{
Use: "get-values-overrides",
Use: "get-values-overrides <feature1> <feature2> ...",
Long: `Get Helm values overrides for a set of features.
If 3 features are passed, then the overrides will be looked
up in the following order:
<overrides_path>/<chart>/values_overrides/<feature-3>.yaml
<overrides_path>/<chart>/values_overrides/<feature-2>.yaml
<overrides_path>/<chart>/values_overrides/<feature-2>-<feature-3>.yaml
<overrides_path>/<chart>/values_overrides/<feature-1>.yaml
<overrides_path>/<chart>/values_overrides/<feature-1>-<feature-3>.yaml
<overrides_path>/<chart>/values_overrides/<feature-1>-<feature-2>.yaml
<overrides_path>/<chart>/values_overrides/<feature-1>-<feature-2>-<feature-3>.yaml
If you think of the features as bits of a binary number where <feature3> is
the least significant bit, then the order corresponds to all numbers from 001
to 111 in binary representation.`,
Run: func(cmd *cobra.Command, args []string) {
features := args[0:]
if len(features) == 0 {
@ -49,7 +65,7 @@ func newRootCommand() *cobra.Command {
fmt.Fprintf(os.Stderr, "Base URL: %s\nBase path: %s\n", baseUrl, basePath)
fmt.Fprintf(os.Stderr, "Chart: %s\n", chart)
if subchart != "" {
fmt.Fprintf(os.Stderr, " Subchart: %s\n", subchart)
fmt.Fprintf(os.Stderr, "Subchart: %s\n", subchart)
}
fmt.Fprintf(os.Stderr, "Features: %s\n", strings.Join(features, " "))
overrideCandidates := generateOverrideCandidates(features)
@ -58,7 +74,7 @@ func newRootCommand() *cobra.Command {
fmt.Println(strings.Join(overrideArgs, " "))
},
}
rootCmd.Flags().BoolVarP(&download, "download", "d", false, "Download the overrides from the internet if does not exist in the path (default: false)")
rootCmd.Flags().BoolVarP(&download, "download", "d", false, "Download the overrides from the internet if not found in the path (default: false)")
rootCmd.Flags().StringVarP(&baseUrl, "url", "u", DefaultBaseUrl, "Base url to download overrides")
rootCmd.Flags().StringVarP(&basePath, "path", "p", cwd, "Path to the overrides")
rootCmd.Flags().StringVarP(&subchart, "subchart", "s", "", "Subchart to get the overrides for")