Skip to content

Commit

Permalink
Merge pull request #292 from fluxcd/int-use-tf-mods
Browse files Browse the repository at this point in the history
tests/integration: Use terraform modules and test-infra/tftestenv
  • Loading branch information
stefanprodan authored Jul 29, 2022
2 parents f683b60 + a931aa6 commit 99e8ea3
Show file tree
Hide file tree
Showing 28 changed files with 75 additions and 2,544 deletions.
2 changes: 1 addition & 1 deletion tests/integration/aws_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (

tfjson "github.com/hashicorp/terraform-json"

tftestenv "github.com/fluxcd/image-reflector-controller/tests/tftestenv"
"github.com/fluxcd/test-infra/tftestenv"
)

// createKubeconfigEKS constructs kubeconfig from the terraform state output at
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/azure_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (

tfjson "github.com/hashicorp/terraform-json"

"github.com/fluxcd/image-reflector-controller/tests/tftestenv"
"github.com/fluxcd/test-infra/tftestenv"
)

// createKubeConfigAKS constructs kubeconfig for an AKS cluster from the
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/gcp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (

tfjson "github.com/hashicorp/terraform-json"

tftestenv "github.com/fluxcd/image-reflector-controller/tests/tftestenv"
"github.com/fluxcd/test-infra/tftestenv"
)

// createKubeconfigGKE constructs kubeconfig from the terraform state output at
Expand Down
4 changes: 1 addition & 3 deletions tests/integration/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@ module github.com/fluxcd/image-reflector-controller/tests/integration

go 1.18

replace github.com/fluxcd/image-reflector-controller/tests/tftestenv => ../tftestenv

