Apps: Add Example App to ./apps (#112069)
* [API Server] Add Example App for reference use. * Remove Printlns. * Upgrade app-sdk to v0.46.0, update apps to handle breaking changes. * Only start the reconciler for the example app if the v1alpha1 API version is enabled. * Some comment doc updates. * Run make update-workspace * Set codeowner for /apps/example * Run make gofmt and make update-workspace * Run prettier on apps/example/README.md * Add COPY apps/example to Dockerfile * Add an authorizer to the example app. * Fix import ordering. * Update apps/example/kinds/manifest.cue Co-authored-by: Owen Diehl <ow.diehl@gmail.com> * Run make update-workspace * Re-run make gen-go for enterprise import updates * Run make update-workspace --------- Co-authored-by: Owen Diehl <ow.diehl@gmail.com>
This commit is contained in:
co-authored by
Owen Diehl
parent
d25f5199c7
commit
bf65c43783
@@ -0,0 +1,28 @@
|
||||
package app
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
|
||||
"github.com/grafana/grafana-app-sdk/app"
|
||||
"github.com/grafana/grafana-app-sdk/simple"
|
||||
)
|
||||
|
||||
var _ simple.KindValidator = NewValidator()
|
||||
|
||||
// Validator implements simple.KindValidator
|
||||
type Validator struct{}
|
||||
|
||||
func NewValidator() *Validator {
|
||||
return &Validator{}
|
||||
}
|
||||
|
||||
// Validate runs any kind of validation on incoming objects,
|
||||
// and returns an error to reject the request.
|
||||
// Here, we just reject any Example resource which is named "invalid"
|
||||
func (v *Validator) Validate(ctx context.Context, req *app.AdmissionRequest) error {
|
||||
if req.Object.GetName() == "invalid" {
|
||||
return errors.New("example cannot be named 'invalid'")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user