Enable possibility of creating pending locations
This commit is contained in:
@@ -17,6 +17,9 @@
|
||||
export type LocationSpec = {
|
||||
type: string;
|
||||
target: string;
|
||||
// When using repo importer plugin, leocation is being created before the component yaml file is merged to the main branch.
|
||||
// This flag is then set to disable validation that prevents creation of location if target file does not yet exist.
|
||||
pendingLocation?: true;
|
||||
};
|
||||
|
||||
export type Location = {
|
||||
|
||||
@@ -21,6 +21,7 @@ export const locationSpecSchema = yup
|
||||
.object<LocationSpec>({
|
||||
type: yup.string().required(),
|
||||
target: yup.string().required(),
|
||||
pendingLocation: yup.bool().oneOf([true]),
|
||||
})
|
||||
.noUnknown();
|
||||
|
||||
|
||||
@@ -79,7 +79,7 @@ export class HigherOrderOperations implements HigherOrderOperation {
|
||||
|
||||
// Read the location fully, bailing on any errors
|
||||
const readerOutput = await this.locationReader.read(spec);
|
||||
if (readerOutput.errors.length) {
|
||||
if (!spec.pendingLocation && readerOutput.errors.length) {
|
||||
const item = readerOutput.errors[0];
|
||||
throw new InputError(
|
||||
`Failed to read location ${item.location.type}:${item.location.target}, ${item.error}`,
|
||||
|
||||
@@ -109,8 +109,12 @@ export class CatalogClient implements CatalogApi {
|
||||
|
||||
const { location, entities } = await response.json();
|
||||
|
||||
if (!location || entities.length === 0)
|
||||
throw new Error(`Location wasn't added: ${target}`);
|
||||
if (!location) throw new Error(`Location wasn't added: ${target}`);
|
||||
|
||||
if (entities.length === 0)
|
||||
throw new Error(
|
||||
`Location was added but has no entities specified yet: ${target}`,
|
||||
);
|
||||
|
||||
return {
|
||||
location,
|
||||
|
||||
Reference in New Issue
Block a user