OpenAPITools / openapi-generator-cli

A node package wrapper for https://github.com/OpenAPITools/openapi-generator
Apache License 2.0
1.47k stars 154 forks source link

[BUG] useDocker is not passing the user and group when running through the passthrough service #716

Open devzeebo opened 1 year ago

devzeebo commented 1 year ago

⚠️ Important Notice

Please differentiate the bug

This repository is not responsible for the actual code generation. If you have problems with the code generation, please open the bug at OpenAPITools/openapi-generator.

Please also check if the bug is already known before you open a new bug.


🐛 Bug Report:

Describe the bug

647 fixed the docker permissions for the generator.service. When executing the cli with options that use the passthrough.service instead, the docker user and group is not set, resulting in root:root permissions

Steps to Reproduce

Steps to reproduce the behavior:

  1. Run a generate command that invokes the passthrough service while using the useDocker option

Expected behavior

When using the passthrough service, the user and group flags are passed to docker

Screenshots

If applicable, add screenshots to help explain your problem.

Operation System (please complete the following information):

Package System (please complete the following information):

Additional context

Add any other context about the problem here.

kasir-barati commented 7 months ago

Having same issue...

anonysoul commented 6 months ago

docker run --user preventing file writing

[[v3.0] ../xsec-portal/src/main/resources/openapi/protocol.yaml] [main] WARN  o.o.c.l.AbstractTypeScriptClientCodegen - Error (model name matches existing language type) cannot be used as a model name. Renamed to ModelError
[[v3.0] ../xsec-portal/src/main/resources/openapi/protocol.yaml] [main] INFO  o.o.codegen.TemplateManager - writing file /local/output/model/./audit.ts
[[v3.0] ../xsec-portal/src/main/resources/openapi/protocol.yaml] Exception in thread "main" java.lang.RuntimeException: Could not generate model 'Audit'
[[v3.0] ../xsec-portal/src/main/resources/openapi/protocol.yaml]        at org.openapitools.codegen.DefaultGenerator.generateModels(DefaultGenerator.java:596)
[[v3.0] ../xsec-portal/src/main/resources/openapi/protocol.yaml]        at org.openapitools.codegen.DefaultGenerator.generateModels(DefaultGenerator.java:451)
[[v3.0] ../xsec-portal/src/main/resources/openapi/protocol.yaml]        at org.openapitools.codegen.DefaultGenerator.generate(DefaultGenerator.java:1304)
[[v3.0] ../xsec-portal/src/main/resources/openapi/protocol.yaml]        at org.openapitools.codegen.cmd.Generate.execute(Generate.java:535)
[[v3.0] ../xsec-portal/src/main/resources/openapi/protocol.yaml]        at org.openapitools.codegen.cmd.OpenApiGeneratorCommand.run(OpenApiGeneratorCommand.java:32)
[[v3.0] ../xsec-portal/src/main/resources/openapi/protocol.yaml]        at org.openapitools.codegen.OpenAPIGenerator.main(OpenAPIGenerator.java:66)
[[v3.0] ../xsec-portal/src/main/resources/openapi/protocol.yaml] Caused by: java.nio.file.NoSuchFileException: /local/output/model/./audit.ts
[[v3.0] ../xsec-portal/src/main/resources/openapi/protocol.yaml]        at java.base/sun.nio.fs.UnixException.translateToIOException(UnixException.java:92)
[[v3.0] ../xsec-portal/src/main/resources/openapi/protocol.yaml]        at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:106)
[[v3.0] ../xsec-portal/src/main/resources/openapi/protocol.yaml]        at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:111)
[[v3.0] ../xsec-portal/src/main/resources/openapi/protocol.yaml]        at java.base/sun.nio.fs.UnixFileSystemProvider.newByteChannel(UnixFileSystemProvider.java:218)
[[v3.0] ../xsec-portal/src/main/resources/openapi/protocol.yaml]        at java.base/java.nio.file.spi.FileSystemProvider.newOutputStream(FileSystemProvider.java:484)
[[v3.0] ../xsec-portal/src/main/resources/openapi/protocol.yaml]        at java.base/java.nio.file.Files.newOutputStream(Files.java:228)
[[v3.0] ../xsec-portal/src/main/resources/openapi/protocol.yaml]        at java.base/java.nio.file.Files.write(Files.java:3512)
[[v3.0] ../xsec-portal/src/main/resources/openapi/protocol.yaml]        at org.openapitools.codegen.TemplateManager.writeToFileRaw(TemplateManager.java:255)
[[v3.0] ../xsec-portal/src/main/resources/openapi/protocol.yaml]        at org.openapitools.codegen.TemplateManager.writeToFile(TemplateManager.java:237)
[[v3.0] ../xsec-portal/src/main/resources/openapi/protocol.yaml]        at org.openapitools.codegen.TemplateManager.writeToFile(TemplateManager.java:198)
[[v3.0] ../xsec-portal/src/main/resources/openapi/protocol.yaml]        at org.openapitools.codegen.TemplateManager.write(TemplateManager.java:164)
[[v3.0] ../xsec-portal/src/main/resources/openapi/protocol.yaml]        at org.openapitools.codegen.DefaultGenerator.processTemplateToFile(DefaultGenerator.java:1455)
[[v3.0] ../xsec-portal/src/main/resources/openapi/protocol.yaml]        at org.openapitools.codegen.DefaultGenerator.processTemplateToFile(DefaultGenerator.java:1442)
[[v3.0] ../xsec-portal/src/main/resources/openapi/protocol.yaml]        at org.openapitools.codegen.DefaultGenerator.generateModel(DefaultGenerator.java:439)
[[v3.0] ../xsec-portal/src/main/resources/openapi/protocol.yaml]        at org.openapitools.codegen.DefaultGenerator.generateModels(DefaultGenerator.java:587)
[[v3.0] ../xsec-portal/src/main/resources/openapi/protocol.yaml]        ... 5 more
[[v3.0] ../xsec-portal/src/main/resources/openapi/protocol.yaml] docker run --rm --user 1000:1000 -v "/home/anonysoul/workspace/company/xsec-server/xsec-portal/src/main/resources/openapi/protocol.yaml:/local/input-spec" -v "/home/anonysoul/workspace/company/xsec-server/xsec-webapp/src/app/core/openapi:/local/output" anonysoul/openapi-generator-cli:v7.6.0 generate --input-spec="/local/input-spec" --generator-name="typescript-angular" --output="/local/output" --additional-properties="fileNaming=kebab-case,withInterfaces=true" --generate-alias-as-model exited with code 1
[v3.0] ../xsec-portal/src/main/resources/openapi/protocol.yaml
  docker run --rm --user 1000:1000 -v "/home/anonysoul/workspace/company/xsec-server/xsec-portal/src/main/resources/openapi/protocol.yaml:/local/input-spec" -v "/home/anonysoul/workspace/company/xsec-server/xsec-webapp/src/app/core/openapi:/local/output" anonysoul/openapi-generator-cli:v7.6.0 generate --input-spec="/local/input-spec" --generator-name="typescript-angular" --output="/local/output" --additional-properties="fileNaming=kebab-case,withInterfaces=true" --generate-alias-as-model

Code generation failed

❌ [openapi-generate] exited with exit code 1.
❌ 1 script failed.