Skip to content

Commit 991760d

Browse files
flakey5emily-shenvicbnikitassharma
authored
feat: containers ssh command (#10582)
* feat: `containers ssh` command Closes CC-4634 Signed-off-by: flakey5 <73616808+flakey5@users.noreply.github.com> * fixup! feat: `containers ssh` command Signed-off-by: flakey5 <73616808+flakey5@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: emily-shen <69125074+emily-shen@users.noreply.github.com> Co-authored-by: Victor Berchet <victor@suumit.com> * code review * Apply suggestions from code review Co-authored-by: emily-shen <69125074+emily-shen@users.noreply.github.com> * code review * code review * fix lock file * fix tests Signed-off-by: flakey5 <73616808+flakey5@users.noreply.github.com> * fixes Signed-off-by: flakey5 <73616808+flakey5@users.noreply.github.com> * tmp * Apply suggestions from code review Co-authored-by: Nikita Sharma <54369599+nikitassharma@users.noreply.github.com> * fix ci (hopefully) Signed-off-by: flakey5 <73616808+flakey5@users.noreply.github.com> * resolve merge conflicts and hide ssh command * move ssh code from containers-shared to wrangler this code will only ever be used by wrangler and not vite/miniflare so it doesn't have to be in containers shared. * Delete .changeset/five-drinks-stick.md * lint * fix up optional positional and update help text --------- Signed-off-by: flakey5 <73616808+flakey5@users.noreply.github.com> Co-authored-by: emily-shen <69125074+emily-shen@users.noreply.github.com> Co-authored-by: Victor Berchet <victor@suumit.com> Co-authored-by: emily-shen <eshen@cloudflare.com> Co-authored-by: Nikita Sharma <54369599+nikitassharma@users.noreply.github.com>
1 parent 41103f5 commit 991760d

File tree

23 files changed

+832
-18
lines changed

23 files changed

+832
-18
lines changed

.changeset/spotty-plums-speak.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@cloudflare/containers-shared": minor
3+
"wrangler": patch
4+
---
5+
6+
Add `containers ssh` command

packages/containers-shared/src/client/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export type { AddressAssignment } from "./models/AddressAssignment";
1717
export type { Application } from "./models/Application";
1818
export type { ApplicationAffinities } from "./models/ApplicationAffinities";
1919
export { ApplicationAffinityColocation } from "./models/ApplicationAffinityColocation";
20+
export { ApplicationAffinityHardwareGeneration } from "./models/ApplicationAffinityHardwareGeneration";
2021
export type { ApplicationConstraintPop } from "./models/ApplicationConstraintPop";
2122
export type { ApplicationConstraints } from "./models/ApplicationConstraints";
2223
export type { ApplicationHealth } from "./models/ApplicationHealth";
@@ -192,13 +193,16 @@ export { SecretNotFound } from "./models/SecretNotFound";
192193
export type { SSHPublicKey } from "./models/SSHPublicKey";
193194
export type { SSHPublicKeyID } from "./models/SSHPublicKeyID";
194195
export type { SSHPublicKeyItem } from "./models/SSHPublicKeyItem";
196+
export type { SSHPublicKeyItemV3 } from "./models/SSHPublicKeyItemV3";
195197
export { SSHPublicKeyNotFoundError } from "./models/SSHPublicKeyNotFoundError";
196198
export type { UnAuthorizedError } from "./models/UnAuthorizedError";
197199
export type { UnixTimestamp } from "./models/UnixTimestamp";
198200
export type { UnknownAccount } from "./models/UnknownAccount";
199201
export { UpdateApplicationRolloutRequest } from "./models/UpdateApplicationRolloutRequest";
200202
export type { UpdateRolloutResponse } from "./models/UpdateRolloutResponse";
201203
export type { UserDeploymentConfiguration } from "./models/UserDeploymentConfiguration";
204+
export type { WranglerSSHConfig } from "./models/WranglerSSHConfig";
205+
export type { WranglerSSHResponse } from "./models/WranglerSSHResponse";
202206

203207
export { AccountService } from "./services/AccountService";
204208
export { ApplicationsService } from "./services/ApplicationsService";

packages/containers-shared/src/client/models/DeploymentV2.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ import type { Observability } from "./Observability";
2727
import type { Placement } from "./Placement";
2828
import type { Ref } from "./Ref";
2929
import type { SSHPublicKeyID } from "./SSHPublicKeyID";
30+
import type { SSHPublicKeyItemV3 } from "./SSHPublicKeyItemV3";
31+
import type { WranglerSSHConfig } from "./WranglerSSHConfig";
3032

3133
/**
3234
* A Deployment represents an intent to run one or many containers, with the same image, in a particular location or region.
@@ -41,6 +43,8 @@ export type DeploymentV2 = {
4143
type: DeploymentType;
4244
image: Image;
4345
location: DeploymentLocation;
46+
wrangler_ssh?: WranglerSSHConfig;
47+
authorized_keys?: Array<SSHPublicKeyItemV3>;
4448
/**
4549
* A list of SSH public key IDs from the account
4650
*/

packages/containers-shared/src/client/models/ModifyUserDeploymentConfiguration.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,16 @@ import type { Observability } from "./Observability";
1818
import type { Port } from "./Port";
1919
import type { ProvisionerConfiguration } from "./ProvisionerConfiguration";
2020
import type { SSHPublicKeyID } from "./SSHPublicKeyID";
21+
import type { SSHPublicKeyItemV3 } from "./SSHPublicKeyItemV3";
22+
import type { WranglerSSHConfig } from "./WranglerSSHConfig";
2123

2224
/**
2325
* Properties required to modify a cloudchamber deployment specified by the user.
2426
*/
2527
export type ModifyUserDeploymentConfiguration = {
2628
image?: Image;
29+
wrangler_ssh?: WranglerSSHConfig;
30+
authorized_keys?: Array<SSHPublicKeyItemV3>;
2731
/**
2832
* A list of SSH public key IDs from the account
2933
*/
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/* istanbul ignore file */
2+
/* tslint:disable */
3+
/* eslint-disable */
4+
5+
import type { SSHPublicKey } from "./SSHPublicKey";
6+
7+
/**
8+
* An SSH public key attached to a specific application or account.
9+
*/
10+
export type SSHPublicKeyItemV3 = {
11+
name: string;
12+
public_key: SSHPublicKey;
13+
};

packages/containers-shared/src/client/models/UserDeploymentConfiguration.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,16 @@ import type { Observability } from "./Observability";
1818
import type { Port } from "./Port";
1919
import type { ProvisionerConfiguration } from "./ProvisionerConfiguration";
2020
import type { SSHPublicKeyID } from "./SSHPublicKeyID";
21+
import type { SSHPublicKeyItemV3 } from "./SSHPublicKeyItemV3";
22+
import type { WranglerSSHConfig } from "./WranglerSSHConfig";
2123

2224
/**
2325
* Properties required to create a cloudchamber deployment specified by the user
2426
*/
2527
export type UserDeploymentConfiguration = {
2628
image: Image;
29+
wrangler_ssh?: WranglerSSHConfig;
30+
authorized_keys?: Array<SSHPublicKeyItemV3>;
2731
/**
2832
* A list of SSH public key IDs from the account
2933
*/
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/* istanbul ignore file */
2+
/* tslint:disable */
3+
/* eslint-disable */
4+
5+
/**
6+
* Configuration properties for SSH'ing into a container with Wrangler
7+
*/
8+
export type WranglerSSHConfig = {
9+
enabled: boolean;
10+
port?: number;
11+
};
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/* istanbul ignore file */
2+
/* tslint:disable */
3+
/* eslint-disable */
4+
5+
export type WranglerSSHResponse = {
6+
url: string;
7+
token: string;
8+
};

packages/containers-shared/src/client/services/DeploymentsService.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import type { ModifyDeploymentV2RequestBody } from "../models/ModifyDeploymentV2
1818
import type { ModifyUserDeploymentConfiguration } from "../models/ModifyUserDeploymentConfiguration";
1919
import type { PlacementID } from "../models/PlacementID";
2020
import type { ReplaceDeploymentRequestBody } from "../models/ReplaceDeploymentRequestBody";
21+
import type { WranglerSSHResponse } from "../models/WranglerSSHResponse";
2122

2223
export class DeploymentsService {
2324
/**
@@ -81,6 +82,31 @@ export class DeploymentsService {
8182
});
8283
}
8384

85+
/**
86+
* Get credentials to SSH into a Container
87+
* Get a JWT to hit the SSH port on a given container.
88+
* @param instanceId
89+
* @returns WranglerSSHResponse Credentials to SSH into a Container
90+
* @throws ApiError
91+
*/
92+
public static containerWranglerSsh(
93+
instanceId: DeploymentID
94+
): CancelablePromise<WranglerSSHResponse> {
95+
return __request(OpenAPI, {
96+
method: "GET",
97+
url: "/instances/{instance_id}/ssh",
98+
path: {
99+
instance_id: instanceId,
100+
},
101+
errors: {
102+
400: `Unknown account`,
103+
401: `Unauthorized`,
104+
404: `Deployment not found`,
105+
500: `There has been an internal error`,
106+
},
107+
});
108+
}
109+
84110
/**
85111
* Create a new deployment
86112
* Creates a new deployment. A Deployment represents an intent to run one container, with image, in a particular location

packages/containers-shared/src/types.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import type {
22
ApplicationAffinityColocation,
33
InstanceType,
44
SchedulingPolicy,
5+
SSHPublicKeyItemV3,
6+
WranglerSSHConfig,
57
} from "./client";
68
import type { ApplicationAffinityHardwareGeneration } from "./client/models/ApplicationAffinityHardwareGeneration";
79

@@ -76,6 +78,8 @@ export type SharedContainerConfig = {
7678
/** if undefined in config, defaults to "full_auto" */
7779
rollout_kind: "full_auto" | "full_manual" | "none";
7880
rollout_active_grace_period: number;
81+
wrangler_ssh?: WranglerSSHConfig;
82+
authorized_keys?: Array<SSHPublicKeyItemV3>;
7983
constraints: {
8084
regions?: string[];
8185
cities?: string[];

0 commit comments

Comments
 (0)