8000 allow adding repository using CLI flag by JeanMertz · Pull Request #2 · blendle/kubecrt · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

allow adding repository using CLI flag #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 13, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 12 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,18 +54,20 @@ Where CHARTS_CONFIG is the location of the YAML file
containing the Kubernetes Charts configuration.

Arguments:
CHARTS_CONFIG Charts configuration file
CHARTS_CONFIG Charts configuration file

Options:
-h, --help Show this screen
--version Show version
-n NS, --namespace=NS Set the .Release.Namespace chart variable, used by
Charts during compilation
-a NAME, --name=NAME Set the .Release.Name chart variable, used by charts
during compilation
-o, --output PATH Write output to a file, instead of STDOUT
--example-config Print an example charts.yaml, including extended
documentation on the tunables
-h, --help Show this screen
--version Show version
-n NS, --namespace=NS Set the .Release.Namespace chart variable,
used by charts during compilation
-a NAME, --name=NAME Set the .Release.Name chart variable, used by
charts during compilation
-o PATH, --output=PATH Write output to a file, instead of STDOUT
-r NAME=URL, --repo=NAME=URL,... List of NAME=URL pairs of repositories to add
to the index before compiling charts config
--example-config Print an example charts.yaml, including
extended documentation on the tunables
```

## Charts Configuration File
Expand Down
22 changes: 12 additions & 10 deletions config/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,20 @@ Where CHARTS_CONFIG is the location of the YAML file
containing the Kubernetes Charts configuration.

Arguments:
CHARTS_CONFIG Charts configuration file
CHARTS_CONFIG Charts configuration file

Options:
-h, --help Show this screen
--version Show version
-n NS, --namespace=NS Set the .Release.Namespace chart variable, used by
Charts during compilation
-a NAME, --name=NAME Set the .Release.Name chart variable, used by charts
during compilation
-o, --output PATH Write output to a file, instead of STDOUT
--example-config Print an example charts.yaml, including extended
documentation on the tunables
-h, --help Show this screen
--version Show version
-n NS, --namespace=NS Set the .Release.Namespace chart variable,
used by charts during compilation
-a NAME, --name=NAME Set the .Release.Name chart variable, used by
charts during compilation
-o PATH, --output=PATH Write output to a file, instead of STDOUT
-r NAME=URL, --repo=NAME=URL,... List of NAME=URL pairs of repositories to add
to the index before compiling charts config
--example-config Print an example charts.yaml, including
extended documentation on the tunables
`

// CLI returns the parsed command-line arguments
Expand Down
15 changes: 14 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"io/ioutil"
"os"
"strings"

"github.com/blendle/kubecrt/chartsconfig"
"github.com/blendle/kubecrt/config"
Expand All @@ -12,13 +13,25 @@ import (

func main() {
cli := config.CLI()

opts, err := config.NewCLIOptions(cli)
if err != nil {
fmt.Fprintf(os.Stderr, "kubecrt arguments error: \n\n%s\n", err)
os.Exit(1)
}

if cli["--repo"] != nil {
for _, r := range strings.Split(cli["--repo"].(string), ",") {
p := strings.SplitN(r, "=", 2)
repo := strings.TrimSpace(string(p[0]))
url := strings.TrimSpace(string(p[1]))

if err = helm.AddRepository(repo, url); err != nil {
fmt.Fprintf(os.Stderr, "error adding repository: \n\n%s\n", err)
os.Exit(1)
}
}
}

cfg, err := readInput(opts.ChartsConfigurationPath)
if err != nil {
fmt.Fprintf(os.Stderr, "charts config IO error: \n\n%s\n", err)
Expand Down
0