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

Ingress annotation validation earlier in k8s lifecycle #1270

Merged
merged 9 commits into from
Dec 8, 2020

Conversation

mikestephen
Copy link

Minimal validation was performed at the stage when errors can be show to the user in k8s
status messages. Most was done later, when errors could only be written to the controller's
log file. This change moves some of the validation to the earlier phase, more will follow.

Proposed changes

Describe the use case and detail of the change. If this PR addresses an issue on GitHub, make sure to include a link to that issue here in this description (not in the title of the PR).

Checklist

Before creating a PR, run through this checklist and mark each as complete.

  • I have read the CONTRIBUTING doc
  • I have added tests that prove my fix is effective or that my feature works
  • I have checked that all unit tests pass after adding my changes
  • [] I have updated necessary documentation
  • I have rebased my branch onto master
  • I will ensure my PR is targeting the master branch and pulling from my branch from my own fork

Minimal validation was performed at the stage when errors can be show to the user in k8s
status messages. Most was done later, when errors could only be written to the controller's
log file. This change moves some of the validation to the earlier phase, more will follow.
Copy link
Contributor

@pleshakov pleshakov left a comment

Choose a reason for hiding this comment

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

@mikestephen looks good! 👏 I think the new annotation validation framework will successfully validate the rest of the annotations

I left a few comments

internal/k8s/validation.go Outdated Show resolved Hide resolved
internal/configs/parsing_helpers_test.go Outdated Show resolved Hide resolved
internal/configs/parsing_helpers_test.go Outdated Show resolved Hide resolved
internal/configs/parsing_helpers_test.go Outdated Show resolved Hide resolved
pkg/apis/configuration/validation/common.go Outdated Show resolved Hide resolved
pkg/apis/configuration/validation/common.go Outdated Show resolved Hide resolved
internal/k8s/validation_test.go Show resolved Hide resolved
Copy link
Contributor

@Dean-Coakley Dean-Coakley left a comment

Choose a reason for hiding this comment

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

Can you satisfy golint before merging?

$ golint internal/configs/parsing_helpers.go
internal/configs/parsing_helpers.go:170:1: exported function ParseInt should have comment or be unexported
internal/configs/parsing_helpers.go:174:1: exported function ParseInt64 should have comment or be unexported
internal/configs/parsing_helpers.go:178:1: exported function ParseUint64 should have comment or be unexported
internal/configs/parsing_helpers.go:207:1: comment on exported const OffsetFmt should be of the form "OffsetFmt ..."
internal/configs/parsing_helpers.go:212:1: exported function ParseOffset should have comment or be unexported
internal/configs/parsing_helpers.go:221:1: comment on exported const SizeFmt should be of the form "SizeFmt ..."
internal/configs/parsing_helpers.go:226:1: exported function ParseSize should have comment or be unexported
internal/configs/parsing_helpers.go:237:1: exported function ParseProxyBuffers should have comment or be unexported

}

// timeRegexp http://nginx.org/en/docs/syntax.html
var timeRegexp = regexp.MustCompile(`^([0-9]+([ms|s|m|h|d|w|M|y]?){0,1} *)+$`)
Copy link
Author

Choose a reason for hiding this comment

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

Building the regexp from the slice of time units didn't seem to be worth the effort.

@mikestephen mikestephen merged commit 1c66bd3 into master Dec 8, 2020
@mikestephen mikestephen deleted the earlier-validation-feedback branch December 8, 2020 16:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants