diff --git a/cmd/ghcs/code.go b/cmd/ghcs/code.go index 245a362be..9f09438d5 100644 --- a/cmd/ghcs/code.go +++ b/cmd/ghcs/code.go @@ -4,7 +4,6 @@ import ( "context" "fmt" "net/url" - "os" "github.com/github/ghcs/internal/api" "github.com/skratchdot/open-golang/open" @@ -33,7 +32,7 @@ func newCodeCmd() *cobra.Command { } func code(codespaceName string, useInsiders bool) error { - apiClient := api.New(os.Getenv("GITHUB_TOKEN")) + apiClient := api.New(GithubToken) ctx := context.Background() user, err := apiClient.GetUser(ctx) diff --git a/cmd/ghcs/create.go b/cmd/ghcs/create.go index 493a70247..45aa794e6 100644 --- a/cmd/ghcs/create.go +++ b/cmd/ghcs/create.go @@ -44,7 +44,7 @@ func newCreateCmd() *cobra.Command { func create(opts *createOptions) error { ctx := context.Background() - apiClient := api.New(os.Getenv("GITHUB_TOKEN")) + apiClient := api.New(GithubToken) locationCh := getLocation(ctx, apiClient) userCh := getUser(ctx, apiClient) log := output.NewLogger(os.Stdout, os.Stderr, false) diff --git a/cmd/ghcs/delete.go b/cmd/ghcs/delete.go index b75def7b6..34c1bc095 100644 --- a/cmd/ghcs/delete.go +++ b/cmd/ghcs/delete.go @@ -48,7 +48,7 @@ func newDeleteCmd() *cobra.Command { } func delete_(log *output.Logger, codespaceName string, force bool) error { - apiClient := api.New(os.Getenv("GITHUB_TOKEN")) + apiClient := api.New(GithubToken) ctx := context.Background() user, err := apiClient.GetUser(ctx) @@ -80,7 +80,7 @@ func delete_(log *output.Logger, codespaceName string, force bool) error { } func deleteAll(log *output.Logger, force bool) error { - apiClient := api.New(os.Getenv("GITHUB_TOKEN")) + apiClient := api.New(GithubToken) ctx := context.Background() user, err := apiClient.GetUser(ctx) @@ -119,7 +119,7 @@ func deleteAll(log *output.Logger, force bool) error { } func deleteByRepo(log *output.Logger, repo string, force bool) error { - apiClient := api.New(os.Getenv("GITHUB_TOKEN")) + apiClient := api.New(GithubToken) ctx := context.Background() user, err := apiClient.GetUser(ctx) diff --git a/cmd/ghcs/list.go b/cmd/ghcs/list.go index 09b0ea5b0..ccc150f08 100644 --- a/cmd/ghcs/list.go +++ b/cmd/ghcs/list.go @@ -32,7 +32,7 @@ func newListCmd() *cobra.Command { } func list(opts *listOptions) error { - apiClient := api.New(os.Getenv("GITHUB_TOKEN")) + apiClient := api.New(GithubToken) ctx := context.Background() user, err := apiClient.GetUser(ctx) diff --git a/cmd/ghcs/logs.go b/cmd/ghcs/logs.go index 40cac88ed..4051cc209 100644 --- a/cmd/ghcs/logs.go +++ b/cmd/ghcs/logs.go @@ -41,7 +41,7 @@ func logs(ctx context.Context, log *output.Logger, codespaceName string, follow ctx, cancel := context.WithCancel(ctx) defer cancel() - apiClient := api.New(os.Getenv("GITHUB_TOKEN")) + apiClient := api.New(GithubToken) user, err := apiClient.GetUser(ctx) if err != nil { diff --git a/cmd/ghcs/ports.go b/cmd/ghcs/ports.go index 052dfd37c..ebfd281cd 100644 --- a/cmd/ghcs/ports.go +++ b/cmd/ghcs/ports.go @@ -48,7 +48,7 @@ func newPortsCmd() *cobra.Command { } func ports(codespaceName string, asJSON bool) error { - apiClient := api.New(os.Getenv("GITHUB_TOKEN")) + apiClient := api.New(GithubToken) ctx := context.Background() log := output.NewLogger(os.Stdout, os.Stderr, asJSON) @@ -196,7 +196,7 @@ func newPortsPrivateCmd() *cobra.Command { func updatePortVisibility(log *output.Logger, codespaceName, sourcePort string, public bool) error { ctx := context.Background() - apiClient := api.New(os.Getenv("GITHUB_TOKEN")) + apiClient := api.New(GithubToken) user, err := apiClient.GetUser(ctx) if err != nil { @@ -258,7 +258,7 @@ func newPortsForwardCmd() *cobra.Command { func forwardPorts(log *output.Logger, codespaceName string, ports []string) error { ctx := context.Background() - apiClient := api.New(os.Getenv("GITHUB_TOKEN")) + apiClient := api.New(GithubToken) portPairs, err := getPortPairs(ports) if err != nil { diff --git a/cmd/ghcs/ssh.go b/cmd/ghcs/ssh.go index 527ae120f..5063e8fc9 100644 --- a/cmd/ghcs/ssh.go +++ b/cmd/ghcs/ssh.go @@ -37,7 +37,7 @@ func ssh(ctx context.Context, sshProfile, codespaceName string, localSSHServerPo ctx, cancel := context.WithCancel(ctx) defer cancel() - apiClient := api.New(os.Getenv("GITHUB_TOKEN")) + apiClient := api.New(GithubToken) log := output.NewLogger(os.Stdout, os.Stderr, false) user, err := apiClient.GetUser(ctx)