docker / app

Make your Docker Compose applications reusable, and share them on Docker Hub
Apache License 2.0
1.57k stars 177 forks source link

docker-app render changes "mode" property value of the configs #423

Open mcadac opened 5 years ago

mcadac commented 5 years ago

Description

docker-app render changes "mode" property value of the configs when the numeric value start with "0"

Steps to reproduce the issue:

  1. Create a docker-compose with a config mode like this

    • source: nginx-config target: /etc/nginx/nginx.conf uid: '5000' gid: '5000' mode: 0660
  2. Execute docker-app render

Describe the results you received:

- source: nginx-config
  target: /etc/nginx/nginx.conf
  uid: "5000"
  gid: "5000"
  mode: 432

Describe the results you expected:

- source: nginx-config
  target: /etc/nginx/nginx.conf
  uid: '5000'
  gid: '5000'
  mode: 0660

Output of docker version:

Client: Docker Engine - Community
 Version:           18.09.0
 API version:       1.39
 Go version:        go1.10.4
 Git commit:        4d60db4
 Built:             Wed Nov  7 00:47:51 2018
 OS/Arch:           windows/amd64
 Experimental:      false

Server: Docker Engine - Community
 Engine:
  Version:          18.09.0
  API version:      1.39 (minimum version 1.12)
  Go version:       go1.10.4
  Git commit:       4d60db4
  Built:            Wed Nov  7 00:55:00 2018
  OS/Arch:          linux/amd64
  Experimental:     false

Output of docker-app version:

Version:      v0.6.0-14-gcc05b95b-dirty
Git commit:   cc05b95b
Built:        Tue Nov 13 13:52:09 2018
OS/Arch:      windows/amd64
Experimental: on
Renderers:    gotemplate, mustache, none, yatee
ulyssessouza commented 5 years ago

The number 432 is the decimal form of the octal 0660. Looks like it's properly read as octal but rendered on its decimal format.

simonferquel commented 5 years ago

Not sure if we can do anything about it, might require a patch in the upstream yaml parsing/rendering package

ijc commented 5 years ago

Using some sort of type octalMode int and then func (o octalMode) SomeInterfaceMethodToRenderIt is usually enough. If app is using the gopkg.in/yaml.v2 parser then MarshalYAML is the SomeInterfaceMethodToRenderIt you need.

Doesn't quite help if you need to preserve whatever was written (i.e. want to support keeping decimal input as is). For that I think you'd basically need a string... But rendering mode unconditionally as octal seems like it wouldn't be too bad.

simonferquel commented 5 years ago

Good call @ijc. Would need to happen in Docker CLI though. Adding the flag.

ulyssessouza commented 5 years ago

@ijc I've tried to print it unconditionally as octal before but it renders as a string.

I've issued that in https://github.com/go-yaml/yaml/issues/420

mcadac commented 5 years ago

Using some sort of type octalMode int and then func (o octalMode) SomeInterfaceMethodToRenderIt is usually enough. If app is using the gopkg.in/yaml.v2 parser then MarshalYAML is the SomeInterfaceMethodToRenderIt you need.

Doesn't quite help if you need to preserve whatever was written (i.e. want to support keeping decimal input as is). For that I think you'd basically need a string... But rendering mode unconditionally as octal seems like it wouldn't be too bad.

@ijc That's right, but in this case, we need to preserve the value because it is file permission in our container, and then when we run container it generates an error for this reason.