Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix feature_gates #39

Merged
merged 4 commits into from
May 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions kind/resource_cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,8 @@ func TestAccClusterConfigBase(t *testing.T) {
resource.TestCheckResourceAttr(resourceName, "kind_config.#", "1"),
resource.TestCheckResourceAttr(resourceName, "kind_config.0.kind", "Cluster"),
resource.TestCheckResourceAttr(resourceName, "kind_config.0.api_version", "kind.x-k8s.io/v1alpha4"),
resource.TestCheckResourceAttr(resourceName, "kind_config.0.runtime_config.#", "1"),
resource.TestCheckResourceAttr(resourceName, "kind_config.0.runtime_config.0", "api_alpha"),
resource.TestCheckResourceAttr(resourceName, "kind_config.0.runtime_config.0.api_alpha", "false"),
resource.TestCheckResourceAttr(resourceName, "kind_config.0.runtime_config.%", "1"),
resource.TestCheckResourceAttr(resourceName, "kind_config.0.runtime_config.api_alpha", "false"),
),
},
{
Expand All @@ -206,9 +205,8 @@ func TestAccClusterConfigBase(t *testing.T) {
resource.TestCheckResourceAttr(resourceName, "kind_config.#", "1"),
resource.TestCheckResourceAttr(resourceName, "kind_config.0.kind", "Cluster"),
resource.TestCheckResourceAttr(resourceName, "kind_config.0.api_version", "kind.x-k8s.io/v1alpha4"),
resource.TestCheckResourceAttr(resourceName, "kind_config.0.feature_gates.#", "1"),
resource.TestCheckResourceAttr(resourceName, "kind_config.0.feature_gates.0", "CSINodeExpandSecret"),
resource.TestCheckResourceAttr(resourceName, "kind_config.0.feature_gates.0.CSINodeExpandSecret", "false"),
resource.TestCheckResourceAttr(resourceName, "kind_config.0.feature_gates.%", "1"),
resource.TestCheckResourceAttr(resourceName, "kind_config.0.feature_gates.CSINodeExpandSecret", "false"),
),
},
},
Expand Down
8 changes: 5 additions & 3 deletions kind/structure_kind_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,19 @@ func flattenKindConfig(d map[string]interface{}) *v1alpha4.Cluster {
runtimeConfig := mapKeyIfExists(d, "runtime_config")
if runtimeConfig != nil {
data := runtimeConfig.(map[string]interface{})
obj.RuntimeConfig = make(map[string]string)
for k, v := range data {
k = strings.ReplaceAll(k, "_", "/") // slash is not allowed in hcl, if there's an underscore replace with slash, e.g. `api_alpha` to `api/alpha`
obj.RuntimeConfig[k] = v.(string)
}
}

featureGates := mapKeyIfExists(d, "features_gates")
featureGates := mapKeyIfExists(d, "feature_gates")
if featureGates != nil {
data := featureGates.(map[string]string)
data := featureGates.(map[string]interface{})
obj.FeatureGates = make(map[string]bool)
for k, v := range data {
if strings.ToLower(v) == "true" {
if strings.ToLower(v.(string)) == "true" {
obj.FeatureGates[k] = true
} else {
obj.FeatureGates[k] = false
Expand Down