From 04cb6ca8cada99a8178cb3b4021dd7ce37136b69 Mon Sep 17 00:00:00 2001 From: Lee Bernick Date: Mon, 24 Oct 2022 14:57:43 -0400 Subject: [PATCH] Move several packages into internal This commit moves several packages in pkg/ into pkg/internal. This reduces the Pipelines API surface by ensuring these packages can't be imported and relied on by clients, as we only intend for pkg/apis and pkg/client to be imported outside of Pipelines. Other packages that contain exported functions used outside of pkg/ will be refactored in a later commit. --- cmd/entrypoint/runner.go | 6 +++--- pkg/apis/config/pod.go | 8 +++++++ pkg/apis/pipeline/v1/param_types.go | 2 +- pkg/apis/pipeline/v1/pipeline_validation.go | 2 +- pkg/apis/pipeline/v1/task_validation.go | 2 +- pkg/apis/pipeline/v1/taskref_types.go | 3 +++ pkg/apis/pipeline/v1/when_types.go | 2 +- pkg/apis/pipeline/v1beta1/param_types.go | 2 +- .../pipeline/v1beta1/pipeline_validation.go | 4 ++-- pkg/apis/pipeline/v1beta1/task_validation.go | 2 +- pkg/apis/pipeline/v1beta1/taskref_types.go | 3 +++ pkg/apis/pipeline/v1beta1/when_types.go | 2 +- pkg/artifacts/artifacts.go | 12 +++++++++++ pkg/internal/affinityassistant/transformer.go | 4 ++-- .../affinityassistant/transformer_test.go | 4 ++-- .../artifacts/artifact_storage_test.go | 15 ++++++------- .../artifacts/artifacts_storage.go | 21 +++++++------------ pkg/internal/computeresources/transformer.go | 2 +- .../container/container_replacements.go | 2 +- .../container/sidecar_replacements.go | 2 +- .../container/sidecar_replacements_test.go | 2 +- .../container/step_replacements.go | 2 +- .../container/step_replacements_test.go | 2 +- pkg/{ => internal}/list/diff.go | 0 pkg/{ => internal}/list/diff_test.go | 0 pkg/{ => internal}/matrix/matrix.go | 0 pkg/{ => internal}/matrix/matrix_test.go | 0 pkg/{ => internal}/matrix/matrix_types.go | 0 .../matrix/matrix_types_test.go | 0 pkg/{ => internal}/pod/creds_init.go | 0 pkg/{ => internal}/pod/creds_init_test.go | 0 pkg/{ => internal}/pod/doc.go | 0 pkg/{ => internal}/pod/entrypoint.go | 0 pkg/{ => internal}/pod/entrypoint_lookup.go | 0 .../pod/entrypoint_lookup_impl.go | 0 .../pod/entrypoint_lookup_impl_test.go | 0 .../pod/entrypoint_lookup_test.go | 0 pkg/{ => internal}/pod/entrypoint_test.go | 0 pkg/{ => internal}/pod/pod.go | 9 ++------ pkg/{ => internal}/pod/pod_test.go | 10 ++++----- pkg/{ => internal}/pod/script.go | 0 pkg/{ => internal}/pod/script_test.go | 0 pkg/{ => internal}/pod/scripts_constants.go | 0 pkg/{ => internal}/pod/status.go | 4 ---- pkg/{ => internal}/pod/status_test.go | 0 pkg/{ => internal}/pod/testdata/HEAD | 0 pkg/{ => internal}/pod/workingdir_init.go | 0 .../pod/workingdir_init_test.go | 0 pkg/{ => internal}/status/status.go | 0 pkg/{ => internal}/status/status_test.go | 0 .../substitution/substitution.go | 0 .../substitution/substitution_test.go | 2 +- .../workspace/affinity_assistant_names.go | 0 pkg/{ => internal}/workspace/apply.go | 2 +- pkg/{ => internal}/workspace/apply_test.go | 2 +- pkg/{ => internal}/workspace/validate.go | 0 pkg/{ => internal}/workspace/validate_test.go | 0 pkg/reconciler/pipeline/dag/dag.go | 2 +- pkg/reconciler/pipeline/dag/dag_test.go | 2 +- .../pipelinerun/affinity_assistant.go | 2 +- .../pipelinerun/affinity_assistant_test.go | 2 +- pkg/reconciler/pipelinerun/pipelinerun.go | 13 +++++------- .../pipelinerun/pipelinerun_test.go | 4 ++-- pkg/reconciler/pipelinerun/resources/apply.go | 2 +- .../resources/pipelinerunresolution.go | 2 +- .../pipelinerun/resources/validate_params.go | 4 ++-- pkg/reconciler/taskrun/controller.go | 2 +- pkg/reconciler/taskrun/resources/apply.go | 6 +++--- .../taskrun/resources/apply_test.go | 2 +- .../taskrun/resources/input_resources.go | 2 +- .../taskrun/resources/output_resource.go | 6 ++++-- pkg/reconciler/taskrun/taskrun.go | 8 +++---- pkg/reconciler/taskrun/taskrun_test.go | 8 +++---- pkg/reconciler/taskrun/validate_resources.go | 4 ++-- test/resolvers_test.go | 6 +++--- test/taskrun_test.go | 6 +++--- test/tektonbundles_test.go | 7 +++---- 77 files changed, 117 insertions(+), 108 deletions(-) create mode 100644 pkg/apis/config/pod.go create mode 100644 pkg/artifacts/artifacts.go rename pkg/{ => internal}/artifacts/artifact_storage_test.go (97%) rename pkg/{ => internal}/artifacts/artifacts_storage.go (94%) rename pkg/{ => internal}/container/container_replacements.go (98%) rename pkg/{ => internal}/container/sidecar_replacements.go (94%) rename pkg/{ => internal}/container/sidecar_replacements_test.go (98%) rename pkg/{ => internal}/container/step_replacements.go (96%) rename pkg/{ => internal}/container/step_replacements_test.go (98%) rename pkg/{ => internal}/list/diff.go (100%) rename pkg/{ => internal}/list/diff_test.go (100%) rename pkg/{ => internal}/matrix/matrix.go (100%) rename pkg/{ => internal}/matrix/matrix_test.go (100%) rename pkg/{ => internal}/matrix/matrix_types.go (100%) rename pkg/{ => internal}/matrix/matrix_types_test.go (100%) rename pkg/{ => internal}/pod/creds_init.go (100%) rename pkg/{ => internal}/pod/creds_init_test.go (100%) rename pkg/{ => internal}/pod/doc.go (100%) rename pkg/{ => internal}/pod/entrypoint.go (100%) rename pkg/{ => internal}/pod/entrypoint_lookup.go (100%) rename pkg/{ => internal}/pod/entrypoint_lookup_impl.go (100%) rename pkg/{ => internal}/pod/entrypoint_lookup_impl_test.go (100%) rename pkg/{ => internal}/pod/entrypoint_lookup_test.go (100%) rename pkg/{ => internal}/pod/entrypoint_test.go (100%) rename pkg/{ => internal}/pod/pod.go (97%) rename pkg/{ => internal}/pod/pod_test.go (99%) rename pkg/{ => internal}/pod/script.go (100%) rename pkg/{ => internal}/pod/script_test.go (100%) rename pkg/{ => internal}/pod/scripts_constants.go (100%) rename pkg/{ => internal}/pod/status.go (99%) rename pkg/{ => internal}/pod/status_test.go (100%) rename pkg/{ => internal}/pod/testdata/HEAD (100%) rename pkg/{ => internal}/pod/workingdir_init.go (100%) rename pkg/{ => internal}/pod/workingdir_init_test.go (100%) rename pkg/{ => internal}/status/status.go (100%) rename pkg/{ => internal}/status/status_test.go (100%) rename pkg/{ => internal}/substitution/substitution.go (100%) rename pkg/{ => internal}/substitution/substitution_test.go (99%) rename pkg/{ => internal}/workspace/affinity_assistant_names.go (100%) rename pkg/{ => internal}/workspace/apply.go (99%) rename pkg/{ => internal}/workspace/apply_test.go (99%) rename pkg/{ => internal}/workspace/validate.go (100%) rename pkg/{ => internal}/workspace/validate_test.go (100%) diff --git a/cmd/entrypoint/runner.go b/cmd/entrypoint/runner.go index 49bc1be6b99..fb680f19ba2 100644 --- a/cmd/entrypoint/runner.go +++ b/cmd/entrypoint/runner.go @@ -8,7 +8,7 @@ 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 + 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, @@ -30,8 +30,8 @@ import ( "sync" "syscall" + "github.com/tektoncd/pipeline/pkg/apis/config" "github.com/tektoncd/pipeline/pkg/entrypoint" - "github.com/tektoncd/pipeline/pkg/pod" ) // TODO(jasonhall): Test that original exit code is propagated and that @@ -112,7 +112,7 @@ func (rr *realRunner) Run(ctx context.Context, args ...string) error { // main process and all children cmd.SysProcAttr = &syscall.SysProcAttr{Setpgid: true} - if os.Getenv("TEKTON_RESOURCE_NAME") == "" && os.Getenv(pod.TektonHermeticEnvVar) == "1" { + if os.Getenv("TEKTON_RESOURCE_NAME") == "" && os.Getenv(config.TektonHermeticEnvVar) == "1" { dropNetworking(cmd) } diff --git a/pkg/apis/config/pod.go b/pkg/apis/config/pod.go new file mode 100644 index 00000000000..9464fe9fbea --- /dev/null +++ b/pkg/apis/config/pod.go @@ -0,0 +1,8 @@ +package config + +const ( + // TektonHermeticEnvVar is the env var we set in containers to indicate they should be run hermetically + TektonHermeticEnvVar = "TEKTON_HERMETIC" + // ReleaseAnnotation is the annotation set on TaskRun pods specifying the version of Pipelines + ReleaseAnnotation = "pipeline.tekton.dev/release" +) diff --git a/pkg/apis/pipeline/v1/param_types.go b/pkg/apis/pipeline/v1/param_types.go index 2269c0896c5..59928c16999 100644 --- a/pkg/apis/pipeline/v1/param_types.go +++ b/pkg/apis/pipeline/v1/param_types.go @@ -24,7 +24,7 @@ import ( "strings" resource "github.com/tektoncd/pipeline/pkg/apis/resource/v1alpha1" - "github.com/tektoncd/pipeline/pkg/substitution" + "github.com/tektoncd/pipeline/pkg/internal/substitution" "k8s.io/apimachinery/pkg/util/sets" "knative.dev/pkg/apis" ) diff --git a/pkg/apis/pipeline/v1/pipeline_validation.go b/pkg/apis/pipeline/v1/pipeline_validation.go index 6c6da8cc377..8fe2342441f 100644 --- a/pkg/apis/pipeline/v1/pipeline_validation.go +++ b/pkg/apis/pipeline/v1/pipeline_validation.go @@ -23,8 +23,8 @@ import ( "github.com/tektoncd/pipeline/pkg/apis/config" "github.com/tektoncd/pipeline/pkg/apis/validate" + "github.com/tektoncd/pipeline/pkg/internal/substitution" "github.com/tektoncd/pipeline/pkg/reconciler/pipeline/dag" - "github.com/tektoncd/pipeline/pkg/substitution" admissionregistrationv1 "k8s.io/api/admissionregistration/v1" "k8s.io/apimachinery/pkg/api/equality" "k8s.io/apimachinery/pkg/util/sets" diff --git a/pkg/apis/pipeline/v1/task_validation.go b/pkg/apis/pipeline/v1/task_validation.go index d2ce8de157a..0d1b7f23800 100644 --- a/pkg/apis/pipeline/v1/task_validation.go +++ b/pkg/apis/pipeline/v1/task_validation.go @@ -27,7 +27,7 @@ import ( "github.com/tektoncd/pipeline/pkg/apis/config" "github.com/tektoncd/pipeline/pkg/apis/validate" "github.com/tektoncd/pipeline/pkg/apis/version" - "github.com/tektoncd/pipeline/pkg/substitution" + "github.com/tektoncd/pipeline/pkg/internal/substitution" admissionregistrationv1 "k8s.io/api/admissionregistration/v1" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/util/sets" diff --git a/pkg/apis/pipeline/v1/taskref_types.go b/pkg/apis/pipeline/v1/taskref_types.go index 74a319dd713..ae7e238d1f2 100644 --- a/pkg/apis/pipeline/v1/taskref_types.go +++ b/pkg/apis/pipeline/v1/taskref_types.go @@ -39,4 +39,7 @@ type TaskKind string const ( // NamespacedTaskKind indicates that the task type has a namespaced scope. NamespacedTaskKind TaskKind = "Task" + // ReasonCouldntGetTask indicates that the reason for the failure status is that the + // Task couldn't be found + ReasonCouldntGetTask = "CouldntGetTask" ) diff --git a/pkg/apis/pipeline/v1/when_types.go b/pkg/apis/pipeline/v1/when_types.go index 7e0ef914736..10c0f7df62c 100644 --- a/pkg/apis/pipeline/v1/when_types.go +++ b/pkg/apis/pipeline/v1/when_types.go @@ -19,7 +19,7 @@ package v1 import ( "fmt" - "github.com/tektoncd/pipeline/pkg/substitution" + "github.com/tektoncd/pipeline/pkg/internal/substitution" "k8s.io/apimachinery/pkg/selection" ) diff --git a/pkg/apis/pipeline/v1beta1/param_types.go b/pkg/apis/pipeline/v1beta1/param_types.go index 959d6b7ca71..f083c6bcb4a 100644 --- a/pkg/apis/pipeline/v1beta1/param_types.go +++ b/pkg/apis/pipeline/v1beta1/param_types.go @@ -23,7 +23,7 @@ import ( "strings" resource "github.com/tektoncd/pipeline/pkg/apis/resource/v1alpha1" - "github.com/tektoncd/pipeline/pkg/substitution" + "github.com/tektoncd/pipeline/pkg/internal/substitution" "k8s.io/apimachinery/pkg/util/sets" "knative.dev/pkg/apis" ) diff --git a/pkg/apis/pipeline/v1beta1/pipeline_validation.go b/pkg/apis/pipeline/v1beta1/pipeline_validation.go index c3d9cd1cd76..993d8da6196 100644 --- a/pkg/apis/pipeline/v1beta1/pipeline_validation.go +++ b/pkg/apis/pipeline/v1beta1/pipeline_validation.go @@ -23,9 +23,9 @@ import ( "github.com/tektoncd/pipeline/pkg/apis/config" "github.com/tektoncd/pipeline/pkg/apis/validate" - "github.com/tektoncd/pipeline/pkg/list" + "github.com/tektoncd/pipeline/pkg/internal/list" + "github.com/tektoncd/pipeline/pkg/internal/substitution" "github.com/tektoncd/pipeline/pkg/reconciler/pipeline/dag" - "github.com/tektoncd/pipeline/pkg/substitution" admissionregistrationv1 "k8s.io/api/admissionregistration/v1" "k8s.io/apimachinery/pkg/api/equality" "k8s.io/apimachinery/pkg/util/sets" diff --git a/pkg/apis/pipeline/v1beta1/task_validation.go b/pkg/apis/pipeline/v1beta1/task_validation.go index a64d5bdb81a..82fd6580409 100644 --- a/pkg/apis/pipeline/v1beta1/task_validation.go +++ b/pkg/apis/pipeline/v1beta1/task_validation.go @@ -27,7 +27,7 @@ import ( "github.com/tektoncd/pipeline/pkg/apis/config" "github.com/tektoncd/pipeline/pkg/apis/validate" "github.com/tektoncd/pipeline/pkg/apis/version" - "github.com/tektoncd/pipeline/pkg/substitution" + "github.com/tektoncd/pipeline/pkg/internal/substitution" admissionregistrationv1 "k8s.io/api/admissionregistration/v1" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/util/sets" diff --git a/pkg/apis/pipeline/v1beta1/taskref_types.go b/pkg/apis/pipeline/v1beta1/taskref_types.go index 49f9ff66ea9..96a57b72a98 100644 --- a/pkg/apis/pipeline/v1beta1/taskref_types.go +++ b/pkg/apis/pipeline/v1beta1/taskref_types.go @@ -47,4 +47,7 @@ const ( NamespacedTaskKind TaskKind = "Task" // ClusterTaskKind indicates that task type has a cluster scope. ClusterTaskKind TaskKind = "ClusterTask" + // ReasonCouldntGetTask indicates that the reason for the failure status is that the + // Task couldn't be found + ReasonCouldntGetTask = "CouldntGetTask" ) diff --git a/pkg/apis/pipeline/v1beta1/when_types.go b/pkg/apis/pipeline/v1beta1/when_types.go index ac53da805d4..b5cf2813ad4 100644 --- a/pkg/apis/pipeline/v1beta1/when_types.go +++ b/pkg/apis/pipeline/v1beta1/when_types.go @@ -19,7 +19,7 @@ package v1beta1 import ( "fmt" - "github.com/tektoncd/pipeline/pkg/substitution" + "github.com/tektoncd/pipeline/pkg/internal/substitution" "k8s.io/apimachinery/pkg/selection" ) diff --git a/pkg/artifacts/artifacts.go b/pkg/artifacts/artifacts.go new file mode 100644 index 00000000000..518de665b23 --- /dev/null +++ b/pkg/artifacts/artifacts.go @@ -0,0 +1,12 @@ +package artifacts + +import "fmt" + +// GetPVCName returns the name that should be used for the PVC for a PipelineRun +func GetPVCName(n named) string { + return fmt.Sprintf("%s-pvc", n.GetName()) +} + +type named interface { + GetName() string +} diff --git a/pkg/internal/affinityassistant/transformer.go b/pkg/internal/affinityassistant/transformer.go index 7e38b43a784..7e8d50bef5d 100644 --- a/pkg/internal/affinityassistant/transformer.go +++ b/pkg/internal/affinityassistant/transformer.go @@ -19,8 +19,8 @@ package affinityassistant import ( "context" - "github.com/tektoncd/pipeline/pkg/pod" - "github.com/tektoncd/pipeline/pkg/workspace" + "github.com/tektoncd/pipeline/pkg/internal/pod" + "github.com/tektoncd/pipeline/pkg/internal/workspace" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) diff --git a/pkg/internal/affinityassistant/transformer_test.go b/pkg/internal/affinityassistant/transformer_test.go index 7523d2f1d4f..bd62f1629c0 100644 --- a/pkg/internal/affinityassistant/transformer_test.go +++ b/pkg/internal/affinityassistant/transformer_test.go @@ -5,7 +5,7 @@ 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 + 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, @@ -21,7 +21,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/tektoncd/pipeline/pkg/internal/affinityassistant" - "github.com/tektoncd/pipeline/pkg/workspace" + "github.com/tektoncd/pipeline/pkg/internal/workspace" "github.com/tektoncd/pipeline/test/diff" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" diff --git a/pkg/artifacts/artifact_storage_test.go b/pkg/internal/artifacts/artifact_storage_test.go similarity index 97% rename from pkg/artifacts/artifact_storage_test.go rename to pkg/internal/artifacts/artifact_storage_test.go index 77d903a2bfa..2d85e5b3a42 100644 --- a/pkg/artifacts/artifact_storage_test.go +++ b/pkg/internal/artifacts/artifact_storage_test.go @@ -27,6 +27,7 @@ import ( "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" resourcev1alpha1 "github.com/tektoncd/pipeline/pkg/apis/resource/v1alpha1" "github.com/tektoncd/pipeline/pkg/apis/resource/v1alpha1/storage" + "github.com/tektoncd/pipeline/pkg/artifacts" "github.com/tektoncd/pipeline/test/diff" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/errors" @@ -295,9 +296,9 @@ func TestInitializeArtifactStorage(t *testing.T) { } // If the expected storage type is PVC, make sure we're actually creating that PVC. if c.storagetype == "pvc" { - _, err := fakekubeclient.CoreV1().PersistentVolumeClaims(pipelinerun.Namespace).Get(ctx, GetPVCName(pipelinerun), metav1.GetOptions{}) + _, err := fakekubeclient.CoreV1().PersistentVolumeClaims(pipelinerun.Namespace).Get(ctx, artifacts.GetPVCName(pipelinerun), metav1.GetOptions{}) if err != nil { - t.Fatalf("Error getting expected PVC %s for PipelineRun %s: %s", GetPVCName(pipelinerun), pipelinerun.Name, err) + t.Fatalf("Error getting expected PVC %s for PipelineRun %s: %s", artifacts.GetPVCName(pipelinerun), pipelinerun.Name, err) } } // Make sure we don't get any errors running CleanupArtifactStorage against the resulting storage, whether it's @@ -455,18 +456,18 @@ func TestCleanupArtifactStorage(t *testing.T) { ArtifactBucket: ab, } ctx := config.ToContext(context.Background(), &configs) - _, err = fakekubeclient.CoreV1().PersistentVolumeClaims(pipelinerun.Namespace).Get(ctx, GetPVCName(pipelinerun), metav1.GetOptions{}) + _, err = fakekubeclient.CoreV1().PersistentVolumeClaims(pipelinerun.Namespace).Get(ctx, artifacts.GetPVCName(pipelinerun), metav1.GetOptions{}) if err != nil { - t.Fatalf("Error getting expected PVC %s for PipelineRun %s: %s", GetPVCName(pipelinerun), pipelinerun.Name, err) + t.Fatalf("Error getting expected PVC %s for PipelineRun %s: %s", artifacts.GetPVCName(pipelinerun), pipelinerun.Name, err) } if err := CleanupArtifactStorage(ctx, pipelinerun, fakekubeclient); err != nil { t.Fatalf("Error cleaning up artifact storage: %s", err) } - _, err = fakekubeclient.CoreV1().PersistentVolumeClaims(pipelinerun.Namespace).Get(ctx, GetPVCName(pipelinerun), metav1.GetOptions{}) + _, err = fakekubeclient.CoreV1().PersistentVolumeClaims(pipelinerun.Namespace).Get(ctx, artifacts.GetPVCName(pipelinerun), metav1.GetOptions{}) if err == nil { - t.Fatalf("Found PVC %s for PipelineRun %s after it should have been cleaned up", GetPVCName(pipelinerun), pipelinerun.Name) + t.Fatalf("Found PVC %s for PipelineRun %s after it should have been cleaned up", artifacts.GetPVCName(pipelinerun), pipelinerun.Name) } else if !errors.IsNotFound(err) { - t.Fatalf("Error checking if PVC %s for PipelineRun %s has been cleaned up: %s", GetPVCName(pipelinerun), pipelinerun.Name, err) + t.Fatalf("Error checking if PVC %s for PipelineRun %s has been cleaned up: %s", artifacts.GetPVCName(pipelinerun), pipelinerun.Name, err) } }) } diff --git a/pkg/artifacts/artifacts_storage.go b/pkg/internal/artifacts/artifacts_storage.go similarity index 94% rename from pkg/artifacts/artifacts_storage.go rename to pkg/internal/artifacts/artifacts_storage.go index ff4e5c69de8..52030e994e5 100644 --- a/pkg/artifacts/artifacts_storage.go +++ b/pkg/internal/artifacts/artifacts_storage.go @@ -21,6 +21,8 @@ import ( "fmt" "strings" + "github.com/tektoncd/pipeline/pkg/artifacts" + "github.com/tektoncd/pipeline/pkg/apis/config" "github.com/tektoncd/pipeline/pkg/apis/pipeline" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" @@ -172,7 +174,7 @@ func newArtifactBucketFromConfig(ctx context.Context, images pipeline.Images) *s } func createPVC(ctx context.Context, pr *v1beta1.PipelineRun, c kubernetes.Interface) (*corev1.PersistentVolumeClaim, error) { - if _, err := c.CoreV1().PersistentVolumeClaims(pr.Namespace).Get(ctx, GetPVCName(pr), metav1.GetOptions{}); err != nil { + if _, err := c.CoreV1().PersistentVolumeClaims(pr.Namespace).Get(ctx, artifacts.GetPVCName(pr), metav1.GetOptions{}); err != nil { if errors.IsNotFound(err) { pvcConfig := config.FromContextOrDefaults(ctx).ArtifactPVC pvcSize, err := resource.ParseQuantity(pvcConfig.Size) @@ -205,11 +207,11 @@ func createPVC(ctx context.Context, pr *v1beta1.PipelineRun, c kubernetes.Interf } func deletePVC(ctx context.Context, pr *v1beta1.PipelineRun, c kubernetes.Interface) error { - if _, err := c.CoreV1().PersistentVolumeClaims(pr.Namespace).Get(ctx, GetPVCName(pr), metav1.GetOptions{}); err != nil { + if _, err := c.CoreV1().PersistentVolumeClaims(pr.Namespace).Get(ctx, artifacts.GetPVCName(pr), metav1.GetOptions{}); err != nil { if !errors.IsNotFound(err) { - return fmt.Errorf("failed to get Persistent Volume %q due to error: %w", GetPVCName(pr), err) + return fmt.Errorf("failed to get Persistent Volume %q due to error: %w", artifacts.GetPVCName(pr), err) } - } else if err := c.CoreV1().PersistentVolumeClaims(pr.Namespace).Delete(ctx, GetPVCName(pr), metav1.DeleteOptions{}); err != nil { + } else if err := c.CoreV1().PersistentVolumeClaims(pr.Namespace).Delete(ctx, artifacts.GetPVCName(pr), metav1.DeleteOptions{}); err != nil { return fmt.Errorf("failed to delete Persistent Volume %q due to error: %w", pr.Name, err) } return nil @@ -220,7 +222,7 @@ func getPVCSpec(pr *v1beta1.PipelineRun, pvcSize resource.Quantity, storageClass return &corev1.PersistentVolumeClaim{ ObjectMeta: metav1.ObjectMeta{ Namespace: pr.Namespace, - Name: GetPVCName(pr), + Name: artifacts.GetPVCName(pr), OwnerReferences: []metav1.OwnerReference{*kmeta.NewControllerRef(pr)}, }, Spec: corev1.PersistentVolumeClaimSpec{ @@ -234,12 +236,3 @@ func getPVCSpec(pr *v1beta1.PipelineRun, pvcSize resource.Quantity, storageClass }, } } - -// GetPVCName returns the name that should be used for the PVC for a PipelineRun -func GetPVCName(n named) string { - return fmt.Sprintf("%s-pvc", n.GetName()) -} - -type named interface { - GetName() string -} diff --git a/pkg/internal/computeresources/transformer.go b/pkg/internal/computeresources/transformer.go index 61e88cba494..bb581495aad 100644 --- a/pkg/internal/computeresources/transformer.go +++ b/pkg/internal/computeresources/transformer.go @@ -21,7 +21,7 @@ import ( "github.com/tektoncd/pipeline/pkg/internal/computeresources/compare" "github.com/tektoncd/pipeline/pkg/internal/computeresources/limitrange" - "github.com/tektoncd/pipeline/pkg/pod" + "github.com/tektoncd/pipeline/pkg/internal/pod" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/resource" corev1listers "k8s.io/client-go/listers/core/v1" diff --git a/pkg/container/container_replacements.go b/pkg/internal/container/container_replacements.go similarity index 98% rename from pkg/container/container_replacements.go rename to pkg/internal/container/container_replacements.go index 64d92d2485a..ceaae64f333 100644 --- a/pkg/container/container_replacements.go +++ b/pkg/internal/container/container_replacements.go @@ -18,7 +18,7 @@ package container import ( "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" - "github.com/tektoncd/pipeline/pkg/substitution" + "github.com/tektoncd/pipeline/pkg/internal/substitution" corev1 "k8s.io/api/core/v1" ) diff --git a/pkg/container/sidecar_replacements.go b/pkg/internal/container/sidecar_replacements.go similarity index 94% rename from pkg/container/sidecar_replacements.go rename to pkg/internal/container/sidecar_replacements.go index 908677a11f4..c965c88c4ed 100644 --- a/pkg/container/sidecar_replacements.go +++ b/pkg/internal/container/sidecar_replacements.go @@ -18,7 +18,7 @@ package container import ( "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" - "github.com/tektoncd/pipeline/pkg/substitution" + "github.com/tektoncd/pipeline/pkg/internal/substitution" ) // ApplySidecarReplacements applies variable interpolation on a Sidecar. diff --git a/pkg/container/sidecar_replacements_test.go b/pkg/internal/container/sidecar_replacements_test.go similarity index 98% rename from pkg/container/sidecar_replacements_test.go rename to pkg/internal/container/sidecar_replacements_test.go index e93bdcc955f..83d71b53886 100644 --- a/pkg/container/sidecar_replacements_test.go +++ b/pkg/internal/container/sidecar_replacements_test.go @@ -21,7 +21,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" - "github.com/tektoncd/pipeline/pkg/container" + "github.com/tektoncd/pipeline/pkg/internal/container" corev1 "k8s.io/api/core/v1" ) diff --git a/pkg/container/step_replacements.go b/pkg/internal/container/step_replacements.go similarity index 96% rename from pkg/container/step_replacements.go rename to pkg/internal/container/step_replacements.go index 1640e749ce9..8c79ea79fde 100644 --- a/pkg/container/step_replacements.go +++ b/pkg/internal/container/step_replacements.go @@ -18,7 +18,7 @@ package container import ( "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" - "github.com/tektoncd/pipeline/pkg/substitution" + "github.com/tektoncd/pipeline/pkg/internal/substitution" ) // ApplyStepReplacements applies variable interpolation on a Step. diff --git a/pkg/container/step_replacements_test.go b/pkg/internal/container/step_replacements_test.go similarity index 98% rename from pkg/container/step_replacements_test.go rename to pkg/internal/container/step_replacements_test.go index 05a7b805fb7..5d12c377ede 100644 --- a/pkg/container/step_replacements_test.go +++ b/pkg/internal/container/step_replacements_test.go @@ -21,7 +21,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" - "github.com/tektoncd/pipeline/pkg/container" + "github.com/tektoncd/pipeline/pkg/internal/container" corev1 "k8s.io/api/core/v1" ) diff --git a/pkg/list/diff.go b/pkg/internal/list/diff.go similarity index 100% rename from pkg/list/diff.go rename to pkg/internal/list/diff.go diff --git a/pkg/list/diff_test.go b/pkg/internal/list/diff_test.go similarity index 100% rename from pkg/list/diff_test.go rename to pkg/internal/list/diff_test.go diff --git a/pkg/matrix/matrix.go b/pkg/internal/matrix/matrix.go similarity index 100% rename from pkg/matrix/matrix.go rename to pkg/internal/matrix/matrix.go diff --git a/pkg/matrix/matrix_test.go b/pkg/internal/matrix/matrix_test.go similarity index 100% rename from pkg/matrix/matrix_test.go rename to pkg/internal/matrix/matrix_test.go diff --git a/pkg/matrix/matrix_types.go b/pkg/internal/matrix/matrix_types.go similarity index 100% rename from pkg/matrix/matrix_types.go rename to pkg/internal/matrix/matrix_types.go diff --git a/pkg/matrix/matrix_types_test.go b/pkg/internal/matrix/matrix_types_test.go similarity index 100% rename from pkg/matrix/matrix_types_test.go rename to pkg/internal/matrix/matrix_types_test.go diff --git a/pkg/pod/creds_init.go b/pkg/internal/pod/creds_init.go similarity index 100% rename from pkg/pod/creds_init.go rename to pkg/internal/pod/creds_init.go diff --git a/pkg/pod/creds_init_test.go b/pkg/internal/pod/creds_init_test.go similarity index 100% rename from pkg/pod/creds_init_test.go rename to pkg/internal/pod/creds_init_test.go diff --git a/pkg/pod/doc.go b/pkg/internal/pod/doc.go similarity index 100% rename from pkg/pod/doc.go rename to pkg/internal/pod/doc.go diff --git a/pkg/pod/entrypoint.go b/pkg/internal/pod/entrypoint.go similarity index 100% rename from pkg/pod/entrypoint.go rename to pkg/internal/pod/entrypoint.go diff --git a/pkg/pod/entrypoint_lookup.go b/pkg/internal/pod/entrypoint_lookup.go similarity index 100% rename from pkg/pod/entrypoint_lookup.go rename to pkg/internal/pod/entrypoint_lookup.go diff --git a/pkg/pod/entrypoint_lookup_impl.go b/pkg/internal/pod/entrypoint_lookup_impl.go similarity index 100% rename from pkg/pod/entrypoint_lookup_impl.go rename to pkg/internal/pod/entrypoint_lookup_impl.go diff --git a/pkg/pod/entrypoint_lookup_impl_test.go b/pkg/internal/pod/entrypoint_lookup_impl_test.go similarity index 100% rename from pkg/pod/entrypoint_lookup_impl_test.go rename to pkg/internal/pod/entrypoint_lookup_impl_test.go diff --git a/pkg/pod/entrypoint_lookup_test.go b/pkg/internal/pod/entrypoint_lookup_test.go similarity index 100% rename from pkg/pod/entrypoint_lookup_test.go rename to pkg/internal/pod/entrypoint_lookup_test.go diff --git a/pkg/pod/entrypoint_test.go b/pkg/internal/pod/entrypoint_test.go similarity index 100% rename from pkg/pod/entrypoint_test.go rename to pkg/internal/pod/entrypoint_test.go diff --git a/pkg/pod/pod.go b/pkg/internal/pod/pod.go similarity index 97% rename from pkg/pod/pod.go rename to pkg/internal/pod/pod.go index 30bf9d8fa1c..54bf3e9194d 100644 --- a/pkg/pod/pod.go +++ b/pkg/internal/pod/pod.go @@ -39,9 +39,6 @@ import ( ) const ( - // TektonHermeticEnvVar is the env var we set in containers to indicate they should be run hermetically - TektonHermeticEnvVar = "TEKTON_HERMETIC" - // ExecutionModeAnnotation is an experimental optional annotation to set the execution mode on a TaskRun ExecutionModeAnnotation = "experimental.tekton.dev/execution-mode" @@ -55,8 +52,6 @@ const ( // These are effectively const, but Go doesn't have such an annotation. var ( - ReleaseAnnotation = "pipeline.tekton.dev/release" - groupVersionKind = schema.GroupVersionKind{ Group: v1beta1.SchemeGroupVersion.Group, Version: v1beta1.SchemeGroupVersion.Version, @@ -218,7 +213,7 @@ func (b *Builder) Build(ctx context.Context, taskRun *v1beta1.TaskRun, taskSpec if taskRun.Annotations[ExecutionModeAnnotation] == ExecutionModeHermetic && alphaAPIEnabled { for i, s := range stepContainers { // Add it at the end so it overrides - env := append(s.Env, corev1.EnvVar{Name: TektonHermeticEnvVar, Value: "1"}) //nolint + env := append(s.Env, corev1.EnvVar{Name: config.TektonHermeticEnvVar, Value: "1"}) //nolint stepContainers[i].Env = env } } @@ -294,7 +289,7 @@ func (b *Builder) Build(ctx context.Context, taskRun *v1beta1.TaskRun, taskSpec } podAnnotations := kmeta.CopyMap(taskRun.Annotations) - podAnnotations[ReleaseAnnotation] = changeset.Get() + podAnnotations[config.ReleaseAnnotation] = changeset.Get() if readyImmediately { podAnnotations[readyAnnotation] = readyAnnotationValue diff --git a/pkg/pod/pod_test.go b/pkg/internal/pod/pod_test.go similarity index 99% rename from pkg/pod/pod_test.go rename to pkg/internal/pod/pod_test.go index ee9bcc31e71..5326c1d319a 100644 --- a/pkg/pod/pod_test.go +++ b/pkg/internal/pod/pod_test.go @@ -54,7 +54,7 @@ var ( } ignoreReleaseAnnotation = func(k string, v string) bool { - return k == ReleaseAnnotation + return k == config.ReleaseAnnotation } featureInjectedSidecar = "running-in-environment-with-injected-sidecars" featureAwaitSidecarReadiness = "await-sidecar-readiness" @@ -1823,11 +1823,11 @@ _EOF_ var trAnnotations map[string]string if c.trAnnotation == nil { trAnnotations = map[string]string{ - ReleaseAnnotation: fakeVersion, + config.ReleaseAnnotation: fakeVersion, } } else { trAnnotations = c.trAnnotation - trAnnotations[ReleaseAnnotation] = fakeVersion + trAnnotations[config.ReleaseAnnotation] = fakeVersion } testTaskRunName := taskRunName if c.trName != "" { @@ -2032,11 +2032,11 @@ debug-fail-continue-heredoc-randomly-generated-mz4c7 var trAnnotations map[string]string if c.trAnnotation == nil { trAnnotations = map[string]string{ - ReleaseAnnotation: fakeVersion, + config.ReleaseAnnotation: fakeVersion, } } else { trAnnotations = c.trAnnotation - trAnnotations[ReleaseAnnotation] = fakeVersion + trAnnotations[config.ReleaseAnnotation] = fakeVersion } tr := &v1beta1.TaskRun{ ObjectMeta: metav1.ObjectMeta{ diff --git a/pkg/pod/script.go b/pkg/internal/pod/script.go similarity index 100% rename from pkg/pod/script.go rename to pkg/internal/pod/script.go diff --git a/pkg/pod/script_test.go b/pkg/internal/pod/script_test.go similarity index 100% rename from pkg/pod/script_test.go rename to pkg/internal/pod/script_test.go diff --git a/pkg/pod/scripts_constants.go b/pkg/internal/pod/scripts_constants.go similarity index 100% rename from pkg/pod/scripts_constants.go rename to pkg/internal/pod/scripts_constants.go diff --git a/pkg/pod/status.go b/pkg/internal/pod/status.go similarity index 99% rename from pkg/pod/status.go rename to pkg/internal/pod/status.go index 74faf6f875d..fc80783dfc2 100644 --- a/pkg/pod/status.go +++ b/pkg/internal/pod/status.go @@ -33,10 +33,6 @@ import ( ) const ( - // ReasonCouldntGetTask indicates that the reason for the failure status is that the - // Task couldn't be found - ReasonCouldntGetTask = "CouldntGetTask" - // ReasonFailedResolution indicated that the reason for failure status is // that references within the TaskRun could not be resolved ReasonFailedResolution = "TaskRunResolutionFailed" diff --git a/pkg/pod/status_test.go b/pkg/internal/pod/status_test.go similarity index 100% rename from pkg/pod/status_test.go rename to pkg/internal/pod/status_test.go diff --git a/pkg/pod/testdata/HEAD b/pkg/internal/pod/testdata/HEAD similarity index 100% rename from pkg/pod/testdata/HEAD rename to pkg/internal/pod/testdata/HEAD diff --git a/pkg/pod/workingdir_init.go b/pkg/internal/pod/workingdir_init.go similarity index 100% rename from pkg/pod/workingdir_init.go rename to pkg/internal/pod/workingdir_init.go diff --git a/pkg/pod/workingdir_init_test.go b/pkg/internal/pod/workingdir_init_test.go similarity index 100% rename from pkg/pod/workingdir_init_test.go rename to pkg/internal/pod/workingdir_init_test.go diff --git a/pkg/status/status.go b/pkg/internal/status/status.go similarity index 100% rename from pkg/status/status.go rename to pkg/internal/status/status.go diff --git a/pkg/status/status_test.go b/pkg/internal/status/status_test.go similarity index 100% rename from pkg/status/status_test.go rename to pkg/internal/status/status_test.go diff --git a/pkg/substitution/substitution.go b/pkg/internal/substitution/substitution.go similarity index 100% rename from pkg/substitution/substitution.go rename to pkg/internal/substitution/substitution.go diff --git a/pkg/substitution/substitution_test.go b/pkg/internal/substitution/substitution_test.go similarity index 99% rename from pkg/substitution/substitution_test.go rename to pkg/internal/substitution/substitution_test.go index 4ba4a1c133d..2c929a4a9e9 100644 --- a/pkg/substitution/substitution_test.go +++ b/pkg/internal/substitution/substitution_test.go @@ -22,7 +22,7 @@ import ( "testing" "github.com/google/go-cmp/cmp" - "github.com/tektoncd/pipeline/pkg/substitution" + "github.com/tektoncd/pipeline/pkg/internal/substitution" "github.com/tektoncd/pipeline/test/diff" "k8s.io/apimachinery/pkg/util/sets" "knative.dev/pkg/apis" diff --git a/pkg/workspace/affinity_assistant_names.go b/pkg/internal/workspace/affinity_assistant_names.go similarity index 100% rename from pkg/workspace/affinity_assistant_names.go rename to pkg/internal/workspace/affinity_assistant_names.go diff --git a/pkg/workspace/apply.go b/pkg/internal/workspace/apply.go similarity index 99% rename from pkg/workspace/apply.go rename to pkg/internal/workspace/apply.go index 613a025cb88..41b61cfd6d1 100644 --- a/pkg/workspace/apply.go +++ b/pkg/internal/workspace/apply.go @@ -22,8 +22,8 @@ import ( "github.com/tektoncd/pipeline/pkg/apis/config" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" + "github.com/tektoncd/pipeline/pkg/internal/substitution" "github.com/tektoncd/pipeline/pkg/names" - "github.com/tektoncd/pipeline/pkg/substitution" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/util/sets" ) diff --git a/pkg/workspace/apply_test.go b/pkg/internal/workspace/apply_test.go similarity index 99% rename from pkg/workspace/apply_test.go rename to pkg/internal/workspace/apply_test.go index 95a257e2f40..b736f7c4ba4 100644 --- a/pkg/workspace/apply_test.go +++ b/pkg/internal/workspace/apply_test.go @@ -7,7 +7,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/tektoncd/pipeline/pkg/apis/config" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" - "github.com/tektoncd/pipeline/pkg/workspace" + "github.com/tektoncd/pipeline/pkg/internal/workspace" "github.com/tektoncd/pipeline/test/diff" "github.com/tektoncd/pipeline/test/names" corev1 "k8s.io/api/core/v1" diff --git a/pkg/workspace/validate.go b/pkg/internal/workspace/validate.go similarity index 100% rename from pkg/workspace/validate.go rename to pkg/internal/workspace/validate.go diff --git a/pkg/workspace/validate_test.go b/pkg/internal/workspace/validate_test.go similarity index 100% rename from pkg/workspace/validate_test.go rename to pkg/internal/workspace/validate_test.go diff --git a/pkg/reconciler/pipeline/dag/dag.go b/pkg/reconciler/pipeline/dag/dag.go index 14da3005592..dc39d765510 100644 --- a/pkg/reconciler/pipeline/dag/dag.go +++ b/pkg/reconciler/pipeline/dag/dag.go @@ -22,7 +22,7 @@ import ( "sort" "strings" - "github.com/tektoncd/pipeline/pkg/list" + "github.com/tektoncd/pipeline/pkg/internal/list" "k8s.io/apimachinery/pkg/util/sets" ) diff --git a/pkg/reconciler/pipeline/dag/dag_test.go b/pkg/reconciler/pipeline/dag/dag_test.go index 29618fd57d7..dfa184d57c0 100644 --- a/pkg/reconciler/pipeline/dag/dag_test.go +++ b/pkg/reconciler/pipeline/dag/dag_test.go @@ -24,7 +24,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" - "github.com/tektoncd/pipeline/pkg/list" + "github.com/tektoncd/pipeline/pkg/internal/list" "github.com/tektoncd/pipeline/pkg/reconciler/pipeline/dag" "github.com/tektoncd/pipeline/test/diff" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" diff --git a/pkg/reconciler/pipelinerun/affinity_assistant.go b/pkg/reconciler/pipelinerun/affinity_assistant.go index 937b8e5fd14..eac9034fbcf 100644 --- a/pkg/reconciler/pipelinerun/affinity_assistant.go +++ b/pkg/reconciler/pipelinerun/affinity_assistant.go @@ -25,8 +25,8 @@ import ( "github.com/tektoncd/pipeline/pkg/apis/pipeline" "github.com/tektoncd/pipeline/pkg/apis/pipeline/pod" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" + "github.com/tektoncd/pipeline/pkg/internal/workspace" "github.com/tektoncd/pipeline/pkg/reconciler/volumeclaim" - "github.com/tektoncd/pipeline/pkg/workspace" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" apierrors "k8s.io/apimachinery/pkg/api/errors" diff --git a/pkg/reconciler/pipelinerun/affinity_assistant_test.go b/pkg/reconciler/pipelinerun/affinity_assistant_test.go index 00a87b46665..fef40878c21 100644 --- a/pkg/reconciler/pipelinerun/affinity_assistant_test.go +++ b/pkg/reconciler/pipelinerun/affinity_assistant_test.go @@ -21,7 +21,7 @@ import ( "testing" "github.com/google/go-cmp/cmp" - "github.com/tektoncd/pipeline/pkg/workspace" + "github.com/tektoncd/pipeline/pkg/internal/workspace" "github.com/tektoncd/pipeline/test/diff" "github.com/tektoncd/pipeline/test/parse" diff --git a/pkg/reconciler/pipelinerun/pipelinerun.go b/pkg/reconciler/pipelinerun/pipelinerun.go index 52782487183..7fd7f5140bf 100644 --- a/pkg/reconciler/pipelinerun/pipelinerun.go +++ b/pkg/reconciler/pipelinerun/pipelinerun.go @@ -34,13 +34,14 @@ import ( "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" resourcev1alpha1 "github.com/tektoncd/pipeline/pkg/apis/resource/v1alpha1" - "github.com/tektoncd/pipeline/pkg/artifacts" clientset "github.com/tektoncd/pipeline/pkg/client/clientset/versioned" pipelinerunreconciler "github.com/tektoncd/pipeline/pkg/client/injection/reconciler/pipeline/v1beta1/pipelinerun" listersv1alpha1 "github.com/tektoncd/pipeline/pkg/client/listers/pipeline/v1alpha1" listers "github.com/tektoncd/pipeline/pkg/client/listers/pipeline/v1beta1" resourcelisters "github.com/tektoncd/pipeline/pkg/client/resource/listers/resource/v1alpha1" - "github.com/tektoncd/pipeline/pkg/matrix" + "github.com/tektoncd/pipeline/pkg/internal/artifacts" + "github.com/tektoncd/pipeline/pkg/internal/matrix" + "github.com/tektoncd/pipeline/pkg/internal/workspace" "github.com/tektoncd/pipeline/pkg/pipelinerunmetrics" tknreconciler "github.com/tektoncd/pipeline/pkg/reconciler" "github.com/tektoncd/pipeline/pkg/reconciler/events" @@ -53,7 +54,6 @@ import ( "github.com/tektoncd/pipeline/pkg/reconciler/volumeclaim" "github.com/tektoncd/pipeline/pkg/remote" resolution "github.com/tektoncd/pipeline/pkg/resolution/resource" - "github.com/tektoncd/pipeline/pkg/workspace" "go.uber.org/zap" corev1 "k8s.io/api/core/v1" kerrors "k8s.io/apimachinery/pkg/api/errors" @@ -89,9 +89,6 @@ const ( // ReasonObjectParameterMissKeys indicates that the object param value provided from PipelineRun spec // misses some keys required for the object param declared in Pipeline spec. ReasonObjectParameterMissKeys = "ObjectParameterMissKeys" - // ReasonCouldntGetTask indicates that the reason for the failure status is that the - // associated Pipeline's Tasks couldn't all be retrieved - ReasonCouldntGetTask = "CouldntGetTask" // ReasonCouldntGetResource indicates that the reason for the failure status is that the // associated PipelineRun's bound PipelineResources couldn't all be retrieved ReasonCouldntGetResource = "CouldntGetResource" @@ -313,7 +310,7 @@ func (c *Reconciler) resolvePipelineState( fn, err := tresources.GetTaskFunc(ctx, c.KubeClientSet, c.PipelineClientSet, c.resolutionRequester, pr, task.TaskRef, trName, pr.Namespace, pr.Spec.ServiceAccountName) if err != nil { // This Run has failed, so we need to mark it as failed and stop reconciling it - pr.Status.MarkFailed(ReasonCouldntGetTask, "Pipeline %s/%s can't be Run; task %s could not be fetched: %s", + pr.Status.MarkFailed(v1beta1.ReasonCouldntGetTask, "Pipeline %s/%s can't be Run; task %s could not be fetched: %s", pipelineMeta.Namespace, pipelineMeta.Name, task.Name, err) return nil, controller.NewPermanentError(err) } @@ -338,7 +335,7 @@ func (c *Reconciler) resolvePipelineState( } switch err := err.(type) { case *resources.TaskNotFoundError: - pr.Status.MarkFailed(ReasonCouldntGetTask, + pr.Status.MarkFailed(v1beta1.ReasonCouldntGetTask, "Pipeline %s/%s can't be Run; it contains Tasks that don't exist: %s", pipelineMeta.Namespace, pipelineMeta.Name, err) default: diff --git a/pkg/reconciler/pipelinerun/pipelinerun_test.go b/pkg/reconciler/pipelinerun/pipelinerun_test.go index a8dbe8ab5a1..5fda49a6add 100644 --- a/pkg/reconciler/pipelinerun/pipelinerun_test.go +++ b/pkg/reconciler/pipelinerun/pipelinerun_test.go @@ -1005,7 +1005,7 @@ spec: pipelineRef: name: pipeline-missing-tasks `), - reason: ReasonCouldntGetTask, + reason: v1beta1.ReasonCouldntGetTask, permanentError: true, wantEvents: []string{ "Normal Started", @@ -7566,7 +7566,7 @@ spec: // Check that the pipeline fails. updatedPipelineRun, _ := prt.reconcileRun("default", "pr", nil, true) - checkPipelineRunConditionStatusAndReason(t, updatedPipelineRun, corev1.ConditionFalse, ReasonCouldntGetTask) + checkPipelineRunConditionStatusAndReason(t, updatedPipelineRun, corev1.ConditionFalse, v1beta1.ReasonCouldntGetTask) } // TestReconcileWithTaskResolver checks that a PipelineRun with a populated Resolver diff --git a/pkg/reconciler/pipelinerun/resources/apply.go b/pkg/reconciler/pipelinerun/resources/apply.go index 9eb4fb502e5..41298e5f28f 100644 --- a/pkg/reconciler/pipelinerun/resources/apply.go +++ b/pkg/reconciler/pipelinerun/resources/apply.go @@ -27,7 +27,7 @@ import ( "github.com/tektoncd/pipeline/pkg/reconciler/taskrun/resources" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" - "github.com/tektoncd/pipeline/pkg/substitution" + "github.com/tektoncd/pipeline/pkg/internal/substitution" ) const ( diff --git a/pkg/reconciler/pipelinerun/resources/pipelinerunresolution.go b/pkg/reconciler/pipelinerun/resources/pipelinerunresolution.go index a1a6260045e..ebcad6977f3 100644 --- a/pkg/reconciler/pipelinerun/resources/pipelinerunresolution.go +++ b/pkg/reconciler/pipelinerun/resources/pipelinerunresolution.go @@ -26,7 +26,7 @@ import ( "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" resourcev1alpha1 "github.com/tektoncd/pipeline/pkg/apis/resource/v1alpha1" - "github.com/tektoncd/pipeline/pkg/list" + "github.com/tektoncd/pipeline/pkg/internal/list" "github.com/tektoncd/pipeline/pkg/reconciler/taskrun/resources" "github.com/tektoncd/pipeline/pkg/remote" kerrors "k8s.io/apimachinery/pkg/api/errors" diff --git a/pkg/reconciler/pipelinerun/resources/validate_params.go b/pkg/reconciler/pipelinerun/resources/validate_params.go index 363d18281c9..35c1467eec4 100644 --- a/pkg/reconciler/pipelinerun/resources/validate_params.go +++ b/pkg/reconciler/pipelinerun/resources/validate_params.go @@ -22,9 +22,9 @@ import ( "github.com/tektoncd/pipeline/pkg/apis/config" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" - "github.com/tektoncd/pipeline/pkg/list" + "github.com/tektoncd/pipeline/pkg/internal/list" + "github.com/tektoncd/pipeline/pkg/internal/substitution" "github.com/tektoncd/pipeline/pkg/reconciler/taskrun" - "github.com/tektoncd/pipeline/pkg/substitution" "k8s.io/apimachinery/pkg/util/sets" ) diff --git a/pkg/reconciler/taskrun/controller.go b/pkg/reconciler/taskrun/controller.go index 9e2b07a9044..d56bf72bf49 100644 --- a/pkg/reconciler/taskrun/controller.go +++ b/pkg/reconciler/taskrun/controller.go @@ -28,7 +28,7 @@ import ( resolutionclient "github.com/tektoncd/pipeline/pkg/client/resolution/injection/client" resolutioninformer "github.com/tektoncd/pipeline/pkg/client/resolution/injection/informers/resolution/v1beta1/resolutionrequest" resourceinformer "github.com/tektoncd/pipeline/pkg/client/resource/injection/informers/resource/v1alpha1/pipelineresource" - "github.com/tektoncd/pipeline/pkg/pod" + "github.com/tektoncd/pipeline/pkg/internal/pod" cloudeventclient "github.com/tektoncd/pipeline/pkg/reconciler/events/cloudevent" "github.com/tektoncd/pipeline/pkg/reconciler/volumeclaim" resolution "github.com/tektoncd/pipeline/pkg/resolution/resource" diff --git a/pkg/reconciler/taskrun/resources/apply.go b/pkg/reconciler/taskrun/resources/apply.go index 473fdb155d8..9fbffc1f394 100644 --- a/pkg/reconciler/taskrun/resources/apply.go +++ b/pkg/reconciler/taskrun/resources/apply.go @@ -28,9 +28,9 @@ import ( "github.com/tektoncd/pipeline/pkg/apis/config" "github.com/tektoncd/pipeline/pkg/apis/pipeline" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" - "github.com/tektoncd/pipeline/pkg/container" - "github.com/tektoncd/pipeline/pkg/pod" - "github.com/tektoncd/pipeline/pkg/substitution" + "github.com/tektoncd/pipeline/pkg/internal/container" + "github.com/tektoncd/pipeline/pkg/internal/pod" + "github.com/tektoncd/pipeline/pkg/internal/substitution" ) const ( diff --git a/pkg/reconciler/taskrun/resources/apply_test.go b/pkg/reconciler/taskrun/resources/apply_test.go index 5855a532675..660b2a3df86 100644 --- a/pkg/reconciler/taskrun/resources/apply_test.go +++ b/pkg/reconciler/taskrun/resources/apply_test.go @@ -26,8 +26,8 @@ import ( "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" "github.com/tektoncd/pipeline/pkg/apis/resource" resourcev1alpha1 "github.com/tektoncd/pipeline/pkg/apis/resource/v1alpha1" + "github.com/tektoncd/pipeline/pkg/internal/workspace" "github.com/tektoncd/pipeline/pkg/reconciler/taskrun/resources" - "github.com/tektoncd/pipeline/pkg/workspace" "github.com/tektoncd/pipeline/test/diff" "github.com/tektoncd/pipeline/test/names" corev1 "k8s.io/api/core/v1" diff --git a/pkg/reconciler/taskrun/resources/input_resources.go b/pkg/reconciler/taskrun/resources/input_resources.go index 24edfe14769..a1470910325 100644 --- a/pkg/reconciler/taskrun/resources/input_resources.go +++ b/pkg/reconciler/taskrun/resources/input_resources.go @@ -24,7 +24,7 @@ import ( "github.com/tektoncd/pipeline/pkg/apis/pipeline" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" "github.com/tektoncd/pipeline/pkg/apis/resource/v1alpha1/storage" - "github.com/tektoncd/pipeline/pkg/artifacts" + "github.com/tektoncd/pipeline/pkg/internal/artifacts" corev1 "k8s.io/api/core/v1" "k8s.io/client-go/kubernetes" ) diff --git a/pkg/reconciler/taskrun/resources/output_resource.go b/pkg/reconciler/taskrun/resources/output_resource.go index b06f2628a3f..bd8fcb35bc5 100644 --- a/pkg/reconciler/taskrun/resources/output_resource.go +++ b/pkg/reconciler/taskrun/resources/output_resource.go @@ -24,7 +24,7 @@ import ( "github.com/tektoncd/pipeline/pkg/apis/pipeline" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" "github.com/tektoncd/pipeline/pkg/apis/resource/v1alpha1/storage" - "github.com/tektoncd/pipeline/pkg/artifacts" + "github.com/tektoncd/pipeline/pkg/internal/artifacts" "k8s.io/client-go/kubernetes" ) @@ -37,8 +37,10 @@ var ( // target directory. // Steps executed: // 1. If taskrun has owner reference as pipelinerun then all outputs are copied to parents PVC +// // and also runs any custom upload steps (upload to blob store) -// 2. If taskrun does not have pipelinerun as owner reference then all outputs resources execute their custom +// 2. If taskrun does not have pipelinerun as owner reference then all outputs resources execute their custom +// // upload steps (like upload to blob store ) // // Resource source path determined diff --git a/pkg/reconciler/taskrun/taskrun.go b/pkg/reconciler/taskrun/taskrun.go index cc4ae38ee68..856bd6173c4 100644 --- a/pkg/reconciler/taskrun/taskrun.go +++ b/pkg/reconciler/taskrun/taskrun.go @@ -37,7 +37,8 @@ import ( resourcelisters "github.com/tektoncd/pipeline/pkg/client/resource/listers/resource/v1alpha1" "github.com/tektoncd/pipeline/pkg/internal/affinityassistant" "github.com/tektoncd/pipeline/pkg/internal/computeresources" - podconvert "github.com/tektoncd/pipeline/pkg/pod" + podconvert "github.com/tektoncd/pipeline/pkg/internal/pod" + "github.com/tektoncd/pipeline/pkg/internal/workspace" tknreconciler "github.com/tektoncd/pipeline/pkg/reconciler" "github.com/tektoncd/pipeline/pkg/reconciler/events" "github.com/tektoncd/pipeline/pkg/reconciler/events/cloudevent" @@ -47,7 +48,6 @@ import ( resolution "github.com/tektoncd/pipeline/pkg/resolution/resource" "github.com/tektoncd/pipeline/pkg/taskrunmetrics" _ "github.com/tektoncd/pipeline/pkg/taskrunmetrics/fake" // Make sure the taskrunmetrics are setup - "github.com/tektoncd/pipeline/pkg/workspace" "go.uber.org/zap" corev1 "k8s.io/api/core/v1" k8serrors "k8s.io/apimachinery/pkg/api/errors" @@ -589,7 +589,7 @@ func (c *Reconciler) updateLabelsAndAnnotations(ctx context.Context, tr *v1beta1 if tr.Annotations == nil { tr.Annotations = make(map[string]string, 1) } - tr.Annotations[podconvert.ReleaseAnnotation] = changeset.Get() + tr.Annotations[config.ReleaseAnnotation] = changeset.Get() newTr, err := c.taskRunLister.TaskRuns(tr.Namespace).Get(tr.Name) if err != nil { @@ -634,7 +634,7 @@ func (c *Reconciler) handlePodCreationError(tr *v1beta1.TaskRun, err error) erro msg += "invalid TaskSpec" } err = controller.NewPermanentError(errors.New(msg)) - tr.Status.MarkResourceFailed(podconvert.ReasonCouldntGetTask, err) + tr.Status.MarkResourceFailed(v1beta1.ReasonCouldntGetTask, err) } return err } diff --git a/pkg/reconciler/taskrun/taskrun_test.go b/pkg/reconciler/taskrun/taskrun_test.go index b75204b7f6a..61a3a3651e3 100644 --- a/pkg/reconciler/taskrun/taskrun_test.go +++ b/pkg/reconciler/taskrun/taskrun_test.go @@ -38,13 +38,13 @@ import ( "github.com/tektoncd/pipeline/pkg/apis/pipeline/pod" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" resourcev1alpha1 "github.com/tektoncd/pipeline/pkg/apis/resource/v1alpha1" - podconvert "github.com/tektoncd/pipeline/pkg/pod" + podconvert "github.com/tektoncd/pipeline/pkg/internal/pod" + "github.com/tektoncd/pipeline/pkg/internal/workspace" "github.com/tektoncd/pipeline/pkg/reconciler/events/cloudevent" "github.com/tektoncd/pipeline/pkg/reconciler/taskrun/resources" ttesting "github.com/tektoncd/pipeline/pkg/reconciler/testing" "github.com/tektoncd/pipeline/pkg/reconciler/volumeclaim" resolutioncommon "github.com/tektoncd/pipeline/pkg/resolution/common" - "github.com/tektoncd/pipeline/pkg/workspace" "github.com/tektoncd/pipeline/test" "github.com/tektoncd/pipeline/test/diff" eventstest "github.com/tektoncd/pipeline/test/events" @@ -2709,7 +2709,7 @@ status: err: errors.New("this is a fatal error"), expectedType: apis.ConditionSucceeded, expectedStatus: corev1.ConditionFalse, - expectedReason: podconvert.ReasonCouldntGetTask, + expectedReason: v1beta1.ReasonCouldntGetTask, }} for _, tc := range testcases { t.Run(tc.description, func(t *testing.T) { @@ -4635,7 +4635,7 @@ func podObjectMeta(name, taskName, taskRunName, ns string, isClusterTask bool) m Name: name, Namespace: ns, Annotations: map[string]string{ - podconvert.ReleaseAnnotation: fakeVersion, + config.ReleaseAnnotation: fakeVersion, }, Labels: map[string]string{ pipeline.TaskRunLabelKey: taskRunName, diff --git a/pkg/reconciler/taskrun/validate_resources.go b/pkg/reconciler/taskrun/validate_resources.go index 29dc1c096be..0030aa6e460 100644 --- a/pkg/reconciler/taskrun/validate_resources.go +++ b/pkg/reconciler/taskrun/validate_resources.go @@ -23,9 +23,9 @@ import ( "github.com/tektoncd/pipeline/pkg/apis/config" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" resourcev1alpha1 "github.com/tektoncd/pipeline/pkg/apis/resource/v1alpha1" - "github.com/tektoncd/pipeline/pkg/list" + "github.com/tektoncd/pipeline/pkg/internal/list" + "github.com/tektoncd/pipeline/pkg/internal/substitution" "github.com/tektoncd/pipeline/pkg/reconciler/taskrun/resources" - "github.com/tektoncd/pipeline/pkg/substitution" "k8s.io/apimachinery/pkg/util/sets" "github.com/hashicorp/go-multierror" diff --git a/test/resolvers_test.go b/test/resolvers_test.go index f3a2f42f322..24d42865a15 100644 --- a/test/resolvers_test.go +++ b/test/resolvers_test.go @@ -34,7 +34,7 @@ import ( "github.com/goccy/kpoward" "github.com/jenkins-x/go-scm/scm/factory" resolverconfig "github.com/tektoncd/pipeline/pkg/apis/config/resolver" - "github.com/tektoncd/pipeline/pkg/pod" + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" "github.com/tektoncd/pipeline/pkg/reconciler/pipelinerun" "github.com/tektoncd/pipeline/pkg/resolution/resolver/git" "github.com/tektoncd/pipeline/test/parse" @@ -189,7 +189,7 @@ spec: t.Logf("Waiting for PipelineRun %s in namespace %s to complete", prName, namespace) if err := WaitForPipelineRunState(ctx, c, prName, timeout, Chain( - FailedWithReason(pod.ReasonCouldntGetTask, prName), + FailedWithReason(v1beta1.ReasonCouldntGetTask, prName), FailedWithMessage("requested resource 'https://api.hub.tekton.dev/v1/resource/Tekton/task/git-clone-this-does-not-exist/0.7/yaml' not found on hub", prName), ), "PipelineRunFailed"); err != nil { t.Fatalf("Error waiting for PipelineRun to finish with expected error: %s", err) @@ -354,7 +354,7 @@ spec: t.Logf("Waiting for PipelineRun %s in namespace %s to complete", prName, namespace) if err := WaitForPipelineRunState(ctx, c, prName, timeout, Chain( - FailedWithReason(pod.ReasonCouldntGetTask, prName), + FailedWithReason(v1beta1.ReasonCouldntGetTask, prName), FailedWithMessage(expectedErr, prName), ), "PipelineRunFailed"); err != nil { t.Fatalf("Error waiting for PipelineRun to finish with expected error: %s", err) diff --git a/test/taskrun_test.go b/test/taskrun_test.go index 45b65648308..eb23b904b30 100644 --- a/test/taskrun_test.go +++ b/test/taskrun_test.go @@ -30,8 +30,8 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" + "github.com/tektoncd/pipeline/pkg/apis/config" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" - "github.com/tektoncd/pipeline/pkg/pod" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" knativetest "knative.dev/pkg/test" @@ -127,11 +127,11 @@ spec: t.Fatalf("-got, +want: %v", d) } - releaseAnnotation, ok := taskrun.Annotations[pod.ReleaseAnnotation] + releaseAnnotation, ok := taskrun.Annotations[config.ReleaseAnnotation] // This should always contain a commit truncated to 7 characters, possibly with "-dirty" suffix (based on knative.dev/pkg/changeset) commitIDRegexp := regexp.MustCompile(`^[a-f0-9]{7}(-dirty)?$`) if !ok || !commitIDRegexp.MatchString(releaseAnnotation) { - t.Fatalf("expected Taskrun to be annotated with %s=devel or with nightly release tag, got %s=%s", pod.ReleaseAnnotation, pod.ReleaseAnnotation, releaseAnnotation) + t.Fatalf("expected Taskrun to be annotated with %s=devel or with nightly release tag, got %s=%s", config.ReleaseAnnotation, config.ReleaseAnnotation, releaseAnnotation) } } diff --git a/test/tektonbundles_test.go b/test/tektonbundles_test.go index 9dca8b08dcd..34b35a1fe25 100644 --- a/test/tektonbundles_test.go +++ b/test/tektonbundles_test.go @@ -31,16 +31,15 @@ import ( "strings" "testing" - "github.com/tektoncd/pipeline/test/parse" - "github.com/google/go-containerregistry/pkg/name" v1 "github.com/google/go-containerregistry/pkg/v1" "github.com/google/go-containerregistry/pkg/v1/empty" "github.com/google/go-containerregistry/pkg/v1/layout" "github.com/google/go-containerregistry/pkg/v1/mutate" "github.com/google/go-containerregistry/pkg/v1/tarball" - "github.com/tektoncd/pipeline/pkg/pod" + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" "github.com/tektoncd/pipeline/pkg/reconciler/pipelinerun" + "github.com/tektoncd/pipeline/test/parse" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "knative.dev/pkg/apis" @@ -420,7 +419,7 @@ spec: t.Logf("Waiting for PipelineRun in namespace %s to finish", namespace) if err := WaitForPipelineRunState(ctx, c, pipelineRunName, timeout, Chain( - FailedWithReason(pod.ReasonCouldntGetTask, pipelineRunName), + FailedWithReason(v1beta1.ReasonCouldntGetTask, pipelineRunName), FailedWithMessage("does not contain a dev.tekton.image.apiVersion annotation", pipelineRunName), ), "PipelineRunFailed"); err != nil { t.Fatalf("Error waiting for PipelineRun to finish with expected error: %s", err)