Skip to content

Commit

Permalink
Remove the custom "name" parameter from cluster resources.
Browse files Browse the repository at this point in the history
This is redundant with the Name that Tasks already declare on Resources.
The name is used both to name the cluster in the kubeconfig and to set the
path for the kubeconfig. Using a name on the resource itself means Tasks can't
know where to expect this file.
  • Loading branch information
dlorenc committed Nov 26, 2019
1 parent 5961b2a commit e1bfcc1
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 16 deletions.
4 changes: 0 additions & 4 deletions docs/resources.md
Original file line number Diff line number Diff line change
Expand Up @@ -552,8 +552,6 @@ cluster. The kubeconfig will be placed in

The Cluster resource has the following parameters:

- `name` (required): The name to be given to the target cluster, will be used
in the kubeconfig and also as part of the path to the kubeconfig file
- `url` (required): Host url of the master node
- `username` (required): the user with access to the cluster
- `password`: to be used for clusters with basic auth
Expand Down Expand Up @@ -687,8 +685,6 @@ spec:
params:
- name: url
value: https://<ip address determined above>
- name: name
value: mycluster
secrets:
- fieldName: cadata
secretName: cluster-ca-data
Expand Down
1 change: 1 addition & 0 deletions pkg/apis/pipeline/v1alpha1/cluster_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ func NewClusterResource(kubeconfigWriterImage string, r *PipelineResource) (*Clu
clusterResource := ClusterResource{
Type: r.Spec.Type,
KubeconfigWriterImage: kubeconfigWriterImage,
Name: r.Name,
}
for _, param := range r.Spec.Params {
switch {
Expand Down
6 changes: 4 additions & 2 deletions pkg/apis/pipeline/v1alpha1/pipelineresource_validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ 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 Down Expand Up @@ -74,8 +75,9 @@ func (rs *PipelineResourceSpec) Validate(ctx context.Context) *apis.FieldError {
}
}

if !nameFound {
return apis.ErrMissingField("name param")
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) {
Expand Down
10 changes: 0 additions & 10 deletions pkg/apis/pipeline/v1alpha1/pipelineresource_validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,6 @@ func TestResourceValidation_Invalid(t *testing.T) {
)),
want: apis.ErrMissingField("username or CAData or token param"),
},
{
name: "cluster with missing name",
res: tb.PipelineResource("test-cluster-resource", "foo", tb.PipelineResourceSpec(
v1alpha1.PipelineResourceTypeCluster,
tb.PipelineResourceSpecParam("url", "http://10.10.10.10"),
tb.PipelineResourceSpecParam("cadata", "bXktY2x1c3Rlci1jZXJ0Cg"),
tb.PipelineResourceSpecParam("token", "my-token"),
)),
want: apis.ErrMissingField("name param"),
},
{
name: "cluster with missing cadata",
res: tb.PipelineResource("test-cluster-resource", "foo", tb.PipelineResourceSpec(
Expand Down

0 comments on commit e1bfcc1

Please sign in to comment.