-
Notifications
You must be signed in to change notification settings - Fork 53
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
Wizard: Add Hostname functionality (HMS-5175) #2672
Conversation
/jira-epic HMS-5164 |
Codecov ReportAttention: Patch coverage is
@@ Coverage Diff @@
## main #2672 +/- ##
==========================================
+ Coverage 85.13% 85.20% +0.07%
==========================================
Files 175 175
Lines 20157 20220 +63
Branches 1955 1970 +15
==========================================
+ Hits 17161 17229 +68
+ Misses 2974 2969 -5
Partials 22 22
... and 1 file with indirect coverage changes Continue to review full report in Codecov by Sentry.
|
What am I doing wrong with the epic? 🤔 |
/jira-epic HMS-5164 |
/retest |
This adds a validated hostname input and new tests.
a0e41e4
to
095c55e
Compare
if (!isHostnameValid(hostname)) { | ||
return { | ||
errors: { | ||
hostname: 'Invalid hostname', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's provide some additional guidance to users about what constitutes a valid hostname.
Had to look this up myself, of course. Run man 5 hostname
and you get this:
HOSTNAME(5) hostname HOSTNAME(5)
NAME
hostname - Local hostname configuration file
SYNOPSIS
/etc/hostname
DESCRIPTION
The /etc/hostname file configures the name of the local system. Unless overridden as described in the next section, systemd(1) will set this hostname during boot using
the sethostname(2) system call.
The file should contain a single newline-terminated hostname string. Comments (lines starting with a "#") are ignored. The hostname should be composed of up to 64 7-bit
ASCII lower-case alphanumeric characters or hyphens forming a valid DNS domain name. It is recommended that this name contains only a single label, i.e. without any
dots. Invalid characters will be filtered out in an attempt to make the name valid, but obviously it is recommended to use a valid name and not rely on this filtering.
You may use hostnamectl(1) to change the value of this file during runtime from the command line. Use systemd-firstboot(1) to initialize it on mounted (but not booted)
system images.
So I would suggest the error say: "Invalid hostname. The hostname should be composed of up to 64 7-bit
ASCII lower-case alphanumeric characters or hyphens forming a valid DNS domain name. It is recommended that this name contains only a single label, i.e. without any
dots."
|
||
export const isHostnameValid = (hostname: string) => { | ||
if (hostname !== '') { | ||
return /^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9-]*[A-Za-z0-9])$/.test( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this expression fits what I'm proposing in my other comment. We just need to also set the max length to 64.
I added a commit with my suggested changes, hope you don't mind. Just want to keep the review cycle to a minimum so we can ship these before end of Q4. |
Hostname validation rules can be found in the hostname man pages (`man 5 hostname`). This commit tweaks the hostname validator function so it is in line with these guidelines by limiting the length to 64 characters and also updates the error message for invalid hostnames to provide users with some additional guidance/context when an invalid hostname is provided.
c0a05e2
to
1e7c164
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🫖
Unit tests failing in pr_check but passing in dev-check. Admin merging. 18:51:03 FAIL src/test/Components/CreateImageWizard/steps/ImageOutput/ImageOutput.test.tsx > Step Image output > revisit step button on Review works**** |
This adds a validated hostname input and new tests.
JIRA: HMS-5175