Merge pull request #2184 from nhooyr/link-flag-1547

cloud: Rename --coder-bind to --link
This commit is contained in:
Anmol Sethi 2020-10-09 13:53:55 -04:00 committed by GitHub
commit 1e4e72aa5b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 7 deletions

View File

@ -48,7 +48,7 @@ export interface Args extends VsArgs {
readonly "reuse-window"?: boolean readonly "reuse-window"?: boolean
readonly "new-window"?: boolean readonly "new-window"?: boolean
readonly "coder-bind"?: OptionalString readonly link?: OptionalString
} }
interface Option<T> { interface Option<T> {
@ -164,7 +164,7 @@ const options: Options<Required<Args>> = {
log: { type: LogLevel }, log: { type: LogLevel },
verbose: { type: "boolean", short: "vvv", description: "Enable verbose logging." }, verbose: { type: "boolean", short: "vvv", description: "Enable verbose logging." },
"coder-bind": { link: {
type: OptionalString, type: OptionalString,
description: ` description: `
Securely bind code-server via Coder Cloud with the passed name. You'll get a URL like Securely bind code-server via Coder Cloud with the passed name. You'll get a URL like

View File

@ -3,6 +3,7 @@ import { spawn } from "child_process"
import path from "path" import path from "path"
import split2 from "split2" import split2 from "split2"
// https://github.com/cdr/coder-cloud
const coderCloudAgent = path.resolve(__dirname, "../../lib/coder-cloud-agent") const coderCloudAgent = path.resolve(__dirname, "../../lib/coder-cloud-agent")
function runAgent(...args: string[]): Promise<void> { function runAgent(...args: string[]): Promise<void> {
@ -33,7 +34,7 @@ function runAgent(...args: string[]): Promise<void> {
} }
export function coderCloudBind(csAddr: string, serverName = ""): Promise<void> { export function coderCloudBind(csAddr: string, serverName = ""): Promise<void> {
logger.info("Remember --coder-bind is a beta feature and requires being accepted for testing") logger.info("Remember --link is a beta feature and requires being accepted for testing")
logger.info("See https://github.com/cdr/code-server/discussions/2137") logger.info("See https://github.com/cdr/code-server/discussions/2137")
// addr needs to be in host:port format. // addr needs to be in host:port format.
// So we trim the protocol. // So we trim the protocol.

View File

@ -36,7 +36,7 @@ const version = pkg.version || "development"
const commit = pkg.commit || "development" const commit = pkg.commit || "development"
const main = async (args: Args, configArgs: Args): Promise<void> => { const main = async (args: Args, configArgs: Args): Promise<void> => {
if (args["coder-bind"]) { if (args.link) {
// If we're being exposed to the cloud, we listen on a random address and disable auth. // If we're being exposed to the cloud, we listen on a random address and disable auth.
args = { args = {
...args, ...args,
@ -46,7 +46,7 @@ const main = async (args: Args, configArgs: Args): Promise<void> => {
socket: undefined, socket: undefined,
cert: undefined, cert: undefined,
} }
logger.info("coder-bind: disabling auth and listening on random localhost port") logger.info("link: disabling auth and listening on random localhost port for cloud agent")
} }
if (!args.auth) { if (!args.auth) {
@ -143,9 +143,9 @@ const main = async (args: Args, configArgs: Args): Promise<void> => {
logger.info(`Opened ${openAddress}`) logger.info(`Opened ${openAddress}`)
} }
if (args["coder-bind"]) { if (args.link) {
try { try {
await coderCloudBind(serverAddress!, args["coder-bind"].value) await coderCloudBind(serverAddress!, args.link.value)
} catch (err) { } catch (err) {
logger.error(err.message) logger.error(err.message)
ipcMain().exit(1) ipcMain().exit(1)