-
Notifications
You must be signed in to change notification settings - Fork 280
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
Adding new resource azuredevops_repository_policy_searchable_branches #1272
base: main
Are you sure you want to change the base?
Adding new resource azuredevops_repository_policy_searchable_branches #1272
Conversation
@microsoft-github-policy-service agree |
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.
@mdevreugd took a quick look. A few changes required.
Also I found that the default searchable branches may exists and TF script is only part of them, these configurations needs to be handled carefully.
Another issue is the dev
and refs/heads/dev
have different meanings but in portal they all show up as dev
refs/heads/dev
"github.com/microsoft/azure-devops-go-api/azuredevops/v7/policy" | ||
) | ||
|
||
type searchbranchesPolicySettings struct { |
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 code can be removed
|
||
maps.Copy(resource.Schema, map[string]*schema.Schema{ | ||
"searchable_branches": { | ||
Type: schema.TypeList, |
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.
Should be TypeSet
instead of TypeList
to avoid potential ordering issues
"enabled": { | ||
Type: schema.TypeBool, | ||
Computed: true, | ||
}, | ||
"blocking": { | ||
Type: schema.TypeBool, | ||
Computed: true, | ||
}, | ||
// API only accepts a single repository as scope. | ||
"repository_ids": { | ||
Type: schema.TypeList, | ||
Required: true, | ||
MinItems: 1, | ||
MaxItems: 1, | ||
Elem: &schema.Schema{ | ||
Type: schema.TypeString, | ||
ValidateFunc: validation.IsUUID, | ||
}, | ||
}, |
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.
These properties are handled in the infrastructure and we can remove them
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.
That's true. The reason why I've added these is to override them, however.
The thing with the Searchable Branches policy is that the API still expects these to be passed, but setting the enabled
or blocking
to true
causes an error.
And you can only scope this for 1 repository, plus I did not want to mess too much with the schema. Hence forcing the repository_ids
to accept only 1.
}) | ||
|
||
maps.Copy(resource.Schema, map[string]*schema.Schema{ | ||
"searchable_branches": { |
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.
"searchable_branches": { | |
"branches": { |
return resource | ||
} | ||
|
||
func searchableBranchesFlattenFunc(d *schema.ResourceData, policyConfig *policy.PolicyConfiguration, projectID *string) error { |
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.
func searchableBranchesFlattenFunc(d *schema.ResourceData, policyConfig *policy.PolicyConfiguration, projectID *string) error { | |
func flattenSearchableBranches(d *schema.ResourceData, policyConfig *policy.PolicyConfiguration, projectID *string) error { |
return nil | ||
} | ||
|
||
func searchableBranchesExpandFunc(d *schema.ResourceData, typeID uuid.UUID) (*policy.PolicyConfiguration, *string, error) { |
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.
func searchableBranchesExpandFunc(d *schema.ResourceData, typeID uuid.UUID) (*policy.PolicyConfiguration, *string, error) { | |
func expandSearchableBranches(d *schema.ResourceData, typeID uuid.UUID) (*policy.PolicyConfiguration, *string, error) { |
Computed: true, | ||
}, | ||
// API only accepts a single repository as scope. | ||
"repository_ids": { |
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 is legacy technical debt. Instead of using a generic scheme, you can add entire schemes as needed and handle create/update/read/delete yourself. Based on the information you shared, it is recommended to do this
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.
Ah, I just read this comment in order. :)
So you're suggesting to not use the generic schema provided by common.
Let me look into it 👍
## Relevant Links | ||
|
||
- [Azure DevOps Service REST API 7.0 - Policy Configurations](https://docs.microsoft.com/en-us/rest/api/azure/devops/policy/configurations?view=azure-devops-rest-7.0) | ||
|
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.
## Timeouts | |
The `timeouts` block allows you to specify [timeouts](https://www.terraform.io/docs/configuration/resources.html#timeouts) for certain actions: | |
* `create` - (Defaults to 30 minutes) Used when creating the Searchable Branches Repository Policy. | |
* `read` - (Defaults to 5 minute) Used when retrieving the Searchable Branches Repository Policy. | |
* `update` - (Defaults to 30 minutes) Used when updating the Searchable Branches Repository Policy. | |
* `delete` - (Defaults to 30 minutes) Used when deleting the Searchable Branches Repository Policy. | |
All Submissions:
What about the current behavior has changed?
This PR adds the resource azuredevops_repository_policy_searchable_branches which have been missing so far.
This will help improve the overall automation capabilities around ADO.
Issue Number: #891
Does this introduce a change to
go.mod
,go.sum
orvendor/
?Does this introduce a breaking change?
Any relevant logs, error output, etc?
(If it’s long, please paste to https://ghostbin.com/ and insert the link here.)
Other information
@microsoft-github-policy-service agree