Browse code

Merge pull request #31006 from vdemeester/30991-secret-mode-in-stack-deploy

Set 0444 as default secret mode in stack deploy
(cherry picked from commit a12454d7a964b99921adabdb8f741da5a94a0e66)

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>

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