Skip to content
This repository has been archived by the owner on Feb 7, 2023. It is now read-only.

Commit

Permalink
bugfix: fix flagset parsing, fix value assignment
Browse files Browse the repository at this point in the history
  • Loading branch information
chrischdi committed May 28, 2018
1 parent 83bc9e0 commit d9cd9a3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
2 changes: 2 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# v0.2

* bug: Fix `for`-loops to use break. Otherwise the last item in loop would have been imported.
* bug: Fix value assignment
* bug: Fix correct use of flagset
14 changes: 7 additions & 7 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func readConfig(path string) (*v1.Config, error) {
}

func main() {
flag.Parse()
flags.Parse(os.Args[1:])

conf, err := readConfig("")
if err != nil {
Expand Down Expand Up @@ -130,10 +130,10 @@ func main() {
var exists bool
// check if context having the same name already exists
exists = false
for _, c := range gconf.Contexts {
for i, c := range gconf.Contexts {
if c.Name == ctx.Name {
if force {
c.Context = ctx.Context
gconf.Contexts[i] = *ctx
} else {
fmt.Fprintf(os.Stderr, "WARN: context having the same name (%s) already exists\n", c.Name)
}
Expand All @@ -147,10 +147,10 @@ func main() {

// check if cluster having the same name already exists
exists = false
for _, c := range gconf.Clusters {
for i, c := range gconf.Clusters {
if c.Name == cluster.Name {
if force {
c.Cluster = cluster.Cluster
gconf.Clusters[i] = *cluster
} else {
fmt.Fprintf(os.Stderr, "WARN: cluster information having the same name (%s) already exists\n", c.Name)
}
Expand All @@ -164,10 +164,10 @@ func main() {

// check if authInfo having the same name already exists
exists = false
for _, a := range gconf.AuthInfos {
for i, a := range gconf.AuthInfos {
if a.Name == authInfo.Name {
if force {
a.AuthInfo = authInfo.AuthInfo
gconf.AuthInfos[i] = *authInfo
} else {
fmt.Fprintf(os.Stderr, "WARN: authentication information having the same name (%s) already exists\n", a.Name)
}
Expand Down

0 comments on commit d9cd9a3

Please sign in to comment.