refactor network name in kyaml container

This commit is contained in:
Donny Xia
2020-08-24 11:40:57 -07:00
parent a2e080bf6c
commit fa15242719
5 changed files with 63 additions and 35 deletions

View File

@@ -280,16 +280,12 @@ func (r RunFns) getFunctionFilters(global bool, fns ...*yaml.RNode) (
// TODO(eddiezane): Provide error info about which function needs the network
return fltrs, errors.Errorf("network required but not enabled with --network")
}
spec.Container.Network.Name = r.NetworkName
spec.Container.Network.Name.Set(r.NetworkName)
}
// command line username has higher priority
if r.User != "" {
spec.Container.User = r.User
}
// default user is nobody
if spec.Container.User.IsEmpty() {
spec.Container.User = runtimeutil.UserNobody
}
c, err := r.functionFilterProvider(*spec, api)
if err != nil {
@@ -393,14 +389,13 @@ func (r *RunFns) ffp(spec runtimeutil.FunctionSpec, api *yaml.RNode) (kio.Filter
}
if !r.DisableContainers && spec.Container.Image != "" {
// TODO: Add a test for this behavior
cf := &container.Filter{
ContainerSpec: runtimeutil.ContainerSpec{
Image: spec.Container.Image,
Network: spec.Container.Network,
StorageMounts: r.StorageMounts,
User: spec.Container.User,
},
}
c := container.NewContainer(runtimeutil.ContainerSpec{
Image: spec.Container.Image,
Network: spec.Container.Network,
StorageMounts: r.StorageMounts,
User: spec.Container.User,
})
cf := &c
cf.Exec.FunctionConfig = api
cf.Exec.GlobalScope = r.GlobalScope
cf.Exec.ResultsFile = resultsFile

View File

@@ -60,7 +60,8 @@ kind:
return
}
filter, _ := instance.functionFilterProvider(spec, api)
cf := &container.Filter{ContainerSpec: runtimeutil.ContainerSpec{Image: "example.com:version"}}
c := container.NewContainer(runtimeutil.ContainerSpec{Image: "example.com:version"})
cf := &c
cf.Exec.FunctionConfig = api
assert.Equal(t, cf, filter)
}
@@ -90,7 +91,8 @@ kind:
return
}
filter, _ := instance.functionFilterProvider(spec, api)
cf := &container.Filter{ContainerSpec: runtimeutil.ContainerSpec{Image: "example.com:version"}}
c := container.NewContainer(runtimeutil.ContainerSpec{Image: "example.com:version"})
cf := &c
cf.Exec.FunctionConfig = api
cf.Exec.GlobalScope = true
assert.Equal(t, cf, filter)