Skip to content

Commit d5a7106

Browse files
committed
fixup! Require one of kubeconfig_path or kubeconfig_raw fix #90
1 parent 74b1225 commit d5a7106

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

kustomize/provider.go

+8-5
Original file line numberDiff line numberDiff line change
@@ -79,20 +79,23 @@ func Provider() *schema.Provider {
7979
if raw != "" {
8080
config, err = getClientConfig([]byte(raw), context)
8181
if err != nil {
82-
config = &rest.Config{}
82+
return nil, fmt.Errorf("provider kustomization: kubeconfig_raw: %s", err)
8383
}
8484
}
8585

8686
if raw == "" && path != "" {
8787
data, _ = readKubeconfigFile(path)
8888
config, err = getClientConfig(data, context)
8989
if err != nil {
90-
config = &rest.Config{}
90+
return nil, fmt.Errorf("provider kustomization: kubeconfig_path: %s", err)
9191
}
9292
}
9393

94+
// empty default config required to support
95+
// using a cluster resource or data source
96+
// that may not exist yet, to configure the provider
9497
if config == nil {
95-
return nil, fmt.Errorf("provider kustomization: no configuration: `kubeconfig_path` or `kubeconfig_raw` required")
98+
config = &rest.Config{}
9699
}
97100

98101
// Increase QPS and Burst rate limits
@@ -101,12 +104,12 @@ func Provider() *schema.Provider {
101104

102105
client, err := dynamic.NewForConfig(config)
103106
if err != nil {
104-
return nil, err
107+
return nil, fmt.Errorf("provider kustomization: %s", err)
105108
}
106109

107110
clientset, err := kubernetes.NewForConfig(config)
108111
if err != nil {
109-
return nil, err
112+
return nil, fmt.Errorf("provider kustomization: %s", err)
110113
}
111114

112115
cgvk := newCachedGroupVersionKind(clientset)

0 commit comments

Comments
 (0)