Add provider argument

This commit is contained in:
Dan Goodman 2021-10-14 11:44:21 -04:00 committed by ab77
parent bb4c2b1f82
commit 19b6d194ea
No known key found for this signature in database
GPG Key ID: D094F44E5E29445A
2 changed files with 23 additions and 2 deletions

View File

@ -16,6 +16,7 @@
*/
import { flags } from '@oclif/command';
import { IArg } from '@oclif/parser/lib/args';
import Command from '../../command';
import * as cf from '../../utils/common-flags';
import { stripIndent } from '../../utils/lazy';
@ -25,13 +26,23 @@ interface FlagsDef {
v13: boolean;
}
export default class InstanceCmd extends Command {
public static args: Array<IArg<any>> = [
{
name: 'provider',
description: 'the cloud provider',
required: true,
},
];
public static description = stripIndent`
Initialize a new cloud instance running balenaOS
A config.json must first be generated using the 'balena config generate' command
`;
public static examples = ['$ balena instance init'];
public static examples = ['$ balena instance init digitalocean'];
public static usage = 'instance [COMMAND]';

View File

@ -65,6 +65,11 @@ export default class InstanceInitCmd extends Command {
public static usage = 'instance init';
public static args: Array<IArg<any>> = [
{
name: 'provider',
description: 'the cloud provider: do | digitalocean | aws | gcp',
required: true,
},
{
name: 'configFile',
description: 'the config.json file path',
@ -92,7 +97,12 @@ export default class InstanceInitCmd extends Command {
public static authenticated = true;
public async run() {
const { args: params, flags: options } = this.parse<FlagsDef, { configFile: string }>(InstanceInitCmd);
const { args: params, flags: options } = this.parse<FlagsDef, { configFile: string, provider: string }>(InstanceInitCmd);
if (!['do', 'digitalocean'].includes(params.provider)) {
console.error('Only DigitalOcean is supported as a provider, please use "do" or "digitalocean" as your provider positional argument.')
return
}
// Check if the config file exists
console.log('Reading config file')