-
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.
Merge pull request #32 from nextflow-io/abhinav/nomad-env-vars
Use env vars as an alternative to client config
- Loading branch information
Showing
13 changed files
with
444 additions
and
236 deletions.
There are no files selected for viewing
168 changes: 0 additions & 168 deletions
168
plugins/nf-nomad/src/main/nextflow/nomad/NomadConfig.groovy
This file was deleted.
Oops, something went wrong.
23 changes: 22 additions & 1 deletion
23
plugins/nf-nomad/src/main/nextflow/nomad/config/AffinitySpec.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
22 changes: 22 additions & 0 deletions
22
plugins/nf-nomad/src/main/nextflow/nomad/config/ConstraintSpec.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
56 changes: 56 additions & 0 deletions
56
plugins/nf-nomad/src/main/nextflow/nomad/config/NomadClientOpts.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,56 @@ | ||
/* | ||
* Copyright 2023-, Stellenbosch University, South Africa | ||
* Copyright 2024, Evaluacion y Desarrollo de Negocios, Spain | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package nextflow.nomad.config | ||
|
||
import groovy.transform.CompileStatic | ||
import groovy.util.logging.Slf4j | ||
|
||
|
||
/** | ||
* Nomad Config | ||
* | ||
* @author Jorge Aguilera <jagedn@gmail.com> | ||
* @author Abhinav Sharma <abhi18av@outlook.com> | ||
*/ | ||
|
||
@Slf4j | ||
@CompileStatic | ||
class NomadClientOpts{ | ||
|
||
final static protected API_VERSION = "v1" | ||
|
||
private Map<String,String> sysEnv | ||
|
||
final String address | ||
final String token | ||
|
||
NomadClientOpts(Map nomadClientOpts, Map<String,String> env=null){ | ||
assert nomadClientOpts!=null | ||
|
||
sysEnv = env==null ? new HashMap<String,String>(System.getenv()) : env | ||
|
||
def tmp = (nomadClientOpts.address?.toString() ?: sysEnv.get('NOMAD_ADDR')) | ||
|
||
if( !tmp.endsWith("/")) | ||
tmp +="/" | ||
this.address = tmp + API_VERSION | ||
this.token = nomadClientOpts.token ?: sysEnv.get('NOMAD_TOKEN') | ||
|
||
//TODO: Add mTLS properties and env vars | ||
// https://developer.hashicorp.com/nomad/docs/commands#mtls-environment-variables | ||
} | ||
} |
62 changes: 62 additions & 0 deletions
62
plugins/nf-nomad/src/main/nextflow/nomad/config/NomadConfig.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,62 @@ | ||
/* | ||
* Copyright 2023-, Stellenbosch University, South Africa | ||
* Copyright 2024, Evaluacion y Desarrollo de Negocios, Spain | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package nextflow.nomad.config | ||
|
||
import groovy.transform.CompileStatic | ||
import groovy.util.logging.Slf4j | ||
|
||
|
||
/** | ||
* Nomad Config | ||
* | ||
* @author Jorge Aguilera <jagedn@gmail.com> | ||
* @author Abhinav Sharma <abhi18av@outlook.com> | ||
*/ | ||
|
||
@Slf4j | ||
@CompileStatic | ||
class NomadConfig { | ||
|
||
private NomadClientOpts clientOpts | ||
private NomadJobOpts jobOpts | ||
private NomadDebug debug | ||
|
||
NomadConfig(Map nomadConfigMap) { | ||
this.clientOpts = new NomadClientOpts((nomadConfigMap?.client ?: Collections.emptyMap()) as Map) | ||
this.jobOpts = new NomadJobOpts((nomadConfigMap?.jobs ?: Collections.emptyMap()) as Map) | ||
this.debug = new NomadDebug((nomadConfigMap?.debug ?: Collections.emptyMap()) as Map) | ||
} | ||
|
||
|
||
NomadClientOpts clientOpts() { clientOpts } | ||
|
||
NomadJobOpts jobOpts() { jobOpts } | ||
|
||
NomadDebug debug() { debug } | ||
|
||
static class NomadDebug { | ||
|
||
@Delegate | ||
Map<String,Object> target | ||
|
||
NomadDebug(Map<String,Object> debug) { | ||
this.target = debug ?: Collections.<String,Object>emptyMap() | ||
} | ||
|
||
boolean getJson() { Boolean.valueOf( target.json as String ) } | ||
} | ||
} |
Oops, something went wrong.