@backstage/plugin-catalog-backend-module-github 0.1.8-next.1 → 0.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,70 @@
1
1
  # @backstage/plugin-catalog-backend-module-github
2
2
 
3
+ ## 0.1.8
4
+
5
+ ### Patch Changes
6
+
7
+ - 8749df3d02: `GitHubEntityProvider`: Add option to configure schedule via `app-config.yaml` instead of in code.
8
+
9
+ Please find how to configure the schedule at the config at
10
+ https://backstage.io/docs/integrations/github/discovery
11
+
12
+ - 7022aebf35: Added `GithubLocationAnalyzer`. This can be used to add to the `CatalogBuilder`. When added this will be used by `RepoLocationAnalyzer` to figure out if the given URL that you are trying to import from the /catalog-import page already contains catalog-info.yaml files.
13
+ - 51046b58b0: Use schedule from config at backend module.
14
+
15
+ Also, it removes `GithubEntityProviderCatalogModuleOptions`
16
+ in favor of config-only for the backend module setup
17
+ like at other similar modules.
18
+
19
+ - 7edb5909e8: Add missing config schema for the `GitHubEntityProvider`.
20
+ - be9474b103: Replaces in-code uses of `GitHub` by `Github` and deprecates old versions.
21
+
22
+ Deprecates
23
+
24
+ - `GitHubEntityProvider` replaced by `GithubEntityProvider`
25
+ - `GitHubLocationAnalyzer` replaced by `GithubLocationAnalyzer`
26
+ - `GitHubLocationAnalyzerOptions` replaced by `GithubLocationAnalyzerOptions`
27
+ - `GitHubOrgEntityProvider` replaced by `GithubOrgEntityProvider`
28
+ - `GitHubOrgEntityProviderOptions` replaced by `GithubOrgEntityProviderOptions`
29
+
30
+ Renames
31
+
32
+ - `GitHubLocationAnalyzer` to `GithubLocationAnalyzer`
33
+ - `GitHubLocationAnalyzerOptions` to `GithubLocationAnalyzerOptions`
34
+
35
+ - a35a27df70: Updated the `moduleId` of the experimental module export.
36
+ - Updated dependencies
37
+ - @backstage/plugin-catalog-node@1.2.0
38
+ - @backstage/catalog-model@1.1.2
39
+ - @backstage/backend-common@0.15.2
40
+ - @backstage/plugin-catalog-backend@1.5.0
41
+ - @backstage/backend-tasks@0.3.6
42
+ - @backstage/backend-plugin-api@0.1.3
43
+ - @backstage/catalog-client@1.1.1
44
+ - @backstage/config@1.0.3
45
+ - @backstage/errors@1.1.2
46
+ - @backstage/integration@1.3.2
47
+ - @backstage/types@1.0.0
48
+
49
+ ## 0.1.8-next.2
50
+
51
+ ### Patch Changes
52
+
53
+ - 7022aebf35: Added `GitHubLocationAnalyzer`. This can be used to add to the `CatalogBuilder`. When added this will be used by `RepoLocationAnalyzer` to figure out if the given URL that you are trying to import from the /catalog-import page already contains catalog-info.yaml files.
54
+ - 7edb5909e8: Add missing config schema for the `GitHubEntityProvider`.
55
+ - Updated dependencies
56
+ - @backstage/plugin-catalog-node@1.2.0-next.2
57
+ - @backstage/plugin-catalog-backend@1.5.0-next.2
58
+ - @backstage/backend-tasks@0.3.6-next.2
59
+ - @backstage/backend-common@0.15.2-next.2
60
+ - @backstage/backend-plugin-api@0.1.3-next.2
61
+ - @backstage/catalog-client@1.1.1-next.2
62
+ - @backstage/catalog-model@1.1.2-next.2
63
+ - @backstage/config@1.0.3-next.2
64
+ - @backstage/errors@1.1.2-next.2
65
+ - @backstage/integration@1.3.2-next.2
66
+ - @backstage/types@1.0.0
67
+
3
68
  ## 0.1.8-next.1
4
69
 
