deprecate EntityName, introduce CompoundEntityRef
deprecate getEntityName, introduce getCompoundEntityRef Signed-off-by: Fredrik Adelöw <freben@gmail.com>
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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 },
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user