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

Add policy yaml validation endpoint #142

Merged
merged 6 commits into from
Dec 10, 2019
Merged

Conversation

asvoboda
Copy link
Member

@asvoboda asvoboda commented Dec 5, 2019

One way to resolve #10.

Another approach could also take in the org/repo and current PR to run a more complete validation of all settings, similar to the details endpoint.

server/handler/validate.go Outdated Show resolved Hide resolved
server/handler/validate.go Outdated Show resolved Hide resolved
server/handler/validate.go Outdated Show resolved Hide resolved
Copy link
Member

@bluekeyes bluekeyes left a comment

Choose a reason for hiding this comment

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

Two minor comments, but looks good otherwise.

README.md Outdated
{"message":"failed to parse approval policy: failed to parse subpolicies for 'and': policy references undefined rule 'the devtools team has approved', allowed values: [the devtools team has]","version":"1.12.5"}
```

You can combine the HTTP response code to automatically detect failures
Copy link
Member

Choose a reason for hiding this comment

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

You can examine the HTTP response code to automatically detect failures?

requestPolicy, err := ioutil.ReadAll(r.Body)
if err != nil {
check.Message = "Unable to read policy file buffer"
baseapp.WriteJSON(w, http.StatusBadRequest, &check)
Copy link
Member

Choose a reason for hiding this comment

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

This might be more appropriate as a 500 error? I'm not sure the client did anything wrong here.

@asvoboda asvoboda merged commit 3a561ab into develop Dec 10, 2019
@asvoboda asvoboda deleted the as/validation-endpoint branch December 10, 2019 17:42
@iamdanfox
Copy link

❤❤❤

@ferozco
Copy link
Contributor

ferozco commented Dec 10, 2019

It would be really sweet if I could leave a comment on a PR to ask policy bot to do the validation and post back whether it is valid

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Verify the validity of policy.yml files before PRs merge
4 participants