@backstage/plugin-catalog-backend-module-github 0.1.8-next.2 → 0.2.0-next.0

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,97 @@
1
1
  # @backstage/plugin-catalog-backend-module-github
2
2
 
3
+ ## 0.2.0-next.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 67fe5bc9a9: BREAKING: Support authenticated backends by including a server token for catalog requests. The constructor of `GithubLocationAnalyzer` now requires an instance of `TokenManager` to be supplied:
8
+
9
+ ```diff
10
+ ...
11
+ builder.addLocationAnalyzers(
12
+ new GitHubLocationAnalyzer({
13
+ discovery: env.discovery,
14
+ config: env.config,
15
+ + tokenManager: env.tokenManager,
16
+ }),
17
+ );
18
+ ...
19
+ ```
20
+
21
+ - f64d66a45c: Added the ability for the GitHub discovery provider to validate that catalog files exist before emitting them.
22
+
23
+ Users can now set the `validateLocationsExist` property to `true` in their GitHub discovery configuration to opt in to this feature.
24
+ This feature only works with `catalogPath`s that do not contain wildcards.
25
+
26
+ When `validateLocationsExist` is set to `true`, the GitHub discovery provider will retrieve the object from the
27
+ repository at the provided `catalogPath`.
28
+ If this file exists and is non-empty, then it will be emitted as a location for further processing.
29
+ If this file does not exist or is empty, then it will not be emitted.
30
+ Not emitting locations that do not exist allows for far fewer calls to the GitHub API to validate locations that do not exist.
31
+
32
+ ### Patch Changes
33
+
34
+ - 67fe5bc9a9: Properly derive Github credentials when making requests in `GithubLocationAnalyzer` to support Github App authentication
35
+ - c1784a4980: Replaces in-code uses of `GitHub` with `Github` and deprecates old versions.
36
+ - Updated dependencies
37
+ - @backstage/backend-common@0.16.0-next.0
38
+ - @backstage/plugin-catalog-backend@1.5.1-next.0
39
+ - @backstage/integration@1.4.0-next.0
40
+ - @backstage/backend-tasks@0.3.7-next.0
41
+ - @backstage/catalog-model@1.1.3-next.0
42
+ - @backstage/types@1.0.1-next.0
43
+ - @backstage/backend-plugin-api@0.1.4-next.0
44
+ - @backstage/plugin-catalog-node@1.2.1-next.0
45
+ - @backstage/catalog-client@1.1.2-next.0
46
+ - @backstage/config@1.0.4-next.0
47
+ - @backstage/errors@1.1.3-next.0
48
+
49
+ ## 0.1.8
50
+
51
+ ### Patch Changes
52
+
53
+ - 8749df3d02: `GitHubEntityProvider`: Add option to configure schedule via `app-config.yaml` instead of in code.
54
+
55
+ Please find how to configure the schedule at the config at
56
+ https://backstage.io/docs/integrations/github/discovery
57
+
58
+ - 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.
59
+ - 51046b58b0: Use schedule from config at backend module.
60
+
61
+ Also, it removes `GithubEntityProviderCatalogModuleOptions`
62
+ in favor of config-only for the backend module setup
63
+ like at other similar modules.
64
+
65
+ - 7edb5909e8: Add missing config schema for the `GitHubEntityProvider`.
66
+ - be9474b103: Replaces in-code uses of `GitHub` by `Github` and deprecates old versions.
67
+
68
+ Deprecates
69
+
70
+ - `GitHubEntityProvider` replaced by `GithubEntityProvider`
71
+ - `GitHubLocationAnalyzer` replaced by `GithubLocationAnalyzer`
72
+ - `GitHubLocationAnalyzerOptions` replaced by `GithubLocationAnalyzerOptions`
73
+ - `GitHubOrgEntityProvider` replaced by `GithubOrgEntityProvider`
74
+ - `GitHubOrgEntityProviderOptions` replaced by `GithubOrgEntityProviderOptions`
75
+
76
+ Renames
77
+
78
+ - `GitHubLocationAnalyzer` to `GithubLocationAnalyzer`
79
+ - `GitHubLocationAnalyzerOptions` to `GithubLocationAnalyzerOptions`
80
+
81
+ - a35a27df70: Updated the `moduleId` of the experimental module export.
82
+ - Updated dependencies
83
+ - @backstage/plugin-catalog-node@1.2.0
84
+ - @backstage/catalog-model@1.1.2
85
+ - @backstage/backend-common@0.15.2
86
+ - @backstage/plugin-catalog-backend@1.5.0
87
+ - @backstage/backend-tasks@0.3.6
88
+ - @backstage/backend-plugin-api@0.1.3
89
+ - @backstage/catalog-client@1.1.1
90
+ - @backstage/config@1.0.3
91
+ - @backstage/errors@1.1.2
92
+ - @backstage/integration@1.3.2
93
+ - @backstage/types@1.0.0
94
+
3
95
  ## 0.1.8-next.2
