diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index a43428a..bc54351 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -35,8 +35,8 @@ env: artifacts: paths: - test.env - only: - - master + rules: + - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH || $CI_COMMIT_BRANCH =~ /k8s-.*/ || $CI_PIPELINE_SOURCE == "web" test: stage: test @@ -51,5 +51,5 @@ test: - TF_ACC=1 go test ./metakube -v -timeout 3h --parallel 10 -run TestAcc needs: - env - only: - - master + rules: + - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH || $CI_COMMIT_BRANCH =~ /k8s-.*/ || $CI_PIPELINE_SOURCE == "web" diff --git a/Makefile b/Makefile index e15d903..fbca1bd 100644 --- a/Makefile +++ b/Makefile @@ -62,6 +62,7 @@ testacc: # METAKUBE_AWS_SUBNET_ID # METAKUBE_AWS_AVAILABILITY_ZONE # METAKUBE_AWS_DISK_SIZE + go clean -testcache TF_ACC=1 go test ./$(PKG_NAME) -v -timeout 120m -parallel 10 $(TESTARGS) sweep: diff --git a/metakube/resource_cluster_structure.go b/metakube/resource_cluster_structure.go index 6968bac..d7be16b 100644 --- a/metakube/resource_cluster_structure.go +++ b/metakube/resource_cluster_structure.go @@ -604,23 +604,23 @@ func expandOpenstackCloudSpec(p []interface{}, include func(string) bool) *model if v, ok := in["user_credentials"]; ok { if vv, ok := v.([]interface{}); ok && len(vv) > 0 && vv[0] != nil { if m, ok := vv[0].(map[string]interface{}); ok { - if v, ok := m["username"]; ok && include("user_credentials.0.username") { + if v, ok := m["username"]; ok { if vv, ok := v.(string); ok && vv != "" { obj.Username = vv } } - if v, ok := m["password"]; ok && include("user_credentials.0.password") { + if v, ok := m["password"]; ok { if vv, ok := v.(string); ok && vv != "" { obj.Password = vv } } - if v, ok := m["project_id"]; ok && include("user_credentials.0.project_id") { + if v, ok := m["project_id"]; ok { if vv, ok := v.(string); ok && vv != "" { obj.ProjectID = vv } } - if v, ok := m["project_name"]; ok && include("user_credentials.0.project_name") { + if v, ok := m["project_name"]; ok { if vv, ok := v.(string); ok && vv != "" { obj.Project = vv } diff --git a/metakube/resource_cluster_test.go b/metakube/resource_cluster_test.go index c9c9dba..5995eaf 100644 --- a/metakube/resource_cluster_test.go +++ b/metakube/resource_cluster_test.go @@ -73,14 +73,7 @@ func TestAccMetakubeCluster_Openstack_Basic(t *testing.T) { if err := clusterOpenstackBasicTemplate.Execute(&config2, data2); err != nil { t.Fatal(err) } - // Uncomment this block once cilium reconciliation is done. - // data4 := *data - // data4.Name += "-cilium" - // data4.CNIPlugin = "cilium" - // var config4 strings.Builder - // if err := clusterOpenstackBasicTemplate.Execute(&config4, data4); err != nil { - // t.Fatal(err) - // } + t.Log("Generated randomname: ", data.Name) resource.Test(t, resource.TestCase{ PreCheck: func() { @@ -161,38 +154,6 @@ func TestAccMetakubeCluster_Openstack_Basic(t *testing.T) { resource.TestCheckResourceAttrSet(resourceName, "deletion_timestamp"), ), }, - // Uncomment this block once cilium reconciliation is done. - // { - // Config: config4.String(), - // Check: resource.ComposeAggregateTestCheckFunc( - // testAccCheckMetaKubeClusterExists(&cluster), - // testAccCheckMetaKubeClusterOpenstackAttributes(&cluster, data4.Name, data4.DatacenterName, data4.Version, false), - // resource.TestCheckResourceAttr(resourceName, "dc_name", data4.DatacenterName), - // resource.TestCheckResourceAttr(resourceName, "name", data4.Name), - // resource.TestCheckResourceAttr(resourceName, "labels.%", "2"), - // resource.TestCheckResourceAttr(resourceName, "labels.a", "b"), - // resource.TestCheckResourceAttr(resourceName, "labels.c", "d"), - // resource.TestCheckResourceAttr(resourceName, "spec.#", "1"), - // resource.TestCheckResourceAttr(resourceName, "spec.0.version", data.Version), - // resource.TestCheckResourceAttr(resourceName, "spec.0.update_window.0.start", "Tue 02:00"), - // resource.TestCheckResourceAttr(resourceName, "spec.0.update_window.0.length", "2h"), - // resource.TestCheckResourceAttr(resourceName, "spec.0.services_cidr", "10.240.16.0/18"), - // resource.TestCheckResourceAttr(resourceName, "spec.0.pods_cidr", "172.25.0.0/18"), - // resource.TestCheckResourceAttr(resourceName, "spec.0.cni_plugin.#", "1"), - // resource.TestCheckResourceAttr(resourceName, "spec.0.cni_plugin.0.type", "cilium"), - // resource.TestCheckResourceAttr(resourceName, "spec.0.cloud.#", "1"), - // resource.TestCheckResourceAttr(resourceName, "spec.0.cloud.0.aws.#", "0"), - // resource.TestCheckResourceAttr(resourceName, "spec.0.cloud.0.openstack.#", "1"), - // resource.TestCheckResourceAttrSet(resourceName, "spec.0.cloud.0.openstack.0.security_group"), - // resource.TestCheckResourceAttrSet(resourceName, "spec.0.cloud.0.openstack.0.network"), - // resource.TestCheckResourceAttrSet(resourceName, "spec.0.cloud.0.openstack.0.subnet_id"), - // resource.TestCheckResourceAttr(resourceName, "spec.0.cloud.0.openstack.0.subnet_cidr", "192.168.2.0/24"), - // resource.TestCheckResourceAttrSet(resourceName, "kube_config"), - // resource.TestCheckResourceAttr(resourceName, "spec.0.audit_logging", "false"), - // resource.TestCheckResourceAttrSet(resourceName, "creation_timestamp"), - // resource.TestCheckResourceAttrSet(resourceName, "deletion_timestamp"), - // ), - // }, { ResourceName: resourceName, ImportState: true,