swagger-api / swagger-api/swagger-codegen

Allow using help command with run-in-docker.sh/docker-entrypoint.sh

Open
#6,703 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Mustache
Stars
17.8k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

Description

docker-entrypoint.sh does not find the "help" @Command even though it is a valid command.

Swagger-codegen version

2.3.0-SNAPSHOT (b22fb30891a8c6a576ead24358dbcd77af2f75c8)

Steps to reproduce
$ ./run-in-docker.sh help
++ dirname ./run-in-docker.sh
+ cd .
+ maven_cache_repo=/home/ted/.m2/repository
+ mkdir -p /home/ted/.m2/repository
++ id -u
++ id -g
+ docker run --rm -it -w /gen -e GEN_DIR=/gen -e MAVEN_CONFIG=/var/maven/.m2 -u 1000:1000 -v /home/ted/swagger-codegen:/gen -v /home/ted/.m2/repository:/var/maven/.m2/repository --entrypoint /gen/docker-entrypoint.sh maven:3-jdk-7 help
match
/gen/docker-entrypoint.sh: line 26: exec: help: not found
Suggest a fix/enhancement

Allow using the help command. Quick workaround patch:

diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh
index 556b6ff..b6e7804 100755
--- a/docker-entrypoint.sh
+++ b/docker-entrypoint.sh
@@ -11,7 +11,7 @@ codegen="${cli}/target/swagger-codegen-cli.jar"
 cmdsrc="${cli}/src/main/java/io/swagger/codegen/cmd"
 
 pattern="@Command(name = \"$1\""
-if expr "x$1" : 'x[a-z][a-z-]*$' > /dev/null && fgrep -qe "$pattern" "$cmdsrc"/*.java; then
+if expr "x$1" : 'x[a-z][a-z-]*$' > /dev/null && fgrep -qe "$pattern" "$cmdsrc"/*.java || expr "$1" = 'help' > /dev/null ; then
     # If ${GEN_DIR} has been mapped elsewhere from default, and that location has not been built
     if [[ ! -f "${codegen}" ]]; then
         (cd "${GEN_DIR}" && exec mvn -am -pl "modules/swagger-codegen-cli" -Duser.home=$(dirname MAVEN_CONFIG) package)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with docker-entrypoint.sh and run-in-docker.sh, then reproduce the failure with ./run-in-docker.sh help. Check how the entrypoint locates commands in cli/src/main/java/io/swagger/codegen/cmd; done means the help command runs successfully through the Docker wrapper without an exec: help error.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, shell
Domain
cli, devops
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.