Generate API Report
Signed-off-by: Tomas Dabasinskas <tomas@dabasinskas.net>
This commit is contained in:
@@ -0,0 +1,79 @@
|
||||
## API Report File for "@backstage/plugin-catalog-backend-module-puppetdb-backend"
|
||||
|
||||
> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
|
||||
|
||||
```ts
|
||||
import { Config } from '@backstage/config';
|
||||
import { EntityProvider } from '@backstage/plugin-catalog-backend';
|
||||
import { EntityProviderConnection } from '@backstage/plugin-catalog-backend';
|
||||
import { JsonValue } from '@backstage/types';
|
||||
import { Logger } from 'winston';
|
||||
import { PluginTaskScheduler } from '@backstage/backend-tasks';
|
||||
import { ResourceEntity } from '@backstage/catalog-model';
|
||||
import { TaskRunner } from '@backstage/backend-tasks';
|
||||
import { TaskScheduleDefinition } from '@backstage/backend-tasks';
|
||||
|
||||
// @public
|
||||
export const ANNOTATION_PUPPET_CERTNAME = 'puppet.com/certname';
|
||||
|
||||
// @public
|
||||
export const DEFAULT_PROVIDER_ID = 'default';
|
||||
|
||||
// @public
|
||||
export const defaultResourceTransformer: ResourceTransformer;
|
||||
|
||||
// @public
|
||||
export class PuppetDbEntityProvider implements EntityProvider {
|
||||
// (undocumented)
|
||||
connect(connection: EntityProviderConnection): Promise<void>;
|
||||
static fromConfig(
|
||||
config: Config,
|
||||
deps: {
|
||||
logger: Logger;
|
||||
schedule?: TaskRunner;
|
||||
scheduler?: PluginTaskScheduler;
|
||||
transformer?: ResourceTransformer;
|
||||
},
|
||||
): PuppetDbEntityProvider[];
|
||||
// (undocumented)
|
||||
getProviderName(): string;
|
||||
refresh(logger: Logger): Promise<void>;
|
||||
}
|
||||
|
||||
// @public
|
||||
export type PuppetDbEntityProviderConfig = {
|
||||
id: string;
|
||||
host: string;
|
||||
query?: string;
|
||||
schedule?: TaskScheduleDefinition;
|
||||
};
|
||||
|
||||
// @public
|
||||
export type PuppetFact = {
|
||||
name: string;
|
||||
value: JsonValue;
|
||||
};
|
||||
|
||||
// @public
|
||||
export type PuppetFactSet = {
|
||||
data: PuppetFact[];
|
||||
href: string;
|
||||
};
|
||||
|
||||
// @public
|
||||
export type PuppetNode = {
|
||||
timestamp: string;
|
||||
certname: string;
|
||||
hash: string;
|
||||
producer_timestamp: string;
|
||||
producer: string;
|
||||
environment: string;
|
||||
facts: PuppetFactSet;
|
||||
};
|
||||
|
||||
// @public
|
||||
export type ResourceTransformer = (
|
||||
node: PuppetNode,
|
||||
config: PuppetDbEntityProviderConfig,
|
||||
) => Promise<ResourceEntity | undefined>;
|
||||
```
|
||||
+1
-4
@@ -14,10 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {
|
||||
TaskScheduleDefinition,
|
||||
TaskScheduleDefinitionConfig,
|
||||
} from '@backstage/backend-tasks';
|
||||
import { TaskScheduleDefinition } from '@backstage/backend-tasks';
|
||||
|
||||
/**
|
||||
* Represents the configuration for the Backstage.
|
||||
|
||||
+1
-2
@@ -20,13 +20,12 @@ import { getVoidLogger } from '@backstage/backend-common';
|
||||
import { PuppetDbEntityProvider } from './PuppetDbEntityProvider';
|
||||
import { EntityProviderConnection } from '@backstage/plugin-catalog-backend';
|
||||
import * as p from '../puppet/read';
|
||||
import { DEFAULT_OWNER } from './constants';
|
||||
import { ANNOTATION_PUPPET_CERTNAME } from '../puppet';
|
||||
import {
|
||||
ANNOTATION_LOCATION,
|
||||
ANNOTATION_ORIGIN_LOCATION,
|
||||
} from '@backstage/catalog-model/';
|
||||
import { ENDPOINT_NODES } from '../puppet/constants';
|
||||
import { DEFAULT_OWNER, ENDPOINT_NODES } from '../puppet/constants';
|
||||
|
||||
const logger = getVoidLogger();
|
||||
|
||||
|
||||
@@ -158,7 +158,7 @@ export class PuppetDbEntityProvider implements EntityProvider {
|
||||
/**
|
||||
* Refreshes the catalog by reading nodes from PuppetDB and registering them as Resource Entities.
|
||||
*
|
||||
* @param logger - The instance of a {@link Logger}.
|
||||
* @param logger - The instance of a Logger.
|
||||
*/
|
||||
async refresh(logger: Logger) {
|
||||
if (!this.connection) {
|
||||
|
||||
@@ -20,10 +20,3 @@
|
||||
* @public
|
||||
*/
|
||||
export const DEFAULT_PROVIDER_ID = 'default';
|
||||
|
||||
/**
|
||||
* Default owner for entities created by the PuppetDB provider.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export const DEFAULT_OWNER = 'unknown';
|
||||
|
||||
@@ -16,4 +16,4 @@
|
||||
|
||||
export { PuppetDbEntityProvider } from './PuppetDbEntityProvider';
|
||||
export type { PuppetDbEntityProviderConfig } from './PuppetDbEntityProviderConfig';
|
||||
export { DEFAULT_PROVIDER_ID, DEFAULT_OWNER } from './constants';
|
||||
export { DEFAULT_PROVIDER_ID } from './constants';
|
||||
|
||||
@@ -30,3 +30,10 @@ export const ENDPOINT_FACTSETS = '/pdb/query/v4/factsets';
|
||||
* Path of PuppetDB Nodes endpoint.
|
||||
*/
|
||||
export const ENDPOINT_NODES = '/pdb/query/v4/nodes';
|
||||
|
||||
/**
|
||||
* Default owner for entities created by the PuppetDB provider.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export const DEFAULT_OWNER = 'unknown';
|
||||
|
||||
@@ -18,8 +18,7 @@ import { PuppetDbEntityProviderConfig } from '../providers';
|
||||
import { PuppetNode } from './types';
|
||||
import { defaultResourceTransformer } from './transformers';
|
||||
import { DEFAULT_NAMESPACE } from '@backstage/catalog-model';
|
||||
import { DEFAULT_OWNER } from '../providers';
|
||||
import { ANNOTATION_PUPPET_CERTNAME } from './constants';
|
||||
import { ANNOTATION_PUPPET_CERTNAME, DEFAULT_OWNER } from './constants';
|
||||
|
||||
describe('defaultResourceTransformer', () => {
|
||||
it('should transform a puppet node to a resource entity', async () => {
|
||||
|
||||
@@ -16,8 +16,7 @@
|
||||
|
||||
import { ResourceTransformer } from './types';
|
||||
import { DEFAULT_NAMESPACE, ResourceEntity } from '@backstage/catalog-model';
|
||||
import { DEFAULT_OWNER } from '../providers';
|
||||
import { ANNOTATION_PUPPET_CERTNAME } from './constants';
|
||||
import { ANNOTATION_PUPPET_CERTNAME, DEFAULT_OWNER } from './constants';
|
||||
|
||||
/**
|
||||
* A default implementation of the {@link ResourceTransformer}.
|
||||
|
||||
Reference in New Issue
Block a user