diff --git a/docs/resources.md b/docs/resources.md index 4c9bdef4a3c..03e1b8d4355 100644 --- a/docs/resources.md +++ b/docs/resources.md @@ -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 @@ -687,8 +685,6 @@ spec: params: - name: url value: https:// - - name: name - value: mycluster secrets: - fieldName: cadata secretName: cluster-ca-data diff --git a/pkg/apis/pipeline/v1alpha1/cluster_resource.go b/pkg/apis/pipeline/v1alpha1/cluster_resource.go index 8034d3e8964..bd379f6cc61 100644 --- a/pkg/apis/pipeline/v1alpha1/cluster_resource.go +++ b/pkg/apis/pipeline/v1alpha1/cluster_resource.go @@ -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 { diff --git a/pkg/apis/pipeline/v1alpha1/pipelineresource_validation.go b/pkg/apis/pipeline/v1alpha1/pipelineresource_validation.go index db18a1d3437..883fb050da4 100644 --- a/pkg/apis/pipeline/v1alpha1/pipelineresource_validation.go +++ b/pkg/apis/pipeline/v1alpha1/pipelineresource_validation.go @@ -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) @@ -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) { diff --git a/pkg/apis/pipeline/v1alpha1/pipelineresource_validation_test.go b/pkg/apis/pipeline/v1alpha1/pipelineresource_validation_test.go index 573a575166c..a8ff6bd2ecd 100644 --- a/pkg/apis/pipeline/v1alpha1/pipelineresource_validation_test.go +++ b/pkg/apis/pipeline/v1alpha1/pipelineresource_validation_test.go @@ -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(