5
70
  ### Patch Changes
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage/plugin-catalog-backend-module-github",
3
- "version": "0.1.8-next.1",
3
+ "version": "0.1.8",
4
4
  "main": "../dist/index.cjs.js",
5
5
  "types": "../dist/index.alpha.d.ts"
6
6
  }
package/config.d.ts CHANGED
@@ -14,6 +14,8 @@
14
14
  * limitations under the License.
15
15
  */
16
16
 
17
+ import { TaskScheduleDefinitionConfig } from '@backstage/backend-tasks';
18
+
17
19
  export interface Config {
18
20
  catalog?: {
19
21
  processors?: {
@@ -45,5 +47,127 @@ export interface Config {
45
47
  }>;
46
48
  };
47
49
  };
50
+
51
+ providers?: {
52
+ /**
53
+ * GithubEntityProvider configuration
54
+ *
55
+ * Uses "default" as default id for the single config variant.
56
+ */
57
+ github?:
58
+ | {
59
+ /**
60
+ * (Optional) The hostname of your GitHub Enterprise instance.
61
+ * Default: `github.com`.
62
+ */
63
+ host?: string;
64
+ /**
65
+ * (Required) Name of your organization account/workspace.
66
+ */
67
+ organization: string;
68
+ /**
69
+ * (Optional) Path where to look for `catalog-info.yaml` files.
70
+ * You can use wildcards - `*` or `**` - to search the path and/or the filename
71
+ * Default: `/catalog-info.yaml`.
72
+ */
73
+ catalogPath?: string;
74
+ /**
75
+ * (Optional) Filter configuration.
76
+ */
77
+ filters?: {
78
+ /**
79
+ * (Optional) String used to filter results based on the branch name.
80
+ */
81
+ branch?: string;
82
+ /**
83
+ * (Optional) Regular expression used to filter results based on the repository name.
84
+ */
85
+ repository?: string;
86
+ /**
87
+ * (Optional) GitHub topic-based filters.
88
+ */
89
+ topic?: {
90
+ /**
91
+ * (Optional) An array of strings used to filter in results based on their associated GitHub topics.
92
+ * If configured, only repositories with one (or more) topic(s) present in the inclusion
93
+ * filter will be ingested.
94
+ *
95
+ * If `include` and `exclude` are used, `exclude` has higher priority.
96
+ */
97
+ include?: string[];
98
+ /**
99
+ * (Optional) An array of strings used to filter out results based on their associated GitHub topics.
100
+ * If configured, all repositories _except_ those with one (or more) topics(s) present in
101
+ * the exclusion filter will be ingested.
102
+ *
103
+ * If `include` and `exclude` are used, `exclude` has higher priority.
104
+ */
105
+ exclude?: string[];
106
+ };
107
+ };
108
+ /**
109
+ * (Optional) TaskScheduleDefinition for the refresh.
110
+ */
111
+ schedule?: TaskScheduleDefinitionConfig;
112
+ }
113
+ | Record<
114
+ string,
115
+ {
116
+ /**
117
+ * (Optional) The hostname of your GitHub Enterprise instance.
118
+ * Default: `github.com`.
119
+ */
120
+ host?: string;
121
+ /**
122
+ * (Required) Name of your organization account/workspace.
123
+ */
124
+ organization: string;
125
+ /**
126
+ * (Optional) Path where to look for `catalog-info.yaml` files.
127
+ * You can use wildcards - `*` or `**` - to search the path and/or the filename
128
+ * Default: `/catalog-info.yaml`.
129
+ */
130
+ catalogPath?: string;
131
+ /**
132
+ * (Optional) Filter configuration.
133
+ */
134
+ filters?: {
135
+ /**
136
+ * (Optional) String used to filter results based on the branch name.
137
+ */
138
+ branch?: string;
139
+ /**
140
+ * (Optional) Regular expression used to filter results based on the repository name.
141
+ */
142
+ repository?: string;
143
+ /**
144
+ * (Optional) GitHub topic-based filters.
145
+ */
146
+ topic?: {
147
+ /**
148
+ * (Optional) An array of strings used to filter in results based on their associated GitHub topics.
149
+ * If configured, only repositories with one (or more) topic(s) present in the inclusion
150
+ * filter will be ingested.
151
+ *
152
+ * If `include` and `exclude` are used, `exclude` has higher priority.
153
+ */
154
+ include?: string[];
155
+ /**
156
+ * (Optional) An array of strings used to filter out results based on their associated GitHub topics.
157
+ * If configured, all repositories _except_ those with one (or more) topics(s) present in
158
+ * the exclusion filter will be ingested.
159
+ *
160
+ * If `include` and `exclude` are used, `exclude` has higher priority.
161
+ */
162
+ exclude?: string[];
163
+ };
164
+ };
165
+ /**
166
+ * (Optional) TaskScheduleDefinition for the refresh.
167
+ */
168
+ schedule?: TaskScheduleDefinitionConfig;
169
+ }
170
+ >;
171
+ };
48
172
  };
