-
Notifications
You must be signed in to change notification settings - Fork 779
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 unique ingress host to library #253
Add unique ingress host to library #253
Conversation
Ah, if metadata.name and metadata.namespace always present, let's just use
those.
…-Torin
On Thu, Sep 26, 2019 at 4:38 PM Max Smythe ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In library/general/uniqueingresshost/template.yaml
<#253 (comment)>
:
> + names:
+ kind: K8sUniqueIngressHost
+ listKind: K8sUniqueIngressHostList
+ plural: k8suniqueingresshost
+ singular: k8suniqueingresshost
+ targets:
+ - target: admission.k8s.gatekeeper.sh
+ rego: |
+ package k8suniqueingresshost
+
+ violation[{"msg": msg}] {
+ input.review.kind.kind == "Ingress"
+ host := input.review.object.spec.rules[_].host
+ ingresses := data.inventory.namespace[_][_]["Ingress"]
+ ingresses[_].spec.rules[_].host == host
+ msg := sprintf("ingress host conflicts with an existing ingress <%v>", [host])
I think I've noticed some inconsistency in whether input.review.name gets
defined or not. It may be worth getting input.review.name by default and
falling back to input.review.object.metadata.name for safety.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#253?email_source=notifications&email_token=AAB2KJP2UMMYQ73QVAOBLSDQLUMUPA5CNFSM4I2IOQ42YY3PNVWWK3TUL52HS4DFWFIHK3DMKJSXC5LFON2FEZLWNFSXPKTDN5WW2ZLOORPWSZGOCGC62EY#discussion_r328815638>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAB2KJLO7TUQDB2HIWH5433QLUMUPANCNFSM4I2IOQ4Q>
.
--
-Torin
|
Sadly, I'm not sure they are always present. |
fc8da42
to
02aa1d1
Compare
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.
LGTM after group is fixed and confirmation we validated that Ingress has input.review.name populated
ac36249
to
f8a5c9a
Compare
bump |
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.
Took another pass. A few minor comments. LGTM.
other := data.inventory.namespace[ns][otherapi]["Ingress"][name] | ||
otherapi == apis[_] | ||
other := data.inventory.namespace[ns][otherapiversion]["Ingress"][name] | ||
re_match("^(extensions|networking.k8s.io).+$", otherapiversion) |
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.
add a /
before the .+$
to guarantee we aren't catching groups like: extensions.something.org
LGTM |
Signed-off-by: Rita Zhang <rita.z.zhang@gmail.com>
Signed-off-by: Rita Zhang <rita.z.zhang@gmail.com>
Signed-off-by: Rita Zhang <rita.z.zhang@gmail.com>
Signed-off-by: Rita Zhang <rita.z.zhang@gmail.com>
Signed-off-by: Rita Zhang <rita.z.zhang@gmail.com>
Signed-off-by: Rita Zhang <rita.z.zhang@gmail.com>
8c1dceb
to
99ff692
Compare
Signed-off-by: Rita Zhang rita.z.zhang@gmail.com