Skip to content

Commit

Permalink
Fix flag parsing (#118)
Browse files Browse the repository at this point in the history
* Remove flag parsing

* Continue flag parsing on error

* Fix flags for new flag set

* Disable code signing for PRs
  • Loading branch information
ricoberger committed Jun 24, 2020
1 parent 5c6cb7f commit 95e2465
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 14 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ jobs:

- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Setup Node.js
uses: actions/setup-node@v1
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Set Docker Tag
if: ${{ github.event_name == 'push' }}
Expand Down
14 changes: 8 additions & 6 deletions cmd/electron/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"flag"
"fmt"
"net/http"
"os"
"strings"

"github.com/kubenav/kubenav/pkg/electron"
Expand All @@ -26,11 +27,12 @@ var (
)

var (
debugFlag = flag.Bool("debug", false, "Enable debug mode.")
kubeconfigFlag = flag.String("kubeconfig", "", "Optional Kubeconfig file.")
kubeconfigIncludeFlag = flag.String("kubeconfig-include", "", "Comma separated list of globs to include in the Kubeconfig.")
kubeconfigExcludeFlag = flag.String("kubeconfig-exclude", "", "Comma separated list of globs to exclude from the Kubeconfig. This flag must be used in combination with the '-kubeconfig-include' flag.")
syncFlag = flag.Bool("sync", false, "Sync the changes from kubenav with the used Kubeconfig file.")
fs = flag.NewFlagSet(os.Args[0], flag.ContinueOnError)
debugFlag = fs.Bool("debug", false, "Enable debug mode.")
kubeconfigFlag = fs.String("kubeconfig", "", "Optional Kubeconfig file.")
kubeconfigIncludeFlag = fs.String("kubeconfig-include", "", "Comma separated list of globs to include in the Kubeconfig.")
kubeconfigExcludeFlag = fs.String("kubeconfig-exclude", "", "Comma separated list of globs to exclude from the Kubeconfig. This flag must be used in combination with the '-kubeconfig-include' flag.")
syncFlag = fs.Bool("sync", false, "Sync the changes from kubenav with the used Kubeconfig file.")
)

// Message is the structure of a Server Sent Event, which contains the Event and Data. Server Sent Events are used to
Expand All @@ -44,7 +46,7 @@ var messageChannel = make(chan Message)

func main() {
// Parse command-line flags.
flag.Parse()
fs.Parse(os.Args[1:])

// Setup the logger and print the version information.
log := logrus.StandardLogger()
Expand Down
18 changes: 10 additions & 8 deletions cmd/server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"io/ioutil"
"net/http"
"os"
"strings"

"github.com/kubenav/kubenav/pkg/electron"
Expand All @@ -16,17 +17,18 @@ import (
)

var (
debugFlag = flag.Bool("debug", false, "Enable debug mode.")
incluster = flag.Bool("incluster", false, "Use the in cluster configuration. Only needed for a Kubernetes based Deployment using the Docker image.")
kubeconfigFlag = flag.String("kubeconfig", "", "Optional Kubeconfig file.")
kubeconfigIncludeFlag = flag.String("kubeconfig-include", "", "Comma separated list of globs to include in the Kubeconfig.")
kubeconfigExcludeFlag = flag.String("kubeconfig-exclude", "", "Comma separated list of globs to exclude from the Kubeconfig. This flag must be used in combination with the '-kubeconfig-include' flag.")
syncFlag = flag.Bool("sync", false, "Sync the changes from kubenav with the used Kubeconfig file.")
fs = flag.NewFlagSet(os.Args[0], flag.ContinueOnError)
debugFlag = fs.Bool("debug", false, "Enable debug mode.")
inclusterFlag = fs.Bool("incluster", false, "Use the in cluster configuration. Only needed for a Kubernetes based Deployment using the Docker image.")
kubeconfigFlag = fs.String("kubeconfig", "", "Optional Kubeconfig file.")
kubeconfigIncludeFlag = fs.String("kubeconfig-include", "", "Comma separated list of globs to include in the Kubeconfig.")
kubeconfigExcludeFlag = fs.String("kubeconfig-exclude", "", "Comma separated list of globs to exclude from the Kubeconfig. This flag must be used in combination with the '-kubeconfig-include' flag.")
syncFlag = fs.Bool("sync", false, "Sync the changes from kubenav with the used Kubeconfig file.")
)

func main() {
// Parse command-line flags.
flag.Parse()
fs.Parse(os.Args[1:])

// Setup the logger and print the version information.
log := logrus.StandardLogger()
Expand All @@ -41,7 +43,7 @@ func main() {
log.Infof(version.BuildContext())

// Create the client for the interaction with the Kubernetes API.
client, err := kube.NewClient(*incluster, *kubeconfigFlag, *kubeconfigIncludeFlag, *kubeconfigExcludeFlag)
client, err := kube.NewClient(*inclusterFlag, *kubeconfigFlag, *kubeconfigIncludeFlag, *kubeconfigExcludeFlag)
if err != nil {
log.WithError(err).Fatalf("Could not create Kubernetes client")
}
Expand Down

0 comments on commit 95e2465

Please sign in to comment.