Skip to content

Commit

Permalink
Merge pull request #90 from uplol/master
Browse files Browse the repository at this point in the history
Fix reference to loop variables in doks admission controller checks
  • Loading branch information
adamwg authored Aug 13, 2020
2 parents 37326c1 + 99bb81f commit 3ab1800
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
6 changes: 6 additions & 0 deletions checks/doks/admission_controller_webhook_replacement.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ func (w *webhookReplacementCheck) Run(objects *kube.Objects) ([]checks.Diagnosti
var diagnostics []checks.Diagnostic

for _, config := range objects.ValidatingWebhookConfigurations.Items {
config := config
for _, wh := range config.Webhooks {
wh := wh
if *wh.FailurePolicy == ar.Ignore {
// Webhooks with failurePolicy: Ignore are fine.
continue
Expand All @@ -74,6 +76,7 @@ func (w *webhookReplacementCheck) Run(objects *kube.Objects) ([]checks.Diagnosti
}
var svcNamespace *v1.Namespace
for _, ns := range objects.Namespaces.Items {
ns := ns
if ns.Name == wh.ClientConfig.Service.Namespace {
svcNamespace = &ns
}
Expand Down Expand Up @@ -103,7 +106,9 @@ func (w *webhookReplacementCheck) Run(objects *kube.Objects) ([]checks.Diagnosti
}

for _, config := range objects.MutatingWebhookConfigurations.Items {
config := config
for _, wh := range config.Webhooks {
wh := wh
if *wh.FailurePolicy == ar.Ignore {
// Webhooks with failurePolicy: Ignore are fine.
continue
Expand All @@ -123,6 +128,7 @@ func (w *webhookReplacementCheck) Run(objects *kube.Objects) ([]checks.Diagnosti
}
var svcNamespace *v1.Namespace
for _, ns := range objects.Namespaces.Items {
ns := ns
if ns.Name == wh.ClientConfig.Service.Namespace {
svcNamespace = &ns
}
Expand Down
4 changes: 4 additions & 0 deletions checks/doks/admission_controller_webhook_timeout.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ func (w *webhookTimeoutCheck) Run(objects *kube.Objects) ([]checks.Diagnostic, e
var diagnostics []checks.Diagnostic

for _, config := range objects.ValidatingWebhookConfigurations.Items {
config := config
for _, wh := range config.Webhooks {
wh := wh
if wh.TimeoutSeconds == nil {
// TimeoutSeconds value should be set to a non-nil value (greater than or equal to 1 and less than 30).
// If the TimeoutSeconds value is set to nil and the cluster version is 1.13.*, users are
Expand All @@ -70,7 +72,9 @@ func (w *webhookTimeoutCheck) Run(objects *kube.Objects) ([]checks.Diagnostic, e
}

for _, config := range objects.MutatingWebhookConfigurations.Items {
config := config
for _, wh := range config.Webhooks {
wh := wh
if wh.TimeoutSeconds == nil {
// TimeoutSeconds value should be set to a non-nil value (greater than or equal to 1 and less than 30).
// If the TimeoutSeconds value is set to nil and the cluster version is 1.13.*, users are
Expand Down

0 comments on commit 3ab1800

Please sign in to comment.