app icon indicating copy to clipboard operation
app copied to clipboard

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

Open mcadac opened this issue 7 years ago • 6 comments

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

mcadac avatar Nov 30 '18 22:11 mcadac

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.

ulyssessouza avatar Dec 17 '18 11:12 ulyssessouza

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

simonferquel avatar Jan 14 '19 10:01 simonferquel

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 avatar Jan 14 '19 11:01 ijc

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

simonferquel avatar Jan 14 '19 11:01 simonferquel

@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

ulyssessouza avatar Jan 14 '19 12:01 ulyssessouza

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.

mcadac avatar Jan 21 '19 16:01 mcadac