Skip to content

Commit

Permalink
change approach
Browse files Browse the repository at this point in the history
  • Loading branch information
SpencerSharkey committed Aug 13, 2020
1 parent 973b3f4 commit 99bb81f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 18 deletions.
21 changes: 11 additions & 10 deletions checks/doks/admission_controller_webhook_replacement.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ func (w *webhookReplacementCheck) Run(objects *kube.Objects) ([]checks.Diagnosti

var diagnostics []checks.Diagnostic

for i := range objects.ValidatingWebhookConfigurations.Items {
config := objects.ValidatingWebhookConfigurations.Items[i]
for k := range config.Webhooks {
wh := config.Webhooks[k]
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 @@ -75,8 +75,8 @@ func (w *webhookReplacementCheck) Run(objects *kube.Objects) ([]checks.Diagnosti
continue
}
var svcNamespace *v1.Namespace
for i := range objects.Namespaces.Items {
ns := objects.Namespaces.Items[i]
for _, ns := range objects.Namespaces.Items {
ns := ns
if ns.Name == wh.ClientConfig.Service.Namespace {
svcNamespace = &ns
}
Expand Down Expand Up @@ -105,10 +105,10 @@ func (w *webhookReplacementCheck) Run(objects *kube.Objects) ([]checks.Diagnosti
}
}

for i := range objects.MutatingWebhookConfigurations.Items {
config := objects.MutatingWebhookConfigurations.Items[i]
for k := range config.Webhooks {
wh := config.Webhooks[k]
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 @@ -128,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
16 changes: 8 additions & 8 deletions checks/doks/admission_controller_webhook_timeout.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ func (w *webhookTimeoutCheck) Description() string {
func (w *webhookTimeoutCheck) Run(objects *kube.Objects) ([]checks.Diagnostic, error) {
var diagnostics []checks.Diagnostic

for i := range objects.ValidatingWebhookConfigurations.Items {
config := objects.ValidatingWebhookConfigurations.Items[i]
for k := range config.Webhooks {
wh := config.Webhooks[k]
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 @@ -71,10 +71,10 @@ func (w *webhookTimeoutCheck) Run(objects *kube.Objects) ([]checks.Diagnostic, e
}
}

for i := range objects.MutatingWebhookConfigurations.Items {
config := objects.MutatingWebhookConfigurations.Items[i]
for k := range config.Webhooks {
wh := config.Webhooks[k]
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 99bb81f

Please sign in to comment.