Skip to content
Open
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
9 changes: 4 additions & 5 deletions libs/i18n/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,7 @@
"Provide a valid container image reference": "Provide a valid container image reference",
"Application image": "Application image",
"Select a type": "Select a type",
"URI": "URI",
"Artifact URI": "Artifact URI",
"OCI reference": "OCI reference",
"e.g. https://example.com/image.qcow2": "e.g. https://example.com/image.qcow2",
"Artifact name": "Artifact name",
"Optional display name": "Optional display name",
Expand Down Expand Up @@ -286,13 +285,14 @@
"Channel names must be valid DNS subdomain names (lowercase alphanumeric, hyphens, dots). Invalid: {{ channels }}": "Channel names must be valid DNS subdomain names (lowercase alphanumeric, hyphens, dots). Invalid: {{ channels }}",
"Deprecation message is required": "Deprecation message is required",
"At least one version is required": "At least one version is required",
"Container image URI is required": "Container image URI is required",
"URI must not include a tag (\":\") or digest (\"@\"). Specify those in the version fields.": "URI must not include a tag (\":\") or digest (\"@\"). Specify those in the version fields.",
"Must not include a tag (\":\") or digest (\"@\"). Specify those in the version fields.": "Must not include a tag (\":\") or digest (\"@\"). Specify those in the version fields.",
"Catalog is required": "Catalog is required",
"Must be a valid URL or data URI": "Must be a valid URL or data URI",
"Type is required": "Type is required",
"Container image reference is required": "Container image reference is required",
"Invalid artifact type": "Invalid artifact type",
"Each artifact type can only be used once": "Each artifact type can only be used once",
"OCI reference is required": "OCI reference is required",
"At least one artifact is required": "At least one artifact is required",
"Select {{ name }}": "Select {{ name }}",
"Provided by {{provider}}": "Provided by {{provider}}",
Expand Down Expand Up @@ -784,7 +784,6 @@
"Select an application type": "Select an application type",
"Definition source": "Definition source",
"Configuration Sources": "Configuration Sources",
"OCI reference": "OCI reference",
"Pull definitions from container registry (reusable, versioned).": "Pull definitions from container registry (reusable, versioned).",
"Inline": "Inline",
"Define application files directly in this interface (custom, one-off).": "Define application files directly in this interface (custom, one-off).",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,10 @@ const TypeConfigStep = ({ isEdit, isReadOnly }: { isEdit?: boolean; isReadOnly?:
isDisabled={isReadOnly}
/>
</FormGroup>
<FormGroup label={t('URI')} isRequired>
<FormGroup label={t('OCI reference')} isRequired>
<TextField
name={`artifacts.${index}.uri`}
aria-label={t('Artifact URI')}
aria-label={t('OCI reference')}
isRequired
isDisabled={isReadOnly}
placeholder={t('e.g. https://example.com/image.qcow2', { nsSeparator: '|' })}
Comment thread
celdrake marked this conversation as resolved.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -513,20 +513,22 @@ const versionsSchema = (t: TFunction, configurable: boolean, isApp: boolean) =>
.min(1, t('At least one version is required'));
});

const artifactURISchema = (t: TFunction) =>
const uriHasNoTagOrDigest = (value: string | undefined) => {
if (!value) {
return true;
}
const path = value.replace(/^[a-z]+:\/\//, '');
const imageName = path.includes('/') ? path.substring(path.lastIndexOf('/') + 1) : path;
return !imageName.includes(':') && !imageName.includes('@');
};
Comment thread
celdrake marked this conversation as resolved.

const imageReferenceWithoutVersionSchema = (t: TFunction, requiredMessage: string) =>
Yup.string()
.required(t('Container image URI is required'))
.required(requiredMessage)
.test(
'no-tag-or-digest',
t('URI must not include a tag (":") or digest ("@"). Specify those in the version fields.'),
(value) => {
if (!value) {
return true;
}
const path = value.replace(/^[a-z]+:\/\//, '');
const imageName = path.includes('/') ? path.substring(path.lastIndexOf('/') + 1) : path;
return !imageName.includes(':') && !imageName.includes('@');
},
t('Must not include a tag (":") or digest ("@"). Specify those in the version fields.'),
uriHasNoTagOrDigest,
Comment thread
celdrake marked this conversation as resolved.
);

export const getValidationSchema = (t: TFunction) =>
Expand All @@ -543,7 +545,7 @@ export const getValidationSchema = (t: TFunction) =>
type: Yup.string().oneOf(Object.values(CatalogItemType)).required(t('Type is required')),
containerUri: Yup.string().when('type', {
is: (type: string) => appTypeIds.includes(type as CatalogItemType),
then: () => artifactURISchema(t),
then: () => imageReferenceWithoutVersionSchema(t, t('Container image reference is required')),
otherwise: () => Yup.string(),
}),
artifacts: Yup.mixed().when('type', {
Expand Down Expand Up @@ -572,7 +574,7 @@ export const getValidationSchema = (t: TFunction) =>
return !duplicateTypes.has(value);
}),
name: Yup.string(),
uri: artifactURISchema(t),
uri: imageReferenceWithoutVersionSchema(t, t('OCI reference is required')),
}),
)
.min(1, t('At least one artifact is required'));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ export const RepositoryForm = ({
<FormGroup label={t('Image name')} isRequired>
<TextField
name={`ociConfig.baseImages.${index}.imageName`}
aria-label={t('Artifact URI')}
aria-label={t('Image name')}
isRequired
/>
</FormGroup>
Expand Down
Loading