Skip to content

Commit 5304510

Browse files
Add -user-secret and -workspace-secret flags to nextflow launch (#7040)
1 parent 916f029 commit 5304510

4 files changed

Lines changed: 65 additions & 1 deletion

File tree

docs/reference/cli.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -832,12 +832,24 @@ The `launch` command launches a pipeline run in Seqera Platform. To log in and c
832832
`-stub-run, -stub`
833833
: Whether to replace scripts with command stubs when executing the run.
834834

835+
`-user-secret`
836+
: :::{versionadded} 26.04.0
837+
:::
838+
: Name of user secret to use in the pipeline.
839+
: Can be specified multiple times.
840+
835841
`-w, -work-dir`
836842
: The directory where intermediate result files are stored.
837843

838844
`-workspace`
839845
: The Seqera Platform workspace name.
840846

847+
`-workspace-secret`
848+
: :::{versionadded} 26.04.0
849+
:::
850+
: Name of workspace secret to use in the pipeline.
851+
: Can be specified multiple times.
852+
841853
**Examples**
842854

843855
Execute a pipeline in Seqera Platform.

modules/nextflow/src/main/groovy/nextflow/cli/CmdLaunch.groovy

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,12 @@ class CmdLaunch extends CmdBase implements UsageAware {
8686
@Parameter(names = ['-main-script'], description = 'The script file to be executed when launching a project directory or repository')
8787
String mainScript
8888

89+
@Parameter(names = ['-user-secret'], description = 'Specify a user secret name to use in the pipeline (can be specified multiple times)')
90+
List<String> userSecrets = []
91+
92+
@Parameter(names = ['-workspace-secret'], description = 'Specify a workspace secret name to use in the pipeline (can be specified multiple times)')
93+
List<String> workspaceSecrets = []
94+
8995
/**
9096
* Defines the parameters to be passed to the pipeline script
9197
*/
@@ -124,7 +130,9 @@ class CmdLaunch extends CmdBase implements UsageAware {
124130
stubRun: stubRun,
125131
mainScript: mainScript,
126132
params: params,
127-
launcher: launcher
133+
launcher: launcher,
134+
userSecrets: userSecrets,
135+
workspaceSecrets: workspaceSecrets
128136
)
129137

130138
// Execute launch
@@ -156,6 +164,8 @@ class CmdLaunch extends CmdBase implements UsageAware {
156164
result << ' -latest Pull latest changes before run'
157165
result << ' -stub-run, -stub Execute the workflow replacing process scripts with command stubs'
158166
result << ' -main-script <file> The script file to be executed when launching a project'
167+
result << ' -user-secret <name> User secret name to use in the pipeline (can be specified multiple times)'
168+
result << ' -workspace-secret <name> Workspace secret name to use in the pipeline (can be specified multiple times)'
159169
result << ' --<param>=<value> Set a parameter used by the pipeline'
160170
result << ''
161171
println result.join('\n').toString()
@@ -191,5 +201,7 @@ class CmdLaunch extends CmdBase implements UsageAware {
191201
String mainScript
192202
Map<String, String> params
193203
Launcher launcher
204+
List<String> userSecrets
205+
List<String> workspaceSecrets
194206
}
195207
}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,8 @@ class LaunchCommandImpl extends BaseCommandImpl implements CmdLaunch.LaunchComma
230230
if (paramsText) launch.paramsText = paramsText
231231
if (options.mainScript) launch.mainScript = options.mainScript
232232
if (options.entryName) launch.entryName = options.entryName
233+
if (options.userSecrets) launch.userSecrets = options.userSecrets as Set
234+
if (options.workspaceSecrets) launch.workspaceSecrets = options.workspaceSecrets as Set
233235

234236
log.debug "Built launch request with ${launch.size()} parameters"
235237
return [launch: launch]

plugins/nf-tower/src/test/io/seqera/tower/plugin/launch/LaunchCommandImplTest.groovy

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -626,6 +626,44 @@ class LaunchCommandImplTest extends Specification {
626626
request.launch.configText == 'process.cpus = 8'
627627
}
628628

629+
def 'should include workspace and user secrets in launch request'() {
630+
given:
631+
def cmd = new LaunchCommandImpl()
632+
def options = new CmdLaunch.LaunchOptions(
633+
pipeline: 'nf-core/rnaseq',
634+
userSecrets: ['MY_USER_SECRET'],
635+
workspaceSecrets: ['DRAGEN_USERNAME', 'DRAGEN_PASSWORD']
636+
)
637+
def context = new LaunchCommandImpl.LaunchContext(
638+
computeEnvId: 'ce-123',
639+
workDir: 's3://bucket/work'
640+
)
641+
642+
when:
643+
def request = cmd.buildLaunchRequestPayload(options, context, 'https://github.com/nf-core/rnaseq', null, null)
644+
645+
then:
646+
request.launch.userSecrets == ['MY_USER_SECRET'] as Set
647+
request.launch.workspaceSecrets == ['DRAGEN_USERNAME', 'DRAGEN_PASSWORD'] as Set
648+
}
649+
650+
def 'should not include secrets in launch request when none provided'() {
651+
given:
652+
def cmd = new LaunchCommandImpl()
653+
def options = new CmdLaunch.LaunchOptions(pipeline: 'nf-core/rnaseq')
654+
def context = new LaunchCommandImpl.LaunchContext(
655+
computeEnvId: 'ce-123',
656+
workDir: 's3://bucket/work'
657+
)
658+
659+
when:
660+
def request = cmd.buildLaunchRequestPayload(options, context, 'https://github.com/nf-core/rnaseq', null, null)
661+
662+
then:
663+
!request.launch.containsKey('userSecrets')
664+
!request.launch.containsKey('workspaceSecrets')
665+
}
666+
629667
// ===== Workflow Status Tests =====
630668

631669
def 'should get color for workflow status'() {

0 commit comments

Comments
 (0)