4
96
 
5
97
  ### Patch Changes
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage/plugin-catalog-backend-module-github",
3
- "version": "0.1.8-next.2",
3
+ "version": "0.2.0-next.0",
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?: {
@@ -48,7 +50,7 @@ export interface Config {
48
50
 
49
51
  providers?: {
50
52
  /**
51
- * GitHubEntityProvider configuration
53
+ * GithubEntityProvider configuration
52
54
  *
53
55
  * Uses "default" as default id for the single config variant.
54
56
  */
@@ -103,6 +105,10 @@ export interface Config {
103
105
  exclude?: string[];
104
106
  };
105
107
  };
108
+ /**
109
+ * (Optional) TaskScheduleDefinition for the refresh.
110
+ */
111
+ schedule?: TaskScheduleDefinitionConfig;
106
112
  }
107
113
  | Record<
108
114
  string,
@@ -156,6 +162,10 @@ export interface Config {
156
162
  exclude?: string[];
157
163
  };
158
164
  };
165
+ /**
166
+ * (Optional) TaskScheduleDefinition for the refresh.
167
+ */
168
+ schedule?: TaskScheduleDefinitionConfig;
159
169
  }
160
170
  >;
161
171
  };
@@ -13,14 +13,15 @@ import { Entity } from '@backstage/catalog-model';
13
13
  import { EntityProvider } from '@backstage/plugin-catalog-backend';
14
14
  import { EntityProviderConnection } from '@backstage/plugin-catalog-backend';
15
15
  import { GithubCredentialsProvider } from '@backstage/integration';
16
- import { GitHubIntegrationConfig } from '@backstage/integration';
16
+ import { GithubIntegrationConfig } from '@backstage/integration';
17
17
  import { LocationSpec } from '@backstage/plugin-catalog-backend';
18
18
  import { Logger } from 'winston';
19
19
  import { PluginEndpointDiscovery } from '@backstage/backend-common';
20
+ import { PluginTaskScheduler } from '@backstage/backend-tasks';
20
21
  import { ScmIntegrationRegistry } from '@backstage/integration';
21
22
  import { ScmLocationAnalyzer } from '@backstage/plugin-catalog-backend';
22
23
  import { TaskRunner } from '@backstage/backend-tasks';
23
- import { TaskScheduleDefinition } from '@backstage/backend-tasks';
24
+ import { TokenManager } from '@backstage/backend-common';
24
25
 
25
26
  /**
26
27
  * Extracts repositories out of a GitHub org.
@@ -55,6 +56,23 @@ export declare class GithubDiscoveryProcessor implements CatalogProcessor {
55
56
  readLocation(location: LocationSpec, _optional: boolean, emit: CatalogProcessorEmit): Promise<boolean>;
56
57
  }
57
58
 
59
+ /**
60
+ * @public
61
+ * @deprecated Use {@link GithubEntityProvider} instead.
62
+ */
63
+ export declare class GitHubEntityProvider implements EntityProvider {
64
+ private readonly delegate;
65
+ static fromConfig(config: Config, options: {
66
+ logger: Logger;
67
+ schedule?: TaskRunner;
68
+ scheduler?: PluginTaskScheduler;
69
+ }): GitHubEntityProvider[];
70
+ private constructor();
71
+ connect(connection: EntityProviderConnection): Promise<void>;
72
+ getProviderName(): string;
73
+ refresh(logger: Logger): Promise<void>;
74
+ }
75
+
58
76
  /**
59
77
  * Discovers catalog files located in [GitHub](https://github.com).
60
78
  * The provider will search your GitHub account and register catalog files matching the configured path
@@ -63,7 +81,7 @@ export declare class GithubDiscoveryProcessor implements CatalogProcessor {
63
81
  *
64
82
  * @public
65
83
  */
