Skip to content

Commit

Permalink
refactors
Browse files Browse the repository at this point in the history
Signed-off-by: Dipankar Das <[email protected]>
  • Loading branch information
dipankardas011 committed Jun 14, 2024
1 parent 2f126ba commit fcb5fd5
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions scripts/repo-variable-writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ type Projects struct {
const (
LocProjMeta string = "../projects/project.json"
LocWriteUpdatedProjects string = "/tmp/updates.json"
EnvGithubPatVarName string = "GH_TOKEN"
)

func toPtr[T any](v T) *T {
Expand Down Expand Up @@ -93,18 +94,17 @@ func fetchLatestRelease(org, proj string) (*string, error) {
}

type GithubVariable struct {
githubToken string
githubToken string
fullRepoName string
}

func NewGithubVariable() (*GithubVariable, error) {
const EnvGithubPat string = "GH_TOKEN"

v, ok := os.LookupEnv(EnvGithubPat)
v, ok := os.LookupEnv(EnvGithubPatVarName)
if !ok || len(v) == 0 {
return nil, fmt.Errorf("the environment variable for github pat is missing")
}
return &GithubVariable{gh_token: v, fullRepoName: "cncf-tags/green-reviews-tooling"}, nil
return &GithubVariable{githubToken: v, fullRepoName: "cncf-tags/green-reviews-tooling"}, nil
}

func (obj *GithubVariable) genUrlAndHeaders(proj string) (*string, map[string]string, error) {
Expand All @@ -118,7 +118,7 @@ func (obj *GithubVariable) genUrlAndHeaders(proj string) (*string, map[string]st
return toPtr[string](url),
map[string]string{
"Accept": "application/vnd.github+json",
"Authorization": "Bearer " + obj.gh_token,
"Authorization": "Bearer " + obj.githubToken,
"X-GitHub-Api-Version": "2022-11-28",
}, nil
}
Expand Down

0 comments on commit fcb5fd5

Please sign in to comment.