Skip to content
This repository has been archived by the owner on Apr 28, 2020. It is now read-only.

Validate hostname in cloud-init settings #543

Merged
merged 1 commit into from
Aug 21, 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
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ Object {
"cloudInit": true,
"useCloudInitCustomScript": false,
},
"validation": null,
"value": null,
},
"imageURL": Object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
validateURL,
validateMemory,
validateUserTemplate,
validateCloudInitHostName,
} from '../../../../utils/validations';
import { objectMerge } from '../../../../utils/utils';
import { settingsValue } from '../../../../k8s/selectors';
Expand All @@ -22,6 +23,7 @@ import {
PROVISION_SOURCE_TYPE_KEY,
MEMORY_KEY,
USER_TEMPLATE_KEY,
HOST_NAME_KEY,
} from '../constants';
import { NAMESPACE_MUST_BE_SELECTED } from '../../../../utils/strings';
import { isProviderValid, validateProvider } from '../providers';
Expand Down Expand Up @@ -51,6 +53,7 @@ const validateResolver = {
[IMAGE_URL_KEY]: asVmSettingsValidator(validateURL),
[PROVIDER_KEY]: validateProviderDropdown,
[MEMORY_KEY]: asVmSettingsValidator(validateMemory),
[HOST_NAME_KEY]: asVmSettingsValidator(validateCloudInitHostName),
};

export const validateVmSettings = (vmSettings, additionalResources) => {
Expand Down
5 changes: 5 additions & 0 deletions src/utils/validations.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,11 @@ export const validateVmLikeEntityName = (value, vmSettings, props) => {
);
};

export const validateCloudInitHostName = value => {
const dnsValidation = validateDNS1123SubdomainValue(value);
return dnsValidation && dnsValidation.isEmptyError ? null : dnsValidation;
};

export const validateUserTemplate = (userTemplateKey, vmSettings, props) => {
const userTemplateName = get(vmSettings, [userTemplateKey, 'value']);
const userTemplate =
Expand Down