Skip to content

Commit

Permalink
add OS_REGION to provider
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert Nemeti committed Feb 20, 2024
1 parent d2b7cae commit f366077
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 4 deletions.
6 changes: 3 additions & 3 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ env:
paths:
- test.env
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH || $CI_COMMIT_BRANCH =~ /k8s-.*/ || $CI_PIPELINE_SOURCE == "web"
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH || $CI_COMMIT_BRANCH =~ /k8s-.*/i || $CI_PIPELINE_SOURCE == "web"

test:
stage: test
Expand All @@ -48,8 +48,8 @@ test:
- go test -race $(go list ./... | grep -v /vendor/)
- go build -race -ldflags "-extldflags '-static'" -o $CI_PROJECT_DIR/mybinary
- go test ./metakube -v -sweep=all
- TF_ACC=1 go test ./metakube -v -timeout 3h --parallel 10 -run TestAcc
- TF_ACC=1 go test ./metakube -v -timeout 3h -parallel 10 -run TestAcc
needs:
- env
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH || $CI_COMMIT_BRANCH =~ /k8s-.*/ || $CI_PIPELINE_SOURCE == "web"
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH || $CI_COMMIT_BRANCH =~ /k8s-.*/i || $CI_PIPELINE_SOURCE == "web"
2 changes: 2 additions & 0 deletions metakube/provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const (
testEnvOpenstackPassword = "METAKUBE_OPENSTACK_PASSWORD"
testEnvOpenstackProjectID = "METAKUBE_OPENSTACK_PROJECT_ID"
testEnvOpenstackProjectName = "METAKUBE_OPENSTACK_PROJECT_NAME"
testEnvOpenstackRegion = "METAKUBE_OPENSTACK_REGION"
testEnvOpenstackImage = "METAKUBE_OPENSTACK_IMAGE"
testEnvOpenstackImage2 = "METAKUBE_OPENSTACK_IMAGE2"
testEnvOpenstackFlavor = "METAKUBE_OPENSTACK_FLAVOR"
Expand Down Expand Up @@ -84,6 +85,7 @@ func testAccPreCheckForOpenstack(t *testing.T) {
checkEnv(t, testEnvOpenstackPassword)
checkEnv(t, testEnvOpenstackProjectID)
checkEnv(t, testEnvOpenstackProjectName)
checkEnv(t, testEnvOpenstackRegion)
checkEnv(t, testEnvOpenstackNodeDC)
checkEnv(t, testEnvOpenstackImage)
checkEnv(t, testEnvOpenstackImage2)
Expand Down
25 changes: 24 additions & 1 deletion metakube/resource_cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ func TestAccMetakubeCluster_Openstack_Basic(t *testing.T) {
OpenstackUser: os.Getenv(testEnvOpenstackUsername),
OpenstackPassword: os.Getenv(testEnvOpenstackPassword),
OpenstackProjectID: os.Getenv(testEnvOpenstackProjectID),
OpenstackRegion: os.Getenv(testEnvOpenstackRegion),
DatacenterName: os.Getenv(testEnvOpenstackNodeDC),
ProjectID: os.Getenv(testEnvProjectID),
Version: os.Getenv(testEnvK8sVersionOpenstack),
Expand Down Expand Up @@ -222,6 +223,11 @@ func TestAccMetakubeCluster_Openstack_ApplicationCredentials_Dynammic(t *testing
resourceName := "metakube_cluster.acctest_cluster"
data := &clusterOpenstackApplicationCredentailsData{
Name: makeRandomName() + "-appcred-dynamic",
OpenstackAuthURL: os.Getenv(testEnvOpenstackAuthURL),
OpenstackUser: os.Getenv(testEnvOpenstackUsername),
OpenstackPassword: os.Getenv(testEnvOpenstackPassword),
OpenstackProjectID: os.Getenv(testEnvOpenstackProjectID),
OpenstackRegion: os.Getenv(testEnvOpenstackRegion),
DatacenterName: os.Getenv(testEnvOpenstackNodeDC),
ProjectID: os.Getenv(testEnvProjectID),
Version: os.Getenv(testEnvK8sVersionOpenstack),
Expand Down Expand Up @@ -269,6 +275,7 @@ func TestAccMetakubeCluster_Openstack_UpgradeVersion(t *testing.T) {
OpenstackProjectID: os.Getenv(testEnvOpenstackProjectID),
DatacenterName: os.Getenv(testEnvOpenstackNodeDC),
ProjectID: os.Getenv(testEnvProjectID),
OpenstackRegion: os.Getenv(testEnvOpenstackRegion),
}
var result strings.Builder
if err := clusterOpenstackBasicTemplate.Execute(&result, data); err != nil {
Expand Down Expand Up @@ -312,6 +319,7 @@ type clusterOpenstackBasicData struct {
OpenstackUser string
OpenstackPassword string
OpenstackProjectID string
OpenstackRegion string

Name string
DatacenterName string
Expand All @@ -337,6 +345,7 @@ provider "openstack" {
user_name = "{{ .OpenstackUser }}"
password = "{{ .OpenstackPassword }}"
tenant_id = "{{ .OpenstackProjectID }}"
region = "{{ .OpenstackRegion }}"
}
resource "metakube_cluster" "acctest_cluster" {
Expand Down Expand Up @@ -417,6 +426,12 @@ resource "openstack_networking_subnet_v2" "subnet_tf_test" {
}`)

type clusterOpenstackApplicationCredentailsData struct {
OpenstackAuthURL string
OpenstackUser string
OpenstackPassword string
OpenstackProjectID string
OpenstackRegion string

Name string
DatacenterName string
ProjectID string
Expand All @@ -436,9 +451,17 @@ terraform {
}
{{ if .Dynamic }}
provider "openstack" {
auth_url = "{{ .OpenstackAuthURL }}"
user_name = "{{ .OpenstackUser }}"
password = "{{ .OpenstackPassword }}"
tenant_id = "{{ .OpenstackProjectID }}"
region = "{{ .OpenstackRegion }}"
}
resource "openstack_identity_application_credential_v3" "app_credential" {
name = "{{ .Name }}"
}
}
{{ end }}
resource "metakube_cluster" "acctest_cluster" {
Expand Down
3 changes: 3 additions & 0 deletions metakube/resource_node_deployment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ func TestAccMetakubeNodeDeployment_Openstack_Basic(t *testing.T) {
OpenstackUser: os.Getenv(testEnvOpenstackUsername),
OpenstackPassword: os.Getenv(testEnvOpenstackPassword),
OpenstackProjectID: os.Getenv(testEnvOpenstackProjectID),
OpenstackRegion: os.Getenv(testEnvOpenstackRegion),
DatacenterName: os.Getenv(testEnvOpenstackNodeDC),
ProjectID: os.Getenv(testEnvProjectID),
ClusterVersion: os.Getenv(testEnvK8sVersionOpenstack),
Expand Down Expand Up @@ -130,6 +131,7 @@ type nodeDeploymentBasicData struct {
OpenstackUser string
OpenstackPassword string
OpenstackProjectID string
OpenstackRegion string

Name string
DatacenterName string
Expand All @@ -155,6 +157,7 @@ var nodeDeploymentBasicTemplate = mustParseTemplate("nodeDeploymentBasic", `
user_name = "{{ .OpenstackUser }}"
password = "{{ .OpenstackPassword }}"
tenant_id = "{{ .OpenstackProjectID }}"
region = "{{ .OpenstackRegion }}"
}
data "openstack_images_image_v2" "image" {
Expand Down

0 comments on commit f366077

Please sign in to comment.