@@ -22,6 +22,7 @@ import (
22
22
kutilerrors "k8s.io/kubernetes/pkg/util/errors"
23
23
24
24
dockerfileparser "github.com/docker/docker/builder/dockerfile/parser"
25
+ ometa "github.com/openshift/origin/pkg/api/meta"
25
26
authapi "github.com/openshift/origin/pkg/authorization/api"
26
27
buildapi "github.com/openshift/origin/pkg/build/api"
27
28
buildutil "github.com/openshift/origin/pkg/build/util"
@@ -361,21 +362,37 @@ func (c *AppConfig) buildPipelines(components app.ComponentReferences, environme
361
362
}
362
363
363
364
// buildTemplates converts a set of resolved, valid references into references to template objects.
364
- func (c * AppConfig ) buildTemplates (components app.ComponentReferences , environment app.Environment ) (string , []runtime.Object , error ) {
365
+ func (c * AppConfig ) buildTemplates (components app.ComponentReferences , parameters app. Environment , environment app.Environment ) (string , []runtime.Object , error ) {
365
366
objects := []runtime.Object {}
366
367
name := ""
367
368
for _ , ref := range components {
368
369
tpl := ref .Input ().ResolvedMatch .Template
369
370
370
371
glog .V (4 ).Infof ("processing template %s/%s" , c .OriginNamespace , tpl .Name )
371
- result , err := TransformTemplate (tpl , c .OSClient , c .OriginNamespace , environment )
372
+ result , err := TransformTemplate (tpl , c .OSClient , c .OriginNamespace , parameters )
372
373
if err != nil {
373
374
return name , nil , err
374
375
}
375
376
if len (name ) == 0 {
376
377
name = tpl .Name
377
378
}
378
379
objects = append (objects , result .Objects ... )
380
+ if len (result .Objects ) > 0 {
381
+ // if environment variables were passed in, let's apply the environment variables
382
+ // to every pod template object
383
+ for i := range result .Objects {
384
+ podSpec , _ , err := ometa .GetPodSpec (result .Objects [i ])
385
+ if err == nil {
386
+ for ii := range podSpec .Containers {
387
+ if podSpec .Containers [ii ].Env != nil {
388
+ podSpec .Containers [ii ].Env = app .JoinEnvironment (environment .List (), podSpec .Containers [ii ].Env )
389
+ } else {
390
+ podSpec .Containers [ii ].Env = environment .List ()
391
+ }
392
+ }
393
+ }
394
+ }
395
+ }
379
396
380
397
DescribeGeneratedTemplate (c .Out , ref .Input ().String (), result , c .OriginNamespace )
381
398
}
@@ -666,7 +683,7 @@ func (c *AppConfig) Run() (*AppResult, error) {
666
683
667
684
objects = app .AddServices (objects , false )
668
685
669
- templateName , templateObjects , err := c .buildTemplates (components .TemplateComponentRefs (), app .Environment (parameters ))
686
+ templateName , templateObjects , err := c .buildTemplates (components .TemplateComponentRefs (), app .Environment (parameters ), app . Environment ( environment ) )
670
687
if err != nil {
671
688
return nil , err
672
689
}
@@ -710,6 +727,22 @@ func (c *AppConfig) Run() (*AppResult, error) {
710
727
}
711
728
}
712
729
730
+ /*
731
+ if len(templateObjects) > 0 {
732
+ for i := range objects {
733
+ podSpec, _, err := ometa.GetPodSpec(objects[i])
734
+ if err == nil {
735
+ for ii := range podSpec.Containers {
736
+ if podSpec.Containers[ii].Env != nil {
737
+ podSpec.Containers[ii].Env = app.JoinEnvironment(podSpec.Containers[ii].Env, app.Environment(environment).List())
738
+ } else {
739
+ podSpec.Containers[ii].Env = app.Environment(environment).List()
740
+ }
741
+ }
742
+ }
743
+ }
744
+ }
745
+ */
713
746
return & AppResult {
714
747
List : & kapi.List {Items : objects },
715
748
Name : name ,
0 commit comments