Skip to content

Commit 30b3d18

Browse files
authored
Merge pull request #687 from adobe/issues/pipeline-variables-service
feat(variables): support service-specific pipeline variables. fixes #686
2 parents 47fbbf9 + b1001e9 commit 30b3d18

File tree

15 files changed

+397
-81
lines changed

15 files changed

+397
-81
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ jobs:
1212
strategy:
1313
matrix:
1414
os: [ubuntu-latest, macos-latest, windows-latest]
15-
node-version: [14.x, 16.x]
15+
node-version: [16.x]
1616
include:
1717
- os: ubuntu-latest
18-
node-version: 14.x
18+
node-version: 16.x
1919
reportCoverage: true
2020
runs-on: ${{ matrix.os }}
2121

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Changelog
22

3+
# [4.2.0](https://github.com/adobe/aio-cli-plugin-cloudmanager/compare/4.1.0...4.2.0) (2024-25-03)
4+
5+
6+
### Features
7+
8+
* **variables:** support service-specific pipeline variables [#686](https://github.com/adobe/aio-cli-plugin-cloudmanager/issues/686) ([3c3d804](https://github.com/adobe/aio-cli-plugin-cloudmanager/commit/3c3d80404df16ad4375f079c67cfef3ea6b15fbd))
9+
310
# [4.1.0](https://github.com/adobe/aio-cli-plugin-cloudmanager/compare/4.0.0...4.1.0) (2023-06-14)
411

512

README.md

Lines changed: 36 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,7 @@ Cloud Manager Plugin for the [Adobe I/O CLI](https://github.com/adobe/aio-cli)
2525

2626
* [Adobe I/O CLI](https://github.com/adobe/aio-cli)
2727
* Node.js version compatibility:
28-
* 12.x -- 12.0.0 or higher.
29-
* 14.x -- 14.0.0 or higher.
30-
* 16.x -- currently incompatible due to lack of support from aio-cli.
28+
* 16.x -- 16.0.0 or higher.
3129
* Use with odd Node versions is *not* recommended.
3230

3331
> Although not recommended for general use, it is possible to use this plugin outside of the Adobe I/O CLI. See [Standalone Use](#standalone-use) below.
@@ -1043,19 +1041,43 @@ ARGUMENTS
10431041
PIPELINEID the pipeline id
10441042
10451043
OPTIONS
1046-
-d, --delete=delete variables/secrets to delete
1047-
-j, --json output in json format
1048-
-p, --programId=programId the programId. if not specified, defaults to 'cloudmanager_programid' config value
1049-
-s, --secret=secret secret values in KEY VALUE format
1050-
-v, --variable=variable variable values in KEY VALUE format
1051-
-y, --yaml output in yaml format
1052-
--imsContextName=imsContextName the alternate IMS context name to use instead of aio-cli-plugin-cloudmanager
1044+
-d, --delete=delete variables/secrets to delete
1045+
-j, --json output in json format
1046+
-p, --programId=programId the programId. if not specified, defaults to 'cloudmanager_programid' config value
1047+
-s, --secret=secret secret values in KEY VALUE format
1048+
-v, --variable=variable variable values in KEY VALUE format
1049+
-y, --yaml output in yaml format
1050+
--imsContextName=imsContextName the alternate IMS context name to use instead of aio-cli-plugin-cloudmanager
10531051
1054-
--jsonFile=jsonFile if set, read variables from a JSON array provided as a file; variables set through
1055-
--variable or --secret flag will take precedence
1052+
--jsonFile=jsonFile if set, read variables from a JSON array provided as a file; variables set through
1053+
--variable or --secret flag will take precedence
10561054
1057-
--jsonStdin if set, read variables from a JSON array provided as standard input; variables set
1058-
through --variable or --secret flag will take precedence
1055+
--jsonStdin if set, read variables from a JSON array provided as standard input; variables set
1056+
through --variable or --secret flag will take precedence
1057+
1058+
--buildDelete=buildDelete variables/secrets to delete for build service
1059+
1060+
--buildSecret=buildSecret secret values in KEY VALUE format for build service
1061+
1062+
--buildVariable=buildVariable variable values in KEY VALUE format for build service
1063+
1064+
--functionalTestDelete=functionalTestDelete variables/secrets to delete for functionalTest service
1065+
1066+
--functionalTestSecret=functionalTestSecret secret values in KEY VALUE format for functionalTest service
1067+
1068+
--functionalTestVariable=functionalTestVariable variable values in KEY VALUE format for functionalTest service
1069+
1070+
--uiTestDelete=uiTestDelete variables/secrets to delete for uiTest service
1071+
1072+
--uiTestSecret=uiTestSecret secret values in KEY VALUE format for uiTest service
1073+
1074+
--uiTestVariable=uiTestVariable variable values in KEY VALUE format for uiTest service
1075+
1076+
--loadTestDelete=loadTestDelete variables/secrets to delete for loadTest service
1077+
1078+
--loadTestSecret=loadTestSecret secret values in KEY VALUE format for loadTest service
1079+
1080+
--loadTestVariable=loadTestVariable variable values in KEY VALUE format for loadTest service
10591081
10601082
--yamlFile=yamlFile if set, read variables from a YAML array provided as a file; variables set through
10611083
--variable or --secret flag will take precedence

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@adobe/aio-cli-plugin-cloudmanager",
33
"description": "Cloud Manager commands for the Adobe I/O CLI",
4-
"version": "4.1.0",
4+
"version": "4.2.0",
55
"author": "Adobe Inc.",
66
"bugs": "https://github.com/adobe/aio-cli-plugin-cloudmanager/issues",
77
"dependencies": {
@@ -43,7 +43,7 @@
4343
"execa": "5.1.1",
4444
"fetch-mock": "9.11.0",
4545
"husky": "5.2.0",
46-
"jest": "27.5.1",
46+
"jest": "29.7.0",
4747
"jest-extended": "2.0.0",
4848
"jest-junit": "13.0.0",
4949
"node-wget": "0.4.3",
@@ -53,7 +53,7 @@
5353
"tmp": "0.2.1"
5454
},
5555
"engines": {
56-
"node": ">=12"
56+
"node": ">=16"
5757
},
5858
"files": [
5959
"/oclif.manifest.json",
@@ -145,7 +145,7 @@
145145
"prepack": "oclif-dev manifest && oclif-dev readme",
146146
"postpack": "rm -f oclif.manifest.json",
147147
"version": "oclif-dev readme && git add README.md",
148-
"e2e": "jest --collectCoverage=false --testRegex './e2e/e2e.js'",
148+
"e2e": "jest --collectCoverage=false --testRegex \"/e2e/*\"",
149149
"semantic-release": "semantic-release",
150150
"semantic-release-dry-run": "semantic-release --dry-run",
151151
"postinstall": "husky install",
@@ -203,4 +203,4 @@
203203
"@semantic-release/github"
204204
]
205205
}
206-
}
206+
}

src/base-variables-command.js

Lines changed: 57 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ const _ = require('lodash')
2424
const { codes: validationCodes } = require('./ValidationErrors')
2525

2626
class BaseVariablesCommand extends BaseCommand {
27-
getFlagDefs () {
28-
return {
27+
getFlagDefs (services) {
28+
const coreFlagDefs = {
2929
variable: {
3030
type: 'string',
3131
},
@@ -36,6 +36,21 @@ class BaseVariablesCommand extends BaseCommand {
3636
action: 'delete',
3737
},
3838
}
39+
40+
const result = {
41+
...coreFlagDefs,
42+
}
43+
44+
services.forEach(service => {
45+
Object.keys(coreFlagDefs).forEach(coreFlagKey => {
46+
const flagName = _.camelCase(`${service} ${coreFlagKey}`)
47+
result[flagName] = {
48+
...coreFlagDefs[coreFlagKey],
49+
service,
50+
}
51+
})
52+
})
53+
return result
3954
}
4055

4156
outputTable (result, flags, extraColumns = {}) {
@@ -167,27 +182,30 @@ BaseVariablesCommand.coreSetterFlags = {
167182
}),
168183
}
169184

170-
BaseVariablesCommand.setterFlags = {
171-
...BaseVariablesCommand.coreSetterFlags,
172-
jsonStdin: flags.boolean({
173-
default: false,
174-
description: 'if set, read variables from a JSON array provided as standard input; variables set through --variable or --secret flag will take precedence',
175-
exclusive: ['jsonFile', 'yamlStdin', 'yamlFile'],
176-
}),
177-
jsonFile: flags.string({
178-
description: 'if set, read variables from a JSON array provided as a file; variables set through --variable or --secret flag will take precedence',
179-
exclusive: ['jsonStdin', 'yamlStdin', 'yamlFile'],
180-
}),
181-
yamlStdin: flags.boolean({
182-
default: false,
183-
description: 'if set, read variables from a YAML array provided as standard input; variables set through --variable or --secret flag will take precedence',
184-
exclusive: ['jsonStdin', 'jsonFile', 'yamlFile'],
185-
}),
186-
yamlFile: flags.string({
187-
description: 'if set, read variables from a YAML array provided as a file; variables set through --variable or --secret flag will take precedence',
188-
exclusive: ['jsonStdin', 'jsonFile', 'yamlStdin'],
189-
}),
190-
...commonFlags.outputFormat,
185+
BaseVariablesCommand.setterFlags = (services) => {
186+
return {
187+
...BaseVariablesCommand.coreSetterFlags,
188+
jsonStdin: flags.boolean({
189+
default: false,
190+
description: 'if set, read variables from a JSON array provided as standard input; variables set through --variable or --secret flag will take precedence',
191+
exclusive: ['jsonFile', 'yamlStdin', 'yamlFile'],
192+
}),
193+
jsonFile: flags.string({
194+
description: 'if set, read variables from a JSON array provided as a file; variables set through --variable or --secret flag will take precedence',
195+
exclusive: ['jsonStdin', 'yamlStdin', 'yamlFile'],
196+
}),
197+
yamlStdin: flags.boolean({
198+
default: false,
199+
description: 'if set, read variables from a YAML array provided as standard input; variables set through --variable or --secret flag will take precedence',
200+
exclusive: ['jsonStdin', 'jsonFile', 'yamlFile'],
201+
}),
202+
yamlFile: flags.string({
203+
description: 'if set, read variables from a YAML array provided as a file; variables set through --variable or --secret flag will take precedence',
204+
exclusive: ['jsonStdin', 'jsonFile', 'yamlStdin'],
205+
}),
206+
...commonFlags.outputFormat,
207+
...BaseVariablesCommand.serviceSetterFlags(services),
208+
}
191209
}
192210

193211
BaseVariablesCommand.getterFlags = {
@@ -237,4 +255,20 @@ BaseVariablesCommand.loadVariablesFromYaml = (rawData, currentVariableTypes, var
237255
loadVariableData(data, currentVariableTypes, variables)
238256
}
239257

258+
BaseVariablesCommand.serviceSetterFlags = (services) => {
259+
const serviceFlags = {}
260+
services.forEach(service => {
261+
Object.keys(BaseVariablesCommand.coreSetterFlags).forEach(coreFlagKey => {
262+
const coreFlag = BaseVariablesCommand.coreSetterFlags[coreFlagKey]
263+
const flagName = _.camelCase(`${service} ${coreFlagKey}`)
264+
serviceFlags[flagName] = flags.string({
265+
description: `${coreFlag.description} for ${service} service`,
266+
multiple: true,
267+
})
268+
})
269+
})
270+
271+
return serviceFlags
272+
}
273+
240274
module.exports = BaseVariablesCommand

src/commands/cloudmanager/environment/bind-ip-allowlist.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ BindIPAllowlist.description = 'Bind an IP Allowlist to an environment'
3838
BindIPAllowlist.args = [
3939
commonArgs.environmentId,
4040
{ name: 'ipAllowlistId', required: true, description: 'the IP allowlist id' },
41-
commonArgs.service,
41+
commonArgs.environmentServices,
4242
]
4343

4444
BindIPAllowlist.flags = {

src/commands/cloudmanager/environment/set-variables.js

Lines changed: 3 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,9 @@ const BaseVariablesCommand = require('../../../base-variables-command')
1515
const { initSdk, sanitizeEnvironmentId } = require('../../../cloudmanager-helpers')
1616
const { flags } = require('@oclif/command')
1717
const Config = require('@adobe/aio-lib-core-config')
18-
const _ = require('lodash')
1918
const commonFlags = require('../../../common-flags')
2019
const commonArgs = require('../../../common-args')
21-
const { services } = require('../../../constants')
20+
const { environmentServices } = require('../../../constants')
2221
const { codes: validationCodes } = require('../../../ValidationErrors')
2322

2423
const IGNORED_PREFIXES = [
@@ -29,20 +28,7 @@ const IGNORED_PREFIXES = [
2928

3029
class SetEnvironmentVariablesCommand extends BaseEnvironmentVariablesCommand {
3130
getFlagDefs () {
32-
const coreFlagDefs = super.getFlagDefs()
33-
const result = {
34-
...coreFlagDefs,
35-
}
36-
services.forEach(service => {
37-
Object.keys(coreFlagDefs).forEach(coreFlagKey => {
38-
const flagName = _.camelCase(`${service} ${coreFlagKey}`)
39-
result[flagName] = {
40-
...coreFlagDefs[coreFlagKey],
41-
service,
42-
}
43-
})
44-
})
45-
return result
31+
return super.getFlagDefs(environmentServices)
4632
}
4733

4834
async run () {
@@ -83,21 +69,10 @@ SetEnvironmentVariablesCommand.args = [
8369
SetEnvironmentVariablesCommand.flags = {
8470
...commonFlags.global,
8571
...commonFlags.programId,
86-
...BaseVariablesCommand.setterFlags,
72+
...BaseVariablesCommand.setterFlags(environmentServices),
8773
strict: flags.boolean({ description: 'performs strict validation of internal variables. Can also be enabled by setting configuration property cloudmanager.environmentVariables.strictValidation to a truthy value.' }),
8874
}
8975

90-
services.forEach(service => {
91-
Object.keys(BaseVariablesCommand.coreSetterFlags).forEach(coreFlagKey => {
92-
const coreFlag = BaseVariablesCommand.coreSetterFlags[coreFlagKey]
93-
const flagName = _.camelCase(`${service} ${coreFlagKey}`)
94-
SetEnvironmentVariablesCommand.flags[flagName] = flags.string({
95-
description: `${coreFlag.description} for ${service} service`,
96-
multiple: true,
97-
})
98-
})
99-
})
100-
10176
SetEnvironmentVariablesCommand.aliases = [
10277
'cloudmanager:set-environment-variables',
10378
]

src/commands/cloudmanager/environment/unbind-ip-allowlist.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ UnbindIPAllowlist.strict = false
4040
UnbindIPAllowlist.args = [
4141
commonArgs.environmentId,
4242
{ name: 'ipAllowlistId', required: true, description: 'the IP allowlist id' },
43-
commonArgs.service,
43+
commonArgs.environmentServices,
4444
]
4545

4646
UnbindIPAllowlist.flags = {

src/commands/cloudmanager/ip-allowlist/bind.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ BindIPAllowlist.strict = false
4444
BindIPAllowlist.args = [
4545
{ name: 'ipAllowlistId', required: true, description: 'the IP allowlist id' },
4646
commonArgs.environmentId,
47-
commonArgs.service,
47+
commonArgs.environmentServices,
4848
]
4949

5050
BindIPAllowlist.flags = {

src/commands/cloudmanager/ip-allowlist/unbind.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ UnbindIPAllowlist.strict = false
4444
UnbindIPAllowlist.args = [
4545
{ name: 'ipAllowlistId', required: true, description: 'the IP allowlist id' },
4646
commonArgs.environmentId,
47-
commonArgs.service,
47+
commonArgs.environmentServices,
4848
]
4949

5050
UnbindIPAllowlist.flags = {

0 commit comments

Comments
 (0)