66
- export declare class GitHubEntityProvider implements EntityProvider {
84
+ export declare class GithubEntityProvider implements EntityProvider {
67
85
  private readonly config;
68
86
  private readonly logger;
69
87
  private readonly integration;
@@ -72,8 +90,9 @@ export declare class GitHubEntityProvider implements EntityProvider {
72
90
  private readonly githubCredentialsProvider;
73
91
  static fromConfig(config: Config, options: {
74
92
  logger: Logger;
75
- schedule: TaskRunner;
76
- }): GitHubEntityProvider[];
93
+ schedule?: TaskRunner;
94
+ scheduler?: PluginTaskScheduler;
95
+ }): GithubEntityProvider[];
77
96
  private constructor();
78
97
  /** {@inheritdoc @backstage/plugin-catalog-backend#EntityProvider.getProviderName} */
79
98
  getProviderName(): string;
@@ -88,26 +107,19 @@ export declare class GitHubEntityProvider implements EntityProvider {
88
107
  }
89
108
 
90
109
  /**
91
- * Registers the GitHubEntityProvider with the catalog processing extension point.
110
+ * Registers the {@link GithubEntityProvider} with the catalog processing extension point.
92
111
  *
93
112
  * @alpha
94
113
  */
95
- export declare const githubEntityProviderCatalogModule: (options?: GithubEntityProviderCatalogModuleOptions | undefined) => BackendFeature;
96
-
97
- /**
98
- * Options for {@link githubEntityProviderCatalogModule}.
99
- *
100
- * @alpha
101
- */
102
- export declare type GithubEntityProviderCatalogModuleOptions = {
103
- schedule?: TaskScheduleDefinition;
104
- };
114
+ export declare const githubEntityProviderCatalogModule: (options?: undefined) => BackendFeature;
105
115
 
106
116
  /** @public */
107
- export declare class GitHubLocationAnalyzer implements ScmLocationAnalyzer {
117
+ export declare class GithubLocationAnalyzer implements ScmLocationAnalyzer {
108
118
  private readonly catalogClient;
109
- private readonly config;
110
- constructor(options: GitHubLocationAnalyzerOptions);
119
+ private readonly githubCredentialsProvider;
120
+ private readonly integrations;
121
+ private readonly tokenManager;
122
+ constructor(options: GithubLocationAnalyzerOptions);
111
123
  supports(url: string): boolean;
112
124
  analyze({ url, catalogFilename }: AnalyzeOptions): Promise<{
113
125
  existing: {
@@ -122,9 +134,10 @@ export declare class GitHubLocationAnalyzer implements ScmLocationAnalyzer {
122
134
  }
123
135
 
124
136
  /** @public */
125
- export declare type GitHubLocationAnalyzerOptions = {
137
+ export declare type GithubLocationAnalyzerOptions = {
126
138
  config: Config;
127
139
  discovery: PluginEndpointDiscovery;
140
+ tokenManager: TokenManager;
128
141
  };
129
142
 
130
143
  /**
@@ -173,21 +186,29 @@ export declare class GithubMultiOrgReaderProcessor implements CatalogProcessor {
173
186
  private getAllOrgs;
174
187
  }
175
188
 
189
+ /**
190
+ * @public
191
+ * @deprecated Use {@link GithubOrgEntityProvider} instead.
192
+ */
193
+ export declare class GitHubOrgEntityProvider extends GithubOrgEntityProvider {
194
+ static fromConfig(config: Config, options: GitHubOrgEntityProviderOptions): GitHubOrgEntityProvider;
195
+ }
196
+
176
197
  /**
177
198
  * Ingests org data (users and groups) from GitHub.
178
199
  *
179
200
  * @public
180
201
  */
181
- export declare class GitHubOrgEntityProvider implements EntityProvider {
202
+ export declare class GithubOrgEntityProvider implements EntityProvider {
182
203
  private options;
183
204
  private readonly credentialsProvider;
184
205
  private connection?;
185
206
  private scheduleFn?;
186
- static fromConfig(config: Config, options: GitHubOrgEntityProviderOptions): GitHubOrgEntityProvider;
207
+ static fromConfig(config: Config, options: GithubOrgEntityProviderOptions): GithubOrgEntityProvider;
187
208
  constructor(options: {
188
209
  id: string;
189
210
  orgUrl: string;
190
- gitHubConfig: GitHubIntegrationConfig;
211
+ gitHubConfig: GithubIntegrationConfig;
191
212
  logger: Logger;
192
213
  githubCredentialsProvider?: GithubCredentialsProvider;
193
214
  });
@@ -206,11 +227,17 @@ export declare class GitHubOrgEntityProvider implements EntityProvider {
206
227
  }
207
228
 
208
229
  /**
209
- * Options for {@link GitHubOrgEntityProvider}.
230
+ * @public
231
+ * @deprecated Use {@link GithubOrgEntityProviderOptions} instead.
232
+ */
233
+ export declare type GitHubOrgEntityProviderOptions = GithubOrgEntityProviderOptions;
234
+
235
+ /**
236
+ * Options for {@link GithubOrgEntityProvider}.
210
237
  *
211
238
  * @public
212
239
  */
213
- export declare interface GitHubOrgEntityProviderOptions {
240
+ export declare interface GithubOrgEntityProviderOptions {
214
241
  /**
215
242
  * A unique, stable identifier for this provider.
216
243
  *
@@ -252,7 +279,7 @@ export declare interface GitHubOrgEntityProviderOptions {
252
279
  *
253
280
  * @remarks
254
281
  *
255
- * Consider using {@link GitHubOrgEntityProvider} instead.
282
+ * Consider using {@link GithubOrgEntityProvider} instead.
256
283
  *
257
284
  * @public
258
285
  */
@@ -13,14 +13,15 @@ import { Entity } from '@backstage/catalog-model';
13
13
  import { EntityProvider } from '@backstage/plugin-catalog-backend';
14
14
  import { EntityProviderConnection } from '@backstage/plugin-catalog-backend';
15
15
  import { GithubCredentialsProvider } from '@backstage/integration';
16
- import { GitHubIntegrationConfig } from '@backstage/integration';
16
+ import { GithubIntegrationConfig } from '@backstage/integration';
17
17
  import { LocationSpec } from '@backstage/plugin-catalog-backend';
18
18
  import { Logger } from 'winston';
19
19
  import { PluginEndpointDiscovery } from '@backstage/backend-common';
20
+ import { PluginTaskScheduler } from '@backstage/backend-tasks';
20
21
  import { ScmIntegrationRegistry } from '@backstage/integration';
21
22
  import { ScmLocationAnalyzer } from '@backstage/plugin-catalog-backend';
22
23
  import { TaskRunner } from '@backstage/backend-tasks';
23
- import { TaskScheduleDefinition } from '@backstage/backend-tasks';
24
+ import { TokenManager } from '@backstage/backend-common';
24
25
 
25
26
  /**
26
27
  * Extracts repositories out of a GitHub org.
@@ -55,6 +56,23 @@ export declare class GithubDiscoveryProcessor implements CatalogProcessor {
55
56
  readLocation(location: LocationSpec, _optional: boolean, emit: CatalogProcessorEmit): Promise<boolean>;
56
57
  }
57
58
 
59
+ /**
60
+ * @public
61
+ * @deprecated Use {@link GithubEntityProvider} instead.
62
+ */
63
+ export declare class GitHubEntityProvider implements EntityProvider {
64
+ private readonly delegate;
65
+ static fromConfig(config: Config, options: {
66
+ logger: Logger;
67
+ schedule?: TaskRunner;
68
+ scheduler?: PluginTaskScheduler;
69
+ }): GitHubEntityProvider[];
70
+ private constructor();
71
+ connect(connection: EntityProviderConnection): Promise<void>;
72
+ getProviderName(): string;
73
+ refresh(logger: Logger): Promise<void>;
74
+ }
75
+
58
76
  /**
59
77
  * Discovers catalog files located in [GitHub](https://github.com).
60
78
  * The provider will search your GitHub account and register catalog files matching the configured path
@@ -63,7 +81,7 @@ export declare class GithubDiscoveryProcessor implements CatalogProcessor {
63
81
  *
64
82
  * @public
65
83
  */
66
- export declare class GitHubEntityProvider implements EntityProvider {
84
+ export declare class GithubEntityProvider implements EntityProvider {
67
85
  private readonly config;
68
86
  private readonly logger;
69
87
  private readonly integration;
@@ -72,8 +90,9 @@ export declare class GitHubEntityProvider implements EntityProvider {
72
90
  private readonly githubCredentialsProvider;
73
91
  static fromConfig(config: Config, options: {
74
92
  logger: Logger;
75
- schedule: TaskRunner;
76
- }): GitHubEntityProvider[];
93
+ schedule?: TaskRunner;
94
+ scheduler?: PluginTaskScheduler;
95
+ }): GithubEntityProvider[];
77
96
  private constructor();
78
97
  /** {@inheritdoc @backstage/plugin-catalog-backend#EntityProvider.getProviderName} */
79
98
  getProviderName(): string;
@@ -89,13 +108,13 @@ export declare class GitHubEntityProvider implements EntityProvider {
89
108
 
90
109
  /* Excluded from this release type: githubEntityProviderCatalogModule */
91
110
 
92
- /* Excluded from this release type: GithubEntityProviderCatalogModuleOptions */
93
-
94
111
  /** @public */
95
- export declare class GitHubLocationAnalyzer implements ScmLocationAnalyzer {
112
+ export declare class GithubLocationAnalyzer implements ScmLocationAnalyzer {
96
113
  private readonly catalogClient;
97
- private readonly config;
98
- constructor(options: GitHubLocationAnalyzerOptions);
114
+ private readonly githubCredentialsProvider;
115
+ private readonly integrations;
116
+ private readonly tokenManager;
117
+ constructor(options: GithubLocationAnalyzerOptions);
99
118
  supports(url: string): boolean;
100
119
  analyze({ url, catalogFilename }: AnalyzeOptions): Promise<{
101
120
  existing: {
@@ -110,9 +129,10 @@ export declare class GitHubLocationAnalyzer implements ScmLocationAnalyzer {
110
129
  }
111
130
 
112
131
  /** @public */
113
- export declare type GitHubLocationAnalyzerOptions = {
132
+ export declare type GithubLocationAnalyzerOptions = {
114
133
  config: Config;
115
134
  discovery: PluginEndpointDiscovery;
135
+ tokenManager: TokenManager;
116
136
  };
117
137
 
118
138
  /**
@@ -161,21 +181,29 @@ export declare class GithubMultiOrgReaderProcessor implements CatalogProcessor {
161
181
  private getAllOrgs;
162
182
  }
163
183
 
184
+ /**
185
+ * @public
186
+ * @deprecated Use {@link GithubOrgEntityProvider} instead.
187
+ */
188
+ export declare class GitHubOrgEntityProvider extends GithubOrgEntityProvider {
189
+ static fromConfig(config: Config, options: GitHubOrgEntityProviderOptions): GitHubOrgEntityProvider;
190
+ }
191
+
164
192
  /**
165
193
  * Ingests org data (users and groups) from GitHub.
166
194
  *
167
195
  * @public
168
196
  */
169
- export declare class GitHubOrgEntityProvider implements EntityProvider {
197
+ export declare class GithubOrgEntityProvider implements EntityProvider {
170
198
  private options;
171
199
  private readonly credentialsProvider;
172
200
  private connection?;
173
201
  private scheduleFn?;
174
- static fromConfig(config: Config, options: GitHubOrgEntityProviderOptions): GitHubOrgEntityProvider;
202
+ static fromConfig(config: Config, options: GithubOrgEntityProviderOptions): GithubOrgEntityProvider;
175
203
  constructor(options: {
176
204
  id: string;
177
205
  orgUrl: string;
178
- gitHubConfig: GitHubIntegrationConfig;
206
+ gitHubConfig: GithubIntegrationConfig;
179
207
  logger: Logger;
180
208
  githubCredentialsProvider?: GithubCredentialsProvider;
181
209
  });
@@ -194,11 +222,17 @@ export declare class GitHubOrgEntityProvider implements EntityProvider {
194
222
  }
195
223
 
196
224
  /**
197
- * Options for {@link GitHubOrgEntityProvider}.
225
+ * @public
226
+ * @deprecated Use {@link GithubOrgEntityProviderOptions} instead.
227
+ */
228
+ export declare type GitHubOrgEntityProviderOptions = GithubOrgEntityProviderOptions;
229
+
230
+ /**
231
+ * Options for {@link GithubOrgEntityProvider}.
198
232
  *
199
233
  * @public
200
234
  */
201
- export declare interface GitHubOrgEntityProviderOptions {
235
+ export declare interface GithubOrgEntityProviderOptions {
202
236
  /**
203
237
  * A unique, stable identifier for this provider.
204
238
  *
@@ -240,7 +274,7 @@ export declare interface GitHubOrgEntityProviderOptions {
240
274
  *
241
275
  * @remarks
242
276
  *
243
- * Consider using {@link GitHubOrgEntityProvider} instead.
277
+ * Consider using {@link GithubOrgEntityProvider} instead.
244
278
  *
245
279
  * @public
246
280
  */