deprecate EntityName, introduce CompoundEntityRef

deprecate getEntityName, introduce getCompoundEntityRef

Signed-off-by: Fredrik Adelöw <freben@gmail.com>
This commit is contained in:
Fredrik Adelöw
2022-03-02 21:26:22 +01:00
parent 80d2674a31
commit 36aa63022b
84 changed files with 393 additions and 268 deletions
+7 -7
View File
@@ -7,9 +7,9 @@
import { ApiRef } from '@backstage/core-plugin-api';
import { BackstagePlugin } from '@backstage/core-plugin-api';
import type { CompoundEntityRef } from '@backstage/catalog-model';
import { DiscoveryApi } from '@backstage/core-plugin-api';
import { Entity } from '@backstage/catalog-model';
import type { EntityName } from '@backstage/catalog-model';
import { IdentityApi } from '@backstage/core-plugin-api';
import { InfoCardVariants } from '@backstage/core-components';
import { RouteRef } from '@backstage/core-plugin-api';
@@ -48,20 +48,20 @@ export const JENKINS_ANNOTATION = 'jenkins.io/job-full-name';
export interface JenkinsApi {
// Warning: (ae-forgotten-export) The symbol "Build" needs to be exported by the entry point index.d.ts
getBuild(options: {
entity: EntityName;
entity: CompoundEntityRef;
jobFullName: string;
buildNumber: string;
}): Promise<Build>;
// Warning: (ae-forgotten-export) The symbol "Project" needs to be exported by the entry point index.d.ts
getProjects(options: {
entity: EntityName;
entity: CompoundEntityRef;
filter: {
branch?: string;
};
}): Promise<Project[]>;
// (undocumented)
retry(options: {
entity: EntityName;
entity: CompoundEntityRef;
jobFullName: string;
buildNumber: string;
}): Promise<void>;
@@ -82,20 +82,20 @@ export class JenkinsClient implements JenkinsApi {
});
// (undocumented)
getBuild(options: {
entity: EntityName;
entity: CompoundEntityRef;
jobFullName: string;
buildNumber: string;
}): Promise<Build>;
// (undocumented)
getProjects(options: {
entity: EntityName;
entity: CompoundEntityRef;
filter: {
branch?: string;
};
}): Promise<Project[]>;
// (undocumented)
retry(options: {
entity: EntityName;
entity: CompoundEntityRef;
jobFullName: string;
buildNumber: string;
}): Promise<void>;
+7 -7
View File
@@ -19,7 +19,7 @@ import {
DiscoveryApi,
IdentityApi,
} from '@backstage/core-plugin-api';
import type { EntityName } from '@backstage/catalog-model';
import type { CompoundEntityRef } from '@backstage/catalog-model';
import { ResponseError } from '@backstage/errors';
export const jenkinsApiRef = createApiRef<JenkinsApi>({
@@ -80,7 +80,7 @@ export interface JenkinsApi {
*/
getProjects(options: {
/** the entity whose jobs should be retrieved. */
entity: EntityName;
entity: CompoundEntityRef;
/** a filter on jobs. Currently this just takes a branch (and assumes certain structures in jenkins) */
filter: { branch?: string };
}): Promise<Project[]>;
@@ -93,13 +93,13 @@ export interface JenkinsApi {
* TODO: abstract jobFullName (so we could support differentiating between the same named job on multiple instances).
*/
getBuild(options: {
entity: EntityName;
entity: CompoundEntityRef;
jobFullName: string;
buildNumber: string;
}): Promise<Build>;
retry(options: {
entity: EntityName;
entity: CompoundEntityRef;
jobFullName: string;
buildNumber: string;
}): Promise<void>;
@@ -118,7 +118,7 @@ export class JenkinsClient implements JenkinsApi {
}
async getProjects(options: {
entity: EntityName;
entity: CompoundEntityRef;
filter: { branch?: string };
}): Promise<Project[]> {
const { entity, filter } = options;
@@ -157,7 +157,7 @@ export class JenkinsClient implements JenkinsApi {
}
async getBuild(options: {
entity: EntityName;
entity: CompoundEntityRef;
jobFullName: string;
buildNumber: string;
}): Promise<Build> {
@@ -182,7 +182,7 @@ export class JenkinsClient implements JenkinsApi {
}
async retry(options: {
entity: EntityName;
entity: CompoundEntityRef;
jobFullName: string;
buildNumber: string;
}): Promise<void> {
@@ -19,7 +19,7 @@ import { jenkinsApiRef } from '../api';
import { useAsyncPolling } from './useAsyncPolling';
import { errorApiRef, useApi } from '@backstage/core-plugin-api';
import { useEntity } from '@backstage/plugin-catalog-react';
import { getEntityName } from '@backstage/catalog-model';
import { getCompoundEntityRef } from '@backstage/catalog-model';
const INTERVAL_AMOUNT = 1500;
@@ -41,7 +41,7 @@ export function useBuildWithSteps({
const getBuildWithSteps = useCallback(async () => {
try {
const entityName = await getEntityName(entity);
const entityName = await getCompoundEntityRef(entity);
return api.getBuild({ entity: entityName, jobFullName, buildNumber });
} catch (e) {
errorApi.post(e);
+3 -3
View File
@@ -18,7 +18,7 @@ import useAsyncRetry from 'react-use/lib/useAsyncRetry';
import { jenkinsApiRef } from '../api';
import { errorApiRef, useApi } from '@backstage/core-plugin-api';
import { useEntity } from '@backstage/plugin-catalog-react';
import { getEntityName } from '@backstage/catalog-model';
import { getCompoundEntityRef } from '@backstage/catalog-model';
export enum ErrorType {
CONNECTION_ERROR,
@@ -33,7 +33,7 @@ export enum ErrorType {
*/
export function useBuilds({ branch }: { branch?: string } = {}) {
const { entity } = useEntity();
const entityName = getEntityName(entity);
const entityName = getCompoundEntityRef(entity);
const api = useApi(jenkinsApiRef);
const errorApi = useApi(errorApiRef);
@@ -60,7 +60,7 @@ export function useBuilds({ branch }: { branch?: string } = {}) {
} = useAsyncRetry(async () => {
try {
const build = await api.getProjects({
entity: getEntityName(entity),
entity: getCompoundEntityRef(entity),
filter: { branch },
});