-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: restruct workspace controller code - part 4 (#685)
Split webhook.go for workspace and ragengine controller individually.
- Loading branch information
Showing
4 changed files
with
40 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT license. | ||
package webhooks | ||
|
||
import ( | ||
"context" | ||
|
||
"k8s.io/apimachinery/pkg/runtime/schema" | ||
"knative.dev/pkg/configmap" | ||
"knative.dev/pkg/controller" | ||
knativeinjection "knative.dev/pkg/injection" | ||
"knative.dev/pkg/webhook/certificates" | ||
"knative.dev/pkg/webhook/resourcesemantics" | ||
"knative.dev/pkg/webhook/resourcesemantics/validation" | ||
|
||
kaitov1alpha1 "github.com/kaito-project/kaito/api/v1alpha1" | ||
) | ||
|
||
func NewWorkspaceWebhooks() []knativeinjection.ControllerConstructor { | ||
return []knativeinjection.ControllerConstructor{ | ||
certificates.NewController, | ||
NewWorkspaceCRDValidationWebhook, | ||
} | ||
} | ||
|
||
func NewWorkspaceCRDValidationWebhook(ctx context.Context, _ configmap.Watcher) *controller.Impl { | ||
return validation.NewAdmissionController(ctx, | ||
"validation.workspace.kaito.sh", | ||
"/validate/workspace.kaito.sh", | ||
WorkspaceResources, | ||
func(ctx context.Context) context.Context { return ctx }, | ||
true, | ||
) | ||
} | ||
|
||
var WorkspaceResources = map[schema.GroupVersionKind]resourcesemantics.GenericCRD{ | ||
kaitov1alpha1.GroupVersion.WithKind("Workspace"): &kaitov1alpha1.Workspace{}, | ||
} |