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

Support blueprint resource for validate sub command to kanctl #1187

Merged
merged 13 commits into from
Jan 21, 2022

Conversation

viveksinghggits
Copy link
Contributor

@viveksinghggits viveksinghggits commented Jan 13, 2022

Change Overview

kanctl command didn't support blueprint resource to get validated. This PR add support for blueprint resource as kanctl validate sub command.
These are some of the validation that we are planning to achieve

  • Make sure function names are correct ✔️
  • Make sure all the mandatory arguments are provided to phase function ✔️
  • If possible make sure if the go template syntax is correct 🚫

Pull request type

Please check the type of change your PR introduces:

  • 🚧 Work in Progress
  • 🌈 Refactoring (no functional changes, no api changes)
  • 🐹 Trivial/Minor
  • 🐛 Bugfix
  • 🌻 Feature
  • 🗺️ Documentation
  • 🤖 Test

Issues

Test Plan

  • 💪 Manual
  • ⚡ Unit test
  • 💚 E2E
kanister/pkg/blueprint/validate(kanctl-val*) » go test                                 vivek@vivek
Failed the 'Validation of phase 00 of action backup, error Required arg missing: command' check.. ❌
Passed the 'Validation of phase 10 of action backup' check.. ✅
Passed the 'Validation of phase 11 of action backup' check.. ✅
Failed the 'Validation of action backup, error Requested function {KubeTasks} has not been registered' check.. ❌
Passed the 'Validation of phase 30 of action backup' check.. ✅
Failed the 'Validation of phase 40 of action backup, error Required arg missing: command' check.. ❌
OK: 1 passed
PASS
ok  	github.com/kanisterio/kanister/pkg/blueprint/validate	0.025s


pkg/kanctl/blueprint.go Show resolved Hide resolved
pkg/kanctl/validate.go Outdated Show resolved Hide resolved
pkg/blueprint/validate/validate.go Outdated Show resolved Hide resolved
pkg/blueprint/validate/validate.go Outdated Show resolved Hide resolved
pkg/blueprint/validate/validate.go Outdated Show resolved Hide resolved
pkg/blueprint/validate/validate_test.go Outdated Show resolved Hide resolved
pkg/blueprint/validate/validate_test.go Outdated Show resolved Hide resolved
pkg/param/render.go Show resolved Hide resolved
@viveksinghggits
Copy link
Contributor Author

Call with supported version of kanister functions

./kanctl validate blueprint -f ../../examples/stable/mysql/mysql-blueprint.yaml --functionVersion v0.0.0
Passed the 'validation of phase deleteFromBlobStore in action delete' check.. ✅
Passed the 'validation of phase restoreFromBlobStore in action restore' check.. ✅
Passed the 'validation of phase dumpToObjectStore in action backup' check.. ✅

Call with unsupported version of kanister functions

./kanctl validate blueprint -f ../../examples/stable/mysql/mysql-blueprint.yaml --functionVersion v0.0.1
INFO[2022-01-19T16:37:07.262511843+01:00] Falling back to default version of the function  FallbackVersion=v0.0.0 File=pkg/blueprint/validate/validate.go Function=KubeTask Line=30 PreferredVersion=v0.0.1
Passed the 'validation of phase dumpToObjectStore in action backup' check.. ✅
INFO[2022-01-19T16:37:07.262563896+01:00] Falling back to default version of the function  FallbackVersion=v0.0.0 File=pkg/blueprint/validate/validate.go Function=KubeTask Line=30 PreferredVersion=v0.0.1
Passed the 'validation of phase deleteFromBlobStore in action delete' check.. ✅
INFO[2022-01-19T16:37:07.262581577+01:00] Falling back to default version of the function  FallbackVersion=v0.0.0 File=pkg/blueprint/validate/validate.go Function=KubeTask Line=30 PreferredVersion=v0.0.1
Passed the 'validation of phase restoreFromBlobStore in action restore' check.. ✅

pkg/kanctl/validate.go Outdated Show resolved Hide resolved
Copy link
Contributor

@pavannd1 pavannd1 left a comment

Choose a reason for hiding this comment

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

Minor suggestions
Merge after addressing

pkg/blueprint/validate/validate.go Show resolved Hide resolved
pkg/phase.go Outdated Show resolved Hide resolved
@mergify mergify bot merged commit e5a2867 into master Jan 21, 2022
@mergify mergify bot deleted the kanctl-val branch January 21, 2022 08:01
viveksinghggits added a commit that referenced this pull request Jan 27, 2022
This commit adds go code to add a webhook server that
does basics check on the bluerint resources when they
are created.
We are doing the only checks that we introduced as
part of #1187
viveksinghggits added a commit that referenced this pull request Feb 1, 2022
This commit adds go code to add a webhook server that
does basics check on the bluerint resources when they
are created.
We are doing the only checks that we introduced as
part of #1187
viveksinghggits added a commit that referenced this pull request Feb 4, 2022
This commit adds go code to add a webhook server that
does basics check on the bluerint resources when they
are created.
We are doing the only checks that we introduced as
part of #1187
viveksinghggits added a commit that referenced this pull request Feb 8, 2022
This commit adds go code to add a webhook server that
does basics check on the bluerint resources when they
are created.
We are doing the only checks that we introduced as
part of #1187
mergify bot pushed a commit that referenced this pull request Feb 8, 2022
* Add val webhook controller for blueprint resources

This commit adds go code to add a webhook server that
does basics check on the bluerint resources when they
are created.
We are doing the only checks that we introduced as
part of #1187

* Update helm to create service and validating webhook configuration

* Remove unnecesary code

* Refactor error messages

* Run webhook server only if webhook certs are mounted in the pod

In the cases if we dont want to run the webhook server in kanister
controller pod but just want to have the `healthz` endpoint and
prom endpoint in that case if we don't mount the webhook certs we
will just be running the standard http server and the webhook server.

* Rebase with master, resolve conflict

* Address review comments, minor refactor

* Address review comments

* Resolve conflicts
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.

None yet

4 participants