Browse code

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 <vincent@sbr.pm>

Vincent Demeester authored on 2017/02/14 23:12:03
Showing 2 changed files
... ...
@@ -217,19 +217,27 @@ func convertServiceSecrets(
217 217
 		if gid == "" {
218 218
 			gid = "0"
219 219
 		}
220
+		mode := secret.Mode
221
+		if mode == nil {
222
+			mode = uint32Ptr(0444)
223
+		}
220 224
 
221 225
 		opts = append(opts, &types.SecretRequestOption{
222 226
 			Source: source,
223 227
 			Target: target,
224 228
 			UID:    uid,
225 229
 			GID:    gid,
226
-			Mode:   os.FileMode(secret.Mode),
230
+			Mode:   os.FileMode(*mode),
227 231
 		})
228 232
 	}
229 233
 
230 234
 	return servicecli.ParseSecrets(client, opts)
231 235
 }
232 236
 
237
+func uint32Ptr(value uint32) *uint32 {
238
+	return &value
239
+}
240
+
233 241
 func convertExtraHosts(extraHosts map[string]string) []string {
234 242
 	hosts := []string{}
235 243
 	for host, ip := range extraHosts {
... ...
@@ -229,7 +229,7 @@ type ServiceSecretConfig struct {
229 229
 	Target string
230 230
 	UID    string
231 231
 	GID    string
232
-	Mode   uint32
232
+	Mode   *uint32
233 233
 }
234 234
 
235 235
 // UlimitsConfig the ulimit configuration