Skip to content

Commit

Permalink
Merge pull request #11 from rreichel3/rename-env-var
Browse files Browse the repository at this point in the history
Renamed the environment variable to match GH syntax
  • Loading branch information
rreichel3 authored Oct 13, 2022
2 parents 664c186 + 05d70a3 commit a6497a1
Show file tree
Hide file tree
Showing 14 changed files with 28 additions and 28 deletions.
4 changes: 2 additions & 2 deletions cmd/github/check_user_exists.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ var checkUserExistsCmd = &cobra.Command{
Short: "Checks if the user exists. If it doesn't it prints the username",
Long: `Who can access a given nwo`,
RunE: func(cmd *cobra.Command, args []string) error {
auth_token, ok := os.LookupEnv("GITHUB_PAT")
auth_token, ok := os.LookupEnv("GITHUB_TOKEN")
if !ok {
fmt.Println("You need to set the GITHUB_PAT environment variable.\n")
fmt.Println("You need to set the GITHUB_TOKEN environment variable.\n")
return nil
}
ts := oauth2.StaticTokenSource(
Expand Down
2 changes: 1 addition & 1 deletion cmd/github/download_search_files.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ var downloadSearchFiles = &cobra.Command{
RunE: func(cmd *cobra.Command, args []string) error {
client, err := getGitHubClient()
if err != nil {
fmt.Println("You need to set the GITHUB_PAT environment variable.\n")
fmt.Println("You need to set the GITHUB_TOKEN environment variable.\n")
return nil
}

Expand Down
12 changes: 6 additions & 6 deletions cmd/github/list_actions_runs.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func init() {
func getRunsForNWO(owner string, repo string) []*github.WorkflowRun {
client, err := getGitHubClient()
if err != nil {
fmt.Println("You need to set the GITHUB_PAT environment variable.\n")
fmt.Println("You need to set the GITHUB_TOKEN environment variable.\n")
return nil
}
allRuns := []*github.WorkflowRun{}
Expand Down Expand Up @@ -51,7 +51,7 @@ func getRunsForNWO(owner string, repo string) []*github.WorkflowRun {
func getActionsWorkflow(owner string, repo string, runID int64) *github.Workflow {
client, err := getGitHubClient()
if err != nil {
fmt.Println("You need to set the GITHUB_PAT environment variable.\n")
fmt.Println("You need to set the GITHUB_TOKEN environment variable.\n")
return nil
}

Expand All @@ -66,7 +66,7 @@ func getActionsWorkflow(owner string, repo string, runID int64) *github.Workflow
func getRepoContents(owner string, repo string, path string, sha string) *github.RepositoryContent {
client, err := getGitHubClient()
if err != nil {
fmt.Println("You need to set the GITHUB_PAT environment variable.\n")
fmt.Println("You need to set the GITHUB_TOKEN environment variable.\n")
return nil
}

Expand All @@ -86,7 +86,7 @@ func getRepoContents(owner string, repo string, path string, sha string) *github
func getJobsForRun(owner string, repo string, runID int64) []*github.WorkflowJob {
client, err := getGitHubClient()
if err != nil {
fmt.Println("You need to set the GITHUB_PAT environment variable.\n")
fmt.Println("You need to set the GITHUB_TOKEN environment variable.\n")
return nil
}

Expand Down Expand Up @@ -121,9 +121,9 @@ var listSelfHostedRuns = &cobra.Command{

var repos = []string{}
if repo == "" {
auth_token, ok := os.LookupEnv("GITHUB_PAT")
auth_token, ok := os.LookupEnv("GITHUB_TOKEN")
if !ok {
fmt.Println("You need to set the GITHUB_PAT environment variable.\n")
fmt.Println("You need to set the GITHUB_TOKEN environment variable.\n")
return nil
}
ts := oauth2.StaticTokenSource(
Expand Down
4 changes: 2 additions & 2 deletions cmd/github/list_actions_workflows.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func init() {
func getWorkflow(owner string, repo string, runID int64) *github.Workflow {
client, err := getGitHubClient()
if err != nil {
fmt.Println("You need to set the GITHUB_PAT environment variable.\n")
fmt.Println("You need to set the GITHUB_TOKEN environment variable.\n")
return nil
}

Expand All @@ -34,7 +34,7 @@ func getWorkflow(owner string, repo string, runID int64) *github.Workflow {
func getContents(owner string, repo string, path string) *github.RepositoryContent {
client, err := getGitHubClient()
if err != nil {
fmt.Println("You need to set the GITHUB_PAT environment variable.\n")
fmt.Println("You need to set the GITHUB_TOKEN environment variable.\n")
return nil
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/github/list_issues.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func init() {
func getIssuesForNWO(owner string, name string) []*github.Issue {
client, err := getGitHubClient()
if err != nil {
fmt.Println("You need to set the GITHUB_PAT environment variable.\n")
fmt.Println("You need to set the GITHUB_TOKEN environment variable.\n")
return nil
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/github/list_issues_attachments.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ var fileUploadRegex = regexp.MustCompile(`(https:\/\/github.com\/.*\/files\/.*)\
func getCommentsForIssue(owner string, name string, number int) []*github.IssueComment {
client, err := getGitHubClient()
if err != nil {
fmt.Println("You need to set the GITHUB_PAT environment variable.\n")
fmt.Println("You need to set the GITHUB_TOKEN environment variable.\n")
return nil
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/github/list_outside_collaborators.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ var listOustideCollaborators = &cobra.Command{
RunE: func(cmd *cobra.Command, args []string) error {
client, err := getGitHubClient()
if err != nil {
fmt.Println("You need to set the GITHUB_PAT environment variable.\n")
fmt.Println("You need to set the GITHUB_TOKEN environment variable.\n")
return nil
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/github/list_public_repos.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ var listPublicRepos = &cobra.Command{
RunE: func(cmd *cobra.Command, args []string) error {
client, err := getGitHubClient()
if err != nil {
fmt.Println("You need to set the GITHUB_PAT environment variable.\n")
fmt.Println("You need to set the GITHUB_TOKEN environment variable.\n")
return nil
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/github/list_repos.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ var listRepos = &cobra.Command{
RunE: func(cmd *cobra.Command, args []string) error {
client, err := getGitHubClient()
if err != nil {
fmt.Println("You need to set the GITHUB_PAT environment variable.\n")
fmt.Println("You need to set the GITHUB_TOKEN environment variable.\n")
return nil
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/github/list_user_gists.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ var listUserGists = &cobra.Command{

client, err := getGitHubClient()
if err != nil {
fmt.Println("You need to set the GITHUB_PAT environment variable.\n")
fmt.Println("You need to set the GITHUB_TOKEN environment variable.\n")
return nil
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/github/overscoped_pages.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ var overscopedPages = &cobra.Command{
RunE: func(cmd *cobra.Command, args []string) error {
client, err := getGitHubClient()
if err != nil {
fmt.Println("You need to set the GITHUB_PAT environment variable.")
fmt.Println("You need to set the GITHUB_TOKEN environment variable.")
return nil
}
opt := &github.RepositoryListByOrgOptions{
Expand Down
4 changes: 2 additions & 2 deletions cmd/github/uses_actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ var continuationNWO string
func listWorkflowsForNWO(owner string, repo string) []*github.Workflow {
client, err := getGitHubClient()
if err != nil {
fmt.Println("You need to set the GITHUB_PAT environment variable.\n")
fmt.Println("You need to set the GITHUB_TOKEN environment variable.\n")
return nil
}
allWorkflows := []*github.Workflow{}
Expand Down Expand Up @@ -50,7 +50,7 @@ func listWorkflowsForNWO(owner string, repo string) []*github.Workflow {
func nwoHasWorkflows(owner string, repo string) (bool, error) {
client, err := getGitHubClient()
if err != nil {
fmt.Println("You need to set the GITHUB_PAT environment variable.\n")
fmt.Println("You need to set the GITHUB_TOKEN environment variable.\n")
return false, err
}

Expand Down
12 changes: 6 additions & 6 deletions cmd/github/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@ import (
)

func getGitHubToken() (string, error) {
auth_token, ok := os.LookupEnv("GITHUB_PAT")
auth_token, ok := os.LookupEnv("GITHUB_TOKEN")
if !ok {
fmt.Println("You need to set the GITHUB_PAT environment variable.")
return "", errors.New("You need to set the GITHUB_PAT environment variable.")
fmt.Println("You need to set the GITHUB_TOKEN environment variable.")
return "", errors.New("You need to set the GITHUB_TOKEN environment variable.")
}
return auth_token, nil
}

func getGitHubClient() (*github.Client, error) {
auth_token, ok := os.LookupEnv("GITHUB_PAT")
auth_token, ok := os.LookupEnv("GITHUB_TOKEN")
if !ok {
fmt.Println("You need to set the GITHUB_PAT environment variable.")
return nil, errors.New("You need to set the GITHUB_PAT environment variable.")
fmt.Println("You need to set the GITHUB_TOKEN environment variable.")
return nil, errors.New("You need to set the GITHUB_TOKEN environment variable.")
}
ts := oauth2.StaticTokenSource(
&oauth2.Token{AccessToken: auth_token},
Expand Down
4 changes: 2 additions & 2 deletions cmd/github/who_can_access.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ var whoCanAccessCmd = &cobra.Command{
Short: "Finds who can access a given nwo",
Long: `Who can access a given nwo`,
RunE: func(cmd *cobra.Command, args []string) error {
auth_token, ok := os.LookupEnv("GITHUB_PAT")
auth_token, ok := os.LookupEnv("GITHUB_TOKEN")
if !ok {
fmt.Println("You need to set the GITHUB_PAT environment variable.\n")
fmt.Println("You need to set the GITHUB_TOKEN environment variable.\n")
return nil
}
ts := oauth2.StaticTokenSource(
Expand Down

0 comments on commit a6497a1

Please sign in to comment.