|
1 | 1 | import AnsibleCmd from '../base-cmd-ansible-abstract' |
| 2 | +import {flags} from '@oclif/command' |
2 | 3 |
|
3 | 4 | export default class ProvisionCmd extends AnsibleCmd { |
4 | 5 | static description = 'Provision containers with Ansible playbooks.' |
5 | 6 |
|
| 7 | + static examples = [ |
| 8 | + '$ ce-dev provision --branch 1.x --config 1.x', |
| 9 | + ] |
| 10 | + |
| 11 | + static flags = { |
| 12 | + help: flags.help({char: 'h'}), |
| 13 | + branch: flags.string({ |
| 14 | + char: 'b', |
| 15 | + description: 'The branch of ce-provision to use for provisioning your containers. See https://github.com/codeenigma/ce-provision for options.', |
| 16 | + default: '1.x', |
| 17 | + }), |
| 18 | + config: flags.string({ |
| 19 | + char: 'c', |
| 20 | + description: 'The branch of the ce-provision-config repository. See https://github.com/codeenigma/ce-dev-ce-provision-config for options.', |
| 21 | + default: '1.x', |
| 22 | + }), |
| 23 | + } |
| 24 | + |
6 | 25 | protected ansibleProjectPlaybooksPath = '/home/ce-dev/projects-playbooks/provision' |
7 | 26 |
|
8 | 27 | protected ansibleScriptsPath = '/home/ce-dev/ce-provision' |
9 | 28 |
|
10 | 29 | protected ansibleScript = 'scripts/provision.sh' |
11 | 30 |
|
| 31 | + protected ownBranch = '1.x' |
| 32 | + |
| 33 | + protected configBranch = '1.x' |
| 34 | + |
12 | 35 | /** |
13 | 36 | * @inheritdoc |
14 | 37 | */ |
15 | 38 | public constructor(argv: string[], config: any) { |
16 | 39 | super(argv, config) |
| 40 | + const {flags} = this.parse(ProvisionCmd) |
17 | 41 | this.ansiblePaths = this.activeProjectInfo.provision |
| 42 | + this.ownBranch = flags.branch |
| 43 | + this.configBranch = flags.config |
18 | 44 | } |
19 | 45 |
|
20 | 46 | protected getCommandParameters(ansiblePath: string): string { |
21 | 47 | const workspace = this.ansibleProjectPlaybooksPath |
22 | 48 | const repo = this.activeProjectInfo.project_name |
23 | | - const ownBranch = '1.x' |
24 | | - const configBranch = '1.x' |
25 | | - let cmd = '--own-branch ' + ownBranch |
26 | | - cmd += ' --config-branch ' + configBranch |
| 49 | + let cmd = '--own-branch ' + this.ownBranch |
| 50 | + cmd += ' --config-branch ' + this.configBranch |
27 | 51 | cmd += ' --workspace ' + workspace |
28 | 52 | cmd += ' --repo ' + repo |
29 | 53 | cmd += ' --branch ce-dev --playbook ' + ansiblePath |
|
0 commit comments