-
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 1 commit
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
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
54 changes: 37 additions & 17 deletions
54
plugins/nf-nomad/src/main/nextflow/nomad/secrets/NomadSecretProvider.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 |
---|---|---|
@@ -1,60 +1,80 @@ | ||
package nextflow.nomad.secrets | ||
|
||
import groovy.util.logging.Slf4j | ||
import nextflow.Global | ||
import nextflow.nomad.config.NomadConfig | ||
import nextflow.nomad.executor.NomadService | ||
import nextflow.plugin.Priority | ||
import nextflow.secret.LocalSecretsProvider | ||
import nextflow.secret.Secret | ||
import nextflow.secret.SecretImpl | ||
import nextflow.secret.SecretsProvider | ||
|
||
@Slf4j | ||
@Priority(-100) // high priority | ||
class NomadSecretProvider implements SecretsProvider, Closeable{ | ||
class NomadSecretProvider extends LocalSecretsProvider implements SecretsProvider { | ||
|
||
@Override | ||
void close() throws IOException { | ||
} | ||
NomadConfig config | ||
|
||
@Override | ||
boolean activable() { | ||
return true | ||
LocalSecretsProvider load() { | ||
return super.load() | ||
} | ||
|
||
@Override | ||
SecretsProvider load() { | ||
this | ||
protected boolean isEnabled(){ | ||
if( !config ){ | ||
config = new NomadConfig(Global.config?.nomad as Map ?: Map.of()) | ||
} | ||
config?.jobOpts()?.secretOpts?.enable | ||
} | ||
|
||
@Override | ||
Secret getSecret(String name) { | ||
log.debug("NomadSecretProvider can't get secret, use nomad cli or nextflow plugin nf-nomad:secrets") | ||
null | ||
if( !this.enabled ) { | ||
return super.getSecret(name) | ||
} | ||
NomadService service = new NomadService(config) | ||
String value = service.getVariableValue(name) | ||
return new SecretImpl(name: name, value: value) | ||
} | ||
|
||
@Override | ||
String getSecretsEnv(List<String> secretNames) { | ||
log.debug("NomadSecretProvider can't get secret, use nomad cli or nextflow plugin nf-nomad:secrets") | ||
if( !this.enabled ) { | ||
return super.getSecretsEnv(secretNames) | ||
} | ||
null | ||
} | ||
|
||
@Override | ||
String getSecretsEnv() { | ||
log.debug("NomadSecretProvider can't get secret, use nomad cli or nextflow plugin nf-nomad:secrets") | ||
if( !this.enabled ) { | ||
return super.getSecretsEnv() | ||
} | ||
null | ||
} | ||
|
||
@Override | ||
void putSecret(String name, String value) { | ||
throw new UnsupportedOperationException("NomadSecretProvider can't put secret, use nomad cli or nextflow plugin nf-nomad:secrets") | ||
if( !this.enabled ) { | ||
super.putSecret(name, value) | ||
} | ||
} | ||
|
||
@Override | ||
void removeSecret(String name) { | ||
throw new UnsupportedOperationException("NomadSecretProvider can't remove secret, use nomad cli or nextflow plugin nf-nomad:secrets") | ||
if( !this.enabled ) { | ||
super.removeSecret(name) | ||
} | ||
} | ||
|
||
@Override | ||
Set<String> listSecretsNames() { | ||
log.debug("NomadSecretProvider can't get secret, use nomad cli or nextflow plugin nf-nomad:secrets") | ||
null | ||
if( !this.enabled ) { | ||
return super.listSecretsNames() | ||
} | ||
NomadService service = new NomadService(config) | ||
service.variablesList as Set<String> | ||
} | ||
|
||
} |
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,3 +18,6 @@ process sayHello { | |
workflow { | ||
Channel.of('Bonjour', 'Ciao', 'Hello', 'Hola') | sayHello | view | ||
} | ||
workflow.onComplete { | ||
println("The secret is: ${secrets.MY_ACCESS_KEY}") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. with current implementation we can access to nomad variables also in workflows!!! |
||
} |
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
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