@rainyun/cli 0.0.0-stage → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +132 -2
- package/bin/postinstall.mjs +13 -0
- package/bin/rainyun-cli.mjs +13 -0
- package/catalog/human-names.json +340 -0
- package/catalog/list.openapi.json +354 -0
- package/catalog/openapi.json +34531 -0
- package/catalog/product-commands.json +332 -0
- package/catalog/public.openapi.json +1895 -0
- package/docs/AGENT_GUIDE.md +64 -0
- package/docs/install.md +44 -0
- package/docs/product-lists.md +48 -0
- package/docs/rgp.md +77 -0
- package/docs/terminal-exec.md +111 -0
- package/examples/public-panel.json +1 -0
- package/examples/public-rcs-price.json +1 -0
- package/examples/rca-terminal-input.json +1 -0
- package/examples/rcs-get.json +1 -0
- package/examples/rcs-list.json +1 -0
- package/examples/rcs-reboot.json +1 -0
- package/examples/terminal-controls.ndjson +3 -0
- package/examples/terminal-input.json +1 -0
- package/node_modules/ws/LICENSE +20 -0
- package/node_modules/ws/README.md +539 -0
- package/node_modules/ws/browser.js +8 -0
- package/node_modules/ws/index.js +22 -0
- package/node_modules/ws/lib/buffer-util.js +142 -0
- package/node_modules/ws/lib/constants.js +19 -0
- package/node_modules/ws/lib/event-target.js +292 -0
- package/node_modules/ws/lib/extension.js +203 -0
- package/node_modules/ws/lib/limiter.js +55 -0
- package/node_modules/ws/lib/permessage-deflate.js +530 -0
- package/node_modules/ws/lib/receiver.js +751 -0
- package/node_modules/ws/lib/sender.js +610 -0
- package/node_modules/ws/lib/stream.js +161 -0
- package/node_modules/ws/lib/subprotocol.js +62 -0
- package/node_modules/ws/lib/validation.js +152 -0
- package/node_modules/ws/lib/websocket-server.js +565 -0
- package/node_modules/ws/lib/websocket.js +1471 -0
- package/node_modules/ws/package.json +74 -0
- package/node_modules/ws/wrapper.mjs +21 -0
- package/package.json +29 -4
- package/skills/rainyun-cli/SKILL.md +46 -0
- package/src/api/catalog.mjs +230 -0
- package/src/api/http.mjs +222 -0
- package/src/api/request.mjs +178 -0
- package/src/api/titles.mjs +9 -0
- package/src/auth/commands.mjs +192 -0
- package/src/auth/store.mjs +162 -0
- package/src/cli.mjs +154 -0
- package/src/commands/dispatch.mjs +128 -0
- package/src/commands/fields.mjs +77 -0
- package/src/commands/products.mjs +209 -0
- package/src/commands/rgs.mjs +44 -0
- package/src/json.mjs +81 -0
- package/src/output/business.mjs +188 -0
- package/src/output/discovery.mjs +197 -0
- package/src/output/examples.mjs +71 -0
- package/src/output/format.mjs +164 -0
- package/src/output/help.json +181 -0
- package/src/output/help.mjs +334 -0
- package/src/rgp/commands.mjs +251 -0
- package/src/rgp/input.mjs +144 -0
- package/src/rgp/operations.json +625 -0
- package/src/rgp/result.mjs +103 -0
- package/src/rgp/transfer.mjs +213 -0
- package/src/terminal/commands.mjs +155 -0
- package/src/terminal/session.mjs +233 -0
- package/src/terminal/target.mjs +155 -0
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
import WebSocket from 'ws';
|
|
2
|
+
import { StringDecoder } from 'node:string_decoder';
|
|
3
|
+
import { buildEndpoint, error } from './target.mjs';
|
|
4
|
+
|
|
5
|
+
function filterOutput(secrets) {
|
|
6
|
+
const values = new Set();
|
|
7
|
+
for (const s of secrets.filter((v) => typeof v === 'string' && v.length)) {
|
|
8
|
+
const form = new URLSearchParams({ v: s }).toString().slice(2);
|
|
9
|
+
for (const value of [s, form, encodeURIComponent(s), form.replaceAll('+', '%20')]) values.add(value);
|
|
10
|
+
}
|
|
11
|
+
const ordered = [...values].sort((a, b) => b.length - a.length);
|
|
12
|
+
const decoder = new StringDecoder('utf8');
|
|
13
|
+
let pending = '';
|
|
14
|
+
return (chunk, final, budget) => {
|
|
15
|
+
const input = pending + (final ? decoder.end() : decoder.write(chunk));
|
|
16
|
+
let cursor = 0,
|
|
17
|
+
output = '';
|
|
18
|
+
pending = '';
|
|
19
|
+
while (cursor < input.length && output.length <= budget + 4) {
|
|
20
|
+
const match = ordered.find((s) => input.startsWith(s, cursor));
|
|
21
|
+
if (match) {
|
|
22
|
+
output += '[REDACTED]';
|
|
23
|
+
cursor += match.length;
|
|
24
|
+
continue;
|
|
25
|
+
}
|
|
26
|
+
if (ordered.some((s) => s.length > input.length - cursor && s.startsWith(input.slice(cursor)))) {
|
|
27
|
+
if (final) output += '[REDACTED]';
|
|
28
|
+
else pending = input.slice(cursor);
|
|
29
|
+
break;
|
|
30
|
+
}
|
|
31
|
+
output += input[cursor++];
|
|
32
|
+
}
|
|
33
|
+
return output;
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
function validateControl(value) {
|
|
37
|
+
if (!value || typeof value !== 'object') return false;
|
|
38
|
+
const n = Object.keys(value).length;
|
|
39
|
+
switch (value.type) {
|
|
40
|
+
case 'input':
|
|
41
|
+
return n === 2 && typeof value.data === 'string' && Buffer.byteLength(value.data) <= 65536;
|
|
42
|
+
case 'resize':
|
|
43
|
+
return (
|
|
44
|
+
n === 3 && [value.cols, value.rows].every((v) => Number.isInteger(v) && v >= 1 && v <= 1000)
|
|
45
|
+
);
|
|
46
|
+
case 'close':
|
|
47
|
+
return n === 1;
|
|
48
|
+
default:
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
export async function session(target, o, ctx) {
|
|
53
|
+
const started = Date.now(),
|
|
54
|
+
{ url, mode } = buildEndpoint(target, o);
|
|
55
|
+
const result = {
|
|
56
|
+
product: target.product,
|
|
57
|
+
id: target.id,
|
|
58
|
+
...(target.container_id ? { container_id: target.container_id } : {}),
|
|
59
|
+
mode,
|
|
60
|
+
output: '',
|
|
61
|
+
output_truncated: false,
|
|
62
|
+
input_attempted: false,
|
|
63
|
+
input_sent: false,
|
|
64
|
+
stop_reason: '',
|
|
65
|
+
duration_ms: 0,
|
|
66
|
+
exit_code: null,
|
|
67
|
+
command_outcome: 'unknown',
|
|
68
|
+
};
|
|
69
|
+
const filter = filterOutput([target.token, url.href, ...(ctx.redactionSecrets || [])]);
|
|
70
|
+
const ws = new WebSocket(url, {
|
|
71
|
+
agent: false,
|
|
72
|
+
origin: 'https://app.rainyun.com',
|
|
73
|
+
followRedirects: false,
|
|
74
|
+
perMessageDeflate: false,
|
|
75
|
+
maxPayload: 1048576,
|
|
76
|
+
handshakeTimeout: Math.min(o.duration_ms, 15000),
|
|
77
|
+
});
|
|
78
|
+
return await new Promise((resolve, reject) => {
|
|
79
|
+
let ended = false,
|
|
80
|
+
connected = false,
|
|
81
|
+
heartbeat,
|
|
82
|
+
bytes = 0,
|
|
83
|
+
pendingWrites = 0,
|
|
84
|
+
closeRequested = false,
|
|
85
|
+
controlTail = Buffer.alloc(0);
|
|
86
|
+
const emit = (event) => {
|
|
87
|
+
if (o.stream) ctx.stdout.write(ctx.jsonStringify(event) + '\n');
|
|
88
|
+
};
|
|
89
|
+
const append = (text) => {
|
|
90
|
+
const buf = Buffer.from(text),
|
|
91
|
+
limit = o.max_output_bytes - bytes;
|
|
92
|
+
if (buf.length >= limit && buf.length) {
|
|
93
|
+
result.output_truncated = true;
|
|
94
|
+
let n = limit;
|
|
95
|
+
while (n > 0 && (buf[n] & 192) === 128) n--;
|
|
96
|
+
text = buf.subarray(0, n).toString();
|
|
97
|
+
}
|
|
98
|
+
if (text) {
|
|
99
|
+
result.output += text;
|
|
100
|
+
bytes += Buffer.byteLength(text);
|
|
101
|
+
emit({ event: 'output', output: text });
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
function end(reason, problem) {
|
|
105
|
+
if (ended) return;
|
|
106
|
+
ended = true;
|
|
107
|
+
clearTimeout(deadline);
|
|
108
|
+
clearInterval(heartbeat);
|
|
109
|
+
ctx.signal?.removeEventListener('abort', abort);
|
|
110
|
+
if (o.stream) {
|
|
111
|
+
ctx.stdin.off('data', onData).off('end', onEOF).off('error', badControl);
|
|
112
|
+
ctx.stdin.pause();
|
|
113
|
+
ctx.stdout.off('error', onOutputError);
|
|
114
|
+
}
|
|
115
|
+
ws.terminate();
|
|
116
|
+
if (!result.output_truncated) append(filter(null, true, o.max_output_bytes - bytes));
|
|
117
|
+
result.duration_ms = Date.now() - started;
|
|
118
|
+
result.stop_reason = result.output_truncated && !problem ? 'output_limit' : reason;
|
|
119
|
+
if (connected && reason !== 'output_error') emit({ event: 'closed', result });
|
|
120
|
+
if (problem) reject(Object.assign(problem, { outcome: 'unknown', details: { terminal: result } }));
|
|
121
|
+
else resolve(o.stream ? undefined : { ok: true, data: result });
|
|
122
|
+
}
|
|
123
|
+
function requestClose() {
|
|
124
|
+
closeRequested = true;
|
|
125
|
+
if (pendingWrites === 0) end('client_closed');
|
|
126
|
+
}
|
|
127
|
+
function send(data, input) {
|
|
128
|
+
if (ended) return;
|
|
129
|
+
if (input) result.input_attempted = true;
|
|
130
|
+
pendingWrites++;
|
|
131
|
+
ws.send(data, { binary: false }, (err) => {
|
|
132
|
+
pendingWrites--;
|
|
133
|
+
if (ended) return;
|
|
134
|
+
if (err)
|
|
135
|
+
end('network_error', error('network', 'Terminal write failed; input may have been sent'));
|
|
136
|
+
else {
|
|
137
|
+
if (input) result.input_sent = true;
|
|
138
|
+
if (closeRequested && !pendingWrites) end('client_closed');
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
function control(line) {
|
|
143
|
+
try {
|
|
144
|
+
const c = ctx.jsonParse(new TextDecoder('utf-8', { fatal: true }).decode(line));
|
|
145
|
+
if (!validateControl(c)) return badControl();
|
|
146
|
+
if (c.type === 'close') return requestClose();
|
|
147
|
+
if (c.type === 'input') send(c.data, true);
|
|
148
|
+
else send(JSON.stringify({ type: 'resize', cols: c.cols, rows: c.rows }), false);
|
|
149
|
+
} catch {
|
|
150
|
+
badControl();
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
function badControl() {
|
|
154
|
+
end('invalid_control', error('usage', 'Invalid terminal control input'));
|
|
155
|
+
}
|
|
156
|
+
function onData(chunk) {
|
|
157
|
+
const data = Buffer.concat([controlTail, Buffer.from(chunk)]);
|
|
158
|
+
let i = 0;
|
|
159
|
+
controlTail = Buffer.alloc(0);
|
|
160
|
+
while (!ended && !closeRequested && i < data.length) {
|
|
161
|
+
const pos = data.indexOf(10, i),
|
|
162
|
+
next = pos < 0 ? data.length : pos;
|
|
163
|
+
if (next - i > 1048576) return badControl();
|
|
164
|
+
if (pos < 0) {
|
|
165
|
+
controlTail = data.subarray(i);
|
|
166
|
+
break;
|
|
167
|
+
}
|
|
168
|
+
control(data.subarray(i, pos));
|
|
169
|
+
i = pos + 1;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
function onEOF() {
|
|
173
|
+
if (controlTail.length && !closeRequested) control(controlTail);
|
|
174
|
+
if (!ended) requestClose();
|
|
175
|
+
}
|
|
176
|
+
function onOutputError() {
|
|
177
|
+
end('output_error', error('network', 'Cannot write terminal events'));
|
|
178
|
+
}
|
|
179
|
+
function abort() {
|
|
180
|
+
end('canceled', error('network', 'Terminal session canceled'));
|
|
181
|
+
}
|
|
182
|
+
const deadline = setTimeout(
|
|
183
|
+
() =>
|
|
184
|
+
connected
|
|
185
|
+
? end('duration')
|
|
186
|
+
: end('connect_failed', error('network', 'Terminal handshake timed out')),
|
|
187
|
+
o.duration_ms
|
|
188
|
+
);
|
|
189
|
+
ctx.signal?.addEventListener('abort', abort, { once: true });
|
|
190
|
+
ws.on('error', (problem) => {
|
|
191
|
+
if (problem.code?.startsWith('WS_ERR_'))
|
|
192
|
+
end('protocol_error', error('protocol', 'Invalid or oversized WebSocket message'));
|
|
193
|
+
else
|
|
194
|
+
end(
|
|
195
|
+
connected ? 'network_error' : 'connect_failed',
|
|
196
|
+
error('network', 'Terminal connection failed; no retry')
|
|
197
|
+
);
|
|
198
|
+
});
|
|
199
|
+
ws.on('unexpected-response', (_req, res) => {
|
|
200
|
+
const s = res.statusCode,
|
|
201
|
+
kind = [401, 403].includes(s) ? 'auth' : s >= 400 ? 'api' : 'protocol';
|
|
202
|
+
res.destroy();
|
|
203
|
+
end(
|
|
204
|
+
'connect_failed',
|
|
205
|
+
Object.assign(error(kind, 'Terminal service rejected the connection'), { http_status: s })
|
|
206
|
+
);
|
|
207
|
+
});
|
|
208
|
+
ws.on('open', () => {
|
|
209
|
+
if (ended) return;
|
|
210
|
+
connected = true;
|
|
211
|
+
if (o.stream) ctx.stdout.on('error', onOutputError);
|
|
212
|
+
emit({ event: 'connected', result });
|
|
213
|
+
if (o.input) send(o.input, true);
|
|
214
|
+
heartbeat = setInterval(() => send('ping', false), 5000);
|
|
215
|
+
if (o.stream) {
|
|
216
|
+
ctx.stdin.on('data', onData).once('end', onEOF).once('error', badControl);
|
|
217
|
+
if (ctx.stdin.readableEnded) onEOF();
|
|
218
|
+
}
|
|
219
|
+
});
|
|
220
|
+
ws.on('message', (buf) => {
|
|
221
|
+
if (ended || (buf.length === 4 && buf.toString() === 'pong')) return;
|
|
222
|
+
append(filter(buf, false, o.max_output_bytes - bytes));
|
|
223
|
+
if (result.output_truncated) end('output_limit');
|
|
224
|
+
});
|
|
225
|
+
ws.on('close', (code) => {
|
|
226
|
+
if (code === 1000 || code === 1001) end('remote_closed');
|
|
227
|
+
else if ([1002, 1003, 1007, 1009].includes(code))
|
|
228
|
+
end('protocol_error', error('protocol', 'Invalid terminal frame'));
|
|
229
|
+
else end('network_error', error('network', 'Terminal connection interrupted'));
|
|
230
|
+
});
|
|
231
|
+
if (ctx.signal?.aborted) abort();
|
|
232
|
+
});
|
|
233
|
+
}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { isIP } from 'node:net';
|
|
2
|
+
|
|
3
|
+
export const error = (kind, message) => Object.assign(new Error(message), { kind });
|
|
4
|
+
const label = /^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/;
|
|
5
|
+
function text(value, max) {
|
|
6
|
+
return (
|
|
7
|
+
typeof value === 'string' &&
|
|
8
|
+
value.length > 0 &&
|
|
9
|
+
Buffer.byteLength(value) <= max &&
|
|
10
|
+
!/\p{Cc}/u.test(value)
|
|
11
|
+
);
|
|
12
|
+
}
|
|
13
|
+
function origin(domain) {
|
|
14
|
+
const fail = error('protocol', 'Invalid helper hostname or port');
|
|
15
|
+
if (typeof domain !== 'string' || domain.length > 300) throw fail;
|
|
16
|
+
const parts = /^(\[[a-fA-F0-9:.]+\]|[a-zA-Z0-9.-]+)(?::(\d+))?$/.exec(domain);
|
|
17
|
+
if (!parts || parts[0] !== domain || (parts[2] && (+parts[2] < 1 || +parts[2] > 65535))) throw fail;
|
|
18
|
+
const hostname = parts[1].toLowerCase().replace(/\.$/, '');
|
|
19
|
+
const ipv6 = hostname.startsWith('[');
|
|
20
|
+
if (
|
|
21
|
+
ipv6
|
|
22
|
+
? isIP(hostname.slice(1, -1)) !== 6
|
|
23
|
+
: hostname.length > 253 || !hostname.split('.').every((v) => label.test(v))
|
|
24
|
+
)
|
|
25
|
+
throw fail;
|
|
26
|
+
// Reject URL's normalization of non-standard numeric IPv4 forms.
|
|
27
|
+
let url;
|
|
28
|
+
try {
|
|
29
|
+
url = new URL('https://' + domain);
|
|
30
|
+
} catch {
|
|
31
|
+
throw fail;
|
|
32
|
+
}
|
|
33
|
+
if (!ipv6 && url.hostname.replace(/\.$/, '') !== hostname) throw fail;
|
|
34
|
+
const local =
|
|
35
|
+
hostname === 'localhost' ||
|
|
36
|
+
(isIP(hostname) === 4 && hostname.startsWith('127.')) ||
|
|
37
|
+
url.hostname === '[::1]';
|
|
38
|
+
return (local ? 'http://' : 'https://') + hostname + (parts[2] ? ':' + Number(parts[2]) : '');
|
|
39
|
+
}
|
|
40
|
+
function verify(target) {
|
|
41
|
+
if (!label.test(target.namespace) || typeof target.namespace !== 'string' || !text(target.token, 4096))
|
|
42
|
+
throw error('protocol', 'Invalid helper credentials');
|
|
43
|
+
if (
|
|
44
|
+
target.product === 'rca' &&
|
|
45
|
+
(!text(target.install_name, 253) ||
|
|
46
|
+
!Number.isSafeInteger(target.region_id) ||
|
|
47
|
+
target.region_id < 1 ||
|
|
48
|
+
!text(target.region_name, 128))
|
|
49
|
+
)
|
|
50
|
+
throw error('protocol', 'Invalid RCA profile');
|
|
51
|
+
return origin(target.helper_domain);
|
|
52
|
+
}
|
|
53
|
+
export async function resolveRGS(id, flags, ctx) {
|
|
54
|
+
let detail;
|
|
55
|
+
try {
|
|
56
|
+
detail = await ctx.getRGS(id, flags);
|
|
57
|
+
} catch (e) {
|
|
58
|
+
const failure = error(
|
|
59
|
+
['usage', 'auth', 'network', 'protocol', 'api'].includes(e.kind) ? e.kind : 'protocol',
|
|
60
|
+
'Unable to read private RGS connection metadata'
|
|
61
|
+
);
|
|
62
|
+
if (Number.isInteger(e.http_status)) failure.http_status = e.http_status;
|
|
63
|
+
if (typeof e.business_code === 'number' || typeof e.business_code === 'bigint')
|
|
64
|
+
failure.business_code = e.business_code;
|
|
65
|
+
failure.operation = 'get_product_rgs_id_2d2988b0';
|
|
66
|
+
throw failure;
|
|
67
|
+
}
|
|
68
|
+
const data = detail?.data?.Data;
|
|
69
|
+
if (detail?.code !== 200 || data?.ID !== id || !data.Node?.Subtype || !data.Plan?.subtype)
|
|
70
|
+
throw error('protocol', 'RGS detail has missing or mismatched instance metadata');
|
|
71
|
+
if (data.Node.Subtype !== 'k8s_panel' || data.Plan.subtype !== 'k8s_panel')
|
|
72
|
+
throw error('api', 'Only k8s_panel RGS instances support this operation');
|
|
73
|
+
const target = {
|
|
74
|
+
product: 'rgs',
|
|
75
|
+
id,
|
|
76
|
+
helper_domain: data.k8s_panel_helper_domain,
|
|
77
|
+
namespace: data.k8s_panel_namespace,
|
|
78
|
+
token: data.k8s_panel_helper_token,
|
|
79
|
+
status: data.Status,
|
|
80
|
+
};
|
|
81
|
+
target.origin = verify(target);
|
|
82
|
+
return target;
|
|
83
|
+
}
|
|
84
|
+
export function importRCA(detail, id, cid) {
|
|
85
|
+
const bad = error('usage', 'Invalid RCA response, container binding or connection metadata');
|
|
86
|
+
const d = detail?.data?.Data,
|
|
87
|
+
p = d?.project,
|
|
88
|
+
r = p?.region;
|
|
89
|
+
if (
|
|
90
|
+
detail?.code !== 200 ||
|
|
91
|
+
d?.id !== id ||
|
|
92
|
+
!Number.isSafeInteger(d.project_id) ||
|
|
93
|
+
d.project_id < 1 ||
|
|
94
|
+
d.project_id !== p?.ID ||
|
|
95
|
+
!r ||
|
|
96
|
+
p.region_id !== r.id ||
|
|
97
|
+
!Array.isArray(d.containers)
|
|
98
|
+
)
|
|
99
|
+
throw bad;
|
|
100
|
+
let install;
|
|
101
|
+
const seen = new Set();
|
|
102
|
+
for (const c of d.containers) {
|
|
103
|
+
if (!Number.isSafeInteger(c?.id) || c.id < 1 || c.app_id !== id || seen.has(c.id)) throw bad;
|
|
104
|
+
seen.add(c.id);
|
|
105
|
+
if (c.id === cid) install = c.app_install_name;
|
|
106
|
+
}
|
|
107
|
+
const target = {
|
|
108
|
+
product: 'rca',
|
|
109
|
+
id,
|
|
110
|
+
container_id: cid,
|
|
111
|
+
helper_domain: r.public_service_domain,
|
|
112
|
+
namespace: p.namespace,
|
|
113
|
+
token: p.APIToken,
|
|
114
|
+
install_name: install,
|
|
115
|
+
region_id: r.id,
|
|
116
|
+
region_name: r.name,
|
|
117
|
+
};
|
|
118
|
+
try {
|
|
119
|
+
verify(target);
|
|
120
|
+
} catch {
|
|
121
|
+
throw bad;
|
|
122
|
+
}
|
|
123
|
+
return target;
|
|
124
|
+
}
|
|
125
|
+
export function buildEndpoint(target, o) {
|
|
126
|
+
const host = verify(target);
|
|
127
|
+
let mode = o.mode;
|
|
128
|
+
const url = new URL(
|
|
129
|
+
'/' + target.namespace + (o.logs ? '/logs' : '/terminal'),
|
|
130
|
+
host.replace(/^http/, 'ws')
|
|
131
|
+
);
|
|
132
|
+
const q = url.searchParams;
|
|
133
|
+
if (target.product === 'rgs') {
|
|
134
|
+
mode = 'attach';
|
|
135
|
+
q.set('app-token', target.token);
|
|
136
|
+
} else {
|
|
137
|
+
const restricted = target.region_id === 3 || target.region_name.toLowerCase() === 'cn-nb1';
|
|
138
|
+
mode = o.logs ? 'logs' : mode === 'auto' ? (restricted ? 'attach' : 'exec') : mode;
|
|
139
|
+
if (restricted && mode === 'exec') throw error('usage', 'This RCA region only supports attach');
|
|
140
|
+
q.set('project-token', target.token);
|
|
141
|
+
q.set('app_install_name', target.install_name);
|
|
142
|
+
}
|
|
143
|
+
const params = o.logs
|
|
144
|
+
? {
|
|
145
|
+
is_follow: false,
|
|
146
|
+
previous: false,
|
|
147
|
+
timestamps: true,
|
|
148
|
+
init_container: false,
|
|
149
|
+
tail_lines: o.tail_lines,
|
|
150
|
+
since_seconds: o.since_seconds,
|
|
151
|
+
}
|
|
152
|
+
: { method: mode, cols: o.cols, rows: o.rows };
|
|
153
|
+
for (const [k, v] of Object.entries(params)) q.set(k, String(v));
|
|
154
|
+
return { mode, url };
|
|
155
|
+
}
|