From 13938361697c45730b4a07cf305ae6e9359e68bc Mon Sep 17 00:00:00 2001 From: Luis Fraile Date: Sun, 10 May 2020 18:56:06 +0200 Subject: [PATCH] Add support for deployments --- README.md | 2 ++ action.yml | 4 ++-- lib/main.js | 8 ++++---- src/main.ts | 8 ++++---- 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index ed2db22..d7c7457 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,7 @@ Please read [Esquio readthedocs](https://esquio.readthedocs.io/en/latest/) first - **toggle-type**: Type of the toggle to set the parameter value. - **parameter-name**: Name of the parameter inside the toggle. - **value**: Value to set to the parameter. +- **deployment-name**: Name of the deplyment you want to set the value for (if you are using rings, otherwise leave empty) ## Example @@ -28,4 +29,5 @@ Please read [Esquio readthedocs](https://esquio.readthedocs.io/en/latest/) first toggle-type: 'Esquio.Toggles.GradualRolloutUserNameToggle,Esquio' parameter-name: 'Percentage' value: '56' + deployment-name: 'Tests' ``` diff --git a/action.yml b/action.yml index 91bd626..230e52e 100644 --- a/action.yml +++ b/action.yml @@ -26,9 +26,9 @@ inputs: value: required: true description: 'Value for the parameter' - ring-name: + deployment-name: required: false - description: 'Name of the ring (if you are using rings, otherwise leave empty)' + description: 'Name of the deplyment you want to set the value for (if you are using rings, otherwise leave empty)' runs: using: 'node12' main: 'lib/main.js' diff --git a/lib/main.js b/lib/main.js index 5b62e76..2e2cbdb 100644 --- a/lib/main.js +++ b/lib/main.js @@ -28,15 +28,15 @@ function run() { const toggleType = core.getInput('toggle-type'); const parameterName = core.getInput('parameter-name'); const parameterValue = core.getInput('value'); - const ringName = core.getInput('ring-name'); - yield setToggleParameter(url.parse(esquioUrl), esquioApiKey, productName, featureName, toggleType, parameterName, parameterValue, ringName); + const deploymentName = core.getInput('deployment-name'); + yield setToggleParameter(url.parse(esquioUrl), esquioApiKey, productName, featureName, toggleType, parameterName, parameterValue, deploymentName); } catch (error) { core.setFailed(error.message); } }); } -function setToggleParameter(esquioUrl, esquioApiKey, productName, featureName, toggleType, parameterName, parameterValue, ringName) { +function setToggleParameter(esquioUrl, esquioApiKey, productName, featureName, toggleType, parameterName, parameterValue, deploymentName) { return __awaiter(this, void 0, void 0, function* () { const options = { hostname: esquioUrl.host, @@ -54,7 +54,7 @@ function setToggleParameter(esquioUrl, esquioApiKey, productName, featureName, t "ToggleType": toggleType, "Name": parameterName, "Value": parameterValue, - "RingName": ringName + "DeploymentName": deploymentName }); const req = https.request(options, (res) => { if (res.statusCode === 200) { diff --git a/src/main.ts b/src/main.ts index 4971ea4..53e4107 100644 --- a/src/main.ts +++ b/src/main.ts @@ -11,9 +11,9 @@ async function run() { const toggleType = core.getInput('toggle-type'); const parameterName = core.getInput('parameter-name'); const parameterValue = core.getInput('value'); - const ringName = core.getInput('ring-name'); + const deploymentName = core.getInput('deployment-name'); - await setToggleParameter(url.parse(esquioUrl), esquioApiKey, productName, featureName, toggleType, parameterName, parameterValue, ringName); + await setToggleParameter(url.parse(esquioUrl), esquioApiKey, productName, featureName, toggleType, parameterName, parameterValue, deploymentName); } catch (error) { core.setFailed(error.message); } @@ -26,7 +26,7 @@ async function setToggleParameter(esquioUrl: url.UrlWithStringQuery, toggleType: string, parameterName: string, parameterValue: string, - ringName: string | undefined) { + deploymentName: string | undefined) { const options = { hostname: esquioUrl.host, @@ -45,7 +45,7 @@ async function setToggleParameter(esquioUrl: url.UrlWithStringQuery, "ToggleType": toggleType, "Name": parameterName, "Value": parameterValue, - "RingName": ringName + "DeploymentName": deploymentName }); const req = https.request(options, (res: any) => {