-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Feat add azure containers cache #24040
Conversation
63af448
to
2351da9
Compare
There was a problem hiding this 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": { |
There was a problem hiding this comment.
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:
terraform-provider-azurerm/internal/services/containers/container_registry_task_resource.go
Line 126 in 46a95c1
ContainerRegistryId string `tfschema:"container_registry_id"` |
} | ||
|
||
func (ContainerRegistryCacheRule) IDValidationFunc() pluginsdk.SchemaValidateFunc { | ||
return validate.ContainerRegistryCacheRuleID |
There was a problem hiding this comment.
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:
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 |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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)
I did, thanks :) I'll try pushing it through in the first week of 2024 :) |
6d164a0
to
09a00ff
Compare
@mhaligowski - is this PR now ready to be reviewed? it has been in draft for a while |
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! |
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. |
No description provided.