Skip to content

Commit

Permalink
Add support for deployments
Browse files Browse the repository at this point in the history
  • Loading branch information
lfraile committed May 10, 2020
1 parent 3515d52 commit 1393836
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 10 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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'
```
4 changes: 2 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
8 changes: 4 additions & 4 deletions lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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) {
Expand Down
8 changes: 4 additions & 4 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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,
Expand All @@ -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) => {
Expand Down

0 comments on commit 1393836

Please sign in to comment.