From f2b68c6cc1664ca0c60457b8c713eec52902a2d2 Mon Sep 17 00:00:00 2001 From: Vincent Demeester Date: Tue, 14 Feb 2017 15:12:03 +0100 Subject: [PATCH] Set 0444 as default secret mode in stack deploy Change the default secret mode to match the default one used in `service` subcommands. Signed-off-by: Vincent Demeester --- cli/compose/convert/service.go | 10 +++++++++- cli/compose/types/types.go | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/cli/compose/convert/service.go b/cli/compose/convert/service.go index ef6a04ebcf..93b910967e 100644 --- a/cli/compose/convert/service.go +++ b/cli/compose/convert/service.go @@ -217,19 +217,27 @@ func convertServiceSecrets( if gid == "" { gid = "0" } + mode := secret.Mode + if mode == nil { + mode = uint32Ptr(0444) + } opts = append(opts, &types.SecretRequestOption{ Source: source, Target: target, UID: uid, GID: gid, - Mode: os.FileMode(secret.Mode), + Mode: os.FileMode(*mode), }) } return servicecli.ParseSecrets(client, opts) } +func uint32Ptr(value uint32) *uint32 { + return &value +} + func convertExtraHosts(extraHosts map[string]string) []string { hosts := []string{} for host, ip := range extraHosts { diff --git a/cli/compose/types/types.go b/cli/compose/types/types.go index c74014fb14..058c4d09b8 100644 --- a/cli/compose/types/types.go +++ b/cli/compose/types/types.go @@ -229,7 +229,7 @@ type ServiceSecretConfig struct { Target string UID string GID string - Mode uint32 + Mode *uint32 } // UlimitsConfig the ulimit configuration