Skip to content

Commit 44893d3

Browse files
Use --plan instead of --size for ephemeral shell (#463)
The API now exposes a `plan` field on the ephemeral-shell create body, with `size` deprecated. Rename the CLI flag and field accordingly. GitOrigin-RevId: 0b319784958c632053b1ee396154df76473a8c47
1 parent 5fefe2d commit 44893d3

3 files changed

Lines changed: 17 additions & 12 deletions

File tree

cmd/ssh.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ You can specify the service ID, service name, or specific instance ID as an argu
3232
# Connect to an ephemeral instance
3333
render ssh srv-abc123 --ephemeral
3434
35-
# Connect to an ephemeral instance with a specific plan size
36-
render ssh srv-abc123 --ephemeral --size standard
35+
# Connect to an ephemeral instance with a specific plan
36+
render ssh srv-abc123 --ephemeral --plan standard
3737
3838
# Pass through ssh arguments
3939
render ssh srv-abc123 -- -L 5432:localhost:5432`,
@@ -131,7 +131,7 @@ func init() {
131131
rootCmd.AddCommand(sshCmd)
132132

133133
sshCmd.Flags().BoolP("ephemeral", "e", false, "Connect to an ephemeral instance")
134-
sshCmd.Flags().String("size", "", "Plan name to use for the ephemeral instance (e.g. starter, standard, pro). Only valid with --ephemeral.")
134+
sshCmd.Flags().String("plan", "", "Plan name to use for the ephemeral instance (e.g. starter, standard, pro). Only valid with --ephemeral.")
135135

136136
sshCmd.RunE = func(cmd *cobra.Command, args []string) error {
137137
ctx := cmd.Context()

pkg/client/types_gen.go

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/tui/views/ssh.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ type SSHInput struct {
2424
Project *client.Project
2525
EnvironmentIDs []string
2626
Ephemeral bool `cli:"ephemeral"`
27-
Size string `cli:"size"`
27+
Plan string `cli:"plan"`
2828

2929
Args []string
3030
}
@@ -48,9 +48,9 @@ func handleSSHError(err error) error {
4848
// createEphemeralShell creates an ephemeral shell pod for the given service
4949
// and returns the ephemeral shell id from the API response (empty string if
5050
// the response did not include one). This must be called before SSH'ing into
51-
// an ephemeral shell. If size is non-empty, it is sent as the requested
51+
// an ephemeral shell. If plan is non-empty, it is sent as the requested
5252
// instance plan name.
53-
func createEphemeralShell(ctx context.Context, serviceID, size string) (string, error) {
53+
func createEphemeralShell(ctx context.Context, serviceID, plan string) (string, error) {
5454
apiCfg, err := config.DefaultAPIConfig()
5555
if err != nil {
5656
return "", fmt.Errorf("failed to get API config: %w", err)
@@ -59,8 +59,8 @@ func createEphemeralShell(ctx context.Context, serviceID, size string) (string,
5959
url := fmt.Sprintf("%sservices/%s/ephemeral-shell", apiCfg.Host, serviceID)
6060

6161
var reqBody io.Reader = bytes.NewReader(nil)
62-
if size != "" {
63-
payload, err := json.Marshal(client.CreateEphemeralShellJSONRequestBody{Size: &size})
62+
if plan != "" {
63+
payload, err := json.Marshal(client.CreateEphemeralShellJSONRequestBody{Plan: &plan})
6464
if err != nil {
6565
return "", fmt.Errorf("failed to encode request body: %w", err)
6666
}
@@ -74,7 +74,7 @@ func createEphemeralShell(ctx context.Context, serviceID, size string) (string,
7474

7575
req.Header = client.AddHeaders(req.Header, apiCfg.Key)
7676
req.Header.Set("Accept", "application/json")
77-
if size != "" {
77+
if plan != "" {
7878
req.Header.Set("Content-Type", "application/json")
7979
}
8080

@@ -199,16 +199,16 @@ func loadDataSSH(ctx context.Context, in *SSHInput) (*exec.Cmd, error) {
199199
}
200200
}
201201

202-
if in.Size != "" && !in.Ephemeral {
202+
if in.Plan != "" && !in.Ephemeral {
203203
return nil, tui.UserFacingError{
204204
Title: "Invalid flags",
205-
Message: "--size is only supported with --ephemeral.",
205+
Message: "--plan is only supported with --ephemeral.",
206206
}
207207
}
208208

209209
if in.Ephemeral {
210210
// Create the ephemeral shell pod first
211-
shellID, err := createEphemeralShell(ctx, serviceInfo.Id, in.Size)
211+
shellID, err := createEphemeralShell(ctx, serviceInfo.Id, in.Plan)
212212
if err != nil {
213213
return nil, tui.UserFacingError{
214214
Title: "Failed to create ephemeral shell",

0 commit comments

Comments
 (0)