-
Notifications
You must be signed in to change notification settings - Fork 4
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
Iteration on Nomad/Variables <-> Nextflow/Secrets #75
Merged
Merged
Changes from 7 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
9a76a7e
first iteration in secrets implementation
jagedn dd47cde
tweak the start-nomad script for different platforms [ci skip]
abhi18av b36638a
nomad secrets, add get set and list commands
jagedn e95d874
delete nomad with stop command [ci skip]
abhi18av d4e7015
tweak the sun-nomadlab config to accommodate variables [ci skip]
abhi18av 38721e9
update the sun-nomadlab config for config level secret vars [ci skip]
abhi18av b39b079
enable nomad secrets via nextflow config
jagedn e4de78b
add test
jagedn 8b2fbf9
fix small bug
jagedn 1cee206
improve local testing env [ci skip]
abhi18av ccb80bd
test with sun-nomadlab and localsecretstore [ci skip]
abhi18av 95e35c2
rename enable -> enabled to comply with standard
abhi18av 4321d22
use the functional config for sun-nomadlab [ci skip]
abhi18av 0efa719
update authors [ci skip]
abhi18av File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,9 +18,13 @@ | |
package nextflow.nomad | ||
|
||
import groovy.transform.CompileStatic | ||
import groovy.util.logging.Slf4j | ||
import nextflow.cli.PluginAbstractExec | ||
import nextflow.nomad.secrets.NomadSecretCmd | ||
import nextflow.nomad.executor.TaskDirectives | ||
import nextflow.plugin.BasePlugin | ||
import nextflow.script.ProcessConfig | ||
import nextflow.secret.SecretsLoader | ||
import org.pf4j.PluginWrapper | ||
|
||
/** | ||
|
@@ -30,14 +34,35 @@ import org.pf4j.PluginWrapper | |
* @author : matthdsm <[email protected]> | ||
*/ | ||
@CompileStatic | ||
class NomadPlugin extends BasePlugin { | ||
@Slf4j | ||
class NomadPlugin extends BasePlugin implements PluginAbstractExec{ | ||
|
||
NomadPlugin(PluginWrapper wrapper) { | ||
super(wrapper) | ||
addCustomDirectives() | ||
SecretsLoader.instance.reset() | ||
} | ||
|
||
private static void addCustomDirectives() { | ||
ProcessConfig.DIRECTIVES.addAll(TaskDirectives.ALL) | ||
} | ||
|
||
@Override | ||
List<String> getCommands() { | ||
return ['secrets'] | ||
} | ||
|
||
@Override | ||
int exec(String cmd, List<String> args) { | ||
return switch (cmd){ | ||
case 'secrets'-> secrets(args.first(), args.drop(1)) | ||
default -> -1 | ||
} | ||
} | ||
|
||
int secrets(String action, List<String>args){ | ||
NomadSecretCmd nomadSecretCmd = new NomadSecretCmd() | ||
nomadSecretCmd.runCommand( session.config , action, args) | ||
return 0 | ||
} | ||
} |
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
13 changes: 13 additions & 0 deletions
13
plugins/nf-nomad/src/main/nextflow/nomad/config/NomadSecretOpts.groovy
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package nextflow.nomad.config | ||
|
||
class NomadSecretOpts { | ||
|
||
final Boolean enable | ||
final String path | ||
|
||
NomadSecretOpts(Map map){ | ||
this.enable = map.containsKey('enable') ? map.get('enable') as boolean : false | ||
this.path = map.path ?: "secrets/nf-nomad" | ||
} | ||
|
||
} |
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
79 changes: 79 additions & 0 deletions
79
plugins/nf-nomad/src/main/nextflow/nomad/secrets/NomadSecretCmd.groovy
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 |
---|---|---|
@@ -0,0 +1,79 @@ | ||
package nextflow.nomad.secrets | ||
|
||
import groovy.util.logging.Slf4j | ||
import nextflow.exception.AbortOperationException | ||
import nextflow.nomad.config.NomadConfig | ||
import nextflow.nomad.executor.NomadService | ||
import nextflow.plugin.Priority | ||
import nextflow.secret.Secret | ||
import nextflow.secret.SecretImpl | ||
import nextflow.secret.SecretsProvider | ||
|
||
@Slf4j | ||
class NomadSecretCmd { | ||
|
||
protected NomadService service | ||
protected NomadConfig nomadConfig | ||
|
||
int runCommand(Map config, String action, List<String> args){ | ||
nomadConfig = new NomadConfig((config.nomad ?: Collections.emptyMap()) as Map) | ||
service = new NomadService(nomadConfig) | ||
return switch (action){ | ||
case 'get' ->execGetSecretNames(args.removeAt(0).toString()) | ||
case 'set' ->execSetSecretNames(args.removeAt(0).toString(),args.removeAt(0).toString()) | ||
case 'list'->execListSecretsNames() | ||
case 'delete'->execDeleteSecretNames(args.removeAt(0).toString()) | ||
default -> -1 | ||
} | ||
} | ||
|
||
int execListSecretsNames(){ | ||
def list = listSecretsNames() | ||
println list.join('\n') | ||
return 0 | ||
} | ||
|
||
int execGetSecretNames(String name){ | ||
if(!name){ | ||
throw new AbortOperationException("Wrong number of arguments") | ||
} | ||
def secret = getSecret(name) | ||
println secret | ||
return 0 | ||
} | ||
|
||
int execSetSecretNames(String name, String value){ | ||
if(!name){ | ||
throw new AbortOperationException("Wrong number of arguments") | ||
} | ||
setSecret(name, value) | ||
return 0 | ||
} | ||
|
||
int execDeleteSecretNames(String name){ | ||
if(!name){ | ||
throw new AbortOperationException("Wrong number of arguments") | ||
} | ||
deleteSecret(name) | ||
return 0 | ||
} | ||
|
||
String getSecret(String name) { | ||
String value = service.getVariableValue(name) | ||
if( !value ) | ||
throw new AbortOperationException("Missing secret name") | ||
value | ||
} | ||
|
||
Set<String> listSecretsNames() { | ||
service.variablesList | ||
} | ||
|
||
void setSecret(String name, String value) { | ||
service.setVariableValue(name, value) | ||
} | ||
|
||
void deleteSecret(String name){ | ||
service.deleteVariable(name) | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jagedn , I've renamed the
enable
toenabled
in order to comply with the general pattern of enabling scopes as per Nextflow configuration