-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Custom Task E2E Test with A Controller Installed
This cl introduces a `wait-task` controller into test/ folder to better support Custom Task e2e testing. Previously we update the Run object to mimic the behavior of a custom task controller. This cl introduces a real controller to reconcile the custom task run.
- Loading branch information
1 parent
8413f85
commit 256aab8
Showing
8 changed files
with
2,654 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Wait Custom Task for Tekton | ||
|
||
This folder is simply copied from [experimental/wait-task](https://github.com/tektoncd/experimental/tree/main/wait-task) | ||
for the testing purpose, with resources used build and release the wait | ||
custom task removed. | ||
|
||
It provides a [Tekton Custom | ||
Task](https://tekton.dev/docs/pipelines/runs/) that, when run, simply waits a | ||
given amount of time before succeeding, specified by an input parameter named | ||
`duration`. |
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,52 @@ | ||
/* | ||
Copyright 2021 The Tekton 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 main // import "github.com/tektoncd/experimental/wait-task/cmd/controller" | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/tektoncd/experimental/wait-task/pkg/reconciler" | ||
runinformer "github.com/tektoncd/pipeline/pkg/client/injection/informers/pipeline/v1alpha1/run" | ||
runreconciler "github.com/tektoncd/pipeline/pkg/client/injection/reconciler/pipeline/v1alpha1/run" | ||
tkncontroller "github.com/tektoncd/pipeline/pkg/controller" | ||
"k8s.io/client-go/tools/cache" | ||
"knative.dev/pkg/configmap" | ||
"knative.dev/pkg/controller" | ||
"knative.dev/pkg/injection/sharedmain" | ||
) | ||
|
||
const controllerName = "wait-task-controller" | ||
|
||
func main() { | ||
sharedmain.Main(controllerName, newController) | ||
} | ||
|
||
func newController(ctx context.Context, cmw configmap.Watcher) *controller.Impl { | ||
c := &reconciler.Reconciler{} | ||
impl := runreconciler.NewImpl(ctx, c, func(impl *controller.Impl) controller.Options { | ||
return controller.Options{ | ||
AgentName: controllerName, | ||
} | ||
}) | ||
|
||
runinformer.Get(ctx).Informer().AddEventHandler(cache.FilteringResourceEventHandler{ | ||
FilterFunc: tkncontroller.FilterRunRef("example.dev/v0", "Wait"), | ||
Handler: controller.HandleAll(impl.Enqueue), | ||
}) | ||
|
||
return impl | ||
} |
Oops, something went wrong.