Skip to content

Commit ea1efac

Browse files
jrhoustonalexsomesan
authored andcommitted
remove empty provider block check (#1120)
1 parent 080eadc commit ea1efac

File tree

1 file changed

+0
-50
lines changed

1 file changed

+0
-50
lines changed

kubernetes/provider.go

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -217,10 +217,6 @@ func (k kubeClientsets) MainClientset() (*kubernetes.Clientset, error) {
217217
return k.mainClientset, nil
218218
}
219219

220-
if err := checkConfigurationValid(k.configData); err != nil {
221-
return nil, err
222-
}
223-
224220
if k.config != nil {
225221
kc, err := kubernetes.NewForConfig(k.config)
226222
if err != nil {
@@ -245,52 +241,6 @@ func (k kubeClientsets) AggregatorClientset() (*aggregator.Clientset, error) {
245241
return k.aggregatorClientset, nil
246242
}
247243

248-
var apiTokenMountPath = "/var/run/secrets/kubernetes.io/serviceaccount"
249-
250-
func inCluster() bool {
251-
host, port := os.Getenv("KUBERNETES_SERVICE_HOST"), os.Getenv("KUBERNETES_SERVICE_PORT")
252-
if host == "" || port == "" {
253-
return false
254-
}
255-
256-
if _, err := os.Stat(apiTokenMountPath); err != nil {
257-
return false
258-
}
259-
return true
260-
}
261-
262-
var authDocumentationURL = "https://registry.terraform.io/providers/hashicorp/kubernetes/latest/docs#authentication"
263-
264-
func checkConfigurationValid(d *schema.ResourceData) error {
265-
if inCluster() {
266-
log.Printf("[DEBUG] Terraform appears to be running inside the Kubernetes cluster")
267-
return nil
268-
}
269-
270-
if os.Getenv("KUBE_CONFIG_PATHS") != "" {
271-
return nil
272-
}
273-
274-
atLeastOneOf := []string{
275-
"host",
276-
"config_path",
277-
"config_paths",
278-
"client_certificate",
279-
"token",
280-
"exec",
281-
}
282-
for _, a := range atLeastOneOf {
283-
if _, ok := d.GetOk(a); ok {
284-
return nil
285-
}
286-
}
287-
288-
return fmt.Errorf(`provider not configured: you must configure a path to your kubeconfig
289-
or explicitly supply credentials via the provider block or environment variables.
290-
291-
See our documentation at: %s`, authDocumentationURL)
292-
}
293-
294244
func providerConfigure(ctx context.Context, d *schema.ResourceData, terraformVersion string) (interface{}, diag.Diagnostics) {
295245
// Config initialization
296246
cfg, err := initializeConfiguration(d)

0 commit comments

Comments
 (0)