Skip to content

Instantly share code, notes, and snippets.

View jwillker's full-sized avatar
:octocat:
...

Jhonn W. Frazão jwillker

:octocat:
...
View GitHub Profile
│ Error: error updating ruleset with ID "6e0e2829a3ea49d7bca03bcd8a561cec"
│ with module.subdomain.module.cloudflare_resources["1"].cloudflare_ruleset.this["0"],
│ on ../../../../../modules/cloudflare/site/main.tf line 53, in resource "cloudflare_ruleset" "this":
│ 53: resource "cloudflare_ruleset" "this" {
│ action parameters are required for the set_cache_settings action (20106)\\
2024-03-07T10:22:31.423-0300 [INFO] Terraform version: 1.5.7
2024-03-07T10:22:31.424-0300 [DEBUG] using github.com/hashicorp/go-tfe v1.26.0
2024-03-07T10:22:31.424-0300 [DEBUG] using github.com/hashicorp/hcl/v2 v2.16.2
2024-03-07T10:22:31.424-0300 [DEBUG] using github.com/hashicorp/terraform-svchost v0.1.0
2024-03-07T10:22:31.424-0300 [DEBUG] using github.com/zclconf/go-cty v1.12.2
2024-03-07T10:22:31.424-0300 [INFO] Go runtime version: go1.21.1
2024-03-07T10:22:31.424-0300 [INFO] CLI args: []string{"terraform", "apply"}
2024-03-07T10:22:31.424-0300 [DEBUG] Attempting to open CLI config file: /Users/jhonn.frazao/.terraformrc
2024-03-07T10:22:31.424-0300 [DEBUG] File doesn't exist, but doesn't need to. Ignoring.
2024-03-07T10:22:31.424-0300 [DEBUG] ignoring non-existing provider search directory terraform.d/plugins
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane
kubeadmConfigPatches:
- |
kind: InitConfiguration
nodeRegistration:
kubeletExtraArgs:
node-labels: "ingress-ready=true"
func assertName(t assert.TestingT, name string, deployment appsv1.Deployment) bool {
// Only assert if theres a want value to assert
// if not return true to don't fail the test
if name == "" {
return true
}
return assert.Equal(
t,
name,
//more code
...
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
var deployment appsv1.Deployment
// Render the deployment object
err := Render(t, "../", "deployment.yaml", tt.args.Release, tt.args.Values, &deployment)
if err != nil {
fmt.Println(err)
}
func TestDeployTemplateRenders(t *testing.T) {
t.Parallel()
type args struct {
Release string
Values map[string]string
}
type want struct {
DeployName string
// Render receive helm parameters and render a k8s object
func Render(t *testing.T, helmChartPath, templateFile, release string, values map[string]string, k8sObject interface{}) error {
// Passing values to helm chart.
options := &helm.Options{
SetValues: values,
}
templateFile = fmt.Sprintf("templates/%s", templateFile)
output, err := helm.RenderTemplateE(t, options, helmChartPath, release, []string{templateFile})
func TestDeployTemplateRendersMetadata(t *testing.T) {
t.Parallel()
var (
// Default Helm values
// Work as values.yaml for tests purposes
deployDefaultValues = map[string]string{
"app.version": "0.1.0",
"app.replicas": "2",
"app.component": "api",
"app.env": "dev",
{{- define "generic.fullname" -}}
{{- .Release.Name | trunc 6 -}}
{{- end }}
{{/*
Selector labels
*/}}
{{- define "generic.selectorLabels" -}}
app.kubernetes.io/name: {{ include "generic.fullname" .}}
app.kubernetes.io/instance: '{{ include "generic.fullname" . }}-{{ .Values.app.version }}'
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "generic.fullname" .}}
labels: &labels
{{- include "generic.commonLabels" . | nindent 4 }}
{{- with .Values.app.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
annotations: &annotations