Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

atlasaction: move github client to internal package #286

Merged
merged 2 commits into from
Dec 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions atlasaction/action.go
Original file line number Diff line number Diff line change
Expand Up @@ -1044,18 +1044,26 @@ func (tc *TriggerContext) SCMClient() (SCMClient, error) {
if token == "" {
tc.Act.Warningf("GITHUB_TOKEN is not set, the action may not have all the permissions")
}
return githubClient(tc.Repo, tc.SCM.APIURL, token), nil
return GitHubClient(tc.Repo, tc.SCM.APIURL, token)
case atlasexec.SCMTypeGitlab:
token := tc.Act.Getenv("GITLAB_TOKEN")
if token == "" {
tc.Act.Warningf("GITLAB_TOKEN is not set, the action may not have all the permissions")
}
return gitlabClient(tc.Act.Getenv("CI_PROJECT_ID"), tc.SCM.APIURL, token), nil
return gitlabClient(
tc.Act.Getenv("CI_PROJECT_ID"),
tc.SCM.APIURL,
token,
), nil
case atlasexec.SCMTypeBitbucket:
token := tc.Act.Getenv("BITBUCKET_ACCESS_TOKEN")
if token == "" {
tc.Act.Warningf("BITBUCKET_ACCESS_TOKEN is not set, the action may not have all the permissions")
}
return BitbucketClient(
tc.Act.Getenv("BITBUCKET_WORKSPACE"),
tc.Act.Getenv("BITBUCKET_REPO_SLUG"),
tc.Act.Getenv("BITBUCKET_ACCESS_TOKEN"),
token,
)
default:
return nil, ErrNoSCM // Not implemented yet.
Expand Down
13 changes: 10 additions & 3 deletions atlasaction/circleci_action.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,19 @@ func (a *circleCIOrb) GetTriggerContext(ctx context.Context) (*TriggerContext, e
tc.Branch = tag
return tc, nil
}
c := githubClient(tc.Repo, tc.SCM.APIURL, ghToken)
var err error
tc.PullRequest, err = c.OpeningPullRequest(ctx, tc.Branch)
c, err := GitHubClient(tc.Repo, tc.SCM.APIURL, ghToken)
if err != nil {
return nil, fmt.Errorf("failed to create GitHub client: %w", err)
}
pr, err := c.OpeningPullRequest(ctx, tc.Branch)
if err != nil {
return nil, fmt.Errorf("failed to get open pull requests: %w", err)
}
tc.PullRequest = &PullRequest{
Number: pr.Number,
URL: pr.URL,
Commit: pr.Commit,
}
}
return tc, nil
}
Loading
Loading