From 71b7abc7cb6c7d5eed41453d3f6ccfad0fa736f3 Mon Sep 17 00:00:00 2001 From: Christie Wilson Date: Mon, 8 Oct 2018 09:27:35 -0700 Subject: [PATCH] Only have one set of examples and test that they are valid We ended up in a state where we had both an `examples` dir and a `samples` dir, and neither were tested, so both were slightly out of sync with each other and the actual types. This was b/c: - When we used kubebuilder, we generated our types from an original set of examples - previously these were in `config/samples` and they ended up in `samples`. We used the validation tests generated by kubebuilder to test these, but when we removed kubebuilder we removed the tests - Before presenting the API to the Build CRD working group, we wanted to have some more complex, real world examples, which @tejal29 created from the `kritis` project and the k8s guestbook example This commit makes sure that all of the functionality demonstrated in `samples` is in `examples`, and removes `samples`. This included: - Fixing `passedConstraints` to be plural as the types expected - Including references to the `PipelineParams` in the `TaskRun` example (removing the duplicated list of result endpoints, since we'll be getting this from the references instead) - Fixing clusterBindings to refer to the actual names of the clusters involved It also adds a step to the integration tests to deploy the examples, which will fail if they do not match the expected schema. At this point they are torn down immediately after creation, but in #108 we can expand this to actually test that they are working. Also had to make some tweaks to the types: - actually including `ClusterBindings` in the `Pipeline` - Using names which include `Resource` instead of `Source`, which we moved away from in #39 Fixes #20 --- samples/README.md | 12 ---- samples/pipeline_v1alpha1_pipeline.yaml | 68 ------------------- samples/pipeline_v1alpha1_pipelineparams.yaml | 27 -------- samples/pipeline_v1alpha1_pipelinerun.yaml | 34 ---------- samples/pipeline_v1alpha1_resources.yaml | 23 ------- samples/pipeline_v1alpha1_task.yaml | 24 ------- samples/pipeline_v1alpha1_taskrun.yaml | 59 ---------------- 7 files changed, 247 deletions(-) delete mode 100644 samples/README.md delete mode 100644 samples/pipeline_v1alpha1_pipeline.yaml delete mode 100644 samples/pipeline_v1alpha1_pipelineparams.yaml delete mode 100644 samples/pipeline_v1alpha1_pipelinerun.yaml delete mode 100644 samples/pipeline_v1alpha1_resources.yaml delete mode 100644 samples/pipeline_v1alpha1_task.yaml delete mode 100644 samples/pipeline_v1alpha1_taskrun.yaml diff --git a/samples/README.md b/samples/README.md deleted file mode 100644 index 9bcb134dd75..00000000000 --- a/samples/README.md +++ /dev/null @@ -1,12 +0,0 @@ -# Samples - -These are samples to demonstrate how the Pipeline CRD is intended to work. - -These samples are also duplicated in Go in the type tests in [./pkg/apis/pipeline/vqalpha1](./pkg/apis/pipeline/v1alpha1), -if updating these samples please update the tests too. - -This includes samples of: - -* [A pipeline](pipeline_v1alpha1_pipeline.yaml) -* [A task used in that pipeline](pipeline_v1alpha1_task.yaml) -* [Parameters to the pipeline](pipeline_v1alpha1_pipelineparams.yaml) \ No newline at end of file diff --git a/samples/pipeline_v1alpha1_pipeline.yaml b/samples/pipeline_v1alpha1_pipeline.yaml deleted file mode 100644 index 0a105ce1f72..00000000000 --- a/samples/pipeline_v1alpha1_pipeline.yaml +++ /dev/null @@ -1,68 +0,0 @@ -apiVersion: pipeline.knative.dev/v1alpha1 -kind: Pipeline -metadata: - name: wizzbang-pipeline - namespace: default -spec: - tasks: - - name: test - taskRef: - name: test-wizzbang-task - inputsourceBindings: - - name: repoUnderTest - key: workspace - resourceRef: - name: wizzbang-git - - name: buildPush - taskRef: - name: build-push-task - inputSourceBindings: - - name: wizzbangSrc - key: workspace - resourceRef: - name: wizzbang-git - passedConstraint: [test-wizzbang-task] - outputSourceBindings: - - name: wizzbangImage - key: builtImage - resourceRef: - name: wizzbang-image - params: - - name: pathToDockerfile - value: build/Dockerfile - - name: integrationTest - taskRef: - name: integration-test-wizzbang-task - inputSourceBindings: - - name: repoUnderTest - key: wizzbang - resourceRef: - name: wizzbang-git - passedConstraint: [test] - outputSourceBindings: - - name: wizzbangImage - key: builtImage - resourceRef: - name: wizzbang-image - passedConstraint: [build-push-task] - - name: deploy - taskRef: - name: deploy-with-helm - params: - - name: pathToHelmCharts - value: deploy/helm - inputSourceBindings: - - name: wizzbangSrc - key: wizzbang - resourceRef: - name: wizzbang-git - passedConstraint: [integration-test-wizzbang-task] - clusterBindings: - - inputName: prod - key: prod - outputSourceBindings: - - name: wizzbangImage - key: builtImage - resourceRef: - name: wizzbang-image - passedConstraint: [build-push-task] \ No newline at end of file diff --git a/samples/pipeline_v1alpha1_pipelineparams.yaml b/samples/pipeline_v1alpha1_pipelineparams.yaml deleted file mode 100644 index c6c9b4336d6..00000000000 --- a/samples/pipeline_v1alpha1_pipelineparams.yaml +++ /dev/null @@ -1,27 +0,0 @@ -apiVersion: pipeline.knative.dev/v1alpha1 -kind: PipelineParams -metadata: - name: wizzbang-pipeline-params - namespace: default -spec: - serviceAccount: 'wizzbangPipelineServiceAccount' - results: - runs: - name: 'runsBucket' - type: 'gcs' - url: 'gcs://somebucket/results/runs' - token: 'todo' - logs: - name: 'logBucket' - type: 'gcs' - url: 'gcs://somebucket/results/logs' - token: 'todo' - tests: - name: 'testBucket' - type: 'gcs' - url: 'gcs://somebucket/results/tests' - token: 'todo' - clusters: - - name: 'prod' - type: 'gke' - endpoint: 'https://prod.gke.corp.com' \ No newline at end of file diff --git a/samples/pipeline_v1alpha1_pipelinerun.yaml b/samples/pipeline_v1alpha1_pipelinerun.yaml deleted file mode 100644 index 73a6c21abd1..00000000000 --- a/samples/pipeline_v1alpha1_pipelinerun.yaml +++ /dev/null @@ -1,34 +0,0 @@ -apiVersion: pipeline.knative.dev/v1alpha1 -kind: PipelineRun -metadata: - name: wizzbang-pipeline-run-sd8f8dfasdfasdfas - namespace: default -spec: - pipelineRef: - name: wizzbang-pipeline - pipelineParamsRef: - name: wizzbang-pipeline-params - triggerRef: - type: manual -status: - taskRuns: - - taskRef: - name: test-wizzbang-task-run-sd8f8dfasdfasdfas - - taskRef: - name: build-push-task-run-sd8f8dfasdfasdfas - conditions: - - type: Started - status: "True" - lastTransitionTime: "2018-10-04T12:25:39Z" - reason: manualTrigger - message: "Pipeline has been triggered manually" - - type: Completed - status: "True" - lastTransitionTime: "2018-10-04T13:25:39Z" - reason: done - message: "Pipeline execution has finished" - - type: Successful - status: "False" - lastTransitionTime: "2018-10-04T13:25:39Z" - reason: taskFailure - message: "TaskRun `test-wizzbang-build-push-run-sd8f8dfasdfasdfas` had non-zero exit code" \ No newline at end of file diff --git a/samples/pipeline_v1alpha1_resources.yaml b/samples/pipeline_v1alpha1_resources.yaml deleted file mode 100644 index 6837fc6c562..00000000000 --- a/samples/pipeline_v1alpha1_resources.yaml +++ /dev/null @@ -1,23 +0,0 @@ -apiVersion: pipeline.knative.dev/v1alpha1 -kind: Resource -metadata: - name: wizzbang-git - namespace: default -spec: - type: git - params: - - name: url - value: github.com/wizzbangcorp/wizzbang - - name: revision - value: HEAD ---- -apiVersion: pipeline.knative.dev/v1alpha1 -kind: Resource -metadata: - name: wizzbang-image - namespace: default -spec: - type: image - params: - - name: url - value: gcr.io/wizzbang-staging \ No newline at end of file diff --git a/samples/pipeline_v1alpha1_task.yaml b/samples/pipeline_v1alpha1_task.yaml deleted file mode 100644 index 23d00311882..00000000000 --- a/samples/pipeline_v1alpha1_task.yaml +++ /dev/null @@ -1,24 +0,0 @@ -apiVersion: pipeline.knative.dev/v1alpha1 -kind: Task -metadata: - name: build-push-task - namespace: default -spec: - inputs: - resources: - - name: workspace - type: git - params: - - name: PATH_TO_DOCKERFILE - value: string - outputs: - resources: - - name: builtImage - buildSpec: - template: - name: kaniko - arguments: - - name: DOCKERFILE - value: ${PATH_TO_DOCKERFILE} - - name: REGISTRY - value: ${REGISTRY} \ No newline at end of file diff --git a/samples/pipeline_v1alpha1_taskrun.yaml b/samples/pipeline_v1alpha1_taskrun.yaml deleted file mode 100644 index 80367da56fc..00000000000 --- a/samples/pipeline_v1alpha1_taskrun.yaml +++ /dev/null @@ -1,59 +0,0 @@ -apiVersion: pipeline.knative.dev/v1alpha1 -kind: TaskRun -metadata: - name: integration-test-wizzbang-task-run-sd8f8dfasdfasdfas - namespace: default -spec: - taskRef: - name: integration-test-wizzbang-task - trigger: - triggerRef: - type: PipelineRun - name: wizzbangPipeline-sd8f8dfasdfasdfas - inputs: - resourcesVersion: - - resourceRef: - name: wizzbang - version: HEAD - params: - - name: 'image' - type: 'string' - value: 'gcr.io/wizzbang-staging/wizzbang@234324k32j432k32l4k2a' - outputs: - artifacts: - - name: builtImage - type: image - results: - runs: - name: 'runsBucket' - type: 'gcs' - url: 'gcs://somebucket/results/runs' - logs: - name: 'logBucket' - type: 'gcs' - url: 'gcs://somebucket/results/logs' - tests: - name: 'testBucket' - type: 'gcs' - url: 'gcs://somebucket/results/tests' -status: - steps: - - name: test - logsURL: 'gcs://somebucket/results/tests/test-wizzbang-task-run-sd8f8dfasdfasdfas/test' - exitCode: 0 - conditions: - - type: Started - status: "True" - lastTransitionTime: "2018-10-04T12:25:39Z" - reason: pipelineRun - message: "Task has been triggered by a Pipeline run" - - type: Completed - status: "True" - lastTransitionTime: "2018-10-04T13:25:39Z" - reason: done - message: "Pipeline execution has finished" - - type: Successful - status: "True" - lastTransitionTime: "2018-10-04T13:25:39Z" - reason: zeroExitCode - message: "All steps completed with an exit code of 0" \ No newline at end of file