catalog-model: Prefix annotations with ANNOTATION_
Signed-off-by: Johan Haals <johan.haals@gmail.com>
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
---
|
||||
'@backstage/catalog-client': patch
|
||||
'@backstage/plugin-catalog': patch
|
||||
'@backstage/plugin-catalog-backend': patch
|
||||
'@backstage/plugin-catalog-backend-module-ldap': patch
|
||||
'@backstage/plugin-catalog-backend-module-msgraph': patch
|
||||
'@backstage/plugin-catalog-react': patch
|
||||
'@backstage/plugin-github-deployments': patch
|
||||
'@backstage/plugin-scaffolder-backend': patch
|
||||
'@backstage/plugin-todo': patch
|
||||
'@backstage/plugin-todo-backend': patch
|
||||
---
|
||||
|
||||
Replaces use of deprecated catalog-model constants.
|
||||
@@ -0,0 +1,6 @@
|
||||
---
|
||||
'@backstage/catalog-model': patch
|
||||
---
|
||||
|
||||
Deprecates `EDIT_URL_ANNOTATION`, `LOCATION_ANNOTATION`, `ORIGIN_LOCATION_ANNOTATION`, `SOURCE_LOCATION_ANNOTATION`, `VIEW_URL_ANNOTATION`
|
||||
and replaces these constants all prefixed with ANNOTATION_ `ANNOTATION_EDIT_URL`, `ANNOTATION_LOCATION`, `ANNOTATION_ORIGIN_LOCATION`, `ANNOTATION_SOURCE_LOCATION`, `ANNOTATION_VIEW_URL`
|
||||
@@ -15,10 +15,10 @@
|
||||
*/
|
||||
|
||||
import {
|
||||
ANNOTATION_LOCATION,
|
||||
ANNOTATION_ORIGIN_LOCATION,
|
||||
Entity,
|
||||
EntityName,
|
||||
LOCATION_ANNOTATION,
|
||||
ORIGIN_LOCATION_ANNOTATION,
|
||||
parseEntityRef,
|
||||
stringifyEntityRef,
|
||||
stringifyLocationRef,
|
||||
@@ -253,7 +253,7 @@ export class CatalogClient implements CatalogApi {
|
||||
options?: CatalogRequestOptions,
|
||||
): Promise<Location | undefined> {
|
||||
const locationCompound =
|
||||
entity.metadata.annotations?.[ORIGIN_LOCATION_ANNOTATION];
|
||||
entity.metadata.annotations?.[ANNOTATION_ORIGIN_LOCATION];
|
||||
if (!locationCompound) {
|
||||
return undefined;
|
||||
}
|
||||
@@ -274,7 +274,7 @@ export class CatalogClient implements CatalogApi {
|
||||
entity: Entity,
|
||||
options?: CatalogRequestOptions,
|
||||
): Promise<Location | undefined> {
|
||||
const locationCompound = entity.metadata.annotations?.[LOCATION_ANNOTATION];
|
||||
const locationCompound = entity.metadata.annotations?.[ANNOTATION_LOCATION];
|
||||
if (!locationCompound) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
@@ -13,6 +13,22 @@ export interface AlphaEntity extends Entity {
|
||||
status?: EntityStatus;
|
||||
}
|
||||
|
||||
// @public
|
||||
export const ANNOTATION_EDIT_URL = 'backstage.io/edit-url';
|
||||
|
||||
// @public
|
||||
export const ANNOTATION_LOCATION = 'backstage.io/managed-by-location';
|
||||
|
||||
// @public
|
||||
export const ANNOTATION_ORIGIN_LOCATION =
|
||||
'backstage.io/managed-by-origin-location';
|
||||
|
||||
// @public
|
||||
export const ANNOTATION_SOURCE_LOCATION = 'backstage.io/source-location';
|
||||
|
||||
// @public
|
||||
export const ANNOTATION_VIEW_URL = 'backstage.io/view-url';
|
||||
|
||||
// @public
|
||||
interface ApiEntityV1alpha1 extends Entity {
|
||||
// (undocumented)
|
||||
@@ -105,7 +121,7 @@ export { DomainEntityV1alpha1 };
|
||||
// @public
|
||||
export const domainEntityV1alpha1Validator: KindValidator;
|
||||
|
||||
// @public
|
||||
// @public @deprecated
|
||||
export const EDIT_URL_ANNOTATION = 'backstage.io/edit-url';
|
||||
|
||||
// @public
|
||||
@@ -325,7 +341,7 @@ type Location_2 = {
|
||||
} & LocationSpec;
|
||||
export { Location_2 as Location };
|
||||
|
||||
// @public
|
||||
// @public @deprecated
|
||||
export const LOCATION_ANNOTATION = 'backstage.io/managed-by-location';
|
||||
|
||||
// @public
|
||||
@@ -365,7 +381,7 @@ export class NoForeignRootFieldsEntityPolicy implements EntityPolicy {
|
||||
enforce(entity: Entity): Promise<Entity>;
|
||||
}
|
||||
|
||||
// @public
|
||||
// @public @deprecated
|
||||
export const ORIGIN_LOCATION_ANNOTATION =
|
||||
'backstage.io/managed-by-origin-location';
|
||||
|
||||
@@ -489,7 +505,7 @@ export class SchemaValidEntityPolicy implements EntityPolicy {
|
||||
enforce(entity: Entity): Promise<Entity>;
|
||||
}
|
||||
|
||||
// @public
|
||||
// @public @deprecated
|
||||
export const SOURCE_LOCATION_ANNOTATION = 'backstage.io/source-location';
|
||||
|
||||
// @public
|
||||
@@ -595,6 +611,6 @@ export type Validators = {
|
||||
isValidTag(value: unknown): boolean;
|
||||
};
|
||||
|
||||
// @public
|
||||
// @public @deprecated
|
||||
export const VIEW_URL_ANNOTATION = 'backstage.io/view-url';
|
||||
```
|
||||
|
||||
@@ -37,6 +37,7 @@ export const ENTITY_META_GENERATED_FIELDS = [
|
||||
* Annotation for linking to entity page from catalog pages.
|
||||
*
|
||||
* @public
|
||||
* @deprecated use {@link ANNOTATION_VIEW_URL} instead.
|
||||
*/
|
||||
export const VIEW_URL_ANNOTATION = 'backstage.io/view-url';
|
||||
|
||||
@@ -44,5 +45,20 @@ export const VIEW_URL_ANNOTATION = 'backstage.io/view-url';
|
||||
* Annotation for linking to entity edit page from catalog pages.
|
||||
*
|
||||
* @public
|
||||
* @deprecated use {@link ANNOTATION_EDIT_URL} instead.
|
||||
*/
|
||||
export const EDIT_URL_ANNOTATION = 'backstage.io/edit-url';
|
||||
|
||||
/**
|
||||
* Annotation for linking to entity page from catalog pages.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export const ANNOTATION_VIEW_URL = 'backstage.io/view-url';
|
||||
|
||||
/**
|
||||
* Annotation for linking to entity edit page from catalog pages.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export const ANNOTATION_EDIT_URL = 'backstage.io/edit-url';
|
||||
|
||||
@@ -19,6 +19,8 @@ export {
|
||||
ENTITY_DEFAULT_NAMESPACE,
|
||||
ENTITY_META_GENERATED_FIELDS,
|
||||
VIEW_URL_ANNOTATION,
|
||||
ANNOTATION_EDIT_URL,
|
||||
ANNOTATION_VIEW_URL,
|
||||
} from './constants';
|
||||
export type {
|
||||
AlphaEntity,
|
||||
|
||||
@@ -17,17 +17,41 @@
|
||||
/**
|
||||
* Constant storing location annotation.
|
||||
*
|
||||
* @public */
|
||||
* @public
|
||||
* @deprecated use {@link ANNOTATION_LOCATION} instead.
|
||||
* */
|
||||
export const LOCATION_ANNOTATION = 'backstage.io/managed-by-location';
|
||||
/**
|
||||
* Constant storing origin location annotation
|
||||
*
|
||||
* @public */
|
||||
* @public
|
||||
* @deprecated use {@link ANNOTATION_ORIGIN_LOCATION} instead.
|
||||
*/
|
||||
export const ORIGIN_LOCATION_ANNOTATION =
|
||||
'backstage.io/managed-by-origin-location';
|
||||
|
||||
/**
|
||||
* Contant storing source location annotation
|
||||
*
|
||||
* @public */
|
||||
* @public
|
||||
* @deprecated use {@link ANNOTATION_SOURCE_LOCATION} instead.
|
||||
* */
|
||||
export const SOURCE_LOCATION_ANNOTATION = 'backstage.io/source-location';
|
||||
|
||||
/**
|
||||
* Constant storing location annotation.
|
||||
*
|
||||
* @public */
|
||||
export const ANNOTATION_LOCATION = 'backstage.io/managed-by-location';
|
||||
/**
|
||||
* Constant storing origin location annotation
|
||||
*
|
||||
* @public */
|
||||
export const ANNOTATION_ORIGIN_LOCATION =
|
||||
'backstage.io/managed-by-origin-location';
|
||||
|
||||
/**
|
||||
* Contant storing source location annotation
|
||||
*
|
||||
* @public */
|
||||
export const ANNOTATION_SOURCE_LOCATION = 'backstage.io/source-location';
|
||||
|
||||
@@ -14,8 +14,9 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { ANNOTATION_SOURCE_LOCATION } from '.';
|
||||
import { Entity, stringifyEntityRef } from '../entity';
|
||||
import { LOCATION_ANNOTATION, SOURCE_LOCATION_ANNOTATION } from './annotation';
|
||||
import { ANNOTATION_LOCATION } from './annotation';
|
||||
|
||||
/**
|
||||
* Parses a string form location reference.
|
||||
@@ -142,8 +143,8 @@ export function getEntitySourceLocation(entity: Entity): {
|
||||
target: string;
|
||||
} {
|
||||
const locationRef =
|
||||
entity.metadata?.annotations?.[SOURCE_LOCATION_ANNOTATION] ??
|
||||
entity.metadata?.annotations?.[LOCATION_ANNOTATION];
|
||||
entity.metadata?.annotations?.[ANNOTATION_SOURCE_LOCATION] ??
|
||||
entity.metadata?.annotations?.[ANNOTATION_LOCATION];
|
||||
|
||||
if (!locationRef) {
|
||||
throw new Error(
|
||||
|
||||
@@ -15,6 +15,9 @@
|
||||
*/
|
||||
|
||||
export {
|
||||
ANNOTATION_LOCATION,
|
||||
ANNOTATION_ORIGIN_LOCATION,
|
||||
ANNOTATION_SOURCE_LOCATION,
|
||||
LOCATION_ANNOTATION,
|
||||
ORIGIN_LOCATION_ANNOTATION,
|
||||
SOURCE_LOCATION_ANNOTATION,
|
||||
|
||||
@@ -15,9 +15,9 @@
|
||||
*/
|
||||
|
||||
import {
|
||||
ANNOTATION_LOCATION,
|
||||
ANNOTATION_ORIGIN_LOCATION,
|
||||
Entity,
|
||||
LOCATION_ANNOTATION,
|
||||
ORIGIN_LOCATION_ANNOTATION,
|
||||
} from '@backstage/catalog-model';
|
||||
import { Config } from '@backstage/config';
|
||||
import {
|
||||
@@ -207,8 +207,8 @@ function withLocations(providerId: string, entity: Entity): Entity {
|
||||
{
|
||||
metadata: {
|
||||
annotations: {
|
||||
[LOCATION_ANNOTATION]: location,
|
||||
[ORIGIN_LOCATION_ANNOTATION]: location,
|
||||
[ANNOTATION_LOCATION]: location,
|
||||
[ANNOTATION_ORIGIN_LOCATION]: location,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
+4
-4
@@ -15,9 +15,9 @@
|
||||
*/
|
||||
import { getVoidLogger } from '@backstage/backend-common';
|
||||
import {
|
||||
ANNOTATION_LOCATION,
|
||||
ANNOTATION_ORIGIN_LOCATION,
|
||||
GroupEntity,
|
||||
LOCATION_ANNOTATION,
|
||||
ORIGIN_LOCATION_ANNOTATION,
|
||||
UserEntity,
|
||||
} from '@backstage/catalog-model';
|
||||
import { EntityProviderConnection } from '@backstage/plugin-catalog-backend';
|
||||
@@ -162,8 +162,8 @@ describe('withLocations', () => {
|
||||
name: 'u1',
|
||||
annotations: {
|
||||
[MICROSOFT_GRAPH_USER_ID_ANNOTATION]: 'uid',
|
||||
[LOCATION_ANNOTATION]: 'msgraph:test/uid',
|
||||
[ORIGIN_LOCATION_ANNOTATION]: 'msgraph:test/uid',
|
||||
[ANNOTATION_LOCATION]: 'msgraph:test/uid',
|
||||
[ANNOTATION_ORIGIN_LOCATION]: 'msgraph:test/uid',
|
||||
},
|
||||
},
|
||||
spec: {
|
||||
|
||||
+4
-4
@@ -15,9 +15,9 @@
|
||||
*/
|
||||
|
||||
import {
|
||||
ANNOTATION_LOCATION,
|
||||
ANNOTATION_ORIGIN_LOCATION,
|
||||
Entity,
|
||||
LOCATION_ANNOTATION,
|
||||
ORIGIN_LOCATION_ANNOTATION,
|
||||
} from '@backstage/catalog-model';
|
||||
import { Config } from '@backstage/config';
|
||||
import {
|
||||
@@ -180,8 +180,8 @@ export function withLocations(providerId: string, entity: Entity): Entity {
|
||||
{
|
||||
metadata: {
|
||||
annotations: {
|
||||
[LOCATION_ANNOTATION]: location,
|
||||
[ORIGIN_LOCATION_ANNOTATION]: location,
|
||||
[ANNOTATION_LOCATION]: location,
|
||||
[ANNOTATION_ORIGIN_LOCATION]: location,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
+10
-10
@@ -15,14 +15,14 @@
|
||||
*/
|
||||
|
||||
import {
|
||||
EDIT_URL_ANNOTATION,
|
||||
ANNOTATION_EDIT_URL,
|
||||
ANNOTATION_LOCATION,
|
||||
ANNOTATION_ORIGIN_LOCATION,
|
||||
ANNOTATION_SOURCE_LOCATION,
|
||||
ANNOTATION_VIEW_URL,
|
||||
Entity,
|
||||
LocationSpec,
|
||||
LOCATION_ANNOTATION,
|
||||
ORIGIN_LOCATION_ANNOTATION,
|
||||
SOURCE_LOCATION_ANNOTATION,
|
||||
stringifyLocationRef,
|
||||
VIEW_URL_ANNOTATION,
|
||||
} from '@backstage/catalog-model';
|
||||
import { ScmIntegrationRegistry } from '@backstage/integration';
|
||||
import { identity, merge, pickBy } from 'lodash';
|
||||
@@ -70,12 +70,12 @@ export class AnnotateLocationEntityProcessor implements CatalogProcessor {
|
||||
metadata: {
|
||||
annotations: pickBy(
|
||||
{
|
||||
[LOCATION_ANNOTATION]: stringifyLocationRef(location),
|
||||
[ORIGIN_LOCATION_ANNOTATION]:
|
||||
[ANNOTATION_LOCATION]: stringifyLocationRef(location),
|
||||
[ANNOTATION_ORIGIN_LOCATION]:
|
||||
stringifyLocationRef(originLocation),
|
||||
[VIEW_URL_ANNOTATION]: viewUrl,
|
||||
[EDIT_URL_ANNOTATION]: editUrl,
|
||||
[SOURCE_LOCATION_ANNOTATION]: sourceLocation,
|
||||
[ANNOTATION_VIEW_URL]: viewUrl,
|
||||
[ANNOTATION_EDIT_URL]: editUrl,
|
||||
[ANNOTATION_SOURCE_LOCATION]: sourceLocation,
|
||||
},
|
||||
identity,
|
||||
),
|
||||
|
||||
@@ -14,9 +14,9 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
import {
|
||||
ANNOTATION_LOCATION,
|
||||
ANNOTATION_ORIGIN_LOCATION,
|
||||
Entity,
|
||||
LOCATION_ANNOTATION,
|
||||
ORIGIN_LOCATION_ANNOTATION,
|
||||
} from '@backstage/catalog-model';
|
||||
import { Config } from '@backstage/config';
|
||||
import {
|
||||
@@ -178,8 +178,8 @@ export function withLocations(
|
||||
{
|
||||
metadata: {
|
||||
annotations: {
|
||||
[LOCATION_ANNOTATION]: location,
|
||||
[ORIGIN_LOCATION_ANNOTATION]: location,
|
||||
[ANNOTATION_LOCATION]: location,
|
||||
[ANNOTATION_ORIGIN_LOCATION]: location,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
@@ -16,12 +16,12 @@
|
||||
|
||||
import { getVoidLogger } from '@backstage/backend-common';
|
||||
import {
|
||||
ANNOTATION_LOCATION,
|
||||
ANNOTATION_ORIGIN_LOCATION,
|
||||
Entity,
|
||||
EntityPolicies,
|
||||
LocationEntity,
|
||||
LocationSpec,
|
||||
LOCATION_ANNOTATION,
|
||||
ORIGIN_LOCATION_ANNOTATION,
|
||||
} from '@backstage/catalog-model';
|
||||
import { ScmIntegrations } from '@backstage/integration';
|
||||
import {
|
||||
@@ -82,8 +82,8 @@ describe('DefaultCatalogProcessingOrchestrator', () => {
|
||||
metadata: {
|
||||
name: 'my-foo-bar',
|
||||
annotations: {
|
||||
[LOCATION_ANNOTATION]: 'url:./here',
|
||||
[ORIGIN_LOCATION_ANNOTATION]: 'url:./there',
|
||||
[ANNOTATION_LOCATION]: 'url:./here',
|
||||
[ANNOTATION_ORIGIN_LOCATION]: 'url:./there',
|
||||
},
|
||||
},
|
||||
};
|
||||
@@ -128,8 +128,8 @@ describe('DefaultCatalogProcessingOrchestrator', () => {
|
||||
metadata: {
|
||||
name: 'my-new-foo-bar',
|
||||
annotations: {
|
||||
[LOCATION_ANNOTATION]: 'url:./new-place',
|
||||
[ORIGIN_LOCATION_ANNOTATION]: 'url:./there',
|
||||
[ANNOTATION_LOCATION]: 'url:./new-place',
|
||||
[ANNOTATION_ORIGIN_LOCATION]: 'url:./there',
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -196,8 +196,8 @@ describe('DefaultCatalogProcessingOrchestrator', () => {
|
||||
metadata: {
|
||||
name: 'l',
|
||||
annotations: {
|
||||
[ORIGIN_LOCATION_ANNOTATION]: 'url:https://example.com/origin.yaml',
|
||||
[LOCATION_ANNOTATION]: 'url:https://example.com/origin.yaml',
|
||||
[ANNOTATION_ORIGIN_LOCATION]: 'url:https://example.com/origin.yaml',
|
||||
[ANNOTATION_LOCATION]: 'url:https://example.com/origin.yaml',
|
||||
},
|
||||
},
|
||||
spec: {
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
import {
|
||||
Entity,
|
||||
EntityRelationSpec,
|
||||
LOCATION_ANNOTATION,
|
||||
ORIGIN_LOCATION_ANNOTATION,
|
||||
ANNOTATION_LOCATION,
|
||||
ANNOTATION_ORIGIN_LOCATION,
|
||||
stringifyLocationRef,
|
||||
} from '@backstage/catalog-model';
|
||||
import { assertError } from '@backstage/errors';
|
||||
@@ -98,8 +98,8 @@ export class ProcessorOutputCollector {
|
||||
...entity.metadata,
|
||||
annotations: {
|
||||
...annotations,
|
||||
[ORIGIN_LOCATION_ANNOTATION]: originLocation,
|
||||
[LOCATION_ANNOTATION]: location,
|
||||
[ANNOTATION_ORIGIN_LOCATION]: originLocation,
|
||||
[ANNOTATION_LOCATION]: location,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
@@ -20,8 +20,8 @@ import {
|
||||
entitySchemaValidator,
|
||||
LocationEntity,
|
||||
LocationSpec,
|
||||
LOCATION_ANNOTATION,
|
||||
ORIGIN_LOCATION_ANNOTATION,
|
||||
ANNOTATION_LOCATION,
|
||||
ANNOTATION_ORIGIN_LOCATION,
|
||||
stringifyEntityRef,
|
||||
} from '@backstage/catalog-model';
|
||||
import { JsonObject, JsonValue } from '@backstage/types';
|
||||
@@ -34,7 +34,7 @@ export function isLocationEntity(entity: Entity): entity is LocationEntity {
|
||||
}
|
||||
|
||||
export function getEntityLocationRef(entity: Entity): string {
|
||||
const ref = entity.metadata.annotations?.[LOCATION_ANNOTATION];
|
||||
const ref = entity.metadata.annotations?.[ANNOTATION_LOCATION];
|
||||
if (!ref) {
|
||||
const entityRef = stringifyEntityRef(entity);
|
||||
throw new InputError(`Entity '${entityRef}' does not have a location`);
|
||||
@@ -43,7 +43,7 @@ export function getEntityLocationRef(entity: Entity): string {
|
||||
}
|
||||
|
||||
export function getEntityOriginLocationRef(entity: Entity): string {
|
||||
const ref = entity.metadata.annotations?.[ORIGIN_LOCATION_ANNOTATION];
|
||||
const ref = entity.metadata.annotations?.[ANNOTATION_ORIGIN_LOCATION];
|
||||
if (!ref) {
|
||||
const entityRef = stringifyEntityRef(entity);
|
||||
throw new InputError(
|
||||
|
||||
@@ -16,8 +16,8 @@
|
||||
import {
|
||||
Entity,
|
||||
LocationSpec,
|
||||
LOCATION_ANNOTATION,
|
||||
ORIGIN_LOCATION_ANNOTATION,
|
||||
ANNOTATION_LOCATION,
|
||||
ANNOTATION_ORIGIN_LOCATION,
|
||||
stringifyEntityRef,
|
||||
} from '@backstage/catalog-model';
|
||||
import { Location } from '@backstage/catalog-client';
|
||||
@@ -112,8 +112,8 @@ export class DefaultLocationService implements LocationService {
|
||||
}),
|
||||
namespace: 'default',
|
||||
annotations: {
|
||||
[LOCATION_ANNOTATION]: `${spec.type}:${spec.target}`,
|
||||
[ORIGIN_LOCATION_ANNOTATION]: `${spec.type}:${spec.target}`,
|
||||
[ANNOTATION_LOCATION]: `${spec.type}:${spec.target}`,
|
||||
[ANNOTATION_ORIGIN_LOCATION]: `${spec.type}:${spec.target}`,
|
||||
},
|
||||
},
|
||||
spec: {
|
||||
|
||||
@@ -18,8 +18,8 @@ import {
|
||||
Entity,
|
||||
LocationEntityV1alpha1,
|
||||
LocationSpec,
|
||||
LOCATION_ANNOTATION,
|
||||
ORIGIN_LOCATION_ANNOTATION,
|
||||
ANNOTATION_LOCATION,
|
||||
ANNOTATION_ORIGIN_LOCATION,
|
||||
stringifyEntityRef,
|
||||
stringifyLocationRef,
|
||||
} from '@backstage/catalog-model';
|
||||
@@ -40,7 +40,7 @@ export function locationSpecToLocationEntity(
|
||||
let originLocation: string;
|
||||
if (parentEntity) {
|
||||
const maybeOwnLocation =
|
||||
parentEntity.metadata.annotations?.[LOCATION_ANNOTATION];
|
||||
parentEntity.metadata.annotations?.[ANNOTATION_LOCATION];
|
||||
if (!maybeOwnLocation) {
|
||||
throw new Error(
|
||||
`Parent entity '${stringifyEntityRef(
|
||||
@@ -52,7 +52,7 @@ export function locationSpecToLocationEntity(
|
||||
}
|
||||
ownLocation = maybeOwnLocation;
|
||||
const maybeOriginLocation =
|
||||
parentEntity.metadata.annotations?.[ORIGIN_LOCATION_ANNOTATION];
|
||||
parentEntity.metadata.annotations?.[ANNOTATION_ORIGIN_LOCATION];
|
||||
if (!maybeOriginLocation) {
|
||||
throw new Error(
|
||||
`Parent entity '${stringifyEntityRef(
|
||||
@@ -74,8 +74,8 @@ export function locationSpecToLocationEntity(
|
||||
metadata: {
|
||||
name: locationSpecToMetadataName(location),
|
||||
annotations: {
|
||||
[LOCATION_ANNOTATION]: ownLocation,
|
||||
[ORIGIN_LOCATION_ANNOTATION]: originLocation,
|
||||
[ANNOTATION_LOCATION]: ownLocation,
|
||||
[ANNOTATION_ORIGIN_LOCATION]: originLocation,
|
||||
},
|
||||
},
|
||||
spec: {
|
||||
|
||||
+8
-8
@@ -16,8 +16,8 @@
|
||||
|
||||
import {
|
||||
Entity,
|
||||
LOCATION_ANNOTATION,
|
||||
ORIGIN_LOCATION_ANNOTATION,
|
||||
ANNOTATION_LOCATION,
|
||||
ANNOTATION_ORIGIN_LOCATION,
|
||||
stringifyEntityRef,
|
||||
} from '@backstage/catalog-model';
|
||||
import { Progress, ResponseErrorPanel } from '@backstage/core-components';
|
||||
@@ -53,8 +53,8 @@ function useColocated(entity: Entity): {
|
||||
} {
|
||||
const catalogApi = useApi(catalogApiRef);
|
||||
const currentEntityRef = stringifyEntityRef(entity);
|
||||
const location = entity.metadata.annotations?.[LOCATION_ANNOTATION];
|
||||
const origin = entity.metadata.annotations?.[ORIGIN_LOCATION_ANNOTATION];
|
||||
const location = entity.metadata.annotations?.[ANNOTATION_LOCATION];
|
||||
const origin = entity.metadata.annotations?.[ANNOTATION_ORIGIN_LOCATION];
|
||||
|
||||
const { loading, error, value } = useAsync(async () => {
|
||||
if (!location && !origin) {
|
||||
@@ -63,10 +63,10 @@ function useColocated(entity: Entity): {
|
||||
const response = await catalogApi.getEntities({
|
||||
filter: [
|
||||
...(location
|
||||
? [{ [`metadata.annotations.${LOCATION_ANNOTATION}`]: location }]
|
||||
? [{ [`metadata.annotations.${ANNOTATION_LOCATION}`]: location }]
|
||||
: []),
|
||||
...(origin
|
||||
? [{ [`metadata.annotations.${ORIGIN_LOCATION_ANNOTATION}`]: origin }]
|
||||
? [{ [`metadata.annotations.${ANNOTATION_ORIGIN_LOCATION}`]: origin }]
|
||||
: []),
|
||||
],
|
||||
});
|
||||
@@ -128,11 +128,11 @@ function Contents(props: { entity: Entity }) {
|
||||
}
|
||||
|
||||
const atLocation = colocatedEntities.filter(
|
||||
e => e.metadata.annotations?.[LOCATION_ANNOTATION] === location,
|
||||
e => e.metadata.annotations?.[ANNOTATION_LOCATION] === location,
|
||||
);
|
||||
const atOrigin = colocatedEntities.filter(
|
||||
e =>
|
||||
e.metadata.annotations?.[ORIGIN_LOCATION_ANNOTATION] === originLocation,
|
||||
e.metadata.annotations?.[ANNOTATION_ORIGIN_LOCATION] === originLocation,
|
||||
);
|
||||
|
||||
return (
|
||||
|
||||
+2
-2
@@ -19,7 +19,7 @@ jest.mock('./useUnregisterEntityDialogState');
|
||||
import userEvent from '@testing-library/user-event';
|
||||
import React from 'react';
|
||||
import { UnregisterEntityDialog } from './UnregisterEntityDialog';
|
||||
import { ORIGIN_LOCATION_ANNOTATION } from '@backstage/catalog-model';
|
||||
import { ANNOTATION_ORIGIN_LOCATION } from '@backstage/catalog-model';
|
||||
import { CatalogClient } from '@backstage/catalog-client';
|
||||
import { catalogApiRef } from '../../api';
|
||||
import { entityRouteRef } from '../../routes';
|
||||
@@ -55,7 +55,7 @@ describe('UnregisterEntityDialog', () => {
|
||||
name: 'n',
|
||||
namespace: 'ns',
|
||||
annotations: {
|
||||
[ORIGIN_LOCATION_ANNOTATION]: 'url:http://example.com',
|
||||
[ANNOTATION_ORIGIN_LOCATION]: 'url:http://example.com',
|
||||
},
|
||||
},
|
||||
spec: {},
|
||||
|
||||
+4
-4
@@ -14,8 +14,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { Entity, ORIGIN_LOCATION_ANNOTATION } from '@backstage/catalog-model';
|
||||
import { CatalogApi, Location } from '@backstage/catalog-client';
|
||||
import { Entity, ANNOTATION_ORIGIN_LOCATION } from '@backstage/catalog-model';
|
||||
import { catalogApiRef } from '../../api';
|
||||
import {
|
||||
act,
|
||||
@@ -79,7 +79,7 @@ describe('useUnregisterEntityDialogState', () => {
|
||||
name: 'n',
|
||||
namespace: 'ns',
|
||||
annotations: {
|
||||
[ORIGIN_LOCATION_ANNOTATION]: 'url:https://example.com',
|
||||
[ANNOTATION_ORIGIN_LOCATION]: 'url:https://example.com',
|
||||
},
|
||||
},
|
||||
spec: {},
|
||||
@@ -113,7 +113,7 @@ describe('useUnregisterEntityDialogState', () => {
|
||||
});
|
||||
|
||||
it('chooses the bootstrap path when necessary', async () => {
|
||||
entity.metadata.annotations![ORIGIN_LOCATION_ANNOTATION] =
|
||||
entity.metadata.annotations![ANNOTATION_ORIGIN_LOCATION] =
|
||||
'bootstrap:bootstrap';
|
||||
|
||||
let rendered: RenderHookResult<unknown, UseUnregisterEntityDialogState>;
|
||||
@@ -137,7 +137,7 @@ describe('useUnregisterEntityDialogState', () => {
|
||||
});
|
||||
|
||||
it('chooses only-delete when there was no location annotation', async () => {
|
||||
delete entity.metadata.annotations![ORIGIN_LOCATION_ANNOTATION];
|
||||
delete entity.metadata.annotations![ANNOTATION_ORIGIN_LOCATION];
|
||||
|
||||
let rendered: RenderHookResult<unknown, UseUnregisterEntityDialogState>;
|
||||
act(() => {
|
||||
|
||||
+3
-3
@@ -18,7 +18,7 @@ import {
|
||||
Entity,
|
||||
EntityName,
|
||||
getEntityName,
|
||||
ORIGIN_LOCATION_ANNOTATION,
|
||||
ANNOTATION_ORIGIN_LOCATION,
|
||||
} from '@backstage/catalog-model';
|
||||
import { catalogApiRef } from '../../api';
|
||||
import { useCallback } from 'react';
|
||||
@@ -60,7 +60,7 @@ export function useUnregisterEntityDialogState(
|
||||
entity: Entity,
|
||||
): UseUnregisterEntityDialogState {
|
||||
const catalogApi = useApi(catalogApiRef);
|
||||
const locationRef = entity.metadata.annotations?.[ORIGIN_LOCATION_ANNOTATION];
|
||||
const locationRef = entity.metadata.annotations?.[ANNOTATION_ORIGIN_LOCATION];
|
||||
const uid = entity.metadata.uid;
|
||||
const isBootstrap = locationRef === 'bootstrap:bootstrap';
|
||||
|
||||
@@ -73,7 +73,7 @@ export function useUnregisterEntityDialogState(
|
||||
if (!locationRef) {
|
||||
colocatedEntitiesPromise = Promise.resolve([]);
|
||||
} else {
|
||||
const locationAnnotationFilter = `metadata.annotations.${ORIGIN_LOCATION_ANNOTATION}`;
|
||||
const locationAnnotationFilter = `metadata.annotations.${ANNOTATION_ORIGIN_LOCATION}`;
|
||||
colocatedEntitiesPromise = catalogApi
|
||||
.getEntities({
|
||||
filter: { [locationAnnotationFilter]: locationRef },
|
||||
|
||||
@@ -15,15 +15,15 @@
|
||||
*/
|
||||
|
||||
import {
|
||||
EDIT_URL_ANNOTATION,
|
||||
ANNOTATION_EDIT_URL,
|
||||
ANNOTATION_VIEW_URL,
|
||||
Entity,
|
||||
VIEW_URL_ANNOTATION,
|
||||
} from '@backstage/catalog-model';
|
||||
|
||||
export function getEntityMetadataViewUrl(entity: Entity): string | undefined {
|
||||
return entity.metadata.annotations?.[VIEW_URL_ANNOTATION];
|
||||
return entity.metadata.annotations?.[ANNOTATION_VIEW_URL];
|
||||
}
|
||||
|
||||
export function getEntityMetadataEditUrl(entity: Entity): string | undefined {
|
||||
return entity.metadata.annotations?.[EDIT_URL_ANNOTATION];
|
||||
return entity.metadata.annotations?.[ANNOTATION_EDIT_URL];
|
||||
}
|
||||
|
||||
@@ -15,9 +15,9 @@
|
||||
*/
|
||||
|
||||
import {
|
||||
ANNOTATION_SOURCE_LOCATION,
|
||||
Entity,
|
||||
parseLocationRef,
|
||||
SOURCE_LOCATION_ANNOTATION,
|
||||
} from '@backstage/catalog-model';
|
||||
import { ScmIntegrationRegistry } from '@backstage/integration';
|
||||
|
||||
@@ -31,7 +31,7 @@ export function getEntitySourceLocation(
|
||||
scmIntegrationsApi: ScmIntegrationRegistry,
|
||||
): EntitySourceLocation | undefined {
|
||||
const sourceLocation =
|
||||
entity.metadata.annotations?.[SOURCE_LOCATION_ANNOTATION];
|
||||
entity.metadata.annotations?.[ANNOTATION_SOURCE_LOCATION];
|
||||
|
||||
if (!sourceLocation) {
|
||||
return undefined;
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
import {
|
||||
Entity,
|
||||
ENTITY_DEFAULT_NAMESPACE,
|
||||
LOCATION_ANNOTATION,
|
||||
ANNOTATION_LOCATION,
|
||||
stringifyEntityRef,
|
||||
} from '@backstage/catalog-model';
|
||||
import {
|
||||
@@ -127,7 +127,7 @@ export function AboutCard({ variant }: AboutCardProps) {
|
||||
cardContentClass = classes.fullHeightCardContent;
|
||||
}
|
||||
|
||||
const entityLocation = entity.metadata.annotations?.[LOCATION_ANNOTATION];
|
||||
const entityLocation = entity.metadata.annotations?.[ANNOTATION_LOCATION];
|
||||
// Limiting the ability to manually refresh to the less expensive locations
|
||||
const allowRefresh =
|
||||
entityLocation?.startsWith('url:') || entityLocation?.startsWith('file:');
|
||||
|
||||
@@ -15,9 +15,9 @@
|
||||
*/
|
||||
|
||||
import {
|
||||
EDIT_URL_ANNOTATION,
|
||||
ANNOTATION_EDIT_URL,
|
||||
ANNOTATION_VIEW_URL,
|
||||
Entity,
|
||||
VIEW_URL_ANNOTATION,
|
||||
} from '@backstage/catalog-model';
|
||||
import { ApiProvider } from '@backstage/core-app-api';
|
||||
import {
|
||||
@@ -123,7 +123,7 @@ describe('CatalogTable component', () => {
|
||||
kind: 'Component',
|
||||
metadata: {
|
||||
name: 'component1',
|
||||
annotations: { [EDIT_URL_ANNOTATION]: 'https://other.place' },
|
||||
annotations: { [ANNOTATION_EDIT_URL]: 'https://other.place' },
|
||||
},
|
||||
};
|
||||
|
||||
@@ -155,7 +155,7 @@ describe('CatalogTable component', () => {
|
||||
kind: 'Component',
|
||||
metadata: {
|
||||
name: 'component1',
|
||||
annotations: { [VIEW_URL_ANNOTATION]: 'https://other.place' },
|
||||
annotations: { [ANNOTATION_VIEW_URL]: 'https://other.place' },
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
import userEvent from '@testing-library/user-event';
|
||||
import React from 'react';
|
||||
import { DeleteEntityDialog } from './DeleteEntityDialog';
|
||||
import { ORIGIN_LOCATION_ANNOTATION } from '@backstage/catalog-model';
|
||||
import { ANNOTATION_ORIGIN_LOCATION } from '@backstage/catalog-model';
|
||||
import { CatalogApi } from '@backstage/catalog-client';
|
||||
import { catalogApiRef } from '@backstage/plugin-catalog-react';
|
||||
import { screen, waitFor } from '@testing-library/react';
|
||||
@@ -42,7 +42,7 @@ describe('DeleteEntityDialog', () => {
|
||||
name: 'n',
|
||||
namespace: 'ns',
|
||||
annotations: {
|
||||
[ORIGIN_LOCATION_ANNOTATION]: 'url:http://example.com',
|
||||
[ANNOTATION_ORIGIN_LOCATION]: 'url:http://example.com',
|
||||
},
|
||||
},
|
||||
spec: {},
|
||||
|
||||
@@ -23,8 +23,8 @@ import {
|
||||
} from '../Router';
|
||||
import { GithubDeploymentsTable } from './GithubDeploymentsTable/GithubDeploymentsTable';
|
||||
import {
|
||||
LOCATION_ANNOTATION,
|
||||
SOURCE_LOCATION_ANNOTATION,
|
||||
ANNOTATION_LOCATION,
|
||||
ANNOTATION_SOURCE_LOCATION,
|
||||
} from '@backstage/catalog-model';
|
||||
|
||||
import {
|
||||
@@ -88,8 +88,8 @@ export const GithubDeploymentsCard = (props: {
|
||||
const { last, lastStatuses, columns } = props;
|
||||
const { entity } = useEntity();
|
||||
const [host] = [
|
||||
entity?.metadata.annotations?.[SOURCE_LOCATION_ANNOTATION],
|
||||
entity?.metadata.annotations?.[LOCATION_ANNOTATION],
|
||||
entity?.metadata.annotations?.[ANNOTATION_SOURCE_LOCATION],
|
||||
entity?.metadata.annotations?.[ANNOTATION_LOCATION],
|
||||
].filter(Boolean);
|
||||
|
||||
return !isGithubDeploymentsAvailable(entity) ? (
|
||||
|
||||
@@ -23,7 +23,7 @@ const fsMock = fs as jest.Mocked<typeof fs>;
|
||||
import { PassThrough } from 'stream';
|
||||
import os from 'os';
|
||||
import { getVoidLogger } from '@backstage/backend-common';
|
||||
import { ORIGIN_LOCATION_ANNOTATION } from '@backstage/catalog-model';
|
||||
import { ANNOTATION_ORIGIN_LOCATION } from '@backstage/catalog-model';
|
||||
import { createCatalogWriteAction } from './write';
|
||||
import { resolve as resolvePath } from 'path';
|
||||
import * as yaml from 'yaml';
|
||||
@@ -51,7 +51,7 @@ describe('catalog:write', () => {
|
||||
name: 'n',
|
||||
namespace: 'ns',
|
||||
annotations: {
|
||||
[ORIGIN_LOCATION_ANNOTATION]: 'url:https://example.com',
|
||||
[ANNOTATION_ORIGIN_LOCATION]: 'url:https://example.com',
|
||||
},
|
||||
},
|
||||
spec: {},
|
||||
@@ -79,7 +79,7 @@ describe('catalog:write', () => {
|
||||
name: 'n',
|
||||
namespace: 'ns',
|
||||
annotations: {
|
||||
[ORIGIN_LOCATION_ANNOTATION]: 'url:https://example.com',
|
||||
[ANNOTATION_ORIGIN_LOCATION]: 'url:https://example.com',
|
||||
},
|
||||
},
|
||||
spec: {},
|
||||
|
||||
@@ -16,9 +16,9 @@
|
||||
|
||||
import {
|
||||
Entity,
|
||||
LOCATION_ANNOTATION,
|
||||
ANNOTATION_LOCATION,
|
||||
parseLocationRef,
|
||||
SOURCE_LOCATION_ANNOTATION,
|
||||
ANNOTATION_SOURCE_LOCATION,
|
||||
} from '@backstage/catalog-model';
|
||||
import { Config } from '@backstage/config';
|
||||
import { assertError } from '@backstage/errors';
|
||||
@@ -59,9 +59,9 @@ export async function getWorkingDirectory(
|
||||
* For file locations this will return a `file://` URL.
|
||||
*/
|
||||
export function getEntityBaseUrl(entity: Entity): string | undefined {
|
||||
let location = entity.metadata.annotations?.[SOURCE_LOCATION_ANNOTATION];
|
||||
let location = entity.metadata.annotations?.[ANNOTATION_SOURCE_LOCATION];
|
||||
if (!location) {
|
||||
location = entity.metadata.annotations?.[LOCATION_ANNOTATION];
|
||||
location = entity.metadata.annotations?.[ANNOTATION_LOCATION];
|
||||
}
|
||||
if (!location) {
|
||||
return undefined;
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
import { InputError, NotFoundError } from '@backstage/errors';
|
||||
import { CatalogApi } from '@backstage/catalog-client';
|
||||
import {
|
||||
LOCATION_ANNOTATION,
|
||||
SOURCE_LOCATION_ANNOTATION,
|
||||
ANNOTATION_LOCATION,
|
||||
ANNOTATION_SOURCE_LOCATION,
|
||||
Entity,
|
||||
parseLocationRef,
|
||||
stringifyEntityRef,
|
||||
@@ -128,7 +128,7 @@ export class TodoReaderService implements TodoService {
|
||||
|
||||
private getEntitySourceUrl(entity: Entity) {
|
||||
const sourceLocation =
|
||||
entity.metadata.annotations?.[SOURCE_LOCATION_ANNOTATION];
|
||||
entity.metadata.annotations?.[ANNOTATION_SOURCE_LOCATION];
|
||||
if (sourceLocation) {
|
||||
const parsed = parseLocationRef(sourceLocation);
|
||||
if (parsed.type !== 'url') {
|
||||
@@ -141,7 +141,7 @@ export class TodoReaderService implements TodoService {
|
||||
return parsed.target;
|
||||
}
|
||||
|
||||
const location = entity.metadata.annotations?.[LOCATION_ANNOTATION];
|
||||
const location = entity.metadata.annotations?.[ANNOTATION_LOCATION];
|
||||
if (location) {
|
||||
const parsed = parseLocationRef(location);
|
||||
if (parsed.type !== 'url') {
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { Entity, LOCATION_ANNOTATION } from '@backstage/catalog-model';
|
||||
import { Entity, ANNOTATION_LOCATION } from '@backstage/catalog-model';
|
||||
import { createDevApp } from '@backstage/dev-utils';
|
||||
import { EntityProvider } from '@backstage/plugin-catalog-react';
|
||||
import OnlineIcon from '@material-ui/icons/Cloud';
|
||||
@@ -31,7 +31,7 @@ const entity: Entity = {
|
||||
metadata: {
|
||||
name: 'backstage',
|
||||
annotations: {
|
||||
[LOCATION_ANNOTATION]:
|
||||
[ANNOTATION_LOCATION]:
|
||||
'https://github.com/backstage/backstage/blob/master/catalog-info.yaml',
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user