forked from aws/eks-anywhere
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Include configurations for curated packages (aws#2434)
- Loading branch information
1 parent
505da83
commit ef49baa
Showing
17 changed files
with
448 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# Curated Packages Customized Configuration | ||
|
||
## Problem | ||
|
||
Currently, the eks anywhere CLI provides `install` command. This command's aim is to provide the ability for users to install a curated package in the cluster. Currently, this command does not support the ability to override any configurations that would enable the user to customize the curated package. | ||
|
||
## Goals and Objectives | ||
|
||
As a curated packages user, I want to: | ||
|
||
* Provide custom configurations to override default configurations from the CLI | ||
|
||
## Possible Solutions | ||
|
||
### Provide separate key value pairs from the CLI | ||
|
||
The first solution would be to provide separate key value pairs through the cli similar to helm (https://all.docs.genesys.com/PrivateEdition/Current/PEGuide/HelmOverrides) | ||
|
||
*Sample* | ||
|
||
```bash | ||
$ eksctl anywhere install package harbor --set key=key --set key2=key2 | ||
``` | ||
|
||
### Provide consolidated key value pairs from the CLI | ||
|
||
Similar to the first solution, the solution would be to consolidate all the key value pairs into one but separated by a delimiter, similar to cobra (https://github.com/spf13/pflag/pull/133) | ||
|
||
*Sample* | ||
|
||
```bash | ||
$ eksctl anywhere install package harbor --config=key1=key1, key2=key2 | ||
``` | ||
|
||
### Provide key value pair through a file and pass the file to the CLI | ||
|
||
This solution is different than both the previous solution given that it takes a file for the configuration | ||
|
||
*Sample* | ||
|
||
```bash | ||
$ cat config.txt | ||
secretKey=use-a-secret-key | ||
harborAdminPassword=test | ||
$ eksctl anywhere install package harbor --config ./config.txt | ||
``` | ||
|
||
## Proposed Solution | ||
Since the amount of configurations required for curated packages is a limited set, we will be implementing [Provide separate key value pairs from the CLI](#Provide-separate-key-value-pairs-from-the-CLI) option. | ||
|
||
## Customized Configuration Discovery | ||
|
||
In order for the user to identify what configurations are available, the CLI needs to provide a mechanism to identify the configurations available for a package. Similar to helm's show values, we would provide a capability that is inline with this format. | ||
|
||
The command would look like below | ||
|
||
```bash | ||
$ eksctl anywhere install package harbor --source cluster --show-options | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
package curatedpackages | ||
|
||
import ( | ||
"bytes" | ||
"fmt" | ||
"os" | ||
"strings" | ||
"text/tabwriter" | ||
|
||
packagesv1 "github.com/aws/eks-anywhere-packages/api/v1alpha1" | ||
) | ||
|
||
func GetConfigurationsFromBundle(bundlePackage *packagesv1.BundlePackage) map[string]packagesv1.VersionConfiguration { | ||
configs := make(map[string]packagesv1.VersionConfiguration) | ||
if bundlePackage == nil || len(bundlePackage.Source.Versions) < 1 { | ||
return configs | ||
} | ||
packageConfigurations := bundlePackage.Source.Versions[0].Configurations | ||
|
||
for _, config := range packageConfigurations { | ||
configs[config.Name] = config | ||
} | ||
return configs | ||
} | ||
|
||
func UpdateConfigurations(originalConfigs map[string]packagesv1.VersionConfiguration, newConfigs map[string]string) error { | ||
for key, val := range newConfigs { | ||
value, exists := originalConfigs[key] | ||
if !exists { | ||
return fmt.Errorf("invalid key: %s. please specify the correct configurations", key) | ||
} | ||
value.Default = val | ||
originalConfigs[key] = value | ||
} | ||
return nil | ||
} | ||
|
||
func GenerateAllValidConfigurations(configs map[string]packagesv1.VersionConfiguration) string { | ||
b := new(bytes.Buffer) | ||
for key, val := range configs { | ||
if val.Default != "" || val.Required { | ||
fmt.Fprintf(b, "%s: \"%s\"\n", key, val.Default) | ||
} | ||
} | ||
return b.String() | ||
} | ||
|
||
func GenerateDefaultConfigurations(configs map[string]packagesv1.VersionConfiguration) string { | ||
b := new(bytes.Buffer) | ||
for key, val := range configs { | ||
if val.Required { | ||
fmt.Fprintf(b, "%s: \"%s\"\n", key, val.Default) | ||
} | ||
} | ||
return b.String() | ||
} | ||
|
||
func ParseConfigurations(configs []string) (map[string]string, error) { | ||
parsedConfigurations := make(map[string]string) | ||
|
||
for _, c := range configs { | ||
keyval := strings.Split(c, "=") | ||
if len(keyval) < 2 { | ||
return nil, fmt.Errorf("please specify %s as key=value", c) | ||
} | ||
key, val := keyval[0], keyval[1] | ||
parsedConfigurations[key] = val | ||
} | ||
return parsedConfigurations, nil | ||
} | ||
|
||
func DisplayConfigurationOptions(configs map[string]packagesv1.VersionConfiguration) { | ||
w := new(tabwriter.Writer) | ||
defer w.Flush() | ||
w.Init(os.Stdout, minWidth, tabWidth, padding, padChar, flags) | ||
fmt.Fprintf(w, "%s\t%s\t%s\t \n", "Configuration", "Required", "Default") | ||
fmt.Fprintf(w, "%s\t%s\t%s\t \n", "-------------", "--------", "-------") | ||
for key, val := range configs { | ||
fmt.Fprintf(w, "%s\t%v\t%s\t \n", key, val.Required, val.Default) | ||
} | ||
} |
Oops, something went wrong.