Skip to content

Commit

Permalink
Remove support for the name parameter to cluster resources.
Browse files Browse the repository at this point in the history
This was deprecated in tektoncd#1474 which was released in 0.9.0. It can safely
be deleted in the next release.
  • Loading branch information
dlorenc committed Dec 3, 2019
1 parent 610c7a5 commit 5b8a7b3
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 19 deletions.
2 changes: 0 additions & 2 deletions pkg/apis/pipeline/v1alpha1/cluster_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,6 @@ func NewClusterResource(kubeconfigWriterImage string, r *PipelineResource) (*Clu
}
for _, param := range r.Spec.Params {
switch {
case strings.EqualFold(param.Name, "Name"):
clusterResource.Name = param.Value
case strings.EqualFold(param.Name, "URL"):
clusterResource.URL = param.Value
case strings.EqualFold(param.Name, "Revision"):
Expand Down
13 changes: 4 additions & 9 deletions pkg/apis/pipeline/v1alpha1/cluster_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,12 @@ func TestNewClusterResource(t *testing.T) {
desc: "basic cluster resource",
resource: tb.PipelineResource("test-cluster-resource", "default", tb.PipelineResourceSpec(
v1alpha1.PipelineResourceTypeCluster,
tb.PipelineResourceSpecParam("name", "test_cluster_resource"),
tb.PipelineResourceSpecParam("url", "http://10.10.10.10"),
tb.PipelineResourceSpecParam("cadata", "bXktY2x1c3Rlci1jZXJ0Cg"),
tb.PipelineResourceSpecParam("token", "my-token"),
)),
want: &v1alpha1.ClusterResource{
Name: "test_cluster_resource",
Name: "test-cluster-resource",
Type: v1alpha1.PipelineResourceTypeCluster,
URL: "http://10.10.10.10",
CAData: []byte("my-cluster-cert"),
Expand All @@ -52,14 +51,13 @@ func TestNewClusterResource(t *testing.T) {
desc: "resource with password instead of token",
resource: tb.PipelineResource("test-cluster-resource", "default", tb.PipelineResourceSpec(
v1alpha1.PipelineResourceTypeCluster,
tb.PipelineResourceSpecParam("name", "test_cluster_resource"),
tb.PipelineResourceSpecParam("url", "http://10.10.10.10"),
tb.PipelineResourceSpecParam("cadata", "bXktY2x1c3Rlci1jZXJ0Cg"),
tb.PipelineResourceSpecParam("username", "user"),
tb.PipelineResourceSpecParam("password", "pass"),
)),
want: &v1alpha1.ClusterResource{
Name: "test_cluster_resource",
Name: "test-cluster-resource",
Type: v1alpha1.PipelineResourceTypeCluster,
URL: "http://10.10.10.10",
CAData: []byte("my-cluster-cert"),
Expand All @@ -71,12 +69,11 @@ func TestNewClusterResource(t *testing.T) {
desc: "set insecure flag to true when there is no cert",
resource: tb.PipelineResource("test-cluster-resource", "foo", tb.PipelineResourceSpec(
v1alpha1.PipelineResourceTypeCluster,
tb.PipelineResourceSpecParam("name", "test.cluster.resource"),
tb.PipelineResourceSpecParam("url", "http://10.10.10.10"),
tb.PipelineResourceSpecParam("token", "my-token"),
)),
want: &v1alpha1.ClusterResource{
Name: "test.cluster.resource",
Name: "test-cluster-resource",
Type: v1alpha1.PipelineResourceTypeCluster,
URL: "http://10.10.10.10",
Token: "my-token",
Expand All @@ -87,14 +84,13 @@ func TestNewClusterResource(t *testing.T) {
desc: "basic cluster resource with namespace",
resource: tb.PipelineResource("test-cluster-resource", "default", tb.PipelineResourceSpec(
v1alpha1.PipelineResourceTypeCluster,
tb.PipelineResourceSpecParam("name", "test_cluster_resource"),
tb.PipelineResourceSpecParam("url", "http://10.10.10.10"),
tb.PipelineResourceSpecParam("cadata", "bXktY2x1c3Rlci1jZXJ0Cg"),
tb.PipelineResourceSpecParam("token", "my-token"),
tb.PipelineResourceSpecParam("namespace", "my-namespace"),
)),
want: &v1alpha1.ClusterResource{
Name: "test_cluster_resource",
Name: "test-cluster-resource",
Type: v1alpha1.PipelineResourceTypeCluster,
URL: "http://10.10.10.10",
CAData: []byte("my-cluster-cert"),
Expand All @@ -106,7 +102,6 @@ func TestNewClusterResource(t *testing.T) {
desc: "basic resource with secrets",
resource: tb.PipelineResource("test-cluster-resource", "default", tb.PipelineResourceSpec(
v1alpha1.PipelineResourceTypeCluster,
tb.PipelineResourceSpecParam("name", "test-cluster-resource"),
tb.PipelineResourceSpecParam("url", "http://10.10.10.10"),
tb.PipelineResourceSpecSecretParam("cadata", "secret1", "cadatakey"),
tb.PipelineResourceSpecSecretParam("token", "secret1", "tokenkey"),
Expand Down
9 changes: 1 addition & 8 deletions pkg/apis/pipeline/v1alpha1/pipelineresource_validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import (
"github.com/tektoncd/pipeline/pkg/apis/validate"
"k8s.io/apimachinery/pkg/api/equality"
"knative.dev/pkg/apis"
logging "knative.dev/pkg/logging"
)

var _ apis.Validatable = (*PipelineResource)(nil)
Expand All @@ -43,7 +42,7 @@ func (rs *PipelineResourceSpec) Validate(ctx context.Context) *apis.FieldError {
return apis.ErrMissingField(apis.CurrentField)
}
if rs.Type == PipelineResourceTypeCluster {
var authFound, cadataFound, nameFound, isInsecure bool
var authFound, cadataFound, isInsecure bool
for _, param := range rs.Params {
switch {
case strings.EqualFold(param.Name, "URL"):
Expand All @@ -57,8 +56,6 @@ func (rs *PipelineResourceSpec) Validate(ctx context.Context) *apis.FieldError {
cadataFound = true
case strings.EqualFold(param.Name, "Token"):
authFound = true
case strings.EqualFold(param.Name, "name"):
nameFound = true
case strings.EqualFold(param.Name, "insecure"):
b, _ := strconv.ParseBool(param.Value)
isInsecure = b
Expand All @@ -75,10 +72,6 @@ func (rs *PipelineResourceSpec) Validate(ctx context.Context) *apis.FieldError {
}
}

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

0 comments on commit 5b8a7b3

Please sign in to comment.