Skip to content

Commit

Permalink
Merge pull request #2 from blendle/repo-flag
Browse files Browse the repository at this point in the history
allow adding repository using CLI flag
  • Loading branch information
JeanMertz authored May 13, 2017
2 parents 52f509f + a50cae2 commit ed49658
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 21 deletions.
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 comments on commit ed49658

Please sign in to comment.