Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
flux2
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
GitHub Mirror
fluxcd
flux2
Commits
ebdf9ed3
Unverified
Commit
ebdf9ed3
authored
3 years ago
by
Stefan Prodan
Browse files
Options
Downloads
Patches
Plain Diff
e2e: Retry the GitHub API calls
Signed-off-by:
Stefan Prodan
<
stefan.prodan@gmail.com
>
parent
a572274c
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
.github/workflows/bootstrap.yaml
+1
-0
1 addition, 0 deletions
.github/workflows/bootstrap.yaml
tests/bootstrap/main.go
+22
-4
22 additions, 4 deletions
tests/bootstrap/main.go
with
23 additions
and
4 deletions
.github/workflows/bootstrap.yaml
+
1
−
0
View file @
ebdf9ed3
...
...
@@ -79,6 +79,7 @@ jobs:
env
:
GITHUB_TOKEN
:
${{ secrets.GITPROVIDER_BOT_TOKEN }}
GITHUB_REPO_NAME
:
${{ steps.vars.outputs.test_repo_name }}
GITHUB_ORG_NAME
:
fluxcd-testing
-
name
:
libgit2
run
:
|
/tmp/flux create source git test-libgit2 \
...
...
This diff is collapsed.
Click to expand it.
tests/bootstrap/main.go
+
22
−
4
View file @
ebdf9ed3
...
...
@@ -7,6 +7,7 @@ import (
"github.com/fluxcd/go-git-providers/github"
"github.com/fluxcd/go-git-providers/gitprovider"
"k8s.io/client-go/util/retry"
)
func
main
()
{
...
...
@@ -55,8 +56,10 @@ spec:
Content
:
&
patchContent
,
},
}
orgName
:=
os
.
Getenv
(
"GITHUB_ORG_NAME"
)
repoName
:=
os
.
Getenv
(
"GITHUB_REPO_NAME"
)
githubToken
:=
os
.
Getenv
(
"GITHUB_TOKEN"
)
githubToken
:=
os
.
Getenv
(
github
.
TokenVariable
)
client
,
err
:=
github
.
NewClient
(
github
.
WithOAuth2Token
(
githubToken
))
if
err
!=
nil
{
log
.
Fatalf
(
"error initializing github client: %s"
,
err
)
...
...
@@ -64,12 +67,27 @@ spec:
repoRef
:=
gitprovider
.
OrgRepositoryRef
{
OrganizationRef
:
gitprovider
.
OrganizationRef
{
Organization
:
"flux-testing"
,
Domain
:
"
github.
com"
,
Organization
:
orgName
,
Domain
:
github
.
DefaultDomain
,
},
RepositoryName
:
repoName
,
}
repo
,
err
:=
client
.
OrgRepositories
()
.
Get
(
context
.
Background
(),
repoRef
)
if
ok
,
err
:=
client
.
HasTokenPermission
(
context
.
Background
(),
gitprovider
.
TokenPermissionRWRepository
);
err
!=
nil
{
log
.
Fatalf
(
"error getting token permission: %s"
,
err
)
}
else
{
if
!
ok
{
log
.
Fatal
(
"token has no write permissions"
)
}
}
var
repo
gitprovider
.
OrgRepository
err
=
retry
.
OnError
(
retry
.
DefaultRetry
,
func
(
err
error
)
bool
{
return
err
!=
nil
},
func
()
error
{
repo
,
err
=
client
.
OrgRepositories
()
.
Get
(
context
.
Background
(),
repoRef
)
return
err
})
if
err
!=
nil
{
log
.
Fatalf
(
"error getting %s repository in org %s: %s"
,
repoRef
.
RepositoryName
,
repoRef
.
Organization
,
err
)
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment