Skip to content

Commit 5b8a7b3

Browse files
committed
Remove support for the name parameter to cluster resources.
This was deprecated in #1474 which was released in 0.9.0. It can safely be deleted in the next release.
1 parent 610c7a5 commit 5b8a7b3

File tree

3 files changed

+5
-19
lines changed

3 files changed

+5
-19
lines changed

pkg/apis/pipeline/v1alpha1/cluster_resource.go

-2
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,6 @@ func NewClusterResource(kubeconfigWriterImage string, r *PipelineResource) (*Clu
6666
}
6767
for _, param := range r.Spec.Params {
6868
switch {
69-
case strings.EqualFold(param.Name, "Name"):
70-
clusterResource.Name = param.Value
7169
case strings.EqualFold(param.Name, "URL"):
7270
clusterResource.URL = param.Value
7371
case strings.EqualFold(param.Name, "Revision"):

pkg/apis/pipeline/v1alpha1/cluster_resource_test.go

+4-9
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,12 @@ func TestNewClusterResource(t *testing.T) {
3535
desc: "basic cluster resource",
3636
resource: tb.PipelineResource("test-cluster-resource", "default", tb.PipelineResourceSpec(
3737
v1alpha1.PipelineResourceTypeCluster,
38-
tb.PipelineResourceSpecParam("name", "test_cluster_resource"),
3938
tb.PipelineResourceSpecParam("url", "http://10.10.10.10"),
4039
tb.PipelineResourceSpecParam("cadata", "bXktY2x1c3Rlci1jZXJ0Cg"),
4140
tb.PipelineResourceSpecParam("token", "my-token"),
4241
)),
4342
want: &v1alpha1.ClusterResource{
44-
Name: "test_cluster_resource",
43+
Name: "test-cluster-resource",
4544
Type: v1alpha1.PipelineResourceTypeCluster,
4645
URL: "http://10.10.10.10",
4746
CAData: []byte("my-cluster-cert"),
@@ -52,14 +51,13 @@ func TestNewClusterResource(t *testing.T) {
5251
desc: "resource with password instead of token",
5352
resource: tb.PipelineResource("test-cluster-resource", "default", tb.PipelineResourceSpec(
5453
v1alpha1.PipelineResourceTypeCluster,
55-
tb.PipelineResourceSpecParam("name", "test_cluster_resource"),
5654
tb.PipelineResourceSpecParam("url", "http://10.10.10.10"),
5755
tb.PipelineResourceSpecParam("cadata", "bXktY2x1c3Rlci1jZXJ0Cg"),
5856
tb.PipelineResourceSpecParam("username", "user"),
5957
tb.PipelineResourceSpecParam("password", "pass"),
6058
)),
6159
want: &v1alpha1.ClusterResource{
62-
Name: "test_cluster_resource",
60+
Name: "test-cluster-resource",
6361
Type: v1alpha1.PipelineResourceTypeCluster,
6462
URL: "http://10.10.10.10",
6563
CAData: []byte("my-cluster-cert"),
@@ -71,12 +69,11 @@ func TestNewClusterResource(t *testing.T) {
7169
desc: "set insecure flag to true when there is no cert",
7270
resource: tb.PipelineResource("test-cluster-resource", "foo", tb.PipelineResourceSpec(
7371
v1alpha1.PipelineResourceTypeCluster,
74-
tb.PipelineResourceSpecParam("name", "test.cluster.resource"),
7572
tb.PipelineResourceSpecParam("url", "http://10.10.10.10"),
7673
tb.PipelineResourceSpecParam("token", "my-token"),
7774
)),
7875
want: &v1alpha1.ClusterResource{
79-
Name: "test.cluster.resource",
76+
Name: "test-cluster-resource",
8077
Type: v1alpha1.PipelineResourceTypeCluster,
8178
URL: "http://10.10.10.10",
8279
Token: "my-token",
@@ -87,14 +84,13 @@ func TestNewClusterResource(t *testing.T) {
8784
desc: "basic cluster resource with namespace",
8885
resource: tb.PipelineResource("test-cluster-resource", "default", tb.PipelineResourceSpec(
8986
v1alpha1.PipelineResourceTypeCluster,
90-
tb.PipelineResourceSpecParam("name", "test_cluster_resource"),
9187
tb.PipelineResourceSpecParam("url", "http://10.10.10.10"),
9288
tb.PipelineResourceSpecParam("cadata", "bXktY2x1c3Rlci1jZXJ0Cg"),
9389
tb.PipelineResourceSpecParam("token", "my-token"),
9490
tb.PipelineResourceSpecParam("namespace", "my-namespace"),
9591
)),
9692
want: &v1alpha1.ClusterResource{
97-
Name: "test_cluster_resource",
93+
Name: "test-cluster-resource",
9894
Type: v1alpha1.PipelineResourceTypeCluster,
9995
URL: "http://10.10.10.10",
10096
CAData: []byte("my-cluster-cert"),
@@ -106,7 +102,6 @@ func TestNewClusterResource(t *testing.T) {
106102
desc: "basic resource with secrets",
107103
resource: tb.PipelineResource("test-cluster-resource", "default", tb.PipelineResourceSpec(
108104
v1alpha1.PipelineResourceTypeCluster,
109-
tb.PipelineResourceSpecParam("name", "test-cluster-resource"),
110105
tb.PipelineResourceSpecParam("url", "http://10.10.10.10"),
111106
tb.PipelineResourceSpecSecretParam("cadata", "secret1", "cadatakey"),
112107
tb.PipelineResourceSpecSecretParam("token", "secret1", "tokenkey"),

pkg/apis/pipeline/v1alpha1/pipelineresource_validation.go

+1-8
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ import (
2525
"github.com/tektoncd/pipeline/pkg/apis/validate"
2626
"k8s.io/apimachinery/pkg/api/equality"
2727
"knative.dev/pkg/apis"
28-
logging "knative.dev/pkg/logging"
2928
)
3029

3130
var _ apis.Validatable = (*PipelineResource)(nil)
@@ -43,7 +42,7 @@ func (rs *PipelineResourceSpec) Validate(ctx context.Context) *apis.FieldError {
4342
return apis.ErrMissingField(apis.CurrentField)
4443
}
4544
if rs.Type == PipelineResourceTypeCluster {
46-
var authFound, cadataFound, nameFound, isInsecure bool
45+
var authFound, cadataFound, isInsecure bool
4746
for _, param := range rs.Params {
4847
switch {
4948
case strings.EqualFold(param.Name, "URL"):
@@ -57,8 +56,6 @@ func (rs *PipelineResourceSpec) Validate(ctx context.Context) *apis.FieldError {
5756
cadataFound = true
5857
case strings.EqualFold(param.Name, "Token"):
5958
authFound = true
60-
case strings.EqualFold(param.Name, "name"):
61-
nameFound = true
6259
case strings.EqualFold(param.Name, "insecure"):
6360
b, _ := strconv.ParseBool(param.Value)
6461
isInsecure = b
@@ -75,10 +72,6 @@ func (rs *PipelineResourceSpec) Validate(ctx context.Context) *apis.FieldError {
7572
}
7673
}
7774

78-
if nameFound {
79-
logging.FromContext(ctx).Warn(
80-
"The name parameter on the cluster resource is deprecated. Support will be removed in a future release")
81-
}
8275
// One auth method must be supplied
8376
if !(authFound) {
8477
return apis.ErrMissingField("username or CAData or token param")

0 commit comments

Comments
 (0)