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 azure containers cache #24040

Closed

Conversation

mhaligowski
Copy link
Contributor

No description provided.

Copy link
Collaborator

@aristosvo aristosvo left a comment

Choose a reason for hiding this comment

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

Hi @mhaligowski! Thanks for all this! I gave you a few pointers to start with, as I don't expect a review from the HC maintainers these days, they will have probably a few more remarks.

There are two tests failing as well:

------- Stdout: -------
=== RUN   TestAccContainerRegistryCacheRule_basic
=== PAUSE TestAccContainerRegistryCacheRule_basic
=== CONT  TestAccContainerRegistryCacheRule_basic
    testcase.go:113: Step 1/2 error: Error running pre-apply refresh: exit status 1
        Error: Unsupported argument
          on terraform_plugin_test.tf line 35, in resource "azurerm_container_registry_cache_rule" "test":
          35:   resource_group_name = azurerm_resource_group.test.name
        An argument named "resource_group_name" is not expected here.
--- FAIL: TestAccContainerRegistryCacheRule_basic (2.78s)
FAIL
------- Stdout: -------
=== RUN   TestAccContainerRegistryCacheRule_requiresImport
=== PAUSE TestAccContainerRegistryCacheRule_requiresImport
=== CONT  TestAccContainerRegistryCacheRule_requiresImport
    testcase.go:113: Step 1/2 error: Error running pre-apply refresh: exit status 1
        Error: Unsupported argument
          on terraform_plugin_test.tf line 35, in resource "azurerm_container_registry_cache_rule" "test":
          35:   resource_group_name = azurerm_resource_group.test.name
        An argument named "resource_group_name" is not expected here.
--- FAIL: TestAccContainerRegistryCacheRule_requiresImport (3.10s)
FAIL

Hope you enjoy the last bits of 2023!

Description: "The name of the cache rule.",
},

"registry": {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would opt for container_registry_id here, which contains both the resource group name and registry name, as input.

How to work with that ID is shown here:

ContainerRegistryId string `tfschema:"container_registry_id"`

}

func (ContainerRegistryCacheRule) IDValidationFunc() pluginsdk.SchemaValidateFunc {
return validate.ContainerRegistryCacheRuleID
Copy link
Collaborator

Choose a reason for hiding this comment

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

I believe you can replace the validate package with the content of cacherules in the new SDK, like this:

Suggested change
return validate.ContainerRegistryCacheRuleID
return cacherules.ValidateCacheRuleID

@@ -5,5 +5,6 @@ package containers

//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=Cluster -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.ContainerService/managedClusters/cluster1
//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=NodePool -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.ContainerService/managedClusters/cluster1/agentPools/pool1
//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=ContainerRegistryCacheRule -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/group1/providers/Microsoft.ContainerRegistry/registries/registry1/cacheRules/rule1
Copy link
Collaborator

Choose a reason for hiding this comment

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

If you don't need the validate package for ID validation, you can remove this resource ID entry as well!

@@ -37,6 +40,12 @@ type Client struct {
}

func NewContainersClient(o *common.ClientOptions) (*Client, error) {
cacheRulesClient, err := cacherules.NewCacheRulesClientWithBaseURI(o.Environment.ResourceManager)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think this declaration of the cacheRulesClient is necessary for the new SDK clients anymore


type ContainerRegistryCacheRuleResource struct{}

func TestAccContainerRegistryCacheRuleName_validation(t *testing.T) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This validate function is already tested in its own package (and you won't need it after all)

@mhaligowski
Copy link
Contributor Author

Hi @mhaligowski! Thanks for all this! I gave you a few pointers to start with, as I don't expect a review from the HC maintainers these days, they will have probably a few more remarks.

There are two tests failing as well:

------- Stdout: -------
=== RUN   TestAccContainerRegistryCacheRule_basic
=== PAUSE TestAccContainerRegistryCacheRule_basic
=== CONT  TestAccContainerRegistryCacheRule_basic
    testcase.go:113: Step 1/2 error: Error running pre-apply refresh: exit status 1
        Error: Unsupported argument
          on terraform_plugin_test.tf line 35, in resource "azurerm_container_registry_cache_rule" "test":
          35:   resource_group_name = azurerm_resource_group.test.name
        An argument named "resource_group_name" is not expected here.
--- FAIL: TestAccContainerRegistryCacheRule_basic (2.78s)
FAIL
------- Stdout: -------
=== RUN   TestAccContainerRegistryCacheRule_requiresImport
=== PAUSE TestAccContainerRegistryCacheRule_requiresImport
=== CONT  TestAccContainerRegistryCacheRule_requiresImport
    testcase.go:113: Step 1/2 error: Error running pre-apply refresh: exit status 1
        Error: Unsupported argument
          on terraform_plugin_test.tf line 35, in resource "azurerm_container_registry_cache_rule" "test":
          35:   resource_group_name = azurerm_resource_group.test.name
        An argument named "resource_group_name" is not expected here.
--- FAIL: TestAccContainerRegistryCacheRule_requiresImport (3.10s)
FAIL

Hope you enjoy the last bits of 2023!

I did, thanks :) I'll try pushing it through in the first week of 2024 :)

@katbyte
Copy link
Collaborator

katbyte commented Mar 21, 2024

@mhaligowski - is this PR now ready to be reviewed? it has been in draft for a while

@stephybun
Copy link
Member

Going to close this for the moment since we haven't heard back. Let us know when you're ready to come back to this @mhaligowski and we can re-open this!

Copy link

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active contributions.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 16, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants