Skip to content
This repository has been archived by the owner on Aug 20, 2024. It is now read-only.

Does not validate Azure or Google blob storage #171

Merged
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# nextflow-io/nf-validation: Changelog

# Version 1.1.4

## Improvements

- No longer does false validation on Azure and GCP cloud storage paths ([#171](https://github.com/nextflow-io/nf-validation/pull/171))

# Version 1.1.3 - Asahikawa

## Improvements
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class DirectoryPathValidator implements FormatValidator {

@Override
public Optional<String> validate(final String subject) {
if (subject.startsWith('s3://')) {
if (subject.matches("(s3://|az://|gs://).*")) {
log.debug("S3 paths are not supported by 'DirectoryPathValidator': '${subject}'")
adamrtalbot marked this conversation as resolved.
Show resolved Hide resolved
return Optional.empty()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class FilePathPatternValidator implements FormatValidator {

@Override
public Optional<String> validate(final String subject) {
if (subject.startsWith('s3://')) {
if (subject.matches("(s3://|az://|gs://).*")) {
log.debug("S3 paths are not supported by 'FilePathPatternValidator': '${subject}'")
adamrtalbot marked this conversation as resolved.
Show resolved Hide resolved
return Optional.empty()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class FilePathValidator implements FormatValidator {

@Override
public Optional<String> validate(final String subject) {
if (subject.startsWith('s3://')) {
if (subject.matches("(s3://|az://|gs://).*")) {
log.debug("S3 paths are not supported by 'FilePathValidator': '${subject}'")
adamrtalbot marked this conversation as resolved.
Show resolved Hide resolved
return Optional.empty()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class PathValidator implements FormatValidator {

@Override
public Optional<String> validate(final String subject) {
if (subject.startsWith('s3://')) {
if (subject.matches("(s3://|az://|gs://).*")) {
log.debug("S3 paths are not supported by 'PathValidator': '${subject}'")
adamrtalbot marked this conversation as resolved.
Show resolved Hide resolved
return Optional.empty()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,7 @@ class SchemaValidator extends PluginExtensionPoint {
// Function to check if a file or directory exists
//
List pathExists(String path, String paramName, Boolean s3PathCheck) {
if (path.startsWith('s3://') && !s3PathCheck) {
if (path.matches("(s3://|az://|gs://).*") && !s3PathCheck) {
log.debug "Ignoring validation of S3 URL path '${path}'".toString()
adamrtalbot marked this conversation as resolved.
Show resolved Hide resolved
} else {
def Path file = Nextflow.file(path) as Path
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,72 @@ class PluginExtensionMethodsTest extends Dsl2Spec{
!stdout
}

def 'should ignore s3 path' () {
given:
def schema = Path.of('src/testResources/nextflow_schema_file_cloud_path.json').toAbsolutePath().toString()
def SCRIPT_TEXT = """
params.input = 's3://fake/path'
include { validateParameters } from 'plugin/nf-validation'

validateParameters(parameters_schema: '$schema')
"""

when:
dsl_eval(SCRIPT_TEXT)
def stdout = capture
.toString()
.readLines()
.findResults {it.contains('WARN nextflow.validation.SchemaValidator') || it.startsWith('* --') ? it : null }

then:
noExceptionThrown()
!stdout
}

def 'should ignore az path' () {
given:
def schema = Path.of('src/testResources/nextflow_schema_file_cloud_path.json').toAbsolutePath().toString()
def SCRIPT_TEXT = """
params.input = 'az://fake/path'
include { validateParameters } from 'plugin/nf-validation'

validateParameters(parameters_schema: '$schema')
"""

when:
dsl_eval(SCRIPT_TEXT)
def stdout = capture
.toString()
.readLines()
.findResults {it.contains('WARN nextflow.validation.SchemaValidator') || it.startsWith('* --') ? it : null }

then:
noExceptionThrown()
!stdout
}

def 'should ignore gs path' () {
given:
def schema = Path.of('src/testResources/nextflow_schema_file_cloud_path.json').toAbsolutePath().toString()
def SCRIPT_TEXT = """
params.input = 'gs://fake/path'
include { validateParameters } from 'plugin/nf-validation'

validateParameters(parameters_schema: '$schema')
"""

when:
dsl_eval(SCRIPT_TEXT)
def stdout = capture
.toString()
.readLines()
.findResults {it.contains('WARN nextflow.validation.SchemaValidator') || it.startsWith('* --') ? it : null }

then:
noExceptionThrown()
!stdout
}

def 'correct validation of numbers with lenient mode' () {
given:
def schema = Path.of('src/testResources/nextflow_schema.json').toAbsolutePath().toString()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"$schema": "http://json-schema.org/draft-07/schema",
"$id": "https://raw.githubusercontent.com/nf-core/testpipeline/master/nextflow_schema.json",
"title": "nf-core/testpipeline pipeline parameters",
"description": "this is a test",
"type": "object",
"definitions": {
"file_patterns": {
"title": "Input/output options",
"type": "object",
"fa_icon": "fas fa-terminal",
"properties": {
"input": {
"type": "string",
"format": "file-path",
"exists": true
}
}
}
},
"allOf": [
{
"$ref": "#/definitions/file_patterns"
}
]
}
Loading