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

Object interfaces as function and with helpers #7

Merged
merged 4 commits into from
Aug 17, 2021

Conversation

snorwin
Copy link
Owner

@snorwin snorwin commented Aug 17, 2021

No description provided.

@coveralls
Copy link

coveralls commented Aug 17, 2021

Pull Request Test Coverage Report for Build 1139937689

  • 60 of 62 (96.77%) changed or added relevant lines in 4 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.4%) to 93.574%

Changes Missing Coverage Covered Lines Changed/Added Lines %
pkg/webhook/mutating_webhook.go 14 16 87.5%
Totals Coverage Status
Change from base Build 1134681289: 0.4%
Covered Lines: 233
Relevant Lines: 249

💛 - Coveralls

@snorwin
Copy link
Owner Author

snorwin commented Aug 17, 2021

Example:

func (w *Webhook) ValidateCreate(ctx context.Context, req admission.Request) admission.Response {
	return admission.ValidateCreateObjectByFunc(ctx, req, func(ctx context.Context, req admission.Request, obj runtime.Object) error {
		_ = log.FromContext(ctx)
	
		pod := obj.(*corev1.Pod)
		// TODO add your programmatic validation logic here
	
		return nil
	})
}

@snorwin snorwin force-pushed the object-interfaces-as-function branch from 5f1cb4f to 2c1aa26 Compare August 17, 2021 15:26
@snorwin snorwin requested a review from bakito August 17, 2021 15:27
@bakito
Copy link
Collaborator

bakito commented Aug 17, 2021

Example:

func (w *Webhook) ValidateCreate(ctx context.Context, req admission.Request) admission.Response {
	return admission.ValidateCreateObjectByFunc(ctx, req, func(ctx context.Context, req admission.Request, obj runtime.Object) error {
		_ = log.FromContext(ctx)
	
		pod := obj.(*corev1.Pod)
		// TODO add your programmatic validation logic here
	
		return nil
	})
}

Can you add this to the Readme?

@snorwin snorwin merged commit b1c64c4 into main Aug 17, 2021
@snorwin snorwin deleted the object-interfaces-as-function branch August 20, 2021 07:19
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.

None yet

3 participants