docker-app render changes "mode" property value of the configs
Description
docker-app render changes "mode" property value of the configs when the numeric value start with "0"
Steps to reproduce the issue:
-
Create a docker-compose with a config mode like this
- source: nginx-config target: /etc/nginx/nginx.conf uid: '5000' gid: '5000' mode: 0660
-
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
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.
Not sure if we can do anything about it, might require a patch in the upstream yaml parsing/rendering package
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.
Good call @ijc. Would need to happen in Docker CLI though. Adding the flag.
@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
Using some sort of
type octalMode intand thenfunc (o octalMode) SomeInterfaceMethodToRenderItis usually enough. Ifappis using thegopkg.in/yaml.v2parser thenMarshalYAMLis theSomeInterfaceMethodToRenderItyou 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.