Skip to content

Commit

Permalink
Add switch to disable kubeconfig (#36)
Browse files Browse the repository at this point in the history
* Add switch to disable kubeconfig

* Change variable disable_local_config to load_config_file

* Fix variable name in the doc

* Fix after review
  • Loading branch information
Serge Ohl authored and radeksimko committed Aug 3, 2017
1 parent 7227105 commit c25963e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
16 changes: 14 additions & 2 deletions kubernetes/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,12 @@ func Provider() terraform.ResourceProvider {
DefaultFunc: schema.EnvDefaultFunc("KUBE_TOKEN", ""),
Description: "Token to authentifcate an service account",
},
"load_config_file": {
Type: schema.TypeBool,
Optional: true,
DefaultFunc: schema.EnvDefaultFunc("KUBE_LOAD_CONFIG_FILE", true),
Description: "Load local kubeconfig.",
},
},

DataSourcesMap: map[string]*schema.Resource{
Expand Down Expand Up @@ -122,8 +128,14 @@ func Provider() terraform.ResourceProvider {
}

func providerConfigure(d *schema.ResourceData) (interface{}, error) {
// Config file loading
cfg, err := tryLoadingConfigFile(d)

var cfg *restclient.Config
var err error
if d.Get("load_config_file").(bool) {
// Config file loading
cfg, err = tryLoadingConfigFile(d)
}

if err != nil {
return nil, err
}
Expand Down
4 changes: 3 additions & 1 deletion website/docs/index.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,6 @@ The following arguments are supported:
* `config_context` - (Optional) Context to choose from the config file. Can be sourced from `KUBE_CTX`.
* `config_context_auth_info` - (Optional) Authentication info context of the kube config (name of the kubeconfig user, `--user` flag in `kubectl`). Can be sourced from `KUBE_CTX_AUTH_INFO`.
* `config_context_cluster` - (Optional) Cluster context of the kube config (name of the kubeconfig cluster, `--cluster` flag in `kubectl`). Can be sourced from `KUBE_CTX_CLUSTER`.
* `token` - (Optional) Token of your service account. Can be sourced from `KUBE_TOKEN`.
* `token` - (Optional) Token of your service account. Can be sourced from `KUBE_TOKEN`.
* `load_config_file` - (Optional) By default the local config (~/.kube/config) is loaded when you use this provider. This option at false disable this behaviour. Can be sourced from `KUBE_LOAD_CONFIG_FILE`.

0 comments on commit c25963e

Please sign in to comment.