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

ignore ingresses without specified class #527

Merged
merged 3 commits into from
Mar 21, 2020

Conversation

dark-shade
Copy link

Provide the flag to ignore ingresses without a specified class.
Fixes #522

Copy link
Owner

@jcmoraisjr jcmoraisjr left a comment

Choose a reason for hiding this comment

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

Hi, thanks for supporting this controller! See below a few changing suggestions.

@@ -36,6 +36,7 @@ The following command-line options are supported:
| [`--verify-hostname`](#verify-hostname) | [true\|false] | `true` | |
| [`--wait-before-shutdown`](#wait-before-shutdown) | seconds as integer | `0` | v0.8 |
| [`--watch-namespace`](#watch-namespace) | namespace | all namespaces | |
| [`--ignore-ingress-without-class`](#ignore-ingress-without-class)| [true\|false] | `false` | |
Copy link
Owner

Choose a reason for hiding this comment

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

Use alphabetical order. Add also v0.10 in the Since column.

Copy link
Author

Choose a reason for hiding this comment

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

made the changes, please verify


## --ignore-ingress-without-class

Defines if the ingress without the ingress.class annotation will be considered or not. If `--ignore-ingress-without-class=true` then only the ingresses with the matching ingress.class annotation will be considered, ingresses with missing or different ingress.class annotation will not be considered. Default is false.
Copy link
Owner

Choose a reason for hiding this comment

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

Use alphabetical order as well.

Copy link
Author

Choose a reason for hiding this comment

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

made the changes, please verify

@@ -136,7 +137,8 @@ const IngressClassKey = "kubernetes.io/ingress.class"
// IsValidClass ...
func (ic *GenericController) IsValidClass(ing *extensions.Ingress) bool {
ann, found := ing.Annotations[IngressClassKey]
return !found || ann == ic.cfg.IngressClass

return (ic.cfg.IgnoreIngressWithoutClass && found && ann == ic.cfg.IngressClass) || (!ic.cfg.IgnoreIngressWithoutClass && (!found || ann == ic.cfg.IngressClass))
Copy link
Owner

Choose a reason for hiding this comment

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

Change to a simpler approach, eg (didn't test)

if !found {
  return !ic.cfg.IgnoreIngressWithoutClass
}
return ann == ic.cfg.IngressClass

Copy link
Author

Choose a reason for hiding this comment

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

made the changes, please verify

@jcmoraisjr
Copy link
Owner

lgtm, thanks! Merging.

@jcmoraisjr jcmoraisjr merged commit d39494f into jcmoraisjr:master Mar 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ignore ingresses without specified class
2 participants