-
Notifications
You must be signed in to change notification settings - Fork 19
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 user-defined compliance messages #280
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,6 +51,27 @@ spec: | |
ConfigurationPolicySpec defines the desired configuration of objects on the cluster, along with | ||
how the controller should handle when the cluster doesn't match the configuration policy. | ||
properties: | ||
customMessage: | ||
description: |- | ||
CustomMessage configures the compliance messages emitted by the configuration policy, to use one | ||
of the specified Go templates based on the current compliance. The data passed to the templates | ||
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.
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. It's not just you, policy templates, object templates, and now message templates get easily confused. I'm not sure what to do about it. |
||
include a `.DefaultMessage` string variable which matches the message that would be emitted if no | ||
custom template was defined, and a `.Policy` object variable which contains the full current | ||
state of the policy. If the policy is using Kubernetes API watches (default but can be configured | ||
with EvaluationInterval), and the object exists, then the full state of each related object will | ||
be available at `.Policy.status.relatedObjects[*].object`. Otherwise, only the identifier | ||
information will be available there. | ||
properties: | ||
compliant: | ||
description: Compliant is the template used for the compliance | ||
message when the policy is compliant. | ||
type: string | ||
noncompliant: | ||
description: |- | ||
NonCompliant is the template used for the compliance message when the policy is not compliant, | ||
including when the status is unknown. | ||
type: string | ||
type: object | ||
evaluationInterval: | ||
description: |- | ||
EvaluationInterval configures the minimum elapsed time before a configuration policy is | ||
|
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.
Oh goodness. What is this, BASIC programming??? 😆 I had no idea this existed in Go.
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.
"any"?
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.
It's not Go without
goto
😆I'm surprised @mprahl didn't comment on this, I think I've tried to sneak in a goto before... here it's just playing the role of a
break
statement for theif currentlyUsingWatch
section. Maybe I set the whole thing up poorly, but when I try to re-write it withoutgoto
, it seems worse to me...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.
@yiraeChristineKim ,
any
is a recent keyword added to go, which just meansinterface{}
, the empty interface. Soany
is "any" type. It's just shorter to write, which makes some of these type assertions nicer on unstructured things.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 assertions really are just paranoia... since it's coming from a properly typed ConfigurationPolicy, I don't think it's possible they could ever fail. But, if they do fail unchecked, it's a
panic
, so that would be pretty bad.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.
@JustinKuli I decided to let the "goto" slide even though I don't like them in general. It's prevalent in the Go standard library so I let it be an artistic decision. 😆
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 like using goto. Great first step @JustinKuli