Skip to content

Commit 3e80b27

Browse files
committed
Propagate values from parent to child
1 parent 6651269 commit 3e80b27

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

internal/builtins/pkg_context.go

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ func (pc *PackageContextGenerator) Process(resourceList *framework.ResourceList)
7474
updatedResources = append(updatedResources, resource)
7575
if gvk.Equals(kptfileGVK) {
7676
// it's a Kptfile, generate a corresponding package context
77-
pkgContext, err := pkgContextResource(resource)
77+
pkgContext, err := pkgContextResource(resource, resourceList.FunctionConfig)
7878
if err != nil {
7979
resourceList.Results = framework.Results{
8080
&framework.Result{
@@ -103,7 +103,7 @@ func (pc *PackageContextGenerator) Process(resourceList *framework.ResourceList)
103103

104104
// pkgContextResource generates package context resource from a given
105105
// Kptfile. The resource is generated adjacent to the Kptfile of the package.
106-
func pkgContextResource(kf *yaml.RNode) (*yaml.RNode, error) {
106+
func pkgContextResource(kf *yaml.RNode, parentConfig *yaml.RNode) (*yaml.RNode, error) {
107107
cm := yaml.MustParse(AbstractPkgContext())
108108

109109
kptfilePath, _, err := kioutil.GetFileAnnotations(kf)
@@ -119,9 +119,17 @@ func pkgContextResource(kf *yaml.RNode) (*yaml.RNode, error) {
119119
return nil, err
120120
}
121121
}
122-
cm.SetDataMap(map[string]string{
122+
data := map[string]string{
123123
"name": kf.GetName(),
124-
})
124+
}
125+
if parentConfig != nil {
126+
parentConfigData := parentConfig.GetDataMap()
127+
for k, v := range parentConfigData {
128+
data["parent."+k] = v
129+
}
130+
}
131+
132+
cm.SetDataMap(data)
125133
return cm, nil
126134
}
127135

0 commit comments

Comments
 (0)