Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move several packages into internal #5681

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions cmd/entrypoint/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand Down Expand Up @@ -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)
}

Expand Down
8 changes: 8 additions & 0 deletions pkg/apis/config/pod.go
Original file line number Diff line number Diff line change
@@ -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"
)
2 changes: 1 addition & 1 deletion pkg/apis/pipeline/v1/param_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/pipeline/v1/pipeline_validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/pipeline/v1/task_validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 3 additions & 0 deletions pkg/apis/pipeline/v1/taskref_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
2 changes: 1 addition & 1 deletion pkg/apis/pipeline/v1/when_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/pipeline/v1beta1/param_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down
4 changes: 2 additions & 2 deletions pkg/apis/pipeline/v1beta1/pipeline_validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/pipeline/v1beta1/task_validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 3 additions & 0 deletions pkg/apis/pipeline/v1beta1/taskref_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
2 changes: 1 addition & 1 deletion pkg/apis/pipeline/v1beta1/when_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down
12 changes: 12 additions & 0 deletions pkg/artifacts/artifacts.go
Original file line number Diff line number Diff line change
@@ -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
}
4 changes: 2 additions & 2 deletions pkg/internal/affinityassistant/transformer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down
4 changes: 2 additions & 2 deletions pkg/internal/affinityassistant/transformer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
}
})
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -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{
Expand All @@ -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
}
2 changes: 1 addition & 1 deletion pkg/internal/computeresources/transformer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
9 changes: 2 additions & 7 deletions pkg/pod/pod.go → pkg/internal/pod/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -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,
Expand Down Expand Up @@ -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
}
}
Expand Down Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions pkg/pod/pod_test.go → pkg/internal/pod/pod_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 != "" {
Expand Down Expand Up @@ -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{
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading