remove config baseUrl
Signed-off-by: Andrew Johnson <ajohnson@gocardless.com>
This commit is contained in:
@@ -23,16 +23,7 @@ export AUTH_CLIENT_SECRET={{YOUR_CLIENT_SECRET}}
|
||||
yarn add @backstage/plugin-github-deployments
|
||||
```
|
||||
|
||||
3. If you use GitHub enterprise then set the host in `app-config.yaml`.
|
||||
|
||||
```yaml
|
||||
# app-config.yaml
|
||||
integrations:
|
||||
github:
|
||||
- host: { { YOUR_GITHUB_HOST_URL } }
|
||||
```
|
||||
|
||||
4. Add the plugin to the app
|
||||
3. Add the plugin to the app
|
||||
|
||||
```typescript
|
||||
// packages/app/src/plugins.ts
|
||||
@@ -40,7 +31,7 @@ integrations:
|
||||
export { plugin as GithubDeployments } from '@backstage/plugin-github-deployments';
|
||||
```
|
||||
|
||||
5. Add the `EntityGithubDeploymentsCard` to the EntityPage:
|
||||
4. Add the `EntityGithubDeploymentsCard` to the EntityPage:
|
||||
|
||||
```typescript
|
||||
// packages/app/src/components/catalog/EntityPage.tsx
|
||||
@@ -58,7 +49,7 @@ const OverviewContent = () => (
|
||||
);
|
||||
```
|
||||
|
||||
6. Add the `github.com/project-slug` annotation to your `catalog-info.yaml` file:
|
||||
5. Add the `github.com/project-slug` annotation to your `catalog-info.yaml` file:
|
||||
|
||||
```yaml
|
||||
apiVersion: backstage.io/v1alpha1
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { ConfigApi, createApiRef, OAuthApi } from '@backstage/core';
|
||||
import { createApiRef, OAuthApi } from '@backstage/core';
|
||||
import { graphql } from '@octokit/graphql';
|
||||
|
||||
export type GithubDeployment = {
|
||||
@@ -40,7 +40,6 @@ export const githubDeploymentsApiRef = createApiRef<GithubDeploymentsApi>({
|
||||
});
|
||||
|
||||
export type Options = {
|
||||
configApi: ConfigApi;
|
||||
githubAuthApi: OAuthApi;
|
||||
};
|
||||
|
||||
@@ -71,31 +70,20 @@ export type QueryResponse = {
|
||||
};
|
||||
|
||||
export class GithubDeploymentsApiClient implements GithubDeploymentsApi {
|
||||
private readonly configApi: ConfigApi;
|
||||
private readonly githubAuthApi: OAuthApi;
|
||||
|
||||
constructor(options: Options) {
|
||||
this.configApi = options.configApi;
|
||||
this.githubAuthApi = options.githubAuthApi;
|
||||
}
|
||||
|
||||
private getBaseUrl() {
|
||||
const providerConfigs =
|
||||
this.configApi.getOptionalConfigArray('integrations.github') ?? [];
|
||||
const targetProviderConfig = providerConfigs[0];
|
||||
return targetProviderConfig?.getOptionalString('apiBaseUrl');
|
||||
}
|
||||
|
||||
async listDeployments(options: {
|
||||
owner: string;
|
||||
repo: string;
|
||||
last: number;
|
||||
}): Promise<GithubDeployment[]> {
|
||||
const token = await this.githubAuthApi.getAccessToken(['repo']);
|
||||
const baseUrl = this.getBaseUrl() || 'https://api.github.com';
|
||||
|
||||
const graphQLWithAuth = graphql.defaults({
|
||||
baseUrl,
|
||||
headers: {
|
||||
authorization: `token ${token}`,
|
||||
},
|
||||
|
||||
@@ -50,10 +50,7 @@ const githubAuthApi: OAuthApi = {
|
||||
const apis = ApiRegistry.from([
|
||||
[configApiRef, configApi],
|
||||
[errorApiRef, errorApiMock],
|
||||
[
|
||||
githubDeploymentsApiRef,
|
||||
new GithubDeploymentsApiClient({ configApi, githubAuthApi }),
|
||||
],
|
||||
[githubDeploymentsApiRef, new GithubDeploymentsApiClient({ githubAuthApi })],
|
||||
]);
|
||||
|
||||
describe('github-deployments', () => {
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
import {
|
||||
configApiRef,
|
||||
createApiFactory,
|
||||
createComponentExtension,
|
||||
createPlugin,
|
||||
@@ -27,9 +26,9 @@ export const githubDeploymentsPlugin = createPlugin({
|
||||
apis: [
|
||||
createApiFactory({
|
||||
api: githubDeploymentsApiRef,
|
||||
deps: { configApi: configApiRef, githubAuthApi: githubAuthApiRef },
|
||||
factory: ({ configApi, githubAuthApi }) =>
|
||||
new GithubDeploymentsApiClient({ configApi, githubAuthApi }),
|
||||
deps: { githubAuthApi: githubAuthApiRef },
|
||||
factory: ({ githubAuthApi }) =>
|
||||
new GithubDeploymentsApiClient({ githubAuthApi }),
|
||||
}),
|
||||
],
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user