refactor: Enable lazy loading for images in BlogPostUtil and remove unnecessary whitespace in Copilot/Init.ts

This commit is contained in:
Simon Larsen
2024-09-05 14:30:30 +01:00
parent 5bfe38736e
commit e7377f6c8f
17 changed files with 98 additions and 18 deletions

View File

@@ -6,6 +6,11 @@
FROM node:21.7.3-alpine3.18
RUN mkdir /tmp/npm && chmod 2777 /tmp/npm && chown 1000:1000 /tmp/npm && npm config set cache /tmp/npm --global
RUN npm config set fetch-retries 5
RUN npm config set fetch-retry-mintimeout 100000
RUN npm config set fetch-retry-maxtimeout 600000
ARG GIT_SHA
ARG APP_VERSION

View File

@@ -6,6 +6,11 @@
FROM node:21.7.3-alpine3.18
RUN mkdir /tmp/npm && chmod 2777 /tmp/npm && chown 1000:1000 /tmp/npm && npm config set cache /tmp/npm --global
RUN npm config set fetch-retries 5
RUN npm config set fetch-retry-mintimeout 100000
RUN npm config set fetch-retry-maxtimeout 600000
ARG GIT_SHA
ARG APP_VERSION

View File

@@ -6,6 +6,11 @@
FROM node:21.2-alpine3.18
RUN mkdir /tmp/npm && chmod 2777 /tmp/npm && chown 1000:1000 /tmp/npm && npm config set cache /tmp/npm --global
RUN npm config set fetch-retries 5
RUN npm config set fetch-retry-mintimeout 100000
RUN npm config set fetch-retry-maxtimeout 600000
ARG GIT_SHA
ARG APP_VERSION

View File

