X Tutup
Skip to content

Commit 4e2c206

Browse files
committed
Merge branch 'main' into join-session
2 parents cee7612 + ab47e97 commit 4e2c206

File tree

10 files changed

+54
-54
lines changed

10 files changed

+54
-54
lines changed

api/api.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -278,11 +278,11 @@ func (a *API) StartCodespace(ctx context.Context, token string, codespace *Codes
278278
if len(b) > 100 {
279279
b = append(b[:97], "..."...)
280280
}
281-
if resp.StatusCode == http.StatusServiceUnavailable && strings.TrimSpace(string(b)) == "7" {
282-
// HTTP 503 with error code 7 (EnvironmentNotShutdown) is benign.
281+
if strings.TrimSpace(string(b)) == "7" {
282+
// Non-HTTP 200 with error code 7 (EnvironmentNotShutdown) is benign.
283283
// Ignore it.
284284
} else {
285-
return fmt.Errorf("failed to start Codespace: %s", b)
285+
return fmt.Errorf("failed to start codespace: %s", b)
286286
}
287287
}
288288

@@ -330,7 +330,7 @@ type SKU struct {
330330
func (a *API) GetCodespacesSKUs(ctx context.Context, user *User, repository *Repository, branch, location string) ([]*SKU, error) {
331331
req, err := http.NewRequest(http.MethodGet, githubAPI+"/vscs_internal/user/"+user.Login+"/skus", nil)
332332
if err != nil {
333-
return nil, fmt.Errorf("err creating request: %v", err)
333+
return nil, fmt.Errorf("error creating request: %v", err)
334334
}
335335

336336
q := req.URL.Query()

cmd/ghcs/code.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ func newCodeCmd() *cobra.Command {
1717

1818
codeCmd := &cobra.Command{
1919
Use: "code [<codespace>]",
20-
Short: "Open a Codespace in VS Code",
20+
Short: "Open a codespace in VS Code",
2121
Args: cobra.MaximumNArgs(1),
2222
RunE: func(cmd *cobra.Command, args []string) error {
2323
var codespaceName string
@@ -52,14 +52,14 @@ func code(codespaceName string, useInsiders bool) error {
5252
if err == codespaces.ErrNoCodespaces {
5353
return err
5454
}
55-
return fmt.Errorf("error choosing Codespace: %v", err)
55+
return fmt.Errorf("error choosing codespace: %v", err)
5656
}
5757
codespaceName = codespace.Name
5858
}
5959

6060
url := vscodeProtocolURL(codespaceName, useInsiders)
6161
if err := open.Run(url); err != nil {
62-
return fmt.Errorf("error opening vscode URL %s: %s. (Is VSCode installed?)", url, err)
62+
return fmt.Errorf("error opening vscode URL %s: %s. (Is VS Code installed?)", url, err)
6363
}
6464

6565
return nil

cmd/ghcs/create.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ func newCreateCmd() *cobra.Command {
2727

2828
createCmd := &cobra.Command{
2929
Use: "create",
30-
Short: "Create a Codespace",
30+
Short: "Create a codespace",
3131
Args: cobra.NoArgs,
3232
RunE: func(cmd *cobra.Command, args []string) error {
3333
return create(opts)
@@ -69,12 +69,12 @@ func create(opts *createOptions) error {
6969

7070
locationResult := <-locationCh
7171
if locationResult.Err != nil {
72-
return fmt.Errorf("error getting Codespace region location: %v", locationResult.Err)
72+
return fmt.Errorf("error getting codespace region location: %v", locationResult.Err)
7373
}
7474

7575
userResult := <-userCh
7676
if userResult.Err != nil {
77-
return fmt.Errorf("error getting Codespace user: %v", userResult.Err)
77+
return fmt.Errorf("error getting codespace user: %v", userResult.Err)
7878
}
7979

8080
machine, err := getMachineName(ctx, opts.machine, userResult.User, repository, branch, locationResult.Location, apiClient)
@@ -85,11 +85,11 @@ func create(opts *createOptions) error {
8585
return errors.New("There are no available machine types for this repository")
8686
}
8787

88-
log.Println("Creating your Codespace...")
88+
log.Println("Creating your codespace...")
8989

9090
codespace, err := apiClient.CreateCodespace(ctx, userResult.User, repository, machine, branch, locationResult.Location)
9191
if err != nil {
92-
return fmt.Errorf("error creating Codespace: %v", err)
92+
return fmt.Errorf("error creating codespace: %v", err)
9393
}
9494

9595
if opts.showStatus {
@@ -154,7 +154,7 @@ func showStatus(ctx context.Context, log *output.Logger, apiClient *api.API, use
154154
}
155155

156156
if err := codespaces.PollPostCreateStates(ctx, log, apiClient, user, codespace, poller); err != nil {
157-
return fmt.Errorf("failed to poll state changes from Codespace: %v", err)
157+
return fmt.Errorf("failed to poll state changes from codespace: %v", err)
158158
}
159159

160160
return nil
@@ -228,7 +228,7 @@ func getBranchName(branch string) (string, error) {
228228
func getMachineName(ctx context.Context, machine string, user *api.User, repo *api.Repository, branch, location string, apiClient *api.API) (string, error) {
229229
skus, err := apiClient.GetCodespacesSKUs(ctx, user, repo, branch, location)
230230
if err != nil {
231-
return "", fmt.Errorf("error getting Codespace SKUs: %v", err)
231+
return "", fmt.Errorf("error requesting machine instance types: %v", err)
232232
}
233233

234234
// if user supplied a machine type, it must be valid

cmd/ghcs/delete.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import (
1515
func newDeleteCmd() *cobra.Command {
1616
deleteCmd := &cobra.Command{
1717
Use: "delete [<codespace>]",
18-
Short: "Delete a Codespace",
18+
Short: "Delete a codespace",
1919
Args: cobra.MaximumNArgs(1),
2020
RunE: func(cmd *cobra.Command, args []string) error {
2121
var codespaceName string
@@ -28,7 +28,7 @@ func newDeleteCmd() *cobra.Command {
2828

2929
deleteAllCmd := &cobra.Command{
3030
Use: "all",
31-
Short: "Delete all Codespaces for the current user",
31+
Short: "Delete all codespaces for the current user",
3232
Args: cobra.NoArgs,
3333
RunE: func(cmd *cobra.Command, args []string) error {
3434
return deleteAll()
@@ -37,7 +37,7 @@ func newDeleteCmd() *cobra.Command {
3737

3838
deleteByRepoCmd := &cobra.Command{
3939
Use: "repo <repo>",
40-
Short: "Delete all Codespaces for a repository",
40+
Short: "Delete all codespaces for a repository",
4141
Args: cobra.ExactArgs(1),
4242
RunE: func(cmd *cobra.Command, args []string) error {
4343
return deleteByRepo(args[0])
@@ -65,11 +65,11 @@ func delete_(codespaceName string) error {
6565

6666
codespace, token, err := codespaces.GetOrChooseCodespace(ctx, apiClient, user, codespaceName)
6767
if err != nil {
68-
return fmt.Errorf("get or choose Codespace: %v", err)
68+
return fmt.Errorf("get or choose codespace: %v", err)
6969
}
7070

7171
if err := apiClient.DeleteCodespace(ctx, user, token, codespace.Name); err != nil {
72-
return fmt.Errorf("error deleting Codespace: %v", err)
72+
return fmt.Errorf("error deleting codespace: %v", err)
7373
}
7474

7575
log.Println("Codespace deleted.")
@@ -89,17 +89,17 @@ func deleteAll() error {
8989

9090
codespaces, err := apiClient.ListCodespaces(ctx, user)
9191
if err != nil {
92-
return fmt.Errorf("error getting Codespaces: %v", err)
92+
return fmt.Errorf("error getting codespaces: %v", err)
9393
}
9494

9595
for _, c := range codespaces {
9696
token, err := apiClient.GetCodespaceToken(ctx, user.Login, c.Name)
9797
if err != nil {
98-
return fmt.Errorf("error getting Codespace token: %v", err)
98+
return fmt.Errorf("error getting codespace token: %v", err)
9999
}
100100

101101
if err := apiClient.DeleteCodespace(ctx, user, token, c.Name); err != nil {
102-
return fmt.Errorf("error deleting Codespace: %v", err)
102+
return fmt.Errorf("error deleting codespace: %v", err)
103103
}
104104

105105
log.Printf("Codespace deleted: %s\n", c.Name)
@@ -120,7 +120,7 @@ func deleteByRepo(repo string) error {
120120

121121
codespaces, err := apiClient.ListCodespaces(ctx, user)
122122
if err != nil {
123-
return fmt.Errorf("error getting Codespaces: %v", err)
123+
return fmt.Errorf("error getting codespaces: %v", err)
124124
}
125125

126126
var deleted bool
@@ -132,18 +132,18 @@ func deleteByRepo(repo string) error {
132132

133133
token, err := apiClient.GetCodespaceToken(ctx, user.Login, c.Name)
134134
if err != nil {
135-
return fmt.Errorf("error getting Codespace token: %v", err)
135+
return fmt.Errorf("error getting codespace token: %v", err)
136136
}
137137

138138
if err := apiClient.DeleteCodespace(ctx, user, token, c.Name); err != nil {
139-
return fmt.Errorf("error deleting Codespace: %v", err)
139+
return fmt.Errorf("error deleting codespace: %v", err)
140140
}
141141

142142
log.Printf("Codespace deleted: %s\n", c.Name)
143143
}
144144

145145
if !deleted {
146-
return fmt.Errorf("No Codespace was found for repository: %s", repo)
146+
return fmt.Errorf("No codespace was found for repository: %s", repo)
147147
}
148148

149149
return list(&listOptions{})

cmd/ghcs/list.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ func newListCmd() *cobra.Command {
1919

2020
listCmd := &cobra.Command{
2121
Use: "list",
22-
Short: "List your Codespaces",
22+
Short: "List your codespaces",
2323
Args: cobra.NoArgs,
2424
RunE: func(cmd *cobra.Command, args []string) error {
2525
return list(opts)
@@ -46,7 +46,7 @@ func list(opts *listOptions) error {
4646

4747
codespaces, err := apiClient.ListCodespaces(ctx, user)
4848
if err != nil {
49-
return fmt.Errorf("error getting Codespaces: %v", err)
49+
return fmt.Errorf("error getting codespaces: %v", err)
5050
}
5151

5252
table := output.NewTable(os.Stdout, opts.asJSON)

cmd/ghcs/logs.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ func newLogsCmd() *cobra.Command {
1717

1818
logsCmd := &cobra.Command{
1919
Use: "logs [<codespace>]",
20-
Short: "Access Codespace logs",
20+
Short: "Access codespace logs",
2121
Args: cobra.MaximumNArgs(1),
2222
RunE: func(cmd *cobra.Command, args []string) error {
2323
var codespaceName string
@@ -52,7 +52,7 @@ func logs(ctx context.Context, tail bool, codespaceName string) error {
5252

5353
codespace, token, err := codespaces.GetOrChooseCodespace(ctx, apiClient, user, codespaceName)
5454
if err != nil {
55-
return fmt.Errorf("get or choose Codespace: %v", err)
55+
return fmt.Errorf("get or choose codespace: %v", err)
5656
}
5757

5858
session, err := codespaces.ConnectToLiveshare(ctx, log, apiClient, user.Login, token, codespace)

cmd/ghcs/ports.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,14 @@ func newPortsCmd() *cobra.Command {
3434

3535
portsCmd := &cobra.Command{
3636
Use: "ports",
37-
Short: "List ports in a Codespace",
37+
Short: "List ports in a codespace",
3838
Args: cobra.NoArgs,
3939
RunE: func(cmd *cobra.Command, args []string) error {
4040
return ports(opts)
4141
},
4242
}
4343

44-
portsCmd.Flags().StringVarP(&opts.codespaceName, "codespace", "c", "", "The `name` of the Codespace to use")
44+
portsCmd.Flags().StringVarP(&opts.codespaceName, "codespace", "c", "", "The `name` of the codespace to use")
4545
portsCmd.Flags().BoolVar(&opts.asJSON, "json", false, "Output as JSON")
4646

4747
portsCmd.AddCommand(newPortsPublicCmd())
@@ -70,7 +70,7 @@ func ports(opts *portsOptions) error {
7070
if err == codespaces.ErrNoCodespaces {
7171
return err
7272
}
73-
return fmt.Errorf("error choosing Codespace: %v", err)
73+
return fmt.Errorf("error choosing codespace: %v", err)
7474
}
7575

7676
devContainerCh := getDevContainer(ctx, apiClient, codespace)
@@ -196,12 +196,12 @@ func updatePortVisibility(log *output.Logger, codespaceName, sourcePort string,
196196

197197
token, err := apiClient.GetCodespaceToken(ctx, user.Login, codespaceName)
198198
if err != nil {
199-
return fmt.Errorf("error getting Codespace token: %v", err)
199+
return fmt.Errorf("error getting codespace token: %v", err)
200200
}
201201

202202
codespace, err := apiClient.GetCodespace(ctx, token, user.Login, codespaceName)
203203
if err != nil {
204-
return fmt.Errorf("error getting Codespace: %v", err)
204+
return fmt.Errorf("error getting codespace: %v", err)
205205
}
206206

207207
session, err := codespaces.ConnectToLiveshare(ctx, log, apiClient, user.Login, token, codespace)
@@ -257,12 +257,12 @@ func forwardPorts(log *output.Logger, codespaceName string, ports []string) erro
257257

258258
token, err := apiClient.GetCodespaceToken(ctx, user.Login, codespaceName)
259259
if err != nil {
260-
return fmt.Errorf("error getting Codespace token: %v", err)
260+
return fmt.Errorf("error getting codespace token: %v", err)
261261
}
262262

263263
codespace, err := apiClient.GetCodespace(ctx, token, user.Login, codespaceName)
264264
if err != nil {
265-
return fmt.Errorf("error getting Codespace: %v", err)
265+
return fmt.Errorf("error getting codespace: %v", err)
266266
}
267267

268268
session, err := codespaces.ConnectToLiveshare(ctx, log, apiClient, user.Login, token, codespace)

cmd/ghcs/ssh.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ func newSSHCmd() *cobra.Command {
2020

2121
sshCmd := &cobra.Command{
2222
Use: "ssh",
23-
Short: "SSH into a Codespace",
23+
Short: "SSH into a codespace",
2424
Args: cobra.NoArgs,
2525
RunE: func(cmd *cobra.Command, args []string) error {
2626
return ssh(context.Background(), sshProfile, codespaceName, sshServerPort)
@@ -29,7 +29,7 @@ func newSSHCmd() *cobra.Command {
2929

3030
sshCmd.Flags().StringVarP(&sshProfile, "profile", "", "", "The `name` of the SSH profile to use")
3131
sshCmd.Flags().IntVarP(&sshServerPort, "server-port", "", 0, "SSH server port number (0 => pick unused)")
32-
sshCmd.Flags().StringVarP(&codespaceName, "codespace", "c", "", "The `name` of the Codespace to use")
32+
sshCmd.Flags().StringVarP(&codespaceName, "codespace", "c", "", "The `name` of the codespace to use")
3333

3434
return sshCmd
3535
}
@@ -53,7 +53,7 @@ func ssh(ctx context.Context, sshProfile, codespaceName string, localSSHServerPo
5353

5454
codespace, token, err := codespaces.GetOrChooseCodespace(ctx, apiClient, user, codespaceName)
5555
if err != nil {
56-
return fmt.Errorf("get or choose Codespace: %v", err)
56+
return fmt.Errorf("get or choose codespace: %v", err)
5757
}
5858

5959
session, err := codespaces.ConnectToLiveshare(ctx, log, apiClient, user.Login, token, codespace)
@@ -151,7 +151,7 @@ func getContainerID(ctx context.Context, logger *output.Logger, terminal *livesh
151151
}
152152

153153
func setupEnv(ctx context.Context, logger *output.Logger, terminal *liveshare.Terminal, containerID, repositoryName, containerUser string) error {
154-
setupBashProfileCmd := fmt.Sprintf(`echo "cd /workspaces/%v; export $(cat /workspaces/.codespaces/shared/.env | xargs); exec /bin/zsh;" > /home/%v/.bash_profile`, repositoryName, containerUser)
154+
setupBashProfileCmd := fmt.Sprintf(`echo "export $(cat /workspaces/.codespaces/shared/.env | xargs); exec /bin/zsh;" > /home/%v/.bash_profile`, containerUser)
155155

156156
logger.Print(".")
157157
compositeCommand := []string{setupBashProfileCmd}

0 commit comments

Comments
 (0)
X Tutup