From 2577009bcb64af46af40fa34764e581a60538457 Mon Sep 17 00:00:00 2001 From: Ganeshrockz Date: Thu, 15 Apr 2021 11:35:18 +0530 Subject: [PATCH] Adding ; as delimiter --- __tests__/run.test.ts | 21 +++++++++++++++++++++ src/input-parameters.ts | 2 +- src/run.ts | 2 +- 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/__tests__/run.test.ts b/__tests__/run.test.ts index 1dd795f0..74261649 100644 --- a/__tests__/run.test.ts +++ b/__tests__/run.test.ts @@ -294,6 +294,27 @@ test("run() - deploy - Manifests provided by both new line and comma as a delimi await expect(action.run()).resolves.not.toThrow(); }); +test("run() - deploy - Manifests provided by both new line and comma and semi-colon as a delimiter", async () => { + const kubectlVersion = 'v1.18.0' + coreMock.getInput = jest.fn().mockImplementation((name) => { + if (name == 'manifests') { + return "bg-smi.yml\nbg.yml,deployment.yml;bg.yml"; + } + if (name == 'action') { + return 'deploy'; + } + return kubectlVersion; + }); + coreMock.setFailed = jest.fn(); + toolCacheMock.find = jest.fn().mockReturnValue(undefined); + toolCacheMock.downloadTool = jest.fn().mockReturnValue('downloadpath'); + toolCacheMock.cacheFile = jest.fn().mockReturnValue('cachepath'); + fileUtility.chmodSync = jest.fn(); + + //Invoke and assert + await expect(action.run()).resolves.not.toThrow(); +}); + test("deployment - deploy() - Invokes with no manifestfiles", async () => { const kubeCtl: jest.Mocked = new Kubectl("") as any; diff --git a/src/input-parameters.ts b/src/input-parameters.ts index 166541db..58259bbe 100644 --- a/src/input-parameters.ts +++ b/src/input-parameters.ts @@ -5,7 +5,7 @@ import * as core from '@actions/core'; export let namespace: string = core.getInput('namespace'); export const containers: string[] = core.getInput('images').split('\n'); export const imagePullSecrets: string[] = core.getInput('imagepullsecrets').split('\n').filter(secret => secret.trim().length > 0); -export const manifests = core.getInput('manifests').split(/[\n,]+/).filter(manifest => manifest.trim().length > 0); +export const manifests = core.getInput('manifests').split(/[\n,;]+/).filter(manifest => manifest.trim().length > 0); export const canaryPercentage: string = core.getInput('percentage'); export const deploymentStrategy: string = core.getInput('strategy'); export const trafficSplitMethod: string = core.getInput('traffic-split-method'); diff --git a/src/run.ts b/src/run.ts index 42942a0f..d68660e3 100644 --- a/src/run.ts +++ b/src/run.ts @@ -59,7 +59,7 @@ export async function run() { namespace = 'default'; } let action = core.getInput('action'); - let manifests = manifestsInput.split(/[\n,]+/).filter(manifest => manifest.trim().length > 0); + let manifests = manifestsInput.split(/[\n,;]+/).filter(manifest => manifest.trim().length > 0); if (manifests.length > 0) { manifests = manifests.map(manifest => {