Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
sixolet committed Jun 19, 2019
1 parent 8a1d412 commit 257e6d4
Show file tree
Hide file tree
Showing 142 changed files with 22,139 additions and 2 deletions.
1 change: 1 addition & 0 deletions docs/cmd/kn.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Eventing: Manage event subscriptions and channels. Connect up event sources.
### Options

```
--config string config file (default is $HOME/.kn.yaml)
-h, --help help for kn
--kubeconfig string kubectl config file (default is $HOME/.kube/config)
```
Expand Down
1 change: 1 addition & 0 deletions docs/cmd/kn_completion.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ kn completion [flags]
### Options inherited from parent commands

```
--config string config file (default is $HOME/.kn.yaml)
--kubeconfig string kubectl config file (default is $HOME/.kube/config)
```

Expand Down
1 change: 1 addition & 0 deletions docs/cmd/kn_revision.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Revision command group
### Options inherited from parent commands

```
--config string config file (default is $HOME/.kn.yaml)
--kubeconfig string kubectl config file (default is $HOME/.kube/config)
```

Expand Down
1 change: 1 addition & 0 deletions docs/cmd/kn_revision_describe.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ kn revision describe NAME [flags]
### Options inherited from parent commands

```
--config string config file (default is $HOME/.kn.yaml)
--kubeconfig string kubectl config file (default is $HOME/.kube/config)
```

Expand Down
1 change: 1 addition & 0 deletions docs/cmd/kn_revision_list.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ kn revision list [flags]
### Options inherited from parent commands

```
--config string config file (default is $HOME/.kn.yaml)
--kubeconfig string kubectl config file (default is $HOME/.kube/config)
```

Expand Down
1 change: 1 addition & 0 deletions docs/cmd/kn_service.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Service command group
### Options inherited from parent commands

```
--config string config file (default is $HOME/.kn.yaml)
--kubeconfig string kubectl config file (default is $HOME/.kube/config)
```

Expand Down
1 change: 1 addition & 0 deletions docs/cmd/kn_service_create.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ kn service create NAME --image IMAGE [flags]
### Options inherited from parent commands

```
--config string config file (default is $HOME/.kn.yaml)
--kubeconfig string kubectl config file (default is $HOME/.kube/config)
```

Expand Down
1 change: 1 addition & 0 deletions docs/cmd/kn_service_delete.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ kn service delete NAME [flags]
### Options inherited from parent commands

```
--config string config file (default is $HOME/.kn.yaml)
--kubeconfig string kubectl config file (default is $HOME/.kube/config)
```

Expand Down
1 change: 1 addition & 0 deletions docs/cmd/kn_service_describe.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ kn service describe NAME [flags]
### Options inherited from parent commands

```
--config string config file (default is $HOME/.kn.yaml)
--kubeconfig string kubectl config file (default is $HOME/.kube/config)
```

Expand Down
1 change: 1 addition & 0 deletions docs/cmd/kn_service_list.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ kn service list [flags]
### Options inherited from parent commands

```
--config string config file (default is $HOME/.kn.yaml)
--kubeconfig string kubectl config file (default is $HOME/.kube/config)
```

Expand Down
1 change: 1 addition & 0 deletions docs/cmd/kn_service_update.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ kn service update NAME [flags]
### Options inherited from parent commands

```
--config string config file (default is $HOME/.kn.yaml)
--kubeconfig string kubectl config file (default is $HOME/.kube/config)
```

Expand Down
1 change: 1 addition & 0 deletions docs/cmd/kn_version.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ kn version [flags]
### Options inherited from parent commands

