Skip to content

Commit

Permalink
added 'wave.scan.cache.enabled'
Browse files Browse the repository at this point in the history
Signed-off-by: munishchouhan <[email protected]>
  • Loading branch information
munishchouhan committed Sep 24, 2024
1 parent 592b727 commit cf25844
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 21 deletions.
12 changes: 9 additions & 3 deletions src/main/groovy/io/seqera/wave/configuration/ScanConfig.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,21 @@ class ScanConfig {
@Value('${wave.scan.retry-attempts:1}')
int retryAttempts

@Value('${wave.scan.cache.enabled:true}')
boolean enableCache

String getScanImage() {
return scanImage
}

@Memoized
Path getCacheDirectory() {
final result = Path.of(buildDirectory).toAbsolutePath().resolve('.trivy-cache')
Files.createDirectories(result)
return result
if ( enableCache ){
final result = Path.of(buildDirectory).toAbsolutePath().resolve('.trivy-cache')
Files.createDirectories(result)
return result
}
return null
}

String getRequestsCpu() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ import jakarta.inject.Inject
@Property(name='wave.build.workspace', value='/some/wsp')
@Property(name='wave.build.repo', value='wave/build')
@Property(name='wave.build.cache', value='wave/build/cache')
@Property(name='wave.scan.cache.enabled', value='false')
class ContainerControllerTest extends Specification {

@Inject
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import io.kubernetes.client.openapi.models.V1Pod
import io.kubernetes.client.openapi.models.V1PodList
import io.kubernetes.client.openapi.models.V1PodStatus
import io.micronaut.context.ApplicationContext
import io.micronaut.context.annotation.Property
import io.micronaut.context.annotation.Replaces
import io.micronaut.test.extensions.spock.annotation.MicronautTest
import io.seqera.wave.configuration.BlobCacheConfig
Expand Down Expand Up @@ -66,7 +67,8 @@ class K8sServiceImplTest extends Specification {
'wave.build.k8s.configPath': '/home/kube.config',
'wave.build.k8s.storage.claimName': 'bar',
'wave.build.k8s.storage.mountPath': '/build',
'wave.scan.enabled': 'true']
'wave.scan.enabled': 'true',
'wave.scan.cache.enabled': 'false']
and:
def ctx = ApplicationContext.run(PROPS)
ctx.getBean(K8sServiceImpl)
Expand Down Expand Up @@ -96,7 +98,8 @@ class K8sServiceImplTest extends Specification {
'wave.build.k8s.namespace': 'foo',
'wave.build.k8s.configPath': '/home/kube.config',
'wave.build.k8s.storage.claimName': 'bar',
'wave.build.k8s.storage.mountPath': '/build' ]
'wave.build.k8s.storage.mountPath': '/build',
'wave.scan.cache.enabled': 'false' ]
and:
def ctx = ApplicationContext.run(PROPS)
def k8sService = ctx.getBean(K8sServiceImpl)
Expand Down Expand Up @@ -143,7 +146,8 @@ class K8sServiceImplTest extends Specification {
'wave.build.k8s.namespace': 'foo',
'wave.build.k8s.configPath': '/home/kube.config',
'wave.build.k8s.storage.claimName': 'bar',
'wave.build.k8s.storage.mountPath': '/build' ]
'wave.build.k8s.storage.mountPath': '/build',
'wave.scan.cache.enabled': 'false' ]
and:
def ctx = ApplicationContext.run(PROPS)
def k8sService = ctx.getBean(K8sServiceImpl)
Expand Down Expand Up @@ -171,7 +175,8 @@ class K8sServiceImplTest extends Specification {
'wave.build.k8s.namespace': 'foo',
'wave.build.k8s.configPath': '/home/kube.config',
'wave.build.k8s.storage.claimName': 'bar',
'wave.build.k8s.storage.mountPath': '/build' ]
'wave.build.k8s.storage.mountPath': '/build',
'wave.scan.cache.enabled': 'false' ]
and:
def ctx = ApplicationContext.run(PROPS)
def k8sService = ctx.getBean(K8sServiceImpl)
Expand All @@ -195,7 +200,8 @@ class K8sServiceImplTest extends Specification {
'wave.build.k8s.namespace' : 'my-ns',
'wave.build.k8s.configPath' : '/home/kube.config',
'wave.build.k8s.storage.claimName': 'build-claim',
'wave.build.k8s.storage.mountPath': '/build']
'wave.build.k8s.storage.mountPath': '/build',
'wave.scan.cache.enabled': 'false']
and:
def ctx = ApplicationContext.run(PROPS)
def k8sService = ctx.getBean(K8sServiceImpl)
Expand Down Expand Up @@ -238,7 +244,8 @@ class K8sServiceImplTest extends Specification {
'wave.build.k8s.namespace': 'my-ns',
'wave.build.k8s.configPath': '/home/kube.config',
'wave.build.k8s.storage.claimName': 'build-claim',
'wave.build.k8s.storage.mountPath': '/build' ]
'wave.build.k8s.storage.mountPath': '/build',
'wave.scan.cache.enabled': 'false' ]
and:
def ctx = ApplicationContext.run(PROPS)
def k8sService = ctx.getBean(K8sServiceImpl)
Expand Down Expand Up @@ -285,7 +292,8 @@ class K8sServiceImplTest extends Specification {
'wave.build.k8s.namespace': 'my-ns',
'wave.build.k8s.configPath': '/home/kube.config',
'wave.build.k8s.storage.claimName': 'build-claim',
'wave.build.k8s.storage.mountPath': '/build' ]
'wave.build.k8s.storage.mountPath': '/build',
'wave.scan.cache.enabled': 'false' ]
and:
def ctx = ApplicationContext.run(PROPS)
def k8sService = ctx.getBean(K8sServiceImpl)
Expand Down Expand Up @@ -329,7 +337,8 @@ class K8sServiceImplTest extends Specification {
'wave.build.k8s.configPath': '/home/kube.config',
'wave.build.k8s.storage.claimName': 'bar',
'wave.build.k8s.storage.mountPath': '/build',
'wave.build.k8s.labels': ['department': 'unit a','organization': 'org']
'wave.build.k8s.labels': ['department': 'unit a','organization': 'org'],
'wave.scan.cache.enabled': 'false'
]
and:
def ctx = ApplicationContext.run(PROPS)
Expand Down Expand Up @@ -359,6 +368,7 @@ class K8sServiceImplTest extends Specification {
],
'wave.build.k8s.resources.requests.cpu': '2',
'wave.build.k8s.resources.requests.memory': '4Gi',
'wave.scan.cache.enabled': 'false'
] as Map<String,Object>
and:
def ctx = ApplicationContext.run(PROPS)
Expand All @@ -384,7 +394,8 @@ class K8sServiceImplTest extends Specification {
'wave.build.k8s.configPath': '/home/kube.config',
'wave.build.k8s.storage.claimName': 'bar',
'wave.build.k8s.storage.mountPath': '/build',
'wave.build.k8s.service-account': 'theAdminAccount'
'wave.build.k8s.service-account': 'theAdminAccount',
'wave.scan.cache.enabled': 'false'
]
and:
def ctx = ApplicationContext.run(PROPS)
Expand All @@ -406,7 +417,8 @@ class K8sServiceImplTest extends Specification {
'wave.build.k8s.namespace': 'my-ns',
'wave.build.k8s.configPath': '/home/kube.config',
'wave.build.k8s.storage.claimName': 'build-claim',
'wave.build.k8s.storage.mountPath': '/build', ]
'wave.build.k8s.storage.mountPath': '/build',
'wave.scan.cache.enabled': 'false' ]
and:
def ctx = ApplicationContext.run(PROPS)
def k8sService = ctx.getBean(K8sServiceImpl)
Expand Down Expand Up @@ -451,7 +463,8 @@ class K8sServiceImplTest extends Specification {
def PROPS = [
'wave.build.workspace': '/build/work',
'wave.build.k8s.namespace': 'my-ns',
'wave.build.k8s.configPath': '/home/kube.config' ]
'wave.build.k8s.configPath': '/home/kube.config',
'wave.scan.cache.enabled': 'false' ]
and:
def ctx = ApplicationContext.run(PROPS)
def k8sService = ctx.getBean(K8sServiceImpl)
Expand Down Expand Up @@ -487,7 +500,8 @@ class K8sServiceImplTest extends Specification {
'wave.build.workspace': '/build/work',
'wave.build.k8s.namespace': 'my-ns',
'wave.build.k8s.service-account': 'foo-sa',
'wave.build.k8s.configPath': '/home/kube.config' ]
'wave.build.k8s.configPath': '/home/kube.config',
'wave.scan.cache.enabled': 'false' ]
and:
def ctx = ApplicationContext.run(PROPS)
def k8sService = ctx.getBean(K8sServiceImpl)
Expand Down Expand Up @@ -633,7 +647,8 @@ class K8sServiceImplTest extends Specification {
'wave.build.k8s.configPath': '/home/kube.config',
'wave.build.k8s.storage.claimName': 'build-claim',
'wave.build.k8s.storage.mountPath': '/build',
'wave.build.retry-attempts': 3
'wave.build.retry-attempts': 3,
'wave.scan.cache.enabled': 'false'
]
and:
def ctx = ApplicationContext.run(PROPS)
Expand Down Expand Up @@ -685,7 +700,8 @@ class K8sServiceImplTest extends Specification {
'wave.build.k8s.configPath': '/home/kube.config',
'wave.build.k8s.storage.claimName': 'build-claim',
'wave.build.k8s.storage.mountPath': '/build',
'wave.build.retry-attempts': 3
'wave.build.retry-attempts': 3,
'wave.scan.cache.enabled': 'false'
]
and:
def ctx = ApplicationContext.run(PROPS)
Expand Down Expand Up @@ -734,7 +750,8 @@ class K8sServiceImplTest extends Specification {
'wave.build.k8s.configPath': '/home/kube.config',
'wave.build.k8s.storage.claimName': 'bar',
'wave.build.k8s.storage.mountPath': '/build',
'wave.build.k8s.service-account': 'theAdminAccount'
'wave.build.k8s.service-account': 'theAdminAccount',
'wave.scan.cache.enabled': 'false'
]
and:
def ctx = ApplicationContext.run(PROPS)
Expand Down Expand Up @@ -778,7 +795,8 @@ class K8sServiceImplTest extends Specification {
'wave.build.k8s.configPath': '/home/kube.config',
'wave.build.k8s.storage.claimName': 'bar',
'wave.build.k8s.storage.mountPath': '/build',
'wave.build.k8s.service-account': 'theAdminAccount'
'wave.build.k8s.service-account': 'theAdminAccount',
'wave.scan.cache.enabled': 'false'
]
and:
def ctx = ApplicationContext.run(PROPS)
Expand Down Expand Up @@ -823,6 +841,7 @@ class K8sServiceImplTest extends Specification {
'wave.build.k8s.storage.claimName': 'bar',
'wave.build.k8s.storage.mountPath': '/build',
'wave.build.k8s.service-account': 'theAdminAccount',
'wave.scan.cache.enabled': 'false'
]
and:
def ctx = ApplicationContext.run(PROPS)
Expand Down Expand Up @@ -869,7 +888,8 @@ class K8sServiceImplTest extends Specification {
'wave.build.k8s.storage.claimName': 'bar',
'wave.build.k8s.storage.mountPath': '/build',
'wave.build.k8s.service-account': 'theAdminAccount',
'wave.mirror.retry-attempts': 3
'wave.mirror.retry-attempts': 3,
'wave.scan.cache.enabled': 'false'
]
and:
def ctx = ApplicationContext.run(PROPS)
Expand Down Expand Up @@ -928,7 +948,8 @@ class K8sServiceImplTest extends Specification {
'wave.build.k8s.storage.claimName': 'bar',
'wave.build.k8s.storage.mountPath': '/build',
'wave.build.k8s.service-account': 'theAdminAccount',
'wave.scan.retry-attempts': 3
'wave.scan.retry-attempts': 3,
'wave.scan.cache.enabled': 'false'
]
and:
def ctx = ApplicationContext.run(PROPS)
Expand Down

0 comments on commit cf25844

Please sign in to comment.