require (
github.com/fluxcd/image-reflector-controller/api v0.18.0
github.com/fluxcd/image-reflector-controller/tests/tftestenv v0.0.0
github.com/fluxcd/test-infra/tftestenv v0.0.0-20220726140458-65e1a901cbb9
github.com/hashicorp/terraform-json v0.14.0
github.com/onsi/gomega v1.18.1
k8s.io/apimachinery v0.24.1
Expand Down
2 changes: 2 additions & 0 deletions tests/integration/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,8 @@ github.com/fluxcd/pkg/apis/acl v0.0.3 h1:Lw0ZHdpnO4G7Zy9KjrzwwBmDZQuy4qEjaU/RvA6
github.com/fluxcd/pkg/apis/acl v0.0.3/go.mod h1:XPts6lRJ9C9fIF9xVWofmQwftvhY25n1ps7W9xw0XLU=
github.com/fluxcd/pkg/apis/meta v0.13.0 h1:0QuNKEExSjk+Rv0I6a85p2H3xOlWhdxZRsh10waEL/c=
github.com/fluxcd/pkg/apis/meta v0.13.0/go.mod h1:Z26X5uTU5LxAyWETGueRQY7TvdPaGfKU7Wye9bdUlho=
github.com/fluxcd/test-infra/tftestenv v0.0.0-20220726140458-65e1a901cbb9 h1:+yQtW3Q9MI2rSvcX2zZUA8q1dMMkSESgH7TfJtvLBU8=
github.com/fluxcd/test-infra/tftestenv v0.0.0-20220726140458-65e1a901cbb9/go.mod h1:k6Gpx/GKi2qtFdGg8oUudww0elpknijNXt5hwKT7OJQ=
github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc=
github.com/form3tech-oss/jwt-go v3.2.2+incompatible/go.mod h1:pbq4aXjuKjdthFRnoDwaVPLA+WlJuPGy+QneDUgJi2k=
github.com/form3tech-oss/jwt-go v3.2.3+incompatible/go.mod h1:pbq4aXjuKjdthFRnoDwaVPLA+WlJuPGy+QneDUgJi2k=
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import (
"k8s.io/apimachinery/pkg/runtime"

imagev1 "github.com/fluxcd/image-reflector-controller/api/v1beta1"
tftestenv "github.com/fluxcd/image-reflector-controller/tests/tftestenv"
"github.com/fluxcd/test-infra/tftestenv"
)

const (
Expand Down
11 changes: 0 additions & 11 deletions tests/integration/terraform/aws/ecr.tf

This file was deleted.

45 changes: 0 additions & 45 deletions tests/integration/terraform/aws/eks.tf

This file was deleted.

18 changes: 18 additions & 0 deletions tests/integration/terraform/aws/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,21 @@ resource "random_pet" "suffix" {}
locals {
name = "flux-test-${random_pet.suffix.id}"
}

module "eks" {
source = "git::https://github.com/fluxcd/test-infra.git//tf-modules/aws/eks"

name = local.name
}

module "test_ecr" {
source = "git::https://github.com/fluxcd/test-infra.git//tf-modules/aws/ecr"

name = "test-repo-${local.name}"
}

module "image_reflector_ecr" {
source = "git::https://github.com/fluxcd/test-infra.git//tf-modules/aws/ecr"

name = "test-image-reflector-${local.name}"
}
14 changes: 5 additions & 9 deletions tests/integration/terraform/aws/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ output "eks_cluster_name" {
}

output "eks_cluster_ca_certificate" {
value = module.eks.cluster_certificate_authority_data
value = module.eks.cluster_ca_data
sensitive = true
}

Expand All @@ -15,22 +15,18 @@ output "eks_cluster_arn" {
value = module.eks.cluster_arn
}

output "account_id" {
value = data.aws_caller_identity.current.account_id
}

output "region" {
value = data.aws_region.current.name
value = module.eks.region
}

output "ecr_repository_url" {
value = aws_ecr_repository.testrepo.repository_url
value = module.test_ecr.repository_url
}

output "ecr_registry_id" {
value = aws_ecr_repository.testrepo.registry_id
value = module.test_ecr.registry_id
}

output "ecr_image_reflector_controller_repo_url" {
value = aws_ecr_repository.image_reflector_controller.repository_url
value = module.image_reflector_ecr.repository_url
}
27 changes: 0 additions & 27 deletions tests/integration/terraform/aws/vpc.tf

This file was deleted.

14 changes: 0 additions & 14 deletions tests/integration/terraform/azure/acr.tf

This file was deleted.

25 changes: 0 additions & 25 deletions tests/integration/terraform/azure/aks.tf

This file was deleted.

20 changes: 19 additions & 1 deletion tests/integration/terraform/azure/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,23 @@ resource "random_pet" "suffix" {
}

locals {
name = "flux-test-${random_pet.suffix.id}"
name = "fluxTest${random_pet.suffix.id}"
}

module "aks" {
source = "git::https://github.com/fluxcd/test-infra.git//tf-modules/azure/aks"

name = local.name
location = var.azure_location
}

module "acr" {
source = "git::https://github.com/fluxcd/test-infra.git//tf-modules/azure/acr"

name = local.name
location = var.azure_location
aks_principal_id = module.aks.principal_id
resource_group = module.aks.resource_group

depends_on = [module.aks]
}
6 changes: 3 additions & 3 deletions tests/integration/terraform/azure/outputs.tf
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
output "aks_kubeconfig" {
value = azurerm_kubernetes_cluster.default.kube_config_raw
value = module.aks.kubeconfig
sensitive = true
}

output "acr_registry_url" {
value = azurerm_container_registry.acr.login_server
value = module.acr.registry_url
}

output "acr_registry_id" {
value = azurerm_container_registry.acr.id
value = module.acr.registry_id
}
13 changes: 0 additions & 13 deletions tests/integration/terraform/gcp/gcr.tf

This file was deleted.

28 changes: 0 additions & 28 deletions tests/integration/terraform/gcp/gke.tf

This file was deleted.

25 changes: 14 additions & 11 deletions tests/integration/terraform/gcp/main.tf
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
terraform {
required_providers {
kubectl = {
source = "gavinbunney/kubectl"
version = "~> 1.14.0"
}
}
provider "google" {
project = var.gcp_project_id
region = var.gcp_region
zone = var.gcp_zone
}

resource "random_pet" "suffix" {}
Expand All @@ -13,8 +10,14 @@ locals {
name = "flux-test-${random_pet.suffix.id}"
}

provider "google" {
project = var.gcp_project_id
region = var.gcp_region
zone = var.gcp_zone
module "gke" {
source = "git::https://github.com/fluxcd/test-infra.git//tf-modules/gcp/gke"

name = local.name
}

module "gcr" {
source = "git::https://github.com/fluxcd/test-infra.git//tf-modules/gcp/gcr"

name = local.name
}
16 changes: 8 additions & 8 deletions tests/integration/terraform/gcp/outputs.tf
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
output "gcr_repository_url" {
value = data.google_container_registry_repository.test_repo.repository_url
}

output "gcp_kubeconfig" {
value = module.gke_auth.kubeconfig_raw
value = module.gke.kubeconfig
sensitive = true
}

output "gcp_project" {
value = data.google_client_config.current.project
value = module.gke.project
}

output "gcp_region" {
value = data.google_client_config.current.region
value = module.gke.region
}

output "gcr_repository_url" {
value = module.gcr.gcr_repository_url
}

output "gcp_artifact_repository" {
value = google_artifact_registry_repository.test_repo.repository_id
value = module.gcr.artifact_repository_id
}
2 changes: 1 addition & 1 deletion tests/integration/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
"path"
"strings"

tftestenv "github.com/fluxcd/image-reflector-controller/tests/tftestenv"
"github.com/fluxcd/test-infra/tftestenv"
)

// updateAndBuildFluxInstallManifests assumes that ./build/flux/ already exists
Expand Down
Loading

0 comments on commit 99e8ea3

Please sign in to comment.