-
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
azurerm_container_registry: support for network_rule_set
property
#3194
azurerm_container_registry: support for network_rule_set
property
#3194
Conversation
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.
hey @fraserdarwent
Thanks for this PR - apologies for the delayed review here!
Taking a look through this mostly LGTM - I've left some (mostly minor) comments in-line, but the main thing remaining is the tests; if we can fix up the comments and add some tests this should otherwise be good to merge 👍
Thanks!
ValidateFunc: validation.StringInSlice([]string{ | ||
string(containerregistry.DefaultActionAllow), | ||
string(containerregistry.DefaultActionDeny), | ||
}, true), |
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.
we're making all new fields case-sensitive; as such can we make this:
}, true), | |
}, false), |
Required: true, | ||
ValidateFunc: validation.StringInSlice([]string{ | ||
string(containerregistry.Allow), | ||
}, true), |
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.
(as above) we're making all new fields case-sensitive - as such can we make this:
}, true), | |
}, false), |
}, | ||
"subnet_id": { | ||
Type: schema.TypeString, | ||
Required: true, |
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.
since this is a Subnet/Resource ID can we validate this:
Required: true, | |
Required: true, | |
ValidateFunc: validate.AzureResourceID, |
Required: true, | ||
ValidateFunc: validation.StringInSlice([]string{ | ||
string(containerregistry.Allow), | ||
}, true), |
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.
(as above) all new fields in the provider are case-sensitive - as such can we make this:
}, true), | |
}, false), |
|
||
`subnet_rule` supports the following: | ||
|
||
* `action` - (Required) The behaviour for requests matching this rule. Can only be `Allow` |
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.
for consistency with other resources can we make this:
* `action` - (Required) The behaviour for requests matching this rule. Can only be `Allow` | |
* `action` - (Required) The behaviour for requests matching this rule. At this time the only supported value is `Allow` |
|
||
* `action` - (Required) The behaviour for requests matching this rule. Can only be `Allow` | ||
|
||
* `subnet_id` - (Required) Resource ID of the subnet from which requests will match the rule. |
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.
for consistency with other resources can we make this:
* `subnet_id` - (Required) Resource ID of the subnet from which requests will match the rule. | |
* `subnet_id` - (Required) The ID of the Subnet from which requests will match the rule. |
config := configs[0].(map[string]interface{}) | ||
|
||
virtualNetworkRuleConfigs := config["subnet_rule"].([]interface{}) | ||
virtualNetworkRules := make([]containerregistry.VirtualNetworkRule, 0, len(virtualNetworkRuleConfigs)) |
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.
we can remove this last item here:
virtualNetworkRules := make([]containerregistry.VirtualNetworkRule, 0, len(virtualNetworkRuleConfigs)) | |
virtualNetworkRules := make([]containerregistry.VirtualNetworkRule, 0) |
@@ -499,3 +560,39 @@ func validateAzureRMContainerRegistryName(v interface{}, k string) (warnings []s | |||
|
|||
return warnings, errors | |||
} | |||
|
|||
func expandNetworkRuleSet(d *schema.ResourceData) *containerregistry.NetworkRuleSet { | |||
configs := d.Get("network_access_profile").(*schema.Set).List() |
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.
since we're making this a List (above) we can make this:
configs := d.Get("network_access_profile").(*schema.Set).List() | |
configs := d.Get("network_access_profile").([]interface{}) |
} | ||
|
||
ipRuleConfigs := config["ip_rule"].([]interface{}) | ||
ipRules := make([]containerregistry.IPRule, 0, len(ipRuleConfigs)) |
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.
(as above) we can remove this final argument here:
ipRules := make([]containerregistry.IPRule, 0, len(ipRuleConfigs)) | |
ipRules := make([]containerregistry.IPRule, 0) |
@tombuildsstuff addressed comments |
@katbyte made suggested changes to pass the tests as the value is computed |
Hi @fraserdarwent,
|
Hi @fraserdarwent, I hope you don't mind but i've pushed some changes to this branch to fix the above error, rename the property to better match the API as well as adding some more tests so I can merge this. It appears VNET rules are being ignored by the API? and only |
network_rule_set
property
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.
Have pushed required changes
This has been released in version 1.32.0 of the provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. As an example: provider "azurerm" {
version = "~> 1.32.0"
}
# ... other configuration ... |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 hashibot-feedback@hashicorp.com. Thanks! |
In response to #3134
(upgrades "github.com/Azure/azure-sdk-for-go/services/containerregistry/mgmt/2017-10-01/containerregistry" to 2018-09-01)
Example Terraform code
Getting an early PR in for feedback.
Still need to update docs and tests.
Fixes #3134