From 868421024195fbb4e4e783b6556dacda39f222ca Mon Sep 17 00:00:00 2001 From: Brad Rydzewski Date: Thu, 21 Apr 2016 01:36:11 -0700 Subject: [PATCH] docker pull authentication using secrets --- engine/compiler/builtin/secrets.go | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/engine/compiler/builtin/secrets.go b/engine/compiler/builtin/secrets.go index bd472950..d5c41849 100644 --- a/engine/compiler/builtin/secrets.go +++ b/engine/compiler/builtin/secrets.go @@ -24,10 +24,22 @@ func (v *secretOp) VisitContainer(node *parse.ContainerNode) error { if !secret.Match(node.Container.Image, v.event) { continue } - if node.Container.Environment == nil { - node.Container.Environment = map[string]string{} + + switch secret.Name { + case "REGISTRY_USERNAME": + node.Container.AuthConfig.Username = secret.Value + case "REGISTRY_PASSWORD": + node.Container.AuthConfig.Password = secret.Value + case "REGISTRY_EMAIL": + node.Container.AuthConfig.Email = secret.Value + case "REGISTRY_TOKEN": + node.Container.AuthConfig.Token = secret.Value + default: + if node.Container.Environment == nil { + node.Container.Environment = map[string]string{} + } + node.Container.Environment[secret.Name] = secret.Value } - node.Container.Environment[secret.Name] = secret.Value } return nil }