Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove the custom "name" parameter from cluster resources. #1474

Merged
merged 1 commit into from
Nov 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I understand this correctly, this uses the resource name as cluster name. Unfortunately this is not OK - which is the reason the name parameter was added - because the resource name must be a DNS valid name, while the cluster name may be not a valid DNS one e.g. my_cluster is a valid cluster name, but not a valid resource name.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah thanks for the explanation. Can you explain why the cluster name matters in your case?

Leaving the name parameter would be fine I think as long as we write to the /workspace/resource-name path instead of the /workspace/cluster-name-param path.

I can't actually see the use case for cluster name though - it's only used inside the .kubeconfig AFAICT, and can be literally anything.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, indeed it doesn't seem to matter at all, sorry about my bad review :(

}
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