Skip to content

Commit

Permalink
Fusion config improvement [ci fast]
Browse files Browse the repository at this point in the history
Signed-off-by: Paolo Di Tommaso <paolo.ditommaso@gmail.com>
  • Loading branch information
pditommaso committed Jan 30, 2023
1 parent bb890d9 commit a1d0846
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,12 @@ class FusionConfig {
this.enabled = opts.enabled
this.exportAwsAccessKeys = opts.exportAwsAccessKeys
this.containerConfigUrl = opts.containerConfigUrl?.toString() ?: env.get('FUSION_CONTAINER_CONFIG_URL')
if( containerConfigUrl && (!containerConfigUrl.startsWith('http://') && !containerConfigUrl.startsWith('https://')))
if( containerConfigUrl && !validProtocol(containerConfigUrl))
throw new IllegalArgumentException("Fusion container config URL should start with 'http:' or 'https:' protocol prefix - offending value: $containerConfigUrl")
}

protected boolean validProtocol(String url) {
url.startsWith('http://') || url.startsWith('https://') || url.startsWith('file:/')
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ class FusionConfigTest extends Specification {
OPTS | ENV | EXPECTED
[:] | [:] | null
[containerConfigUrl:'http://foo.com'] | [:] | 'http://foo.com'
[containerConfigUrl:'https://bar.com'] | [:] | 'https://bar.com'
[containerConfigUrl:'file:///some/file']| [:] | 'file:///some/file'
[:] | [FUSION_CONTAINER_CONFIG_URL:'http://bar.com'] | 'http://bar.com'
[containerConfigUrl:'http://foo.com'] | [FUSION_CONTAINER_CONFIG_URL:'http://bar.com'] | 'http://foo.com'

Expand Down

0 comments on commit a1d0846

Please sign in to comment.