@@ -31,37 +31,38 @@ import (
3131)
3232
3333type config struct {
34- AssetDir string `hcl:"asset_dir"`
35- CachedInstall string `hcl:"cached_install,optional"`
36- ClusterName string `hcl:"cluster_name"`
37- ControllerDomains []string `hcl:"controller_domains"`
38- ControllerMacs []string `hcl:"controller_macs"`
39- ControllerNames []string `hcl:"controller_names"`
40- DisableSelfHostedKubelet bool `hcl:"disable_self_hosted_kubelet,optional"`
41- K8sDomainName string `hcl:"k8s_domain_name"`
42- MatchboxCAPath string `hcl:"matchbox_ca_path"`
43- MatchboxClientCertPath string `hcl:"matchbox_client_cert_path"`
44- MatchboxClientKeyPath string `hcl:"matchbox_client_key_path"`
45- MatchboxEndpoint string `hcl:"matchbox_endpoint"`
46- MatchboxHTTPEndpoint string `hcl:"matchbox_http_endpoint"`
47- NetworkMTU int `hcl:"network_mtu,optional"`
48- OSChannel string `hcl:"os_channel,optional"`
49- OSVersion string `hcl:"os_version,optional"`
50- SSHPubKeys []string `hcl:"ssh_pubkeys"`
51- WorkerNames []string `hcl:"worker_names"`
52- WorkerMacs []string `hcl:"worker_macs"`
53- WorkerDomains []string `hcl:"worker_domains"`
54- Labels map [string ]string `hcl:"labels,optional"`
55- OIDC * oidc.Config `hcl:"oidc,block"`
56- EnableTLSBootstrap bool `hcl:"enable_tls_bootstrap,optional"`
57- EncryptPodTraffic bool `hcl:"encrypt_pod_traffic,optional"`
58- IgnoreX509CNCheck bool `hcl:"ignore_x509_cn_check,optional"`
59- ConntrackMaxPerCore int `hcl:"conntrack_max_per_core,optional"`
60- InstallToSmallestDisk bool `hcl:"install_to_smallest_disk,optional"`
61- InstallDisk string `hcl:"install_disk,optional"`
62- KernelArgs []string `hcl:"kernel_args,optional"`
63- DownloadProtocol string `hcl:"download_protocol,optional"`
64- NetworkIPAutodetectionMethod string `hcl:"network_ip_autodetection_method,optional"`
34+ AssetDir string `hcl:"asset_dir"`
35+ CachedInstall string `hcl:"cached_install,optional"`
36+ ClusterName string `hcl:"cluster_name"`
37+ ControllerDomains []string `hcl:"controller_domains"`
38+ ControllerMacs []string `hcl:"controller_macs"`
39+ ControllerNames []string `hcl:"controller_names"`
40+ DisableSelfHostedKubelet bool `hcl:"disable_self_hosted_kubelet,optional"`
41+ K8sDomainName string `hcl:"k8s_domain_name"`
42+ MatchboxCAPath string `hcl:"matchbox_ca_path"`
43+ MatchboxClientCertPath string `hcl:"matchbox_client_cert_path"`
44+ MatchboxClientKeyPath string `hcl:"matchbox_client_key_path"`
45+ MatchboxEndpoint string `hcl:"matchbox_endpoint"`
46+ MatchboxHTTPEndpoint string `hcl:"matchbox_http_endpoint"`
47+ NetworkMTU int `hcl:"network_mtu,optional"`
48+ OSChannel string `hcl:"os_channel,optional"`
49+ OSVersion string `hcl:"os_version,optional"`
50+ SSHPubKeys []string `hcl:"ssh_pubkeys"`
51+ WorkerNames []string `hcl:"worker_names"`
52+ WorkerMacs []string `hcl:"worker_macs"`
53+ WorkerDomains []string `hcl:"worker_domains"`
54+ Labels map [string ]string `hcl:"labels,optional"`
55+ OIDC * oidc.Config `hcl:"oidc,block"`
56+ EnableTLSBootstrap bool `hcl:"enable_tls_bootstrap,optional"`
57+ EncryptPodTraffic bool `hcl:"encrypt_pod_traffic,optional"`
58+ IgnoreX509CNCheck bool `hcl:"ignore_x509_cn_check,optional"`
59+ ConntrackMaxPerCore int `hcl:"conntrack_max_per_core,optional"`
60+ InstallToSmallestDisk bool `hcl:"install_to_smallest_disk,optional"`
61+ InstallDisk string `hcl:"install_disk,optional"`
62+ KernelArgs []string `hcl:"kernel_args,optional"`
63+ DownloadProtocol string `hcl:"download_protocol,optional"`
64+ NetworkIPAutodetectionMethod string `hcl:"network_ip_autodetection_method,optional"`
65+ CLCSnippets map [string ][]string `hcl:"clc_snippets,optional"`
6566 KubeAPIServerExtraFlags []string
6667}
6768
@@ -231,6 +232,7 @@ func createTerraformConfigFile(cfg *config, terraformPath string) error {
231232 KernelArgs []string
232233 DownloadProtocol string
233234 NetworkIPAutodetectionMethod string
235+ CLCSnippets map [string ][]string
234236 }{
235237 CachedInstall : cfg .CachedInstall ,
236238 ClusterName : cfg .ClusterName ,
@@ -262,6 +264,7 @@ func createTerraformConfigFile(cfg *config, terraformPath string) error {
262264 KernelArgs : cfg .KernelArgs ,
263265 DownloadProtocol : cfg .DownloadProtocol ,
264266 NetworkIPAutodetectionMethod : cfg .NetworkIPAutodetectionMethod ,
267+ CLCSnippets : cfg .CLCSnippets ,
265268 }
266269
267270 if err := t .Execute (f , terraformCfg ); err != nil {
@@ -304,5 +307,25 @@ func (c *config) checkValidConfig() hcl.Diagnostics {
304307 diagnostics = append (diagnostics , diags ... )
305308 }
306309
310+ for key , list := range c .CLCSnippets {
311+ if key == "" || len (list ) == 0 {
312+ diagnostics = append (diagnostics , & hcl.Diagnostic {
313+ Severity : hcl .DiagError ,
314+ Summary : "key/value for clc_snippets map can't be empty" ,
315+ Detail : fmt .Sprintf ("either key or value for clc_snippets is empty: %q : %v" , key , list ),
316+ })
317+ }
318+
319+ for _ , data := range list {
320+ if data == "" {
321+ diagnostics = append (diagnostics , & hcl.Diagnostic {
322+ Severity : hcl .DiagError ,
323+ Summary : "Values list for clc_snippets cannot contain an empty element" ,
324+ Detail : fmt .Sprintf ("found empty element in the key value pair: %q : %v" , key , list ),
325+ })
326+ }
327+ }
328+ }
329+
307330 return diagnostics
308331}
0 commit comments