|
| 1 | +package ovh |
| 2 | + |
| 3 | +import ( |
| 4 | + "fmt" |
| 5 | + "os" |
| 6 | + "testing" |
| 7 | + |
| 8 | + "github.com/hashicorp/terraform-plugin-testing/helper/acctest" |
| 9 | + "github.com/hashicorp/terraform-plugin-testing/helper/resource" |
| 10 | +) |
| 11 | + |
| 12 | +func TestAccCloudProjectContainerRegistryIAMDataSource_basic(t *testing.T) { |
| 13 | + serviceName := os.Getenv("OVH_CLOUD_PROJECT_SERVICE_TEST") |
| 14 | + region := os.Getenv("OVH_CLOUD_PROJECT_CONTAINERREGISTRY_REGION_TEST") |
| 15 | + registryName := acctest.RandomWithPrefix(test_prefix) |
| 16 | + |
| 17 | + config := fmt.Sprintf( |
| 18 | + testAccCloudProjectContainerRegistryIAMDataSourceConfig, |
| 19 | + serviceName, |
| 20 | + region, |
| 21 | + registryName, |
| 22 | + ) |
| 23 | + |
| 24 | + resource.Test(t, resource.TestCase{ |
| 25 | + PreCheck: func() { |
| 26 | + testAccPreCheckContainerRegistryIAM(t) |
| 27 | + }, |
| 28 | + Providers: testAccProviders, |
| 29 | + Steps: []resource.TestStep{ |
| 30 | + { |
| 31 | + Config: config, |
| 32 | + Check: resource.ComposeTestCheckFunc( |
| 33 | + resource.TestCheckResourceAttr( |
| 34 | + "data.ovh_cloud_project_containerregistry_iam.iamData", "iam_enabled", "true"), |
| 35 | + ), |
| 36 | + }, |
| 37 | + }, |
| 38 | + }) |
| 39 | +} |
| 40 | + |
| 41 | +var testAccCloudProjectContainerRegistryIAMDataSourceConfig = ` |
| 42 | +data "ovh_cloud_project_capabilities_containerregistry_filter" "registryCap" { |
| 43 | + service_name = "%s" |
| 44 | + plan_name = "SMALL" |
| 45 | + region = "%s" |
| 46 | +} |
| 47 | +
|
| 48 | +resource "ovh_cloud_project_containerregistry" "registry" { |
| 49 | + service_name = data.ovh_cloud_project_capabilities_containerregistry_filter.registryCap.service_name |
| 50 | + plan_id = data.ovh_cloud_project_capabilities_containerregistry_filter.registryCap.id |
| 51 | + name = "%s" |
| 52 | + region = data.ovh_cloud_project_capabilities_containerregistry_filter.registryCap.region |
| 53 | +} |
| 54 | +
|
| 55 | +resource "ovh_cloud_project_containerregistry_iam" "iam" { |
| 56 | + service_name = ovh_cloud_project_containerregistry.registry.service_name |
| 57 | + registry_id = ovh_cloud_project_containerregistry.registry.id |
| 58 | +
|
| 59 | + depends_on = [ |
| 60 | + ovh_cloud_project_containerregistry.registry |
| 61 | + ] |
| 62 | +} |
| 63 | +
|
| 64 | +data "ovh_cloud_project_containerregistry_iam" "iamData" { |
| 65 | + service_name = ovh_cloud_project_containerregistry.registry.service_name |
| 66 | + registry_id = ovh_cloud_project_containerregistry.registry.id |
| 67 | +
|
| 68 | + depends_on = [ |
| 69 | + ovh_cloud_project_containerregistry_iam.iam |
| 70 | + ] |
| 71 | +} |
| 72 | +` |
0 commit comments