Skip to content

Commit

Permalink
Remove legacy Cluster Resource behavior left in place for the 0.14.0 …
Browse files Browse the repository at this point in the history
…release.

This is a cleanup commit that should go in after 0.14.0 is cut. It was introduced
in tektoncd#2697, to fix tektoncd#2694.
  • Loading branch information
dlorenc committed Jun 11, 2020
1 parent bd885f8 commit 33fbdde
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 52 deletions.
19 changes: 0 additions & 19 deletions pkg/apis/resource/v1alpha1/cluster/cluster_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,9 @@ import (
b64 "encoding/base64"
"encoding/json"
"fmt"
"path/filepath"
"strconv"
"strings"

"github.com/tektoncd/pipeline/pkg/apis/pipeline"
"github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1"
resource "github.com/tektoncd/pipeline/pkg/apis/resource/v1alpha1"
"github.com/tektoncd/pipeline/pkg/names"
Expand Down Expand Up @@ -61,9 +59,6 @@ type Resource struct {

KubeconfigWriterImage string `json:"-"`
ShellImage string `json:"-"`

// Temporary field to hold the old, legacy value for name. See #2694
LegacyName string `json:"-"`
}

// NewResource create a new k8s cluster resource to pass to a pipeline task
Expand All @@ -76,7 +71,6 @@ func NewResource(name string, kubeconfigWriterImage, shellImage string, r *resou
KubeconfigWriterImage: kubeconfigWriterImage,
ShellImage: shellImage,
Name: name,
LegacyName: r.Name,
}
for _, param := range r.Spec.Params {
switch {
Expand Down Expand Up @@ -199,19 +193,6 @@ func (s *Resource) GetInputTaskModifier(ts *v1beta1.TaskSpec, path string) (v1be
return &v1beta1.InternalTaskModifier{
StepsToPrepend: []v1beta1.Step{
step,
// See #2694.
linkDirStep(s.ShellImage, s.Name, s.LegacyName),
},
}, nil
}

// See #2694
func linkDirStep(shellImage string, name, legacyName string) v1beta1.Step {
srcPath := filepath.Join(pipeline.WorkspaceDir, name)
dstPath := filepath.Join(pipeline.WorkspaceDir, legacyName)
return v1beta1.Step{Container: corev1.Container{
Name: names.SimpleNameGenerator.RestrictLengthWithRandomSuffix(fmt.Sprintf("ln-dir-%s", strings.ToLower(name))),
Image: shellImage,
Command: []string{"ln", "-s", srcPath, dstPath},
}}
}
9 changes: 0 additions & 9 deletions pkg/apis/resource/v1alpha1/cluster/cluster_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,6 @@ func TestNewClusterResource(t *testing.T) {
t.Errorf("Test: %q; TestNewClusterResource() error = %v", c.desc, err)
}
c.want.ShellImage = "override-with-shell-image:latest"
c.want.LegacyName = "test-resource"
if d := cmp.Diff(got, c.want); d != "" {
t.Errorf("Diff:\n%s", diff.PrintWantGot(d))
}
Expand Down Expand Up @@ -194,14 +193,6 @@ func TestClusterResource_GetInputTaskModifier(t *testing.T) {
}},
},
},
// We need to temporarily create another directory for the legacy name
// See #2694.
{
Container: corev1.Container{
Name: "ln-dir-test-cluster-resource-mz4c7",
Command: []string{"ln", "-s", "/workspace/test-cluster-resource", "/workspace"},
},
},
}

got, err := clusterResource.GetInputTaskModifier(&ts, "/location")
Expand Down
14 changes: 0 additions & 14 deletions pkg/reconciler/taskrun/resources/input_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -852,13 +852,6 @@ gsutil cp gs://fake-bucket/rules.zip /workspace/gcs-dir
},
},
},
{
Container: corev1.Container{
Name: "ln-dir-cluster3-mz4c7",
Image: "busybox",
Command: []string{"ln", "-s", "/workspace/cluster3", "/workspace/cluster3"},
},
},
},
Resources: &v1beta1.TaskResources{
Inputs: clusterInputs,
Expand Down Expand Up @@ -922,13 +915,6 @@ gsutil cp gs://fake-bucket/rules.zip /workspace/gcs-dir
}},
},
},
{
Container: corev1.Container{
Name: "ln-dir-cluster2-mz4c7",
Image: "busybox",
Command: []string{"ln", "-s", "/workspace/cluster2", "/workspace/cluster2"},
},
},
},
Resources: &v1beta1.TaskResources{
Inputs: clusterInputs,
Expand Down
10 changes: 0 additions & 10 deletions test/cluster_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,16 +142,6 @@ func getClusterResourceTask(namespace, name, configName string) *v1beta1.Task {
Name: "config-vol",
MountPath: "/config",
}},
}}, {Container: corev1.Container{
// See #2694
Name: "check-legacy-contents",
Image: "ubuntu",
Command: []string{"bash"},
Args: []string{"-c", "cmp -b /workspace/helloworld-cluster/kubeconfig /config/test.data"},
VolumeMounts: []corev1.VolumeMount{{
Name: "config-vol",
MountPath: "/config",
}},
}},
},
},
Expand Down

0 comments on commit 33fbdde

Please sign in to comment.