From d0dce585044c5b9b855fa53a007d4aa2baa43699 Mon Sep 17 00:00:00 2001
From: Phillip Stagnet
Date: Tue, 5 Sep 2023 13:57:56 +0200
Subject: [PATCH] Change sshkeyagent field to a bool pointer
---
go.mod | 2 +-
go.sum | 2 ++
metakube/resource_cluster_structure.go | 6 ++++--
metakube/resource_cluster_structure_test.go | 4 ++--
4 files changed, 9 insertions(+), 5 deletions(-)
diff --git a/go.mod b/go.mod
index dc26e5c..39b1868 100644
--- a/go.mod
+++ b/go.mod
@@ -17,7 +17,7 @@ require (
github.com/hashicorp/go-version v1.5.0
github.com/hashicorp/terraform-plugin-sdk/v2 v2.17.0
github.com/mitchellh/go-homedir v1.1.0
- github.com/syseleven/go-metakube v0.0.0-20230807132826-2e9a3e9c216b
+ github.com/syseleven/go-metakube v0.0.0-20230901105753-2acbd56de0ef
go.uber.org/zap v1.19.0
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4
)
diff --git a/go.sum b/go.sum
index cc3600d..350a46b 100644
--- a/go.sum
+++ b/go.sum
@@ -308,6 +308,8 @@ github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PK
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/syseleven/go-metakube v0.0.0-20230807132826-2e9a3e9c216b h1:UHhAGAmluLK8VVJdWFD2rOf35DlNQIMkDlQcVdzSJRM=
github.com/syseleven/go-metakube v0.0.0-20230807132826-2e9a3e9c216b/go.mod h1:Wmf9qWGkFXBGAJxXuwGH+SH6eq9txahkGRpTUz/JFhY=
+github.com/syseleven/go-metakube v0.0.0-20230901105753-2acbd56de0ef h1:vHHN4hkSmM1hkdDwO3/Ty3Ywwk5KHF69POdzRmo5sgk=
+github.com/syseleven/go-metakube v0.0.0-20230901105753-2acbd56de0ef/go.mod h1:Wmf9qWGkFXBGAJxXuwGH+SH6eq9txahkGRpTUz/JFhY=
github.com/syseleven/terraform-plugin-sdk/v2 v2.17.0-sys11-1 h1:M2c981F8TnNf8yFGD51oHNzMYcIIQ6nbySBrvUQrckM=
github.com/syseleven/terraform-plugin-sdk/v2 v2.17.0-sys11-1/go.mod h1:tunSMaRkZLxRmsJZAFXiznrk8Vl+KJ+GAfW52tQMu7w=
github.com/tidwall/pretty v1.0.0 h1:HsD+QiTn7sK6flMKIvNmpqz1qrpP3Ps6jOKIKMooyg4=
diff --git a/metakube/resource_cluster_structure.go b/metakube/resource_cluster_structure.go
index b385f19..6968bac 100644
--- a/metakube/resource_cluster_structure.go
+++ b/metakube/resource_cluster_structure.go
@@ -21,7 +21,9 @@ func metakubeResourceClusterFlattenSpec(values clusterPreserveValues, in *models
att["update_window"] = flattenUpdateWindow(in.UpdateWindow)
}
- att["enable_ssh_agent"] = in.EnableUserSSHKeyAgent
+ if in.EnableUserSSHKeyAgent != nil {
+ att["enable_ssh_agent"] = *in.EnableUserSSHKeyAgent
+ }
att["audit_logging"] = false
if in.AuditLogging != nil {
@@ -314,7 +316,7 @@ func metakubeResourceClusterExpandSpec(p []interface{}, dcName string, include f
if v, ok := in["enable_ssh_agent"]; ok && include("enable_ssh_agent") {
if vv, ok := v.(bool); ok {
- obj.EnableUserSSHKeyAgent = vv
+ obj.EnableUserSSHKeyAgent = &vv
}
}
diff --git a/metakube/resource_cluster_structure_test.go b/metakube/resource_cluster_structure_test.go
index 6af3ac5..562fc85 100644
--- a/metakube/resource_cluster_structure_test.go
+++ b/metakube/resource_cluster_structure_test.go
@@ -9,6 +9,7 @@ import (
)
func TestMetakubeClusterFlattenSpec(t *testing.T) {
+ trueBool := true
cases := []struct {
Input *models.ClusterSpec
ExpectedOutput []interface{}
@@ -20,7 +21,7 @@ func TestMetakubeClusterFlattenSpec(t *testing.T) {
Start: "Tue 02:00",
Length: "3h",
},
- EnableUserSSHKeyAgent: true,
+ EnableUserSSHKeyAgent: &trueBool,
AuditLogging: &models.AuditLoggingSettings{},
Cloud: &models.CloudSpec{
DatacenterName: "eu-west-1",
@@ -83,7 +84,6 @@ func TestMetakubeClusterFlattenSpec(t *testing.T) {
"audit_logging": false,
"pod_security_policy": false,
"pod_node_selector": false,
- "enable_ssh_agent": false,
},
},
},