@@ -18,10 +18,8 @@ import { CompressionAlgorithm } from "@opentelemetry/otlp-exporter-base";
import { Resource } from "@opentelemetry/resources";
import {
BatchLogRecordProcessor,
ConsoleLogRecordExporter,
LoggerProvider,
LogRecordProcessor,
SimpleLogRecordProcessor,
} from "@opentelemetry/sdk-logs";
import {
MeterProvider,
@@ -167,9 +165,7 @@ export default class Telemetry {
}),
});
let logRecordProcessor: LogRecordProcessor = new SimpleLogRecordProcessor(
new ConsoleLogRecordExporter(),
);
let logRecordProcessor: LogRecordProcessor | null = null;
if (this.getOltpLogsEndpoint() && hasHeaders) {
const logExporter: OTLPLogExporter = new OTLPLogExporter({
@@ -181,19 +177,21 @@ export default class Telemetry {
logRecordProcessor = new BatchLogRecordProcessor(logExporter);
}
this.loggerProvider.addLogRecordProcessor(logRecordProcessor);
if (logRecordProcessor) {
this.loggerProvider.addLogRecordProcessor(logRecordProcessor);
}
logs.setGlobalLoggerProvider(this.loggerProvider);
const nodeSdkConfiguration: Partial<opentelemetry.NodeSDKConfiguration> =
{
idGenerator: new AWSXRayIdGenerator(),
instrumentations: [],
resource: this.getResource({
serviceName: data.serviceName,
}),
autoDetectResources: true,
};
{
idGenerator: new AWSXRayIdGenerator(),
instrumentations: [],
resource: this.getResource({
serviceName: data.serviceName,
}),
autoDetectResources: true,
};
if (traceExporter) {
nodeSdkConfiguration.traceExporter = traceExporter;

View File

@@ -6,6 +6,11 @@
FROM node:22.3.0
RUN mkdir /tmp/npm && chmod 2777 /tmp/npm && chown 1000:1000 /tmp/npm && npm config set cache /tmp/npm --global
RUN npm config set fetch-retries 5
RUN npm config set fetch-retry-mintimeout 100000
RUN npm config set fetch-retry-maxtimeout 600000
ARG GIT_SHA
ARG APP_VERSION

View File

@@ -27,6 +27,9 @@ let currentFixCount: number = 1;
const init: PromiseVoidFunction = async (): Promise<void> => {
// check if copilot is disabled.
debugger;
if (GetIsCopilotDisabled()) {
logger.info("Copilot is disabled. Exiting.");
ProcessUtil.haltProcessWithSuccess();
@@ -49,6 +52,19 @@ const init: PromiseVoidFunction = async (): Promise<void> => {
const servicesToImprove: ServiceCopilotCodeRepository[] =
await ServiceRepositoryUtil.getServicesToImprove();
logger.debug(`Found ${servicesToImprove.length} services to improve.`);
// if no services to improve, then exit.
if (servicesToImprove.length === 0) {
logger.info("No services to improve. Exiting.");
ProcessUtil.haltProcessWithSuccess();
}
for (const serviceToImprove of servicesToImprove) {
logger.debug(`- ${serviceToImprove.serviceCatalog!.name}`);
}
await cloneRepository({
codeRepositoryResult,
});
@@ -207,8 +223,8 @@ const setUpRepository: PromiseVoidFunction = async (): Promise<void> => {
logger.info(
"Repository setup PR created - #" +
pullRequest.pullRequestNumber +
". Please megre this PR to continue using Copilot. Exiting..",
pullRequest.pullRequestNumber +
". Please megre this PR to continue using Copilot. Exiting..",
);
ProcessUtil.haltProcessWithSuccess();

View File

@@ -290,6 +290,8 @@ export default class CodeRepositoryUtil {
});
this.folderNameOfClonedRepository = folderName;
logger.debug(`Repository cloned to ${repoLocalPath}/${folderName}`);
}
public static async executeScript(data: { script: string }): Promise<string> {

View File

@@ -19,7 +19,7 @@ import ObjectID from "Common/Types/ObjectID";
export default class ServiceRepositoryUtil {
public static codeRepositoryResult: CodeRepositoryResult | null = null;
public static servicesToImprove: Array<ServiceCopilotCodeRepository> = [];
public static servicesToImprove: Array<ServiceCopilotCodeRepository> | null = null;
public static setCodeRepositoryResult(data: {
codeRepositoryResult: CodeRepositoryResult;
@@ -103,7 +103,7 @@ export default class ServiceRepositoryUtil {
const { serviceCatalogId } = data;
const serviceRepository: ServiceCopilotCodeRepository | undefined =
ServiceRepositoryUtil.servicesToImprove.find(
(await ServiceRepositoryUtil.getServicesToImprove()).find(
(serviceRepository: ServiceCopilotCodeRepository) => {
return (
serviceRepository.serviceCatalog!.id?.toString() ===

View File

@@ -6,6 +6,11 @@
FROM node:21.7.3-alpine3.18
RUN mkdir /tmp/npm && chmod 2777 /tmp/npm && chown 1000:1000 /tmp/npm && npm config set cache /tmp/npm --global
RUN npm config set fetch-retries 5
RUN npm config set fetch-retry-mintimeout 100000
RUN npm config set fetch-retry-maxtimeout 600000
ARG GIT_SHA
ARG APP_VERSION

View File

@@ -9,6 +9,11 @@
FROM node:21.6
RUN mkdir /tmp/npm && chmod 2777 /tmp/npm && chown 1000:1000 /tmp/npm && npm config set cache /tmp/npm --global
RUN npm config set fetch-retries 5
RUN npm config set fetch-retry-mintimeout 100000
RUN npm config set fetch-retry-maxtimeout 600000
ARG GIT_SHA
ARG APP_VERSION

View File

@@ -2,6 +2,11 @@ FROM node:21.7.3-alpine3.18
RUN mkdir /tmp/npm && chmod 2777 /tmp/npm && chown 1000:1000 /tmp/npm && npm config set cache /tmp/npm --global
RUN npm config set fetch-retries 5
RUN npm config set fetch-retry-mintimeout 100000
RUN npm config set fetch-retry-maxtimeout 600000
ARG GIT_SHA
ARG APP_VERSION

View File

@@ -6,6 +6,11 @@
FROM node:21.7.3-alpine3.18
RUN mkdir /tmp/npm && chmod 2777 /tmp/npm && chown 1000:1000 /tmp/npm && npm config set cache /tmp/npm --global
RUN npm config set fetch-retries 5
RUN npm config set fetch-retry-mintimeout 100000
RUN npm config set fetch-retry-maxtimeout 600000
ARG GIT_SHA
ARG APP_VERSION

View File

@@ -6,6 +6,11 @@
FROM node:21.6-alpine3.18
RUN mkdir /tmp/npm && chmod 2777 /tmp/npm && chown 1000:1000 /tmp/npm && npm config set cache /tmp/npm --global
RUN npm config set fetch-retries 5
RUN npm config set fetch-retry-mintimeout 100000
RUN npm config set fetch-retry-maxtimeout 600000
ARG GIT_SHA
ARG APP_VERSION

View File

@@ -6,6 +6,11 @@
FROM node:22.5
RUN mkdir /tmp/npm && chmod 2777 /tmp/npm && chown 1000:1000 /tmp/npm && npm config set cache /tmp/npm --global
RUN npm config set fetch-retries 5
RUN npm config set fetch-retry-mintimeout 100000
RUN npm config set fetch-retry-maxtimeout 600000
ARG GIT_SHA
ARG APP_VERSION

View File

@@ -6,6 +6,11 @@
FROM node:21.7.3-alpine3.18
RUN mkdir /tmp/npm && chmod 2777 /tmp/npm && chown 1000:1000 /tmp/npm && npm config set cache /tmp/npm --global
RUN npm config set fetch-retries 5
RUN npm config set fetch-retry-mintimeout 100000
RUN npm config set fetch-retry-maxtimeout 600000
ARG GIT_SHA
ARG APP_VERSION

View File

@@ -6,6 +6,10 @@
FROM node:21.7.3-alpine3.18
RUN mkdir /tmp/npm && chmod 2777 /tmp/npm && chown 1000:1000 /tmp/npm && npm config set cache /tmp/npm --global
RUN npm config set fetch-retries 5
RUN npm config set fetch-retry-mintimeout 100000
RUN npm config set fetch-retry-maxtimeout 600000
ARG GIT_SHA
ARG APP_VERSION

View File

@@ -1,6 +1,11 @@
FROM node:21.7.3-alpine3.18
RUN mkdir /tmp/npm && chmod 2777 /tmp/npm && chown 1000:1000 /tmp/npm && npm config set cache /tmp/npm --global
RUN npm config set fetch-retries 5
RUN npm config set fetch-retry-mintimeout 100000
RUN npm config set fetch-retry-maxtimeout 600000
# Install bash.
RUN apk add bash && apk add curl