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

Add validation for cluster_name #1641

Merged
merged 1 commit into from
Nov 22, 2021
Merged

Conversation

ahmedwaleedmalik
Copy link
Member

What this PR does / why we need it:
Add validation for cluster_name variable

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes #1630

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

Add validation for `cluster_name` variable

@kubermatic-bot kubermatic-bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. dco-signoff: yes Denotes that all commits in the pull request have the valid DCO signoff message. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Nov 22, 2021
Copy link
Member

@kron4eg kron4eg left a comment

Choose a reason for hiding this comment

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

/approve

@kubermatic-bot kubermatic-bot added the lgtm Indicates that a PR is ready to be merged. label Nov 22, 2021
@kubermatic-bot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ahmedwaleedmalik, kron4eg

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kubermatic-bot kubermatic-bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 22, 2021
@kubermatic-bot
Copy link
Contributor

LGTM label has been added.

Git tree hash: f79ebe50bc312f5f2c16732c69c09b78aa8ade33

@ahmedwaleedmalik
Copy link
Member Author

/retest

1 similar comment
@ahmedwaleedmalik
Copy link
Member Author

/retest

@kubermatic-bot kubermatic-bot merged commit 1cb1372 into master Nov 22, 2021
@kubermatic-bot kubermatic-bot added this to the KubeOne 1.4 milestone Nov 22, 2021
@kubermatic-bot kubermatic-bot deleted the cluser-name-validation branch November 22, 2021 16:16
cedi pushed a commit to cedi/kubeone that referenced this pull request Nov 23, 2021
This commit fixes an rather annoying issue where `ValidateName` does not
print the correct value of the invalid cluster name which made the issue
hard to debug.

Background:
I recently upgraded from an earlier KubeOne version to master and my cluster-name contained dots (`.`).
However since kubermatic#1641 this is no longer valid.

The output of this validation looked like

```bash
$ kubeone apply --manifest kubeone.yaml --credentials credentials.yaml --tfjson output.json --auto-approve --verbose

Error: failed to initialize State: failed to build state: failed to load cluster: unable to load a given KubeOneCluster object: unable to validate the given KubeOneCluster object: name: Invalid value: "": .name should be lowercase and can only contain alphanumeric characters and hyphens(-)
```

With this commit in place the output looks like this:

```bash
$ kubeone install --manifest kubeone.yaml --credentials credentials.yaml --tfjson output.json --verbose
Error: failed to initialize State: failed to build state: failed to load cluster: unable to load a given KubeOneCluster object: unable to validate the given KubeOneCluster object: name: Invalid value: "k8s.cedi.dev": .name should be lowercase and can only contain alphanumeric characters and hyphens(-)
```

Signed-off-by: Cedric Kienzler <[email protected]>
kubermatic-bot pushed a commit that referenced this pull request Nov 23, 2021
…lue (#1646)

This commit fixes an rather annoying issue where `ValidateName` does not
print the correct value of the invalid cluster name which made the issue
hard to debug.

Background:
I recently upgraded from an earlier KubeOne version to master and my cluster-name contained dots (`.`).
However since #1641 this is no longer valid.

The output of this validation looked like

```bash
$ kubeone apply --manifest kubeone.yaml --credentials credentials.yaml --tfjson output.json --auto-approve --verbose

Error: failed to initialize State: failed to build state: failed to load cluster: unable to load a given KubeOneCluster object: unable to validate the given KubeOneCluster object: name: Invalid value: "": .name should be lowercase and can only contain alphanumeric characters and hyphens(-)
```

With this commit in place the output looks like this:

```bash
$ kubeone install --manifest kubeone.yaml --credentials credentials.yaml --tfjson output.json --verbose
Error: failed to initialize State: failed to build state: failed to load cluster: unable to load a given KubeOneCluster object: unable to validate the given KubeOneCluster object: name: Invalid value: "k8s.cedi.dev": .name should be lowercase and can only contain alphanumeric characters and hyphens(-)
```

Signed-off-by: Cedric Kienzler <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. dco-signoff: yes Denotes that all commits in the pull request have the valid DCO signoff message. lgtm Indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Avoid creating resources with uppercase names by validating the inputs
3 participants