49
173
  }
@@ -4,19 +4,23 @@
4
4
  * @packageDocumentation
5
5
  */
6
6
 
7
+ import { AnalyzeOptions } from '@backstage/plugin-catalog-backend';
7
8
  import { BackendFeature } from '@backstage/backend-plugin-api';
8
9
  import { CatalogProcessor } from '@backstage/plugin-catalog-backend';
9
10
  import { CatalogProcessorEmit } from '@backstage/plugin-catalog-backend';
10
11
  import { Config } from '@backstage/config';
12
+ import { Entity } from '@backstage/catalog-model';
11
13
  import { EntityProvider } from '@backstage/plugin-catalog-backend';
12
14
  import { EntityProviderConnection } from '@backstage/plugin-catalog-backend';
13
15
  import { GithubCredentialsProvider } from '@backstage/integration';
14
16
  import { GitHubIntegrationConfig } from '@backstage/integration';
15
17
  import { LocationSpec } from '@backstage/plugin-catalog-backend';
16
18
  import { Logger } from 'winston';
19
+ import { PluginEndpointDiscovery } from '@backstage/backend-common';
20
+ import { PluginTaskScheduler } from '@backstage/backend-tasks';
17
21
  import { ScmIntegrationRegistry } from '@backstage/integration';
22
+ import { ScmLocationAnalyzer } from '@backstage/plugin-catalog-backend';
18
23
  import { TaskRunner } from '@backstage/backend-tasks';
19
- import { TaskScheduleDefinition } from '@backstage/backend-tasks';
20
24
 
21
25
  /**
22
26
  * Extracts repositories out of a GitHub org.
@@ -51,6 +55,23 @@ export declare class GithubDiscoveryProcessor implements CatalogProcessor {
51
55
  readLocation(location: LocationSpec, _optional: boolean, emit: CatalogProcessorEmit): Promise<boolean>;
52
56
  }
53
57
 
58
+ /**
59
+ * @public
60
+ * @deprecated Use {@link GithubEntityProvider} instead.
61
+ */
62
+ export declare class GitHubEntityProvider implements EntityProvider {
63
+ private readonly delegate;
64
+ static fromConfig(config: Config, options: {
65
+ logger: Logger;
66
+ schedule?: TaskRunner;
67
+ scheduler?: PluginTaskScheduler;
68
+ }): GitHubEntityProvider[];
69
+ private constructor();
70
+ connect(connection: EntityProviderConnection): Promise<void>;
71
+ getProviderName(): string;
72
+ refresh(logger: Logger): Promise<void>;
73
+ }
74
+
54
75
  /**
55
76
  * Discovers catalog files located in [GitHub](https://github.com).
56
77
  * The provider will search your GitHub account and register catalog files matching the configured path
@@ -59,7 +80,7 @@ export declare class GithubDiscoveryProcessor implements CatalogProcessor {
59
80
  *
60
81
  * @public
61
82
  */