```
--config string config file (default is $HOME/.kn.yaml)
--kubeconfig string kubectl config file (default is $HOME/.kube/config)
```

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ require (
github.com/peterbourgon/diskv v2.0.1+incompatible // indirect
github.com/spf13/cobra v0.0.3
github.com/spf13/pflag v1.0.3
github.com/spf13/viper v1.3.1 // indirect
github.com/spf13/viper v1.3.1
github.com/stretchr/objx v0.2.0 // indirect
go.uber.org/atomic v1.4.0 // indirect
go.uber.org/multierr v1.1.0 // indirect
Expand Down
1 change: 1 addition & 0 deletions pkg/kn/commands/test_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ Eventing: Manage event subscriptions and channels. Connect up event sources.`,
if params.Output != nil {
rootCmd.SetOutput(params.Output)
}
rootCmd.PersistentFlags().StringVar(&CfgFile, "config", "", "config file (default is $HOME/.kn.yaml)")
rootCmd.PersistentFlags().StringVar(&KubeCfgFile, "kubeconfig", "", "kubectl config file (default is $HOME/.kube/config)")

rootCmd.AddCommand(subCommand)
Expand Down
3 changes: 3 additions & 0 deletions pkg/kn/commands/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ import (
"k8s.io/client-go/tools/clientcmd"
)

// CfgFile is Kn's config file is the path for the Kubernetes config
var CfgFile string

// KubeCfgFile is the path for the Kubernetes config
var KubeCfgFile string

Expand Down
30 changes: 30 additions & 0 deletions pkg/kn/core/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"github.com/knative/client/pkg/kn/commands/service"
homedir "github.com/mitchellh/go-homedir"
"github.com/spf13/cobra"
"github.com/spf13/viper"
_ "k8s.io/client-go/plugin/pkg/client/auth/gcp"
_ "k8s.io/client-go/plugin/pkg/client/auth/oidc"
)
Expand Down Expand Up @@ -62,6 +63,7 @@ Eventing: Manage event subscriptions and channels. Connect up event sources.`,
if p.Output != nil {
rootCmd.SetOutput(p.Output)
}
rootCmd.PersistentFlags().StringVar(&commands.CfgFile, "config", "", "config file (default is $HOME/.kn.yaml)")
rootCmd.PersistentFlags().StringVar(&commands.KubeCfgFile, "kubeconfig", "", "kubectl config file (default is $HOME/.kube/config)")

rootCmd.AddCommand(service.NewServiceCommand(p))
Expand All @@ -75,7 +77,9 @@ Eventing: Manage event subscriptions and channels. Connect up event sources.`,
}

func InitializeConfig() {
cobra.OnInitialize(initConfig)
cobra.OnInitialize(initKubeConfig)

}

func initKubeConfig() {
Expand All @@ -93,3 +97,29 @@ func initKubeConfig() {
commands.KubeCfgFile = filepath.Join(home, ".kube", "config")
}
}

// initConfig reads in config file and ENV variables if set.
func initConfig() {
if commands.CfgFile != "" {
// Use config file from the flag.
viper.SetConfigFile(commands.CfgFile)
} else {
// Find home directory.
home, err := homedir.Dir()
if err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}

// Search config in home directory with name ".kn" (without extension).
viper.AddConfigPath(home)
viper.SetConfigName(".kn")
}

viper.AutomaticEnv() // read in environment variables that match

// If a config file is found, read it in.
if err := viper.ReadInConfig(); err == nil {
fmt.Fprintln(os.Stderr, "Using config file:", viper.ConfigFileUsed())
}
}
5 changes: 5 additions & 0 deletions vendor/github.com/fsnotify/fsnotify/.editorconfig

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions vendor/github.com/fsnotify/fsnotify/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 30 additions & 0 deletions vendor/github.com/fsnotify/fsnotify/.travis.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

52 changes: 52 additions & 0 deletions vendor/github.com/fsnotify/fsnotify/AUTHORS

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 28 additions & 0 deletions vendor/github.com/fsnotify/fsnotify/LICENSE

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

37 changes: 37 additions & 0 deletions vendor/github.com/fsnotify/fsnotify/fen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 257e6d4

Please sign in to comment.