-
Notifications
You must be signed in to change notification settings - Fork 592
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add eventpolicy reconciler Signed-off-by: Dharmjit Singh <sdharmjit@vmware.com> * Fixed Review Comments * fixed eventpolicy api unit test Signed-off-by: Dharmjit Singh <sdharmjit@vmware.com> * Fixed more review comments Signed-off-by: Dharmjit Singh <sdharmjit@vmware.com> * Fixed more review comments-2 Signed-off-by: Dharmjit Singh <sdharmjit@vmware.com> * Fixed eventpolicy unittests organization/naming Signed-off-by: Dharmjit Singh <sdharmjit@vmware.com> --------- Signed-off-by: Dharmjit Singh <sdharmjit@vmware.com>
- Loading branch information
Dharmjit Singh
authored
Jun 28, 2024
1 parent
6992e6f
commit beb71be
Showing
12 changed files
with
625 additions
and
38 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
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,47 @@ | ||
/* | ||
Copyright 2024 The Knative Authors | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package eventpolicy | ||
|
||
import ( | ||
"context" | ||
|
||
eventpolicyinformer "knative.dev/eventing/pkg/client/injection/informers/eventing/v1alpha1/eventpolicy" | ||
eventpolicyreconciler "knative.dev/eventing/pkg/client/injection/reconciler/eventing/v1alpha1/eventpolicy" | ||
"knative.dev/pkg/configmap" | ||
"knative.dev/pkg/controller" | ||
"knative.dev/pkg/resolver" | ||
) | ||
|
||
// NewController initializes the controller and is called by the generated code | ||
// Registers event handlers to enqueue events | ||
func NewController( | ||
ctx context.Context, | ||
cmw configmap.Watcher, | ||
) *controller.Impl { | ||
// Access informers | ||
eventPolicyInformer := eventpolicyinformer.Get(ctx) | ||
|
||
r := &Reconciler{} | ||
impl := eventpolicyreconciler.NewImpl(ctx, r) | ||
|
||
r.authResolver = resolver.NewAuthenticatableResolverFromTracker(ctx, impl.Tracker) | ||
|
||
// Set up event handlers | ||
eventPolicyInformer.Informer().AddEventHandler(controller.HandleAll(impl.Enqueue)) | ||
|
||
return impl | ||
} |
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,39 @@ | ||
/* | ||
Copyright 2024 The Knative Authors | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package eventpolicy | ||
|
||
import ( | ||
"testing" | ||
|
||
"knative.dev/pkg/configmap" | ||
|
||
. "knative.dev/pkg/reconciler/testing" | ||
|
||
// Fake injection informers | ||
_ "knative.dev/eventing/pkg/client/injection/informers/eventing/v1alpha1/eventpolicy/fake" | ||
_ "knative.dev/pkg/client/injection/ducks/duck/v1/authstatus/fake" | ||
) | ||
|
||
func TestNew(t *testing.T) { | ||
ctx, _ := SetupFakeContext(t) | ||
|
||
c := NewController(ctx, configmap.NewStaticWatcher()) | ||
|
||
if c == nil { | ||
t.Fatal("Expected NewController to return a non-nil value") | ||
} | ||
} |
Oops, something went wrong.