Repository: kinvolk/lokomotive
Pull request #588 (2020-06-09 09:26:40)

New internal package for helper functions
This PR adds a new `internal` package that is not exposed to the outside world. The intention is to begin consolidating functions in various `util` packages scattered in the codebase.

The first function that is to be added is RenderTemplate which renders the provided go template.


Patch:
diff --git a/ci/aws/aws-cluster.lokocfg.envsubst b/ci/aws/aws-cluster.lokocfg.envsubst
index a42d7691..28003f5b 100644
--- a/ci/aws/aws-cluster.lokocfg.envsubst
+++ b/ci/aws/aws-cluster.lokocfg.envsubst
@@ -16,21 +16,6 @@ cluster "aws" {
   os_channel       = var.os_channel
   ssh_pubkeys      = ["$PUB_KEY"]
 
-  controller_clc_snippets = [
-    <<EOF
-storage:
-  files:
-    - path: /opt/clc_snippet_hello
-      filesystem: root
-      contents:
-        inline: Hello, world!
-      mode: 0644
-      user:
-        id: 500
-      group:
-        id: 500
-EOF
-  ]
   worker_pool "wp" {
     count         = 2
     ssh_pubkeys   = ["$PUB_KEY"]
@@ -40,21 +25,6 @@ EOF
     tags = {
       "deployment" = "ci"
     }
-    clc_snippets = [
-      <<EOF
-storage:
-  files:
-    - path: /opt/clc_snippet_hello
-      filesystem: root
-      contents:
-        inline: Hello, world!
-      mode: 0644
-      user:
-        id: 500
-      group:
-        id: 500
-EOF
-    ]
   }
 
   # Adds oidc flags to API server with default values.
diff --git a/ci/packet-arm/packet-arm-cluster.lokocfg.envsubst b/ci/packet-arm/packet-arm-cluster.lokocfg.envsubst
index 7f263fff..429b6b10 100644
--- a/ci/packet-arm/packet-arm-cluster.lokocfg.envsubst
+++ b/ci/packet-arm/packet-arm-cluster.lokocfg.envsubst
@@ -3,21 +3,6 @@ cluster "packet" {
   cluster_name     = "$CLUSTER_ID"
   controller_count = 1
 
-  controller_clc_snippets = [
-    <<EOF
-storage:
-  files:
-    - path: /opt/clc_snippet_hello
-      filesystem: root
-      contents:
-        inline: Hello, world!
-      mode: 0644
-      user:
-        id: 500
-      group:
-        id: 500
-EOF
-  ]
   dns {
     provider = "route53"
     zone     = "$AWS_DNS_ZONE"
@@ -42,21 +27,6 @@ EOF
     os_arch         = "arm64"
     os_channel      = "alpha"
     node_type       = "c2.large.arm"
-    clc_snippets = [
-      <<EOF
-storage:
-  files:
-    - path: /opt/clc_snippet_hello
-      filesystem: root
-      contents:
-        inline: Hello, world!
-      mode: 0644
-      user:
-        id: 500
-      group:
-        id: 500
-EOF
-    ]
   }
 
   # Adds oidc flags to API server with default values.
diff --git a/ci/packet/packet-cluster.lokocfg.envsubst b/ci/packet/packet-cluster.lokocfg.envsubst
index 395e58e3..3e085ea1 100644
--- a/ci/packet/packet-cluster.lokocfg.envsubst
+++ b/ci/packet/packet-cluster.lokocfg.envsubst
@@ -3,21 +3,6 @@ cluster "packet" {
   cluster_name     = "$CLUSTER_ID"
   controller_count = 1
 
-  controller_clc_snippets = [
-    <<EOF
-storage:
-  files:
-    - path: /opt/clc_snippet_hello
-      filesystem: root
-      contents:
-        inline: Hello, world!
-      mode: 0644
-      user:
-        id: 500
-      group:
-        id: 500
-EOF
-  ]
   dns {
     provider = "route53"
     zone     = "$AWS_DNS_ZONE"
@@ -35,21 +20,6 @@ EOF
     count     = 2
     node_type = "c2.medium.x86"
     labels    = "testing.io=yes,roleofnode=testing"
-    clc_snippets = [
-      <<EOF
-storage:
-  files:
-    - path: /opt/clc_snippet_hello
-      filesystem: root
-      contents:
-        inline: Hello, world!
-      mode: 0644
-      user:
-        id: 500
-      group:
-        id: 500
-EOF
-    ]
   }
 
   # Adds oidc flags to API server with default values.
diff --git a/docs/configuration-reference/platforms/packet.md b/docs/configuration-reference/platforms/packet.md
index a0207a7d..7e84ce26 100644
--- a/docs/configuration-reference/platforms/packet.md
+++ b/docs/configuration-reference/platforms/packet.md
@@ -35,7 +35,6 @@ variable "cluster_name" {}
 variable "controllers_count" {}
 variable "workers_count" {}
 variable "controller_type" {}
-variable "controller_clc_snippets" {}
 variable "workers_type" {}
 variable "dns_zone" {}
 variable "route53_zone_id" {}
@@ -49,7 +48,6 @@ variable "oidc_issuer_url" {}
 variable "oidc_client_id" {}
 variable "oidc_username_claim" {}
 variable "oidc_groups_claim" {}
-variable "worker_clc_snippets" {}
 
 backend "s3" {
   bucket         = var.state_s3_bucket
@@ -73,8 +71,6 @@ cluster "packet" {
 
   controller_type = "t1.small.x86"
 
-  controller_clc_snippets = var.controller_clc.snippets
-
   facility = var.facility
 
   os_channel = "stable"
@@ -133,12 +129,6 @@ cluster "packet" {
   worker_pool "worker-pool-1" {
     count = var.workers_count
 
-    clc_snippets = var.worker_clc_snippets
-
-    tags = {
-      pool = "storage"
-    }
-
     ipxe_script_url = ""
 
     os_arch = "amd64"
@@ -199,7 +189,6 @@ node_type = var.custom_default_worker_type
 | `tags`                                | List of tags that will be propagated to master nodes.                                                                                                                         | -               | false    |
 | `controller_count`                    | Number of controller nodes.                                                                                                                                                   | 1               | false    |
 | `controller_type`                     | Packet instance type for controllers.                                                                                                                                         | "t1.small.x86"  | false    |
-| `controller_clc_snippets`             | Controller Flatcar Container Linux Config snippets.                                                                                                                           | []              | false    |
 | `dns`                                 | DNS configuration block.                                                                                                                                                      | -               | true     |
 | `dns.zone`                            | A DNS zone to use for the cluster. The following format is used for cluster-related DNS records: `<record>.<cluster_name>.<dns_zone>`                                         | -               | true     |
 | `dns.provider`                        | DNS provider to use for the cluster. Valid values: `cloudflare`, `route53`, `manual`.                                                                                         | -               | true     |
@@ -228,8 +217,6 @@ node_type = var.custom_default_worker_type
 | `certs_validity_period_hours`         | Validity of all the certificates in hours.                                                                                                                                    | 8760            | false    |
 | `worker_pool`                         | Configuration block for worker pools. There can be more than one.                                                                                                             | -               | true     |
 | `worker_pool.count`                   | Number of workers in the worker pool. Can be changed afterwards to add or delete workers.                                                                                     | 1               | true     |
-| `worker_pool.clc_snippets`            | Flatcar Container Linux Config snippets for nodes in the worker pool.                                                                                                         | []              | false    |
-| `worker_pool.tags`                    | List of tags that will be propagated to nodes in the worker pool.                                                                                                             | -               | false    |
 | `worker_pool.disable_bgp`             | Disable BGP on nodes. Nodes won't be able to connect to Packet BGP peers.                                                                                                     | false           | false    |
 | `worker_pool.ipxe_script_url`         | Boot via iPXE. Required for arm64.                                                                                                                                            | -               | false    |
 | `worker_pool.os_arch`                 | Flatcar Container Linux architecture to install (amd64, arm64).                                                                                                               | "amd64"         | false    |
diff --git a/pkg/components/util/template.go b/internal/template/template.go
similarity index 78%
rename from pkg/components/util/template.go
rename to internal/template/template.go
index d9d54c18..de3d6bae 100644
--- a/pkg/components/util/template.go
+++ b/internal/template/template.go
@@ -12,16 +12,18 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-package util
+// Package template contains the utility functions that help in rendering
+// the go templates.
+package template
 
 import (
 	"bytes"
 	"text/template"
 )
 
-// RenderTemplate applies a parsed template to the specified data object
+// Render applies a parsed template to the specified data object
 // and returns the output as string or an error.
-func RenderTemplate(tmpl string, obj interface{}) (string, error) {
+func Render(tmpl string, obj interface{}) (string, error) {
 	t, err := template.New("render").Parse(tmpl)
 	if err != nil {
 		return "", err
diff --git a/pkg/backend/local/local.go b/pkg/backend/local/local.go
index 94f483ed..4f494fd9 100644
--- a/pkg/backend/local/local.go
+++ b/pkg/backend/local/local.go
@@ -18,8 +18,8 @@ import (
 	"github.com/hashicorp/hcl/v2"
 	"github.com/hashicorp/hcl/v2/gohcl"
 
+	"github.com/kinvolk/lokomotive/internal/template"
 	"github.com/kinvolk/lokomotive/pkg/backend"
-	"github.com/kinvolk/lokomotive/pkg/components/util"
 )
 
 type local struct {
@@ -45,7 +45,7 @@ func NewLocalBackend() *local {
 
 // Render renders the Go template with local backend configuration.
 func (l *local) Render() (string, error) {
-	return util.RenderTemplate(backendConfigTmpl, l)
+	return template.Render(backendConfigTmpl, l)
 }
 
 // Validate validates the local backend configuration.
diff --git a/pkg/backend/s3/s3.go b/pkg/backend/s3/s3.go
index 825fd82b..a0dc2f92 100644
--- a/pkg/backend/s3/s3.go
+++ b/pkg/backend/s3/s3.go
@@ -21,8 +21,8 @@ import (
 	"github.com/hashicorp/hcl/v2/gohcl"
 	"github.com/pkg/errors"
 
+	"github.com/kinvolk/lokomotive/internal/template"
 	"github.com/kinvolk/lokomotive/pkg/backend"
-	"github.com/kinvolk/lokomotive/pkg/components/util"
 )
 
 type s3 struct {
@@ -52,7 +52,7 @@ func NewS3Backend() *s3 {
 
 // Render renders the Go template with s3 backend configuration.
 func (s *s3) Render() (string, error) {
-	return util.RenderTemplate(backendConfigTmpl, s)
+	return template.Render(backendConfigTmpl, s)
 }
 
 // Validate validates the s3 backend configuration.
diff --git a/pkg/components/cert-manager/component.go b/pkg/components/cert-manager/component.go
index 44f073e6..9411c10e 100644
--- a/pkg/components/cert-manager/component.go
+++ b/pkg/components/cert-manager/component.go
@@ -21,6 +21,7 @@ import (
 	"github.com/hashicorp/hcl/v2/gohcl"
 	"github.com/pkg/errors"
 
+	"github.com/kinvolk/lokomotive/internal/template"
 	"github.com/kinvolk/lokomotive/pkg/components"
 	"github.com/kinvolk/lokomotive/pkg/components/util"
 )
@@ -79,7 +80,7 @@ func (c *component) RenderManifests() (map[string]string, error) {
 		return nil, errors.Wrap(err, "load chart from assets")
 	}
 
-	values, err := util.RenderTemplate(chartValuesTmpl, c)
+	values, err := template.Render(chartValuesTmpl, c)
 	if err != nil {
 		return nil, errors.Wrap(err, "render chart values template")
 	}
diff --git a/pkg/components/cluster-autoscaler/component.go b/pkg/components/cluster-autoscaler/component.go
index fd239c3d..7723c6af 100644
--- a/pkg/components/cluster-autoscaler/component.go
+++ b/pkg/components/cluster-autoscaler/component.go
@@ -26,6 +26,7 @@ import (
 	"github.com/packethost/packngo"
 	"github.com/pkg/errors"
 
+	"github.com/kinvolk/lokomotive/internal/template"
 	"github.com/kinvolk/lokomotive/pkg/components"
 	"github.com/kinvolk/lokomotive/pkg/components/util"
 )
@@ -323,7 +324,7 @@ func (c *component) RenderManifests() (map[string]string, error) {
 		c.Packet.AuthToken = base64.StdEncoding.EncodeToString([]byte(os.Getenv("PACKET_AUTH_TOKEN")))
 	}
 
-	values, err := util.RenderTemplate(chartValuesTmpl, c)
+	values, err := template.Render(chartValuesTmpl, c)
 	if err != nil {
 		return nil, errors.Wrap(err, "render chart values template")
 	}
diff --git a/pkg/components/contour/component.go b/pkg/components/contour/component.go
index 76c0dc8a..eaf4941e 100644
--- a/pkg/components/contour/component.go
+++ b/pkg/components/contour/component.go
@@ -19,9 +19,10 @@ import (
 
 	"github.com/hashicorp/hcl/v2"
 	"github.com/hashicorp/hcl/v2/gohcl"
-	"github.com/kinvolk/lokomotive/pkg/components/util"
 
+	internaltemplate "github.com/kinvolk/lokomotive/internal/template"
 	"github.com/kinvolk/lokomotive/pkg/components"
+	"github.com/kinvolk/lokomotive/pkg/components/util"
 )
 
 const (
@@ -101,7 +102,7 @@ func (c *component) RenderManifests() (map[string]string, error) {
 		return nil, fmt.Errorf("failed to marshal node affinity: %w", err)
 	}
 
-	values, err := util.RenderTemplate(chartValuesTmpl, c)
+	values, err := internaltemplate.Render(chartValuesTmpl, c)
 	if err != nil {
 		return nil, fmt.Errorf("rendering values template failed: %w", err)
 	}
diff --git a/pkg/components/dex/component.go b/pkg/components/dex/component.go
index 72a33ac6..b3b24e6f 100644
--- a/pkg/components/dex/component.go
+++ b/pkg/components/dex/component.go
@@ -25,8 +25,8 @@ import (
 	"github.com/hashicorp/hcl/v2/gohcl"
 	"github.com/pkg/errors"
 
+	internaltemplate "github.com/kinvolk/lokomotive/internal/template"
 	"github.com/kinvolk/lokomotive/pkg/components"
-	"github.com/kinvolk/lokomotive/pkg/components/util"
 )
 
 const name = "dex"
@@ -310,17 +310,17 @@ func (c *component) RenderManifests() (map[string]string, error) {
 	}
 	c.StaticClientsRaw = staticClients
 
-	configMap, err := util.RenderTemplate(configMapTmpl, c)
+	configMap, err := internaltemplate.Render(configMapTmpl, c)
 	if err != nil {
 		return nil, errors.Wrap(err, "execute template failed")
 	}
 
-	ingressBuf, err := util.RenderTemplate(ingressTmpl, c)
+	ingressBuf, err := internaltemplate.Render(ingressTmpl, c)
 	if err != nil {
 		return nil, errors.Wrap(err, "execute template failed")
 	}
 
-	deployment, err := util.RenderTemplate(deploymentTmpl, c)
+	deployment, err := internaltemplate.Render(deploymentTmpl, c)
 	if err != nil {
 		return nil, errors.Wrap(err, "execute template failed")
 	}
diff --git a/pkg/components/external-dns/component.go b/pkg/components/external-dns/component.go
index 7f5290d6..683c543c 100644
--- a/pkg/components/external-dns/component.go
+++ b/pkg/components/external-dns/component.go
@@ -20,9 +20,11 @@ import (
 
 	"github.com/hashicorp/hcl/v2"
 	"github.com/hashicorp/hcl/v2/gohcl"
+	"github.com/pkg/errors"
+
+	"github.com/kinvolk/lokomotive/internal/template"
 	"github.com/kinvolk/lokomotive/pkg/components"
 	"github.com/kinvolk/lokomotive/pkg/components/util"
-	"github.com/pkg/errors"
 )
 
 const name = "external-dns"
@@ -128,7 +130,7 @@ func (c *component) RenderManifests() (map[string]string, error) {
 		c.AwsConfig.SecretAccessKey = secretAccessKey
 	}
 
-	values, err := util.RenderTemplate(chartValuesTmpl, c)
+	values, err := template.Render(chartValuesTmpl, c)
 	if err != nil {
 		return nil, errors.Wrap(err, "render chart values template")
 	}
diff --git a/pkg/components/metallb/component.go b/pkg/components/metallb/component.go
index c01dd1ca..bc7e505b 100644
--- a/pkg/components/metallb/component.go
+++ b/pkg/components/metallb/component.go
@@ -17,9 +17,11 @@ package metallb
 import (
 	"github.com/hashicorp/hcl/v2"
 	"github.com/hashicorp/hcl/v2/gohcl"
+	"github.com/pkg/errors"
+
+	"github.com/kinvolk/lokomotive/internal/template"
 	"github.com/kinvolk/lokomotive/pkg/components"
 	"github.com/kinvolk/lokomotive/pkg/components/util"
-	"github.com/pkg/errors"
 )
 
 const name = "metallb"
@@ -85,17 +87,17 @@ func (c *component) RenderManifests() (map[string]string, error) {
 	}
 	c.ControllerTolerationsJSON = t
 
-	controllerStr, err := util.RenderTemplate(deploymentController, c)
+	controllerStr, err := template.Render(deploymentController, c)
 	if err != nil {
 		return nil, errors.Wrap(err, "render template failed")
 	}
 
-	speakerStr, err := util.RenderTemplate(daemonsetSpeaker, c)
+	speakerStr, err := template.Render(daemonsetSpeaker, c)
 	if err != nil {
 		return nil, errors.Wrap(err, "render template failed")
 	}
 
-	configMapStr, err := util.RenderTemplate(configMap, c)
+	configMapStr, err := template.Render(configMap, c)
 	if err != nil {
 		return nil, errors.Wrap(err, "rendering ConfigMap template failed")
 	}
diff --git a/pkg/components/metrics-server/component.go b/pkg/components/metrics-server/component.go
index 609f938f..a0ef246e 100644
--- a/pkg/components/metrics-server/component.go
+++ b/pkg/components/metrics-server/component.go
@@ -21,6 +21,7 @@ import (
 	"github.com/hashicorp/hcl/v2/gohcl"
 	"github.com/pkg/errors"
 
+	"github.com/kinvolk/lokomotive/internal/template"
 	"github.com/kinvolk/lokomotive/pkg/components"
 	"github.com/kinvolk/lokomotive/pkg/components/util"
 )
@@ -75,7 +76,7 @@ func (c *component) RenderManifests() (map[string]string, error) {
 		return nil, errors.Wrap(err, "load chart from assets")
 	}
 
-	values, err := util.RenderTemplate(chartValuesTmpl, c)
+	values, err := template.Render(chartValuesTmpl, c)
 	if err != nil {
 		return nil, errors.Wrap(err, "render chart values template")
 	}
diff --git a/pkg/components/openebs-operator/component.go b/pkg/components/openebs-operator/component.go
index 0845aad6..99d0eb07 100644
--- a/pkg/components/openebs-operator/component.go
+++ b/pkg/components/openebs-operator/component.go
@@ -20,6 +20,7 @@ import (
 	"github.com/hashicorp/hcl/v2"
 	"github.com/hashicorp/hcl/v2/gohcl"
 
+	"github.com/kinvolk/lokomotive/internal/template"
 	"github.com/kinvolk/lokomotive/pkg/components"
 	"github.com/kinvolk/lokomotive/pkg/components/util"
 )
@@ -101,7 +102,7 @@ func (c *component) RenderManifests() (map[string]string, error) {
 		return nil, fmt.Errorf("load chart from assets: %w", err)
 	}
 
-	values, err := util.RenderTemplate(chartValuesTmpl, c)
+	values, err := template.Render(chartValuesTmpl, c)
 	if err != nil {
 		return nil, fmt.Errorf("render chart values template: %w", err)
 	}
diff --git a/pkg/components/prometheus-operator/component.go b/pkg/components/prometheus-operator/component.go
index 748baf94..08e37148 100644
--- a/pkg/components/prometheus-operator/component.go
+++ b/pkg/components/prometheus-operator/component.go
@@ -21,6 +21,7 @@ import (
 	"github.com/hashicorp/hcl/v2/gohcl"
 	"github.com/pkg/errors"
 
+	"github.com/kinvolk/lokomotive/internal/template"
 	"github.com/kinvolk/lokomotive/pkg/components"
 	"github.com/kinvolk/lokomotive/pkg/components/types"
 	"github.com/kinvolk/lokomotive/pkg/components/util"
@@ -149,7 +150,7 @@ func (c *component) RenderManifests() (map[string]string, error) {
 		return nil, errors.Wrap(err, "load chart from assets")
 	}
 
-	values, err := util.RenderTemplate(chartValuesTmpl, c)
+	values, err := template.Render(chartValuesTmpl, c)
 	if err != nil {
 		return nil, errors.Wrap(err, "render chart values template")
 	}
diff --git a/pkg/components/rook-ceph/component.go b/pkg/components/rook-ceph/component.go
index 34710f69..e40344be 100644
--- a/pkg/components/rook-ceph/component.go
+++ b/pkg/components/rook-ceph/component.go
@@ -19,9 +19,11 @@ import (
 
 	"github.com/hashicorp/hcl/v2"
 	"github.com/hashicorp/hcl/v2/gohcl"
+	"github.com/pkg/errors"
+
+	internaltemplate "github.com/kinvolk/lokomotive/internal/template"
 	"github.com/kinvolk/lokomotive/pkg/components"
 	"github.com/kinvolk/lokomotive/pkg/components/util"
-	"github.com/pkg/errors"
 )
 
 const name = "rook-ceph"
@@ -74,7 +76,7 @@ func (c *component) RenderManifests() (map[string]string, error) {
 
 	// Parse template with values
 	for k, v := range template {
-		rendered, err := util.RenderTemplate(v, c)
+		rendered, err := internaltemplate.Render(v, c)
 		if err != nil {
 			return nil, fmt.Errorf("template rendering failed for %q: %w", k, err)
 		}
diff --git a/pkg/components/rook/component.go b/pkg/components/rook/component.go
index 97c25d08..338e42fc 100644
--- a/pkg/components/rook/component.go
+++ b/pkg/components/rook/component.go
@@ -19,6 +19,8 @@ import (
 
 	"github.com/hashicorp/hcl/v2"
 	"github.com/hashicorp/hcl/v2/gohcl"
+
+	"github.com/kinvolk/lokomotive/internal/template"
 	"github.com/kinvolk/lokomotive/pkg/components"
 	"github.com/kinvolk/lokomotive/pkg/components/util"
 )
@@ -75,7 +77,7 @@ func (c *component) RenderManifests() (map[string]string, error) {
 
 	c.RookNodeAffinity = convertNodeSelector(c.NodeSelector)
 
-	values, err := util.RenderTemplate(chartValuesTmpl, c)
+	values, err := template.Render(chartValuesTmpl, c)
 	if err != nil {
 		return nil, fmt.Errorf("rendering values template failed: %w", err)
 	}
diff --git a/pkg/components/velero/velero.go b/pkg/components/velero/velero.go
index 2e9739a3..52a0cc2d 100644
--- a/pkg/components/velero/velero.go
+++ b/pkg/components/velero/velero.go
@@ -22,6 +22,7 @@ import (
 	"github.com/hashicorp/hcl/v2/gohcl"
 	"github.com/pkg/errors"
 
+	"github.com/kinvolk/lokomotive/internal/template"
 	"github.com/kinvolk/lokomotive/pkg/components"
 	"github.com/kinvolk/lokomotive/pkg/components/util"
 	"github.com/kinvolk/lokomotive/pkg/components/velero/azure"
@@ -152,7 +153,7 @@ func (c *component) RenderManifests() (map[string]string, error) {
 		return nil, errors.Wrap(err, "load chart from assets")
 	}
 
-	values, err := util.RenderTemplate(chartValuesTmpl, c)
+	values, err := template.Render(chartValuesTmpl, c)
 	if err != nil {
 		return nil, errors.Wrap(err, "render chart values template")
 	}
diff --git a/pkg/platform/packet/packet.go b/pkg/platform/packet/packet.go
index ce6e96b9..df32720f 100644
--- a/pkg/platform/packet/packet.go
+++ b/pkg/platform/packet/packet.go
@@ -60,8 +60,6 @@ type workerPool struct {
 	SetupRaidHDD          bool              `hcl:"setup_raid_hdd,optional"`
 	SetupRaidSSD          bool              `hcl:"setup_raid_ssd,optional"`
 	SetupRaidSSDFS        bool              `hcl:"setup_raid_ssd_fs,optional"`
-	CLCSnippets           []string          `hcl:"clc_snippets,optional"`
-	Tags                  map[string]string `hcl:"tags,optional"`
 	NodesDependOn         []string          // Not exposed to the user
 }
 
@@ -72,7 +70,6 @@ type config struct {
 	Tags                     map[string]string `hcl:"tags,optional"`
 	ControllerCount          int               `hcl:"controller_count"`
 	ControllerType           string            `hcl:"controller_type,optional"`
-	ControllerCLCSnippets    []string          `hcl:"controller_clc_snippets,optional"`
 	DNS                      dns.Config        `hcl:"dns,block"`
 	Facility                 string            `hcl:"facility"`
 	ProjectID                string            `hcl:"project_id"`
@@ -228,13 +225,7 @@ func createTerraformConfigFile(cfg *config, terraformPath string) error {
 	if err != nil {
 		return errors.Wrapf(err, "failed to marshal tags")
 	}
-	// Append lokoctl-version tag to all worker pools.
-	for i := range cfg.WorkerPools {
-		// Using index as we are using []workerPool which creates a copy of the slice
-		// Hence when the template is rendered worker pool Tags is empty.
-		// TODO: Add tests for validating the worker pool configuration.
-		util.AppendTags(&cfg.WorkerPools[i].Tags)
-	}
+
 	// Add explicit terraform dependencies for nodes with specific hw
 	// reservation UUIDs.
 	cfg.terraformAddDeps()
diff --git a/pkg/platform/packet/template.go b/pkg/platform/packet/template.go
index d4da1ad0..e3e6d572 100644
--- a/pkg/platform/packet/template.go
+++ b/pkg/platform/packet/template.go
@@ -84,16 +84,6 @@ module "packet-{{.Config.ClusterName}}" {
   }
   {{- end }}
 
-  {{- if .Config.ControllerCLCSnippets}}
-  controller_clc_snippets = [
-	{{- range $clc_snippet := .Config.ControllerCLCSnippets}}
-    <<EOF
-{{ $clc_snippet }}
-EOF
-    ,
-  {{- end }}
-  ]
-  {{- end }}
   {{- if .Config.ReservationIDsDefault }}
   reservation_ids_default = "{{.Config.ReservationIDsDefault}}"
   {{- end }}
@@ -135,27 +125,8 @@ module "worker-{{ $pool.Name }}" {
 
   ssh_keys  = {{$.SSHPublicKeys}}
 
-  {{- if $pool.CLCSnippets}}
-  clc_snippets = [
-	{{- range $clc_snippet := $pool.CLCSnippets}}
-    <<EOF
-{{ $clc_snippet }}
-EOF
-    ,
-  {{- end}}
-  ]
-  {{- end }}
-
   cluster_name = "{{$.Config.ClusterName}}"
-
-  {{- if $pool.Tags }}
-  tags = [
-      {{- range $key, $value := $pool.Tags }}
-      "{{ $key }}:{{ $value }}",
-      {{- end }}
-	]
-  {{- end }}
-
+  tags         = {{$.Tags}}
   project_id   = "{{$.Config.ProjectID}}"
   facility     = "{{$.Config.Facility}}"
   {{- if $.Config.ClusterDomainSuffix }}


Test patch:
diff --git a/internal/template/template_test.go b/internal/template/template_test.go
new file mode 100644
index 00000000..7979077e
--- /dev/null
+++ b/internal/template/template_test.go
@@ -0,0 +1,57 @@
+// Copyright 2020 The Lokomotive Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package template_test
+
+import (
+	"testing"
+
+	"github.com/kinvolk/lokomotive/internal/template"
+)
+
+type testRenderer struct {
+	Test string
+}
+
+func TestRenderSuccess(t *testing.T) {
+	tmpl := `Rendered template is: {{ .Test }}`
+	expected := "Rendered template is: Success"
+
+	tr := &testRenderer{Test: "Success"}
+
+	output, err := template.Render(tmpl, tr)
+	if err != nil {
+		t.Fatalf("error rendering template not expected, got: %q", err)
+	}
+
+	if output != expected {
+		t.Fatalf("expected: %s, got: %s", expected, output)
+	}
+}
+
+func TestRenderFail(t *testing.T) {
+	tmpl := `Rendered template is: {{ .UnknownField }}`
+	expected := "Rendered template is: Success"
+
+	tr := &testRenderer{Test: "Fail"}
+
+	output, err := template.Render(tmpl, tr)
+	if err == nil {
+		t.Fatalf("expected error in rendering template")
+	}
+
+	if output != "" {
+		t.Fatalf("expected: %s, got: %s", expected, output)
+	}
+}
diff --git a/test/system/clc_snippets_test.go b/test/system/clc_snippets_test.go
deleted file mode 100644
index e8a8a7d6..00000000
--- a/test/system/clc_snippets_test.go
+++ /dev/null
@@ -1,101 +0,0 @@
-// Copyright 2020 The Lokomotive Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//     http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-// +build aws aws_edge packet
-// +build e2e
-
-package system // nolint:testpackage
-
-import (
-	"context"
-	"fmt"
-	"testing"
-	"time"
-
-	appsv1 "k8s.io/api/apps/v1"
-	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
-	"sigs.k8s.io/yaml"
-
-	testutil "github.com/kinvolk/lokomotive/test/components/util"
-)
-
-const (
-	fileName = "clc_snippet_hello"
-)
-
-// Define manifest as YAML and then unmarshal it to a Go struct so that it is easier to
-// write and debug, as it can be copy-pasted to a file and applied manually.
-const clcSnippetsAddedToNodesDSManifest = `apiVersion: apps/v1
-kind: DaemonSet
-metadata:
-  generateName: test-clc-snippets-
-spec:
-  selector:
-    matchLabels:
-      name: test-clc-snippets
-  template:
-    metadata:
-      labels:
-        name: test-clc-snippets
-    spec:
-      tolerations:
-      - key: node-role.kubernetes.io/master
-        effect: NoSchedule
-      terminationGracePeriodSeconds: 1
-      containers:
-      - name: test-clc-snippets
-        image: ubuntu
-        command: ["bash"]
-        volumeMounts:
-        - name: opt
-          mountPath: /opt
-          readOnly: true
-      volumes:
-      - name: opt
-        hostPath:
-          path: /opt
-`
-
-func TestFileCreatedByCLCSnippetExistsOnNodes(t *testing.T) {
-	t.Parallel()
-
-	namespace := "kube-system"
-
-	client := testutil.CreateKubeClient(t)
-
-	ds := &appsv1.DaemonSet{}
-	if err := yaml.Unmarshal([]byte(clcSnippetsAddedToNodesDSManifest), ds); err != nil {
-		t.Fatalf("failed unmarshaling manifest: %v", err)
-	}
-
-	// Set the right arguments from the manifest with the correct fileName
-	ds.Spec.Template.Spec.Containers[0].Args = []string{
-		"-c",
-		fmt.Sprintf("test -e /opt/%s && exec tail -f /dev/null", fileName),
-	}
-
-	ds, err := client.AppsV1().DaemonSets(namespace).Create(context.TODO(), ds, metav1.CreateOptions{})
-	if err != nil {
-		t.Fatalf("failed to create DaemonSet: %v", err)
-	}
-
-	testutil.WaitForDaemonSet(t, client, namespace, ds.ObjectMeta.Name, time.Second*5, time.Minute*5)
-
-	t.Cleanup(func() {
-		if err := client.AppsV1().DaemonSets(namespace).Delete(
-			context.TODO(), ds.ObjectMeta.Name, metav1.DeleteOptions{}); err != nil {
-			t.Logf("failed to remove DaemonSet: %v", err)
-		}
-	})
-}