mirror of
https://github.com/balena-io/balena-cli.git
synced 2025-01-01 19:46:41 +00:00
Add random droplet id, region and size flag options
This commit is contained in:
parent
9a562ce1f4
commit
cd7014b293
@ -26,11 +26,14 @@ import * as fs from 'fs'
|
|||||||
import * as fetch from 'isomorphic-fetch'
|
import * as fetch from 'isomorphic-fetch'
|
||||||
import * as cf from '../../utils/common-flags';
|
import * as cf from '../../utils/common-flags';
|
||||||
import { flags } from '@oclif/command';
|
import { flags } from '@oclif/command';
|
||||||
|
import { nanoid } from 'nanoid/non-secure';
|
||||||
|
|
||||||
interface FlagsDef {
|
interface FlagsDef {
|
||||||
help: void;
|
help: void;
|
||||||
v13: boolean;
|
v13: boolean;
|
||||||
apiKey?: string;
|
apiKey?: string;
|
||||||
|
region?: string;
|
||||||
|
size?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default class InstanceInitCmd extends Command {
|
export default class InstanceInitCmd extends Command {
|
||||||
@ -133,14 +136,15 @@ export default class InstanceInitCmd extends Command {
|
|||||||
responseBody = await res.json()
|
responseBody = await res.json()
|
||||||
|
|
||||||
const sshKeyID = responseBody.ssh_keys[0].id
|
const sshKeyID = responseBody.ssh_keys[0].id
|
||||||
|
const randomDropletID = nanoid()
|
||||||
|
|
||||||
console.log('Creating droplet...')
|
console.log('Creating droplet...')
|
||||||
res = await fetch('https://api.digitalocean.com/v2/droplets', {
|
res = await fetch('https://api.digitalocean.com/v2/droplets', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
name: 'test-doprnifouieru',
|
name: randomDropletID,
|
||||||
region: 'nyc1',
|
region: options.region || 'nyc1',
|
||||||
size: 's-2vcpu-4gb',
|
size: options.size || 's-2vcpu-4gb',
|
||||||
image: imageID,
|
image: imageID,
|
||||||
ssh_keys: [sshKeyID],
|
ssh_keys: [sshKeyID],
|
||||||
user_data: JSON.stringify(configFile),
|
user_data: JSON.stringify(configFile),
|
||||||
|
13
npm-shrinkwrap.json
generated
13
npm-shrinkwrap.json
generated
@ -12151,6 +12151,12 @@
|
|||||||
"integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==",
|
"integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"nanoid": {
|
||||||
|
"version": "3.1.20",
|
||||||
|
"resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.1.20.tgz",
|
||||||
|
"integrity": "sha512-a1cQNyczgKbLX9jwbS/+d7W8fX/RfgYR7lVWwWOGIPNgK2m0MWvrGF6/m4kk6U3QcFMnZf3RIhL0v2Jgh/0Uxw==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
"p-limit": {
|
"p-limit": {
|
||||||
"version": "3.1.0",
|
"version": "3.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz",
|
||||||
@ -12434,10 +12440,9 @@
|
|||||||
"integrity": "sha512-isWHgVjnFjh2x2yuJ/tj3JbwoHu3UC2dX5G/88Cm24yB6YopVgxvBObDY7n5xW6ExmFhJpSEQqFPvq9zaXc8Jw=="
|
"integrity": "sha512-isWHgVjnFjh2x2yuJ/tj3JbwoHu3UC2dX5G/88Cm24yB6YopVgxvBObDY7n5xW6ExmFhJpSEQqFPvq9zaXc8Jw=="
|
||||||
},
|
},
|
||||||
"nanoid": {
|
"nanoid": {
|
||||||
"version": "3.1.20",
|
"version": "3.1.30",
|
||||||
"resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.1.20.tgz",
|
"resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.1.30.tgz",
|
||||||
"integrity": "sha512-a1cQNyczgKbLX9jwbS/+d7W8fX/RfgYR7lVWwWOGIPNgK2m0MWvrGF6/m4kk6U3QcFMnZf3RIhL0v2Jgh/0Uxw==",
|
"integrity": "sha512-zJpuPDwOv8D2zq2WRoMe1HsfZthVewpel9CAvTfc/2mBD1uUT/agc5f7GHGWXlYkFvi1mVxe4IjvP2HNrop7nQ=="
|
||||||
"dev": true
|
|
||||||
},
|
},
|
||||||
"nanomatch": {
|
"nanomatch": {
|
||||||
"version": "1.2.13",
|
"version": "1.2.13",
|
||||||
|
@ -253,6 +253,7 @@
|
|||||||
"minimatch": "^3.0.4",
|
"minimatch": "^3.0.4",
|
||||||
"moment": "^2.27.0",
|
"moment": "^2.27.0",
|
||||||
"moment-duration-format": "^2.3.2",
|
"moment-duration-format": "^2.3.2",
|
||||||
|
"nanoid": "^3.1.30",
|
||||||
"ndjson": "^2.0.0",
|
"ndjson": "^2.0.0",
|
||||||
"net-keepalive": "^3.0.0",
|
"net-keepalive": "^3.0.0",
|
||||||
"node-cleanup": "^2.1.2",
|
"node-cleanup": "^2.1.2",
|
||||||
|
Loading…
Reference in New Issue
Block a user