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

[FIX] Made version field required for custom provider #72

Merged
merged 1 commit into from
Jul 22, 2024
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 @@ -117,7 +117,7 @@ export default (Vue as VueConstructor<
fvExtraRules() {
return {
name: providerNameValidator(this.$store.getters['i18n/t']),
version: providerVersionValidator(this.$store.getters['i18n/t']),
version: providerVersionValidator(this.$store.getters['i18n/t'], this.isCustom),
url: urlValidator(this.$store.getters['i18n/t'])
};
},
Expand Down Expand Up @@ -213,9 +213,7 @@ export default (Vue as VueConstructor<
this.value.spec.credentials = null;
}
try {
await this.save();

return this.done();
await this.save(btnCb, null);
} catch (err) {
this.errors.push(err);
btnCb(false);
Expand Down Expand Up @@ -297,6 +295,7 @@ export default (Vue as VueConstructor<
label-key="capi.provider.version.label"
placeholder-key="capi.provider.version.placeholder"
:rules="fvGetAndReportPathRules('spec.version')"
required
/>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion pkg/capi/l10n/en-us.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ validation:
pattern: '"{key}" must match the pattern <code>{pattern}</code>.'
stringFormat: '"{key}" must be a valid {format}.'
uniqueItems: '"{key}" may not contain duplicate elements.'
version: Version format must match format for this provisioner.
version: "Version format should be in the semver format prefixed with 'v'. Example: v1.9.3"
name: Name is required and must consist of lower case alphanumeric characters, '-' or '.', and must start and end with an alphanumeric character.
port: Port value must be a number.
url: '"Value" must be a valid URL.'
Expand Down
4 changes: 2 additions & 2 deletions pkg/capi/util/validators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,8 @@ export const urlValidator = function(t: Translation): Validator {
return (val: string) => val && !val.match(/^https?:\/\/(.*)$/) ? t('validation.url') : undefined;
};

export const providerVersionValidator = function(t: Translation): Validator {
return (val: string) => val && !val.match(/^(\.*\w*)*$/) ? t('validation.version') : undefined;
export const providerVersionValidator = function(t: Translation, required: boolean): Validator {
return (val: string) => (required && !val) || (val && !val.match(/^v(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/)) ? t('validation.version') : undefined;
};

export const providerNameValidator = function(t: Translation): Validator {
Expand Down