Added validation and docs for commands in container API#961
Conversation
Signed-off-by: munishchouhan <hrma017@gmail.com>
…ing-commands-in-cran-builds
Signed-off-by: munishchouhan <hrma017@gmail.com>
Signed-off-by: munishchouhan <hrma017@gmail.com>
Signed-off-by: munishchouhan <hrma017@gmail.com>
Signed-off-by: munishchouhan <hrma017@gmail.com>
|
tested locally:
|
…ing-commands-in-cran-builds
This reverts commit 56d4c3b.
|
The problem with this PR is that encourages a fragmentation across singularity and and docker build, while we should try to limit as much as possible . I think it would be better to limit I've reverted by commit from master. |
Ok, SO only |
|
It would be assumed the |
Summary
Updated TypeSpec API definitions and documentation to clarify that the commands field in CranOpts, CondaOpts, and PixiOpts requires valid Dockerfile instruction keywords
(e.g., RUN, CMD, ENTRYPOINT, USER).
Changes
wave-utils/src/main/java/io/seqera/wave/util/DockerHelper.java):validateCommands(List<String>)method to validate command listsisValidDockerCommand(String)method to check individual commandsgetValidKeywords()method to expose the set of valid keywordsFROM,RUN,CMD,LABEL,EXPOSE,ENV,ADD,COPYENTRYPOINT,VOLUME,USER,WORKDIR,ARG,ONBUILDSTOPSIGNAL,HEALTHCHECK,SHELL^\\s*([A-Z]+)\\b) to extract and validate keywordsIllegalArgumentExceptionwith detailed error message including command indexIntegration Points
CranHelper (
src/main/groovy/io/seqera/wave/util/CranHelper.groovy):addCommandsmethod to callDockerHelper.validateCommands()TemplateUtils (
src/main/java/io/seqera/wave/util/TemplateUtils.java):addCommandsmethod to callDockerHelper.validateCommands()Test Coverage
DockerHelperTest (
wave-utils/src/test/groovy/io/seqera/wave/util/DockerHelperTest.groovy):CranHelperTest (
src/test/groovy/io/seqera/wave/util/CranHelperTest.groovy):TemplateUtilsTest (
src/test/groovy/io/seqera/wave/util/TemplateUtilsTest.groovy):Examples Updated
Before (would cause Docker build error)
{ "cranOpts": { "commands": ["apt-get update"] } }After (valid)
{ "cranOpts": { "commands": [ "RUN apt-get update", "ENV MY_VAR=value", "USER root", "WORKDIR /app" ] } }