Skip to content

Commit 1bc43ee

Browse files
committed
♻️ refactor(access_token): add SEQERA_ACCESS_TOKEN as a preferred alias to TOWER_ACCESS_TOKEN
Signed-off-by: Ken Brewer <kenibrewer@users.noreply.github.com>
1 parent 0171fad commit 1bc43ee

File tree

3 files changed

+15
-10
lines changed

3 files changed

+15
-10
lines changed

modules/nextflow/src/main/groovy/nextflow/platform/PlatformHelper.groovy

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,17 @@ class PlatformHelper {
3030
/**
3131
* Return the configured Platform access token: if `TOWER_WORKFLOW_ID` is provided in the environment, it means
3232
* we are running in a Platform-made run and we should ONLY retrieve the token from the environment. Otherwise,
33-
* check the configuration or fallback to the environment. If no token is found, return null.
33+
* check the configuration or fallback to the environment. The access token can be provided via either
34+
* SEQERA_ACCESS_TOKEN (preferred) or TOWER_ACCESS_TOKEN environment variables. If no token is found, return null.
3435
*
3536
* @param opts the configuration options for Platform (e.g. `session.config.navigate('tower')`)
3637
* @param env the applicable environment variables
3738
* @return the Platform access token
3839
*/
3940
static String getAccessToken(Map opts, Map<String,String> env) {
4041
final token = env.get('TOWER_WORKFLOW_ID')
41-
? env.get('TOWER_ACCESS_TOKEN')
42-
: opts.containsKey('accessToken') ? opts.accessToken as String : env.get('TOWER_ACCESS_TOKEN')
42+
? (env.get('SEQERA_ACCESS_TOKEN') ?: env.get('TOWER_ACCESS_TOKEN'))
43+
: opts.containsKey('accessToken') ? opts.accessToken as String : (env.get('SEQERA_ACCESS_TOKEN') ?: env.get('TOWER_ACCESS_TOKEN'))
4344
return token
4445
}
4546

modules/nf-commons/src/main/nextflow/plugin/PluginsFacade.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ class PluginsFacade implements PluginStateListener {
430430
}
431431

432432
// add tower plugin when config contains tower options
433-
if( (Bolts.navigate(config,'tower.enabled') || Bolts.navigate(config,'fusion.enabled') || env.TOWER_ACCESS_TOKEN ) && !specs.find {it.id == 'nf-tower' } ) {
433+
if( (Bolts.navigate(config,'tower.enabled') || Bolts.navigate(config,'fusion.enabled') || env.TOWER_ACCESS_TOKEN || env.SEQERA_ACCESS_TOKEN) && !specs.find {it.id == 'nf-tower' } ) {
434434
specs << defaultPlugins.getPlugin('nf-tower')
435435
}
436436
if( (Bolts.navigate(config,'wave.enabled') || Bolts.navigate(config,'fusion.enabled')) && !specs.find {it.id == 'nf-wave' } ) {

plugins/nf-tower/src/main/io/seqera/tower/plugin/TowerClient.groovy

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -378,15 +378,19 @@ class TowerClient implements TraceObserver {
378378
log.info(LoggerHelper.STICKY, msg)
379379
}
380380

381+
/**
382+
* Get the access token for Seqera Platform authentication.
383+
* When 'TOWER_WORKFLOW_ID' is provided in the env, it's a tower made launch
384+
* therefore the access token should only be taken from the env.
385+
* Otherwise check into the config file and fallback in the env.
386+
* The access token can be provided via either SEQERA_ACCESS_TOKEN (preferred) or TOWER_ACCESS_TOKEN environment variables.
387+
*/
381388
String getAccessToken() {
382-
// when 'TOWER_WORKFLOW_ID' is provided in the env, it's a tower made launch
383-
// therefore the access token should only be taken from the env
384-
// otherwise check into the config file and fallback in the env
385389
def token = env.get('TOWER_WORKFLOW_ID')
386-
? env.get('TOWER_ACCESS_TOKEN')
387-
: session.config.navigate('tower.accessToken', env.get('TOWER_ACCESS_TOKEN'))
390+
? (env.get('SEQERA_ACCESS_TOKEN') ?: env.get('TOWER_ACCESS_TOKEN'))
391+
: session.config.navigate('tower.accessToken', env.get('SEQERA_ACCESS_TOKEN') ?: env.get('TOWER_ACCESS_TOKEN'))
388392
if( !token )
389-
throw new AbortOperationException("Missing Seqera Platform access token -- Make sure there's a variable TOWER_ACCESS_TOKEN in your environment")
393+
throw new AbortOperationException("Missing Seqera Platform access token -- Make sure there's a variable SEQERA_ACCESS_TOKEN or TOWER_ACCESS_TOKEN in your environment")
390394
return token
391395
}
392396

0 commit comments

Comments
 (0)