Make GITHUB_TOKEN configurable through Go member
Co-authored-by: Jose Garcia <josebalius@github.com>
This commit is contained in:
parent
c2f3537a32
commit
8c0c7a8e19
7 changed files with 11 additions and 12 deletions
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue