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

feat: Add IP Restriction for Container Registry #552

Merged
merged 1 commit into from
Feb 9, 2024

Conversation

nicolaslacroux
Copy link
Contributor

@nicolaslacroux nicolaslacroux commented Feb 1, 2024

Description

Add Managed Private Registry IP Restrictions feature (relative to ovh/public-cloud-roadmap#23)

Type of change

Please delete options that are not relevant.

  • New feature (non-breaking change which adds functionality)
  • Documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • Test A: make testacc TESTARGS="-run TestAccCloudProjectContainerRegistryIPRestrictionsManagement_basic"
  • Test B: make testacc TESTARGS="-run TestAccCloudProjectContainerRegistryIPRestrictionsRegistry_basic"
  • Test C: make testacc TESTARGS="-run TestAccCloudProjectContainerIPRestrictionsManagementDataSource_basic"
  • Test D: make testacc TESTARGS="-run TestAccCloudProjectContainerIPRestrictionsRegistryDataSource_basic"

Test Configuration:

  • Terraform version: terraform version: Terraform v1.6.6
  • Existing HCL configuration you used:
data "ovh_cloud_project_capabilities_containerregistry_filter" "registryCap" {
	service_name = "xxxxxxxxxxxxxxxxxxxxxxxx"
	plan_name    = "SMALL"
	region       = "GRA"
}

resource "ovh_cloud_project_containerregistry" "registry" {
	service_name = data.ovh_cloud_project_capabilities_containerregistry_filter.registryCap.service_name
	plan_id      = data.ovh_cloud_project_capabilities_containerregistry_filter.registryCap.id
	name         = "test-tf"
	region       = data.ovh_cloud_project_capabilities_containerregistry_filter.registryCap.region
}

resource "ovh_cloud_project_containerregistry_ip_restrictions_management" "my-mgt-iprestrictions" {
	service_name = ovh_cloud_project_containerregistry.registry.service_name
	registry_id  = ovh_cloud_project_containerregistry.registry.id

	ip_restrictions = [
		{   
			description = "first ip_block"
			ip_block = "121.122.123.124/32"
    	},
		{   
			description = "second ip_block"
			ip_block = "124.123.122.121/32"
    	}
    ]
}

resource "ovh_cloud_project_containerregistry_ip_restrictions_registry" "my-registry-iprestrictions" {
	service_name = ovh_cloud_project_containerregistry.registry.service_name
	registry_id  = ovh_cloud_project_containerregistry.registry.id

	ip_restrictions = [
		{   
			description = "first ip_block"
			ip_block = "121.122.123.124/32"
    	},
		{   
			description = "second ip_block"
			ip_block = "124.123.122.121/32"
    	}
    ]
}

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings or issues
  • I have added acceptance tests that prove my fix is effective or that my feature works
  • New and existing acceptance tests pass locally with my changes
  • I ran succesfully go mod vendor if I added or modify go.mod file

@nicolaslacroux nicolaslacroux force-pushed the mpr/feature/add-iprestrions branch 3 times, most recently from f92c991 to f018681 Compare February 2, 2024 05:15
ip_block = "121.121.121.121/32"
description = "my new awesome ip description"
}
]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indentation issue here (and on lines above)

@amstuta
Copy link
Collaborator

amstuta commented Feb 6, 2024

just ran the tests locally, this PR make the two following tests fail, can you fix them ?

=== RUN   TestAccCloudProjectContainerIPRestrictionsManagementDataSource_basic
    provider_test.go:373: Read Cloud Project /cloud/project/e77c310b1d7c4e6e844ac89b9290ff09 -> status: 'ok', desc: 'ovh_tf_provider_CDS'
    data_cloud_project_containerregistry_ip_restrictions_management_test.go:63: Step 1/1 error: Error running pre-apply plan: exit status 1

        Error: Missing required argument

          on terraform_plugin_test.tf line 40, in data "ovh_cloud_project_containerregistry_ip_restrictions_management" "mgt-iprestrictions-data":
          40: data "ovh_cloud_project_containerregistry_ip_restrictions_management" "mgt-iprestrictions-data" {

        The argument "ip_restrictions" is required, but no definition was found.
--- FAIL: TestAccCloudProjectContainerIPRestrictionsManagementDataSource_basic (0.21s)
=== RUN   TestAccCloudProjectContainerIPRestrictionsRegistryDataSource_basic
    provider_test.go:373: Read Cloud Project /cloud/project/e77c310b1d7c4e6e844ac89b9290ff09 -> status: 'ok', desc: 'ovh_tf_provider_CDS'
    data_cloud_project_containerregistry_ip_restrictions_registry_test.go:63: Step 1/1 error: Error running pre-apply plan: exit status 1

        Error: Missing required argument

          on terraform_plugin_test.tf line 40, in data "ovh_cloud_project_containerregistry_ip_restrictions_registry" "registry-iprestrictions-data":
          40: data "ovh_cloud_project_containerregistry_ip_restrictions_registry" "registry-iprestrictions-data" {

        The argument "ip_restrictions" is required, but no definition was found.
--- FAIL: TestAccCloudProjectContainerIPRestrictionsRegistryDataSource_basic (0.20s)

@nicolaslacroux nicolaslacroux force-pushed the mpr/feature/add-iprestrions branch 2 times, most recently from d0bbd83 to 97af769 Compare February 9, 2024 09:26
Type: schema.TypeString,
Description: "Service name",
Required: true,
ForceNew: true,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same comments on ForceNew and Computed as in above datasource

@nicolaslacroux nicolaslacroux force-pushed the mpr/feature/add-iprestrions branch from 97af769 to 25fe273 Compare February 9, 2024 13:40
@amstuta amstuta merged commit d20d859 into ovh:master Feb 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants