-
Notifications
You must be signed in to change notification settings - Fork 638
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for bearer token to GithubRepositoryProvider
This commit adds the ability to use the GITHUB_TOKEN env variable to authenticate the access to GitHub repository. The env variable is used when no creds are found in the scm file. Signed-off-by: Paolo Di Tommaso <[email protected]>
- Loading branch information
1 parent
6f3ed6e
commit c4d3938
Showing
6 changed files
with
84 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,14 +20,17 @@ package nextflow.scm | |
import groovy.transform.CompileDynamic | ||
import groovy.transform.CompileStatic | ||
import groovy.transform.Memoized | ||
import groovy.util.logging.Slf4j | ||
import nextflow.SysEnv | ||
|
||
/** | ||
* Implements a repository provider for GitHub service | ||
* | ||
* @author Paolo Di Tommaso <[email protected]> | ||
*/ | ||
@Slf4j | ||
@CompileStatic | ||
final class GithubRepositoryProvider extends RepositoryProvider { | ||
class GithubRepositoryProvider extends RepositoryProvider { | ||
|
||
GithubRepositoryProvider(String project, ProviderConfig config=null) { | ||
this.project = project | ||
|
@@ -44,6 +47,21 @@ final class GithubRepositoryProvider extends RepositoryProvider { | |
return "${config.endpoint}/repos/${project}" | ||
} | ||
|
||
@Override | ||
boolean hasCredentials() { | ||
super.hasCredentials() ?: SysEnv.containsKey('GITHUB_TOKEN') | ||
} | ||
|
||
@Override | ||
String getUser() { | ||
super.getUser() ?: SysEnv.get('GITHUB_TOKEN') | ||
} | ||
|
||
@Override | ||
String getPassword() { | ||
super.getPassword() ?: (SysEnv.containsKey('GITHUB_TOKEN') ? 'x-oauth-basic' : null) | ||
} | ||
|
||
/** {@inheritDoc} */ | ||
@Override | ||
String getContentUrl( String path ) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters