diff --git a/options.json b/options.json index e74bf95..7742d4f 100644 --- a/options.json +++ b/options.json @@ -15775,9 +15775,5 @@ ] } }, - "required": [ - "functions", - "images" - ], "type": "object" } \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 074135c..bd7de09 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@hybridless/hybridless", - "version": "0.1.11", + "version": "0.1.12", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@hybridless/hybridless", - "version": "0.1.11", + "version": "0.1.12", "license": "GNU GPLv3", "dependencies": { "@babel/core": "^7.23.7", diff --git a/package.json b/package.json index 86d0837..17e186a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@hybridless/hybridless", - "version": "0.1.11", + "version": "0.1.13", "description": "", "main": "index.js", "scripts": { diff --git a/src/assets/job-batch/Dockerfile-Job-Nodejs18 b/src/assets/job-batch/Dockerfile-Job-Nodejs18 index 305f306..05c2a2c 100644 --- a/src/assets/job-batch/Dockerfile-Job-Nodejs18 +++ b/src/assets/job-batch/Dockerfile-Job-Nodejs18 @@ -2,7 +2,7 @@ FROM ghcr.io/hybridless/node:18-alpine # Copy files COPY /usr/src/app/ /usr/src/app/ -COPY proxy.js /usr/src/hybridless-runtime/proxy.js +COPY proxy.js /usr/src/hybridless-runtime/proxy.mjs # Set the working directory WORKDIR /usr/src/app diff --git a/src/core/DepsManager.ts b/src/core/DepsManager.ts index fa53e53..5dbf9eb 100644 --- a/src/core/DepsManager.ts +++ b/src/core/DepsManager.ts @@ -11,6 +11,7 @@ export default class DepsManager { private requiresECSRolePermission: boolean; private requiresECS: boolean; private requiresMvn: boolean; + private requiresGo: boolean; private requiresLogsRetention: boolean; // private readonly plugin: Hybridless; @@ -24,12 +25,14 @@ export default class DepsManager { public enableECSPlugin(): void { this.requiresECS = true; } public enableECSRolePermission(): void { this.requiresECSRolePermission = true; } public enableMvn(): void { this.requiresMvn = true; } + public enableGo(): void { this.requiresGo = true; } // public isLogsRetentionRequired(): boolean { return this.requiresWebpack; } public isWebpackRequired(): boolean { return this.requiresWebpack; } public isECSRolePermissionRequired(): boolean { return this.requiresECSRolePermission; } public isECSRequired(): boolean { return this.requiresECS; } public isMvnRequired(): boolean { return this.requiresMvn; } + public isGoRequired(): boolean { return this.requiresGo; } // public async loadDependecies(): BPromise { const pluginsList = this.plugin.service.plugins; @@ -55,8 +58,9 @@ export default class DepsManager { // // .then(() => (!this.depManager.isWebpackRequired() ? BPromise.resolve() : this.serverless.pluginManager.spawn('webpack:compile'))) // // .then(() => (!this.depManager.isWebpackRequired() ? BPromise.resolve() : this.serverless.pluginManager.spawn('webpack:package'))); // } - return BPromise.resolve() - .then(() => (!this.isMvnRequired() ? BPromise.resolve() : this._compileJava())); + if (this.isMvnRequired()) return BPromise.resolve().then(() => this._compileJava()); + if (this.isGoRequired()) return BPromise.resolve().then(() => this._compileGo()); + return BPromise.resolve(); } /* private */ private _isPluginInstalledServerless(pluginsList: Array, dependency: string): boolean { @@ -74,6 +78,17 @@ export default class DepsManager { } }); } + private async _compileGo(): BPromise { + return new BPromise(async (resolve, reject) => { + this.plugin.logger.info('Go is required to compile GoLang code, compiling...'); + const exec = await this._runCommand(Globals.Go_Build_Command); + if (exec && exec.stderr && exec.stderr.toLowerCase().indexOf('error')) reject(exec.stderr); + else { + // if (exec && exec.stdout) this.plugin.logger.debug(exec.stdout); -- Maven output seems huge enough to desconsider it and just output on errors + resolve(); + } + }); + } private async _runCommand(command, params = []): BPromise { return new BPromise(async (resolve, reject) => { if (!params) params = []; diff --git a/src/core/Globals.ts b/src/core/Globals.ts index ba14d4d..975119c 100644 --- a/src/core/Globals.ts +++ b/src/core/Globals.ts @@ -12,9 +12,10 @@ export default class Globals { //Dependecies public static Deps_Webpack = 'serverless-webpack'; public static Deps_ECS = '@hybridless/serverless-ecs-plugin'; - public static Deps_LambdaLogsRetention = 'serverless-plugin-log-retention'; + public static Deps_LambdaLogsRetention = '@hybridless/serverless-plugin-log-retention'; //Java support public static Mvn_Build_Command = 'mvn clean install'; + public static Go_Build_Command = 'go mod tidy'; //Defaults public static DefaultLogsMultilinePattern = '(([a-zA-Z0-9\-]* \[[a-zA-Za-]*\] )|(\[[a-zA-Za -]*\] ))'; public static DefaultHealthCheckInterval = 15; diff --git a/src/options.ts b/src/options.ts index 7fef155..543ffbc 100644 --- a/src/options.ts +++ b/src/options.ts @@ -1,7 +1,7 @@ //Plugin export interface OPlugin { - functions: { [key: string]: OFunction } | { [key: string]: OFunction }[]; - images: { [key: string]: OImage } | { [key: string]: OImage }[]; + functions?: { [key: string]: OFunction } | { [key: string]: OFunction }[]; + images?: { [key: string]: OImage } | { [key: string]: OImage }[]; disableWebpack?: boolean; buildConcurrency?: number; tags?: { [key: string]: any } | { [key: string]: any }[]; @@ -75,6 +75,7 @@ export enum OFunctionHttpdTaskRuntime { nodejs18 = 'nodejs18', php5 = 'php5', php7 = 'php7', + go = 'go', container = 'container' }; export enum OFunctionProcessTaskRuntime { diff --git a/src/resources/BaseEvents/FunctionContainerBaseEvent.ts b/src/resources/BaseEvents/FunctionContainerBaseEvent.ts index 850573e..50dc4a0 100644 --- a/src/resources/BaseEvents/FunctionContainerBaseEvent.ts +++ b/src/resources/BaseEvents/FunctionContainerBaseEvent.ts @@ -46,6 +46,7 @@ export class FunctionContainerBaseEvent extends FunctionBaseEvent { if (this.event.runtime && this.event.runtime.toLowerCase().indexOf('java') != -1) this.plugin.depManager.enableMvn(); + if (this.event.runtime && this.event.runtime.toLowerCase().indexOf('go') != -1) this.plugin.depManager.enableGo(); if (this.event.runtime && this.event.runtime.toLowerCase().indexOf('node') != -1 && !this.plugin.options.disableWebpack) this.plugin.depManager.enableWebpack(); if (this.event.eventType != OFunctionEventType.lambda && this.event.eventType != OFunctionEventType.lambdaContainer) { this.plugin.depManager.enableECSPlugin(); diff --git a/src/resources/FunctionLambdaEvent.ts b/src/resources/FunctionLambdaEvent.ts index 29956b9..cd86c3c 100644 --- a/src/resources/FunctionLambdaEvent.ts +++ b/src/resources/FunctionLambdaEvent.ts @@ -29,6 +29,7 @@ export class FunctionLambdaEvent extends FunctionBaseEvent return new BPromise(async (resolve, reject) => { if (this.event.runtime && this.event.runtime.toLowerCase().indexOf('node') != -1 && !this.plugin.options.disableWebpack) this.plugin.depManager.enableWebpack(); if (this.event.runtime && this.event.runtime.toLowerCase().indexOf('java') != -1 && !this.plugin.options.disableWebpack) this.plugin.depManager.enableMvn(); + if (this.event.runtime && this.event.runtime.toLowerCase().indexOf('go') != -1 && !this.plugin.options.disableWebpack) this.plugin.depManager.enableGo(); if (this.event.logsRetentionInDays) this.plugin.depManager.enableLogsRetention(); resolve(); });