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 36d49eb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
4 changes: 0 additions & 4 deletions projects/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@
"modern-ebpf",
"kmod"
]
},
{
"name": "kepler",
"organization": "sustainable-computing-io"
}
]
}
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 36d49eb

Please sign in to comment.