62
- export declare class GitHubEntityProvider implements EntityProvider {
83
+ export declare class GithubEntityProvider implements EntityProvider {
63
84
  private readonly config;
64
85
  private readonly logger;
65
86
  private readonly integration;
@@ -68,8 +89,9 @@ export declare class GitHubEntityProvider implements EntityProvider {
68
89
  private readonly githubCredentialsProvider;
69
90
  static fromConfig(config: Config, options: {
70
91
  logger: Logger;
71
- schedule: TaskRunner;
72
- }): GitHubEntityProvider[];
92
+ schedule?: TaskRunner;
93
+ scheduler?: PluginTaskScheduler;
94
+ }): GithubEntityProvider[];
73
95
  private constructor();
74
96
  /** {@inheritdoc @backstage/plugin-catalog-backend#EntityProvider.getProviderName} */
75
97
  getProviderName(): string;
@@ -84,19 +106,34 @@ export declare class GitHubEntityProvider implements EntityProvider {
84
106
  }
85
107
 
86
108
  /**
87
- * Registers the GitHubEntityProvider with the catalog processing extension point.
109
+ * Registers the {@link GithubEntityProvider} with the catalog processing extension point.
88
110
  *
89
111
  * @alpha
90
112
  */
91
- export declare const githubEntityProviderCatalogModule: (options?: GithubEntityProviderCatalogModuleOptions | undefined) => BackendFeature;
113
+ export declare const githubEntityProviderCatalogModule: (options?: undefined) => BackendFeature;
92
114
 
93
- /**
94
- * Options for {@link githubEntityProviderCatalogModule}.
95
- *
96
- * @alpha
97
- */
98
- export declare type GithubEntityProviderCatalogModuleOptions = {
99
- schedule?: TaskScheduleDefinition;
115
+ /** @public */
116
+ export declare class GithubLocationAnalyzer implements ScmLocationAnalyzer {
117
+ private readonly catalogClient;
118
+ private readonly config;
119
+ constructor(options: GithubLocationAnalyzerOptions);
120
+ supports(url: string): boolean;
121
+ analyze({ url, catalogFilename }: AnalyzeOptions): Promise<{
122
+ existing: {
123
+ location: {
124
+ type: string;
125
+ target: string;
126
+ };
127
+ isRegistered: boolean;
128
+ entity: Entity;
129
+ }[];
130
+ }>;
131
+ }
132
+
133
+ /** @public */
134
+ export declare type GithubLocationAnalyzerOptions = {
135
+ config: Config;
136
+ discovery: PluginEndpointDiscovery;
100
137
  };
101
138
 
102
139
  /**
@@ -145,17 +182,25 @@ export declare class GithubMultiOrgReaderProcessor implements CatalogProcessor {
145
182
  private getAllOrgs;
146
183
  }
147
184
 
185
+ /**
186
+ * @public
187
+ * @deprecated Use {@link GithubOrgEntityProvider} instead.
188
+ */
189
+ export declare class GitHubOrgEntityProvider extends GithubOrgEntityProvider {
190
+ static fromConfig(config: Config, options: GitHubOrgEntityProviderOptions): GitHubOrgEntityProvider;
191
+ }
192
+
148
193
  /**
149
194
  * Ingests org data (users and groups) from GitHub.
150
195
  *
151
196
  * @public
152
197
  */
153
- export declare class GitHubOrgEntityProvider implements EntityProvider {
198
+ export declare class GithubOrgEntityProvider implements EntityProvider {
154
199
  private options;
155
200
  private readonly credentialsProvider;
156
201
  private connection?;
157
202
  private scheduleFn?;
158
- static fromConfig(config: Config, options: GitHubOrgEntityProviderOptions): GitHubOrgEntityProvider;
203
+ static fromConfig(config: Config, options: GithubOrgEntityProviderOptions): GithubOrgEntityProvider;
159
204
  constructor(options: {
160
205
  id: string;
161
206
  orgUrl: string;
@@ -178,11 +223,17 @@ export declare class GitHubOrgEntityProvider implements EntityProvider {
178
223
  }
179
224
 
180
225
  /**
181
- * Options for {@link GitHubOrgEntityProvider}.
226
+ * @public
227
+ * @deprecated Use {@link GithubOrgEntityProviderOptions} instead.
228
+ */
229
+ export declare type GitHubOrgEntityProviderOptions = GithubOrgEntityProviderOptions;
230
+
231
+ /**
232
+ * Options for {@link GithubOrgEntityProvider}.
182
233
  *
183
234
  * @public
184
235
  */
185
- export declare interface GitHubOrgEntityProviderOptions {
236
+ export declare interface GithubOrgEntityProviderOptions {
186
237
  /**
187
238
  * A unique, stable identifier for this provider.
188
239
  *
@@ -224,7 +275,7 @@ export declare interface GitHubOrgEntityProviderOptions {
224
275
  *
225
276
  * @remarks
226
277
  *
227
- * Consider using {@link GitHubOrgEntityProvider} instead.
278
+ * Consider using {@link GithubOrgEntityProvider} instead.
228
279
  *
229
280
  * @public
230
281
  */
@@ -4,19 +4,23 @@
4
4
  * @packageDocumentation
5
5
  */
6
6
 
7
+ import { AnalyzeOptions } from '@backstage/plugin-catalog-backend';
7
8
  import { BackendFeature } from '@backstage/backend-plugin-api';
8
9
  import { CatalogProcessor } from '@backstage/plugin-catalog-backend';
9
10
  import { CatalogProcessorEmit } from '@backstage/plugin-catalog-backend';
10
11
  import { Config } from '@backstage/config';
12
+ import { Entity } from '@backstage/catalog-model';
11
13
  import { EntityProvider } from '@backstage/plugin-catalog-backend';
12
14
  import { EntityProviderConnection } from '@backstage/plugin-catalog-backend';
13
15
  import { GithubCredentialsProvider } from '@backstage/integration';
14
16
  import { GitHubIntegrationConfig } from '@backstage/integration';
15
17
  import { LocationSpec } from '@backstage/plugin-catalog-backend';
16
18
  import { Logger } from 'winston';
19
+ import { PluginEndpointDiscovery } from '@backstage/backend-common';
20
+ import { PluginTaskScheduler } from '@backstage/backend-tasks';
17
21
  import { ScmIntegrationRegistry } from '@backstage/integration';
22
+ import { ScmLocationAnalyzer } from '@backstage/plugin-catalog-backend';
18
23
  import { TaskRunner } from '@backstage/backend-tasks';
19
- import { TaskScheduleDefinition } from '@backstage/backend-tasks';
20
24
 
21
25
  /**
22
26
  * Extracts repositories out of a GitHub org.
@@ -51,6 +55,23 @@ export declare class GithubDiscoveryProcessor implements CatalogProcessor {
51
55
  readLocation(location: LocationSpec, _optional: boolean, emit: CatalogProcessorEmit): Promise<boolean>;
52
56
  }
53
57
 
58
+ /**
59
+ * @public
60
+ * @deprecated Use {@link GithubEntityProvider} instead.
61
+ */
62
+ export declare class GitHubEntityProvider implements EntityProvider {
63
+ private readonly delegate;
64
+ static fromConfig(config: Config, options: {
65
+ logger: Logger;
66
+ schedule?: TaskRunner;
67
+ scheduler?: PluginTaskScheduler;
68
+ }): GitHubEntityProvider[];
69
+ private constructor();
70
+ connect(connection: EntityProviderConnection): Promise<void>;
71
+ getProviderName(): string;
72
+ refresh(logger: Logger): Promise<void>;
73
+ }
74
+
54
75
  /**
55
76
  * Discovers catalog files located in [GitHub](https://github.com).
56
77
  * The provider will search your GitHub account and register catalog files matching the configured path
@@ -59,7 +80,7 @@ export declare class GithubDiscoveryProcessor implements CatalogProcessor {
59
80
  *
60
81
  * @public
61
82
  */
62
- export declare class GitHubEntityProvider implements EntityProvider {
83
+ export declare class GithubEntityProvider implements EntityProvider {
63
84
  private readonly config;
64
85
  private readonly logger;
65
86
  private readonly integration;
@@ -68,8 +89,9 @@ export declare class GitHubEntityProvider implements EntityProvider {
68
89
  private readonly githubCredentialsProvider;
69
90
  static fromConfig(config: Config, options: {
70
91
  logger: Logger;
71
- schedule: TaskRunner;
72
- }): GitHubEntityProvider[];
92
+ schedule?: TaskRunner;
93
+ scheduler?: PluginTaskScheduler;
94
+ }): GithubEntityProvider[];
73
95
  private constructor();
74
96
  /** {@inheritdoc @backstage/plugin-catalog-backend#EntityProvider.getProviderName} */
75
97
  getProviderName(): string;
@@ -85,7 +107,29 @@ export declare class GitHubEntityProvider implements EntityProvider {
85
107
 
86
108
  /* Excluded from this release type: githubEntityProviderCatalogModule */
87
109
 
88
- /* Excluded from this release type: GithubEntityProviderCatalogModuleOptions */
110
+ /** @public */
111
+ export declare class GithubLocationAnalyzer implements ScmLocationAnalyzer {
112
+ private readonly catalogClient;
113
+ private readonly config;
114
+ constructor(options: GithubLocationAnalyzerOptions);
115
+ supports(url: string): boolean;
116
+ analyze({ url, catalogFilename }: AnalyzeOptions): Promise<{
117
+ existing: {
118
+ location: {
119
+ type: string;
120
+ target: string;
121
+ };
122
+ isRegistered: boolean;
123
+ entity: Entity;
124
+ }[];
125
+ }>;
126
+ }
127
+
128
+ /** @public */
129
+ export declare type GithubLocationAnalyzerOptions = {
130
+ config: Config;
131
+ discovery: PluginEndpointDiscovery;
132
+ };
89
133
 
90
134
  /**
91
135
  * The configuration parameters for a multi-org GitHub processor.
@@ -133,17 +177,25 @@ export declare class GithubMultiOrgReaderProcessor implements CatalogProcessor {
133
177
  private getAllOrgs;
134
178
  }
135
179
 
180
+ /**
181
+ * @public
182
+ * @deprecated Use {@link GithubOrgEntityProvider} instead.
183
+ */
184
+ export declare class GitHubOrgEntityProvider extends GithubOrgEntityProvider {
185
+ static fromConfig(config: Config, options: GitHubOrgEntityProviderOptions): GitHubOrgEntityProvider;
186
+ }
187
+
136
188
  /**
137
189
  * Ingests org data (users and groups) from GitHub.
138
190
  *
139
191
  * @public
140
192
  */
141
- export declare class GitHubOrgEntityProvider implements EntityProvider {
193
+ export declare class GithubOrgEntityProvider implements EntityProvider {
142
194
  private options;
143
195
  private readonly credentialsProvider;
144
196
  private connection?;
145
197
  private scheduleFn?;
146
- static fromConfig(config: Config, options: GitHubOrgEntityProviderOptions): GitHubOrgEntityProvider;
198
+ static fromConfig(config: Config, options: GithubOrgEntityProviderOptions): GithubOrgEntityProvider;
147
199
  constructor(options: {
148
200
  id: string;
149
201
  orgUrl: string;
@@ -166,11 +218,17 @@ export declare class GitHubOrgEntityProvider implements EntityProvider {
166
218
  }
167
219
 
168
220
  /**
169
- * Options for {@link GitHubOrgEntityProvider}.
221
+ * @public
222
+ * @deprecated Use {@link GithubOrgEntityProviderOptions} instead.
223
+ */
224
+ export declare type GitHubOrgEntityProviderOptions = GithubOrgEntityProviderOptions;
225
+
226
+ /**
227
+ * Options for {@link GithubOrgEntityProvider}.
170
228
  *
171
229
  * @public
172
230
  */
173
- export declare interface GitHubOrgEntityProviderOptions {
231
+ export declare interface GithubOrgEntityProviderOptions {
174
232
  /**
175
233
  * A unique, stable identifier for this provider.
176
234
  *
@@ -212,7 +270,7 @@ export declare interface GitHubOrgEntityProviderOptions {
212
270
  *
213
271
  * @remarks
214
272
  *
215
- * Consider using {@link GitHubOrgEntityProvider} instead.
273
+ * Consider using {@link GithubOrgEntityProvider} instead.
216
274
  *
217
275
  * @public
218
276
  */