-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
enable nomad secrets via nextflow config
if false use Local implementation Signed-off-by: Jorge Aguilera <[email protected]>
- Loading branch information
Showing
7 changed files
with
85 additions
and
33 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
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
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