-
Notifications
You must be signed in to change notification settings - Fork 2k
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
api: Add parsed rules to policy response #6017
Changes from all commits
0fae6f1
069f595
837d484
0d4275b
ffb10e6
3206229
5356a78
0f860f4
1eb3cf8
7c7637c
241ed98
e5a2d13
4f1dbc3
8b18396
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ import ( | |
metrics "github.com/armon/go-metrics" | ||
log "github.com/hashicorp/go-hclog" | ||
memdb "github.com/hashicorp/go-memdb" | ||
policy "github.com/hashicorp/nomad/acl" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd recommend not shadowing the name here, when reading the code it can make interpretation difficult when there are multiple names for one package. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. my previous attempt at this had it called There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah - I guess so :( - That's unfortunate but makes sense 👍 |
||
"github.com/hashicorp/nomad/helper/uuid" | ||
"github.com/hashicorp/nomad/nomad/state" | ||
"github.com/hashicorp/nomad/nomad/structs" | ||
|
@@ -263,6 +264,12 @@ func (a *ACL) GetPolicy(args *structs.ACLPolicySpecificRequest, reply *structs.S | |
reply.Policy = out | ||
if out != nil { | ||
reply.Index = out.ModifyIndex | ||
rules, err := policy.Parse(out.Rules) | ||
|
||
backspace marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if err != nil { | ||
return err | ||
} | ||
reply.Policy.RulesJSON = rules | ||
} else { | ||
// Use the last index that affected the policy table | ||
index, err := state.Index("acl_policy") | ||
|
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.
When I changed the parse error-handling to
return err
as @schmichael suggested, it caused a test failure becausewrite
, as stored here, isn’t valid HCL. Since theRules
aren’t actually being used anywhere in the test, I changed it to store valid HCL instead.