-
Notifications
You must be signed in to change notification settings - Fork 905
[MAINT] Fix github_organization_ruleset with push target
#2958
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
base: go-github-v68
Are you sure you want to change the base?
[MAINT] Fix github_organization_ruleset with push target
#2958
Conversation
| "ref_name": { | ||
| Type: schema.TypeList, | ||
| Required: true, | ||
| Optional: 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.
This is a non breaking change ➕
stevehipwell
left a comment
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 think this change likely wants to wait for the SDK upgrade as a lot of this area is modified in future versions.
FYI the error behaviours previously seen should have been mitigated by #2705 so if there is an error the provider should handle it gracefully.
| ValidateFunc: validation.StringInSlice([]string{"branch", "tag", "push", "repository"}, false), | ||
| Description: "The target of the ruleset. Possible values are `branch`, `tag`, `push` and `repository`.", |
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.
The SDK doesn't support repository target rules, mainly because I've only just discovered that despite being in a separate UI area they're merged into the existing API. This is made even less discoverable by the top example of targets not having repository as an option, the schemas not being updated, and nobody at GitHub being able to give me a definitive answer.
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.
v79 of the SDK does support those: https://github.com/google/go-github/blob/master/github/rules.go#L220
I honestly wanted to already put them there, so that it's ready when we get to upgrade. But I can remove it for now
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 literally just added support for them in google/go-github#3850 and they've just been released in v80.0.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.
This needs removing.
| Optional: true, | ||
| MaxItems: 1, | ||
| Description: "Parameters for an organization ruleset condition. `ref_name` is required alongside one of `repository_name` or `repository_id`.", | ||
| Description: "Parameters for an organization ruleset condition. For `branch` and `tag` targets, `ref_name` is required alongside one of `repository_name` or `repository_id`. The `push` target does not require `ref_name` conditions. For `repository` target, the conditions object should only contain the `repository_name` and the `repository_id`.", |
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 doesn't look quite right, all org rulesets support complex repository targeting (SDK dependent). Push and repository (see above) targets don't support a ref target.
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'm not sure what you mean, I extrapolated this based on the REST API description. AFAIK there isn't anything more we can currently use (since custom_property targeting is not an option yet)
Though it's true that ref_name is optional even for tag and branch targets
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.
The wording isn't right even if the field names are, the REST API makes a complete mess of this too. My point was that it'd be worth making the comment clearer as to what the fields actually do.
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.
You are right that we can try to describe it better than the API docs. I'll try my hand at that.
0531db8 to
9dd2965
Compare
|
|
||
| var ruleset *github.RepositoryRuleset | ||
|
|
||
| ruleset, _, err = client.Organizations.UpdateRepositoryRuleset(ctx, org, rulesetID, *rulesetReq) |
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.
Checking if the bypass actors have changed and the length is 0 here would allow you to use the clear function to resolve #2952. See #2891 (comment).
1bdfa45 to
efd67ae
Compare
Signed-off-by: Timo Sand <[email protected]>
Signed-off-by: Timo Sand <[email protected]>
…rks properly Signed-off-by: Timo Sand <[email protected]>
…sport` Updated the logging transport in the RateLimitedHTTPClient function to use NewLoggingHTTPTransport. As the subsystem would need to be explicitly inititated in each resource Signed-off-by: Timo Sand <[email protected]>
By using the `*Context` CRUD functions we get context pass-through and enable HTTP Req/Resp Debug logging Signed-off-by: Timo Sand <[email protected]>
Signed-off-by: Timo Sand <[email protected]>
Signed-off-by: Timo Sand <[email protected]>
Signed-off-by: Timo Sand <[email protected]>
Signed-off-by: Timo Sand <[email protected]>
Signed-off-by: Timo Sand <[email protected]>
Signed-off-by: Timo Sand <[email protected]>
Signed-off-by: Timo Sand <[email protected]>
Signed-off-by: Timo Sand <[email protected]>
It's a required field in the API and go-github doesn't use `omitempty`, so it submits `nil` if it isn't sent explicitly. This change tries to keep it in the state, without having a configuration option for it (poor choice?) And it defaults to all 3 available merge methods if it can't set something from the state. Signed-off-by: Timo Sand <[email protected]>
This is a required field and the SDK doesn't omit if it's empty Signed-off-by: Timo Sand <[email protected]>
Signed-off-by: Timo Sand <[email protected]>
Signed-off-by: Timo Sand <[email protected]>
This enables better debugging during tests as we are able to use get logs for HTTP req/resp Signed-off-by: Timo Sand <[email protected]>
…on_rulesets_without_errors` to pass Signed-off-by: Timo Sand <[email protected]>
Signed-off-by: Timo Sand <[email protected]>
…null` Signed-off-by: Timo Sand <[email protected]>
Signed-off-by: Timo Sand <[email protected]>
…_all_bypass_modes` Main fix: `bypass_actors` is returned as sorted from GH API so tests need re-indexing Signed-off-by: Timo Sand <[email protected]>
Signed-off-by: Timo Sand <[email protected]>
Signed-off-by: Timo Sand <[email protected]>
Signed-off-by: Timo Sand <[email protected]>
Signed-off-by: Timo Sand <[email protected]>
Signed-off-by: Timo Sand <[email protected]>
Signed-off-by: Timo Sand <[email protected]>
Signed-off-by: Timo Sand <[email protected]>
Signed-off-by: Timo Sand <[email protected]>
Signed-off-by: Timo Sand <[email protected]>
Signed-off-by: Timo Sand <[email protected]>
… to org rulesets will never be a thing Signed-off-by: Timo Sand <[email protected]>
Signed-off-by: Timo Sand <[email protected]>
Signed-off-by: Timo Sand <[email protected]>
…re empty lists by default Signed-off-by: Timo Sand <[email protected]>
Signed-off-by: Timo Sand <[email protected]>
Signed-off-by: Timo Sand <[email protected]>
Signed-off-by: Timo Sand <[email protected]>
Signed-off-by: Timo Sand <[email protected]>
By using the `*Context` CRUD functions we get context pass-through and enable HTTP Req/Resp Debug logging Signed-off-by: Timo Sand <[email protected]>
…_id` Signed-off-by: Timo Sand <[email protected]>
Signed-off-by: Timo Sand <[email protected]>
Signed-off-by: Timo Sand <[email protected]>
Signed-off-by: Timo Sand <[email protected]>
Signed-off-by: Timo Sand <[email protected]>
github_organization_ruleset with push targetgithub_organization_ruleset with push target
…s.context` is not empty Signed-off-by: Timo Sand <[email protected]>
Signed-off-by: Timo Sand <[email protected]>
52d95d4 to
6782aab
Compare
Signed-off-by: Timo Sand <[email protected]>
stevehipwell
left a comment
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.
Would it be possible to either de-scope this PR or open a new PR with the smallest number of changes possible to fix the outstanding bugs?
| client.Transport = NewEtagTransport(client.Transport) | ||
| client.Transport = NewRateLimitTransport(client.Transport, WithWriteDelay(writeDelay), WithReadDelay(readDelay), WithParallelRequests(parallelRequests)) | ||
| client.Transport = logging.NewSubsystemLoggingHTTPTransport("GitHub", client.Transport) | ||
| client.Transport = logging.NewLoggingHTTPTransport(client.Transport) |
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.
Could you explain why we need this change?
| ValidateFunc: validation.StringInSlice([]string{"branch", "tag", "push", "repository"}, false), | ||
| Description: "The target of the ruleset. Possible values are `branch`, `tag`, `push` and `repository`.", |
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 needs removing.
| }, | ||
| "bypass_actors": { | ||
| Type: schema.TypeList, | ||
| Type: schema.TypeList, // TODO: These are returned from GH API sorted by actor_id, we might want to investigate if we want to include sorting |
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 think we should sort the returned values based on the inputs which would stop churn.
Resolves #2929, #2467
Before the change?
ref_namewould cause the provider to Panic asref_nameis a required fieldAfter the change?
pushrulesets to an organizationref_nameshould no longer be needed to be set forpushtargetconditions&targetvalidation logic should ensure correct fields are populatedPull request checklist
Schema migrations have been created if needed (example)Does this introduce a breaking change?
Please see our docs on breaking changes to help!