Fix feedback
Signed-off-by: Martina Iglesias Fernandez <martina@roadie.io>
This commit is contained in:
+3
-3
@@ -151,9 +151,9 @@ integrations:
|
||||
token:
|
||||
$env: AZURE_TOKEN
|
||||
# googleGcs:
|
||||
# clientEmail:
|
||||
# $env: GCS_CLIENT_EMAIL
|
||||
# privateKey: 'example@example.com'
|
||||
# clientEmail: 'example@example.com'
|
||||
# privateKey:
|
||||
# $env: GCS_PRIVATE_KEY
|
||||
|
||||
catalog:
|
||||
rules:
|
||||
|
||||
@@ -22,7 +22,10 @@ import {
|
||||
UrlReader,
|
||||
} from './types';
|
||||
import getRawBody from 'raw-body';
|
||||
import { readGoogleGcsIntegrationConfig } from '@backstage/integration';
|
||||
import {
|
||||
GoogleGcsIntegrationConfig,
|
||||
readGoogleGcsIntegrationConfig,
|
||||
} from '@backstage/integration';
|
||||
|
||||
const GOOGLE_GCS_HOST = 'storage.cloud.google.com';
|
||||
|
||||
@@ -53,7 +56,7 @@ export class GoogleGcsUrlReader implements UrlReader {
|
||||
);
|
||||
let storage: Storage;
|
||||
if (!gcsConfig.clientEmail || !gcsConfig.privateKey) {
|
||||
logger.warn(
|
||||
logger.info(
|
||||
'googleGcs credentials not found in config. Using default credentials provider.',
|
||||
);
|
||||
storage = new Storage();
|
||||
@@ -65,12 +68,15 @@ export class GoogleGcsUrlReader implements UrlReader {
|
||||
},
|
||||
});
|
||||
}
|
||||
const reader = new GoogleGcsUrlReader(storage);
|
||||
const reader = new GoogleGcsUrlReader(gcsConfig, storage);
|
||||
const predicate = (url: URL) => url.host === GOOGLE_GCS_HOST;
|
||||
return [{ reader, predicate }];
|
||||
};
|
||||
|
||||
constructor(private readonly storage: Storage) {}
|
||||
constructor(
|
||||
private readonly integration: GoogleGcsIntegrationConfig,
|
||||
private readonly storage: Storage,
|
||||
) {}
|
||||
|
||||
async read(url: string): Promise<Buffer> {
|
||||
try {
|
||||
@@ -93,6 +99,7 @@ export class GoogleGcsUrlReader implements UrlReader {
|
||||
}
|
||||
|
||||
toString() {
|
||||
return `gcs{host=${GOOGLE_GCS_HOST},authed=true}}`;
|
||||
const key = this.integration.privateKey;
|
||||
return `googleGcs{host=${GOOGLE_GCS_HOST},authed=${Boolean(key)}}`;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,15 +42,12 @@ export function readGoogleGcsIntegrationConfig(
|
||||
return {};
|
||||
}
|
||||
|
||||
if (!config.has('clientEmail') || !config.has('privateKey')) {
|
||||
if (!config.has('clientEmail') && !config.has('privateKey')) {
|
||||
return {};
|
||||
}
|
||||
|
||||
const privateKey = config
|
||||
.getOptionalString('privateKey')
|
||||
?.split('\\n')
|
||||
.join('\n');
|
||||
const privateKey = config.getString('privateKey').split('\\n').join('\n');
|
||||
|
||||
const clientEmail = config.getOptionalString('clientEmail');
|
||||
const clientEmail = config.getString('clientEmail');
|
||||
return { clientEmail: clientEmail, privateKey: privateKey };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user