From ab9d6f5eea71225f38e609367ee099277f249777 Mon Sep 17 00:00:00 2001 From: Andrew Kahr <22359829+AndrewKahr@users.noreply.github.com> Date: Tue, 14 Nov 2023 19:27:21 -0800 Subject: [PATCH] Allow customization of container registry and image version --- action.yml | 8 ++++++++ dist/index.js | Bin 22176171 -> 22176646 bytes dist/index.js.map | Bin 14646882 -> 14647413 bytes src/model/build-parameters.ts | 4 ++++ src/model/image-tag.test.ts | 15 +++++++++++---- src/model/image-tag.ts | 17 +++++++++++------ src/model/input.ts | 8 ++++++++ 7 files changed, 42 insertions(+), 10 deletions(-) diff --git a/action.yml b/action.yml index 2ada25e6..42778847 100644 --- a/action.yml +++ b/action.yml @@ -124,6 +124,14 @@ inputs: 'Isolation mode to use for the docker container. Can be one of process, hyperv, or default. Default will pick the default mode as described by Microsoft where server versions use process and desktop versions use hyperv. Only applicable on Windows' + containerRegistryRepository: + required: false + default: 'unityci/editor' + description: 'Container registry url to pull image from. Only applicable if customImage is not set.' + containerRegistryImageVersion: + required: false + default: '3' + description: 'Container registry image version. Only applicable if customImage is not set.' allowDirtyBuild: required: false default: '' diff --git a/dist/index.js b/dist/index.js index 1753a2900e0c068a5804cf2cbbf69b26403e890d..4ddfc66b93a3338291fae99c674ab3e327341638 100644 GIT binary patch delta 1843 zcmaLXX;hR|9LMo9_#iTXf&vP-pn?pFBZ%mLAfmY7f<|eZ8|sK-Fhj#kiJDoOR90qF zP5WkPMWK~7S)!Pg(Y~jpR+ei~W?5=#eSdX0d7^yr`M!AWz5jF1eeu+8Ycwz4-e_KL zvH9zk#fIjV*vlMM9(Q$#z0y_X@VMO7If)KurPnh(!#dkOr_@{SvCeWiJ*5t(-Tkl4 zzWnU?h~{ra6{Tf%UwBqrY>VxGFJ)xLEVbBbEH)E@&?;cD8GEgHX^AaP{BxWCSo~|; zWV^e{;c})0%wK}jcib@L2QR3LqkQD5L|IB1+} zuD@V|k>m^89U9jB1e4t5{)Rf^|6ahqDmOUVH{(!<|46M7sgp6yC(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(jXfwrG4`Sa`>-FSkWhvLD91q@!eJc2 zQB>dIx1OuvZ8AjCL3a&!NHC)FH)Z!*?;Wp|}k2|=F zduYIYG~xl8@DPvCjK_F_r+9`IJjV;X#4Ef;E8gHO-r+sk@Btt3Nfuo`yG8#8Cr_v6 diff --git a/src/model/build-parameters.ts b/src/model/build-parameters.ts index 4cd8a523..a91e165e 100644 --- a/src/model/build-parameters.ts +++ b/src/model/build-parameters.ts @@ -44,6 +44,8 @@ class BuildParameters { public dockerCpuLimit!: string; public dockerMemoryLimit!: string; public dockerIsolationMode!: string; + public containerRegistryRepository!: string; + public containerRegistryImageVersion!: string; public customParameters!: string; public sshAgent!: string; @@ -170,6 +172,8 @@ class BuildParameters { dockerCpuLimit: Input.dockerCpuLimit, dockerMemoryLimit: Input.dockerMemoryLimit, dockerIsolationMode: Input.dockerIsolationMode, + containerRegistryRepository: Input.containerRegistryRepository, + containerRegistryImageVersion: Input.containerRegistryImageVersion, providerStrategy: CloudRunnerOptions.providerStrategy, buildPlatform: CloudRunnerOptions.buildPlatform, kubeConfig: CloudRunnerOptions.kubeConfig, diff --git a/src/model/image-tag.test.ts b/src/model/image-tag.test.ts index 77934e5d..47adf65e 100644 --- a/src/model/image-tag.test.ts +++ b/src/model/image-tag.test.ts @@ -5,11 +5,11 @@ describe('ImageTag', () => { editorVersion: '2099.9.f9f9', targetPlatform: 'Test', builderPlatform: '', + containerRegistryRepository: 'unityci/editor', + containerRegistryImageVersion: '3', }; const defaults = { - repository: 'unityci', - name: 'editor', image: 'unityci/editor', }; @@ -21,8 +21,7 @@ describe('ImageTag', () => { it('accepts parameters and sets the right properties', () => { const image = new ImageTag(testImageParameters); - expect(image.repository).toStrictEqual('unityci'); - expect(image.name).toStrictEqual('editor'); + expect(image.repository).toStrictEqual('unityci/editor'); expect(image.editorVersion).toStrictEqual(testImageParameters.editorVersion); expect(image.targetPlatform).toStrictEqual(testImageParameters.targetPlatform); expect(image.builderPlatform).toStrictEqual(testImageParameters.builderPlatform); @@ -53,6 +52,8 @@ describe('ImageTag', () => { const image = new ImageTag({ editorVersion: '2099.1.1111', targetPlatform: testImageParameters.targetPlatform, + containerRegistryRepository: 'unityci/editor', + containerRegistryImageVersion: '3', }); switch (process.platform) { case 'win32': @@ -68,6 +69,8 @@ describe('ImageTag', () => { editorVersion: '2099.1.1111', targetPlatform: testImageParameters.targetPlatform, customImage: `${defaults.image}:2099.1.1111@347598437689743986`, + containerRegistryRepository: 'unityci/editor', + containerRegistryImageVersion: '3', }); expect(image.toString()).toStrictEqual(image.customImage); @@ -77,6 +80,8 @@ describe('ImageTag', () => { const image = new ImageTag({ editorVersion: '2019.2.11f1', targetPlatform: 'WebGL', + containerRegistryRepository: 'unityci/editor', + containerRegistryImageVersion: '3', }); switch (process.platform) { @@ -93,6 +98,8 @@ describe('ImageTag', () => { const image = new ImageTag({ editorVersion: '2019.2.11f1', targetPlatform: 'NoTarget', + containerRegistryRepository: 'unityci/editor', + containerRegistryImageVersion: '3', }); switch (process.platform) { diff --git a/src/model/image-tag.ts b/src/model/image-tag.ts index 35b4bbeb..cf484708 100644 --- a/src/model/image-tag.ts +++ b/src/model/image-tag.ts @@ -2,7 +2,6 @@ import Platform from './platform'; class ImageTag { public repository: string; - public name: string; public cloudRunnerBuilderPlatform!: string; public editorVersion: string; public targetPlatform: string; @@ -12,7 +11,14 @@ class ImageTag { public imagePlatformPrefix: string; constructor(imageProperties: { [key: string]: string }) { - const { editorVersion, targetPlatform, customImage, cloudRunnerBuilderPlatform } = imageProperties; + const { + editorVersion, + targetPlatform, + customImage, + cloudRunnerBuilderPlatform, + containerRegistryRepository, + containerRegistryImageVersion, + } = imageProperties; if (!ImageTag.versionPattern.test(editorVersion)) { throw new Error(`Invalid version "${editorVersion}".`); @@ -23,8 +29,7 @@ class ImageTag { this.customImage = customImage; // Or - this.repository = 'unityci'; - this.name = 'editor'; + this.repository = containerRegistryRepository; this.editorVersion = editorVersion; this.targetPlatform = targetPlatform; this.cloudRunnerBuilderPlatform = cloudRunnerBuilderPlatform; @@ -33,7 +38,7 @@ class ImageTag { this.imagePlatformPrefix = ImageTag.getImagePlatformPrefixes( isCloudRunnerLocal ? process.platform : cloudRunnerBuilderPlatform, ); - this.imageRollingVersion = 3; // Will automatically roll to the latest non-breaking version. + this.imageRollingVersion = Number(containerRegistryImageVersion); // Will automatically roll to the latest non-breaking version. } static get versionPattern(): RegExp { @@ -156,7 +161,7 @@ class ImageTag { } get image(): string { - return `${this.repository}/${this.name}`.replace(/^\/+/, ''); + return `${this.repository}`.replace(/^\/+/, ''); } toString(): string { diff --git a/src/model/input.ts b/src/model/input.ts index 94a0f2b4..7733ea1f 100644 --- a/src/model/input.ts +++ b/src/model/input.ts @@ -256,6 +256,14 @@ class Input { return Input.getInput('dockerIsolationMode') || 'default'; } + static get containerRegistryRepository(): string { + return Input.getInput('containerRegistryUrl')!; + } + + static get containerRegistryImageVersion(): string { + return Input.getInput('containerRegistryImageVersion')!; + } + public static ToEnvVarFormat(input: string) { if (input.toUpperCase() === input) { return input;