mirror of
https://github.com/balena-io/balena-cli.git
synced 2025-01-30 16:13:59 +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 cf from '../../utils/common-flags';
|
||||
import { flags } from '@oclif/command';
|
||||
import { nanoid } from 'nanoid/non-secure';
|
||||
|
||||
interface FlagsDef {
|
||||
help: void;
|
||||
v13: boolean;
|
||||
apiKey?: string;
|
||||
region?: string;
|
||||
size?: string;
|
||||
}
|
||||
|
||||
export default class InstanceInitCmd extends Command {
|
||||
@ -133,14 +136,15 @@ export default class InstanceInitCmd extends Command {
|
||||
responseBody = await res.json()
|
||||
|
||||
const sshKeyID = responseBody.ssh_keys[0].id
|
||||
const randomDropletID = nanoid()
|
||||
|
||||
console.log('Creating droplet...')
|
||||
res = await fetch('https://api.digitalocean.com/v2/droplets', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({
|
||||
name: 'test-doprnifouieru',
|
||||
region: 'nyc1',
|
||||
size: 's-2vcpu-4gb',
|
||||
name: randomDropletID,
|
||||
region: options.region || 'nyc1',
|
||||
size: options.size || 's-2vcpu-4gb',
|
||||
image: imageID,
|
||||
ssh_keys: [sshKeyID],
|
||||
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==",
|
||||
"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": {
|
||||
"version": "3.1.0",
|
||||
"resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz",
|
||||
@ -12434,10 +12440,9 @@
|
||||
"integrity": "sha512-isWHgVjnFjh2x2yuJ/tj3JbwoHu3UC2dX5G/88Cm24yB6YopVgxvBObDY7n5xW6ExmFhJpSEQqFPvq9zaXc8Jw=="
|
||||
},
|
||||
"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
|
||||
"version": "3.1.30",
|
||||
"resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.1.30.tgz",
|
||||
"integrity": "sha512-zJpuPDwOv8D2zq2WRoMe1HsfZthVewpel9CAvTfc/2mBD1uUT/agc5f7GHGWXlYkFvi1mVxe4IjvP2HNrop7nQ=="
|
||||
},
|
||||
"nanomatch": {
|
||||
"version": "1.2.13",
|
||||
|
@ -253,6 +253,7 @@
|
||||
"minimatch": "^3.0.4",
|
||||
"moment": "^2.27.0",
|
||||
"moment-duration-format": "^2.3.2",
|
||||
"nanoid": "^3.1.30",
|
||||
"ndjson": "^2.0.0",
|
||||
"net-keepalive": "^3.0.0",
|
||||
"node-cleanup": "^2.1.2",
|
||||
|
Loading…
x
Reference in New Issue
Block a user