Skip to content

Commit

Permalink
Added proxy_url config. See #75
Browse files Browse the repository at this point in the history
  • Loading branch information
alekc committed Dec 6, 2023
1 parent ca6ec65 commit 9c07d38
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ The following arguments are supported:
* `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`.
* `proxy_url` - (Optional) URL to the proxy to be used for all API requests. URLs with "http", "https", and "socks5" schemes are supported. Can be sourced from `KUBE_PROXY_URL`.
* `exec` - (Optional) Configuration block to use an [exec-based credential plugin] (https://kubernetes.io/docs/reference/access-authn-authz/authentication/#client-go-credential-plugins), e.g. call an external command to receive user credentials.
* `api_version` - (Required) API version to use when decoding the ExecCredentials resource, e.g. `client.authentication.k8s.io/v1beta1`.
* `command` - (Required) Command to execute.
Expand Down
9 changes: 9 additions & 0 deletions kubernetes/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,12 @@ func Provider() *schema.Provider {
DefaultFunc: schema.EnvDefaultFunc("KUBE_TOKEN", ""),
Description: "Token to authentifcate an service account",
},
"proxy_url": {
Type: schema.TypeString,
Optional: true,
Description: "URL to the proxy to be used for all API requests",
DefaultFunc: schema.EnvDefaultFunc("KUBE_PROXY_URL", ""),
},
"load_config_file": {
Type: schema.TypeBool,
Optional: true,
Expand Down Expand Up @@ -374,6 +380,9 @@ func initializeConfiguration(d *schema.ResourceData) (*restclient.Config, error)
if v, ok := d.GetOk("token"); ok {
overrides.AuthInfo.Token = v.(string)
}
if v, ok := d.GetOk("proxy_url"); ok {
overrides.ClusterDefaults.ProxyURL = v.(string)
}

cc := clientcmd.NewNonInteractiveDeferredLoadingClientConfig(loader, overrides)
cfg, err := cc.ClientConfig()
Expand Down

0 comments on commit 9c07d38

Please sign in to comment.