remove --network-name flag from kpt fn run

This commit is contained in:
Donny Xia
2020-09-18 12:39:49 -07:00
parent 3514317b3d
commit 87d2187436
3 changed files with 20 additions and 37 deletions

View File

@@ -62,8 +62,6 @@ func GetRunFnRunner(name string) *RunFnRunner {
r.Command.Flags().BoolVar(
&r.Network, "network", false, "enable network access for functions that declare it")
r.Command.Flags().StringVar(
&r.NetworkName, "network-name", "bridge", "the docker network to run the container in")
r.Command.Flags().StringArrayVar(
&r.Mounts, "mount", []string{},
"a list of storage options read from the filesystem")
@@ -96,7 +94,6 @@ type RunFnRunner struct {
RunFns runfn.RunFns
ResultsDir string
Network bool
NetworkName string
Mounts []string
LogSteps bool
Env []string
@@ -133,8 +130,8 @@ func (r *RunFnRunner) getContainerFunctions(c *cobra.Command, dataItems []string
}
if r.Network {
err = fn.PipeE(
yaml.LookupCreate(yaml.MappingNode, "container", "network"),
yaml.SetField("required", yaml.NewScalarRNode("true")))
yaml.Lookup("container"),
yaml.SetField("network", yaml.NewScalarRNode("true")))
if err != nil {
return nil, err
}
@@ -309,7 +306,6 @@ func (r *RunFnRunner) preRunE(c *cobra.Command, args []string) error {
Input: input,
Path: path,
Network: r.Network,
NetworkName: r.NetworkName,
EnableStarlark: r.EnableStar,
EnableExec: r.EnableExec,
StorageMounts: storageMounts,

View File

@@ -29,7 +29,6 @@ func TestRunFnCommand_preRunE(t *testing.T) {
output io.Writer
functionPaths []string
network bool
networkName string
mount []string
}{
{
@@ -99,13 +98,12 @@ apiVersion: v1
args: []string{"run", "dir", "--image", "foo:bar", "--network"},
path: "dir",
network: true,
networkName: "bridge",
expected: `
metadata:
name: function-input
annotations:
config.kubernetes.io/function: |
container: {image: 'foo:bar', network: {required: true}}
container: {image: 'foo:bar', network: true}
data: {}
kind: ConfigMap
apiVersion: v1
@@ -113,16 +111,15 @@ apiVersion: v1
},
{
name: "with network name",
args: []string{"run", "dir", "--image", "foo:bar", "--network", "--network-name", "foo"},
args: []string{"run", "dir", "--image", "foo:bar", "--network"},
path: "dir",
network: true,
networkName: "foo",
expected: `
metadata:
name: function-input
annotations:
config.kubernetes.io/function: |
container: {image: 'foo:bar', network: {required: true}}
container: {image: 'foo:bar', network: true}
data: {}
kind: ConfigMap
apiVersion: v1
@@ -202,7 +199,6 @@ apiVersion: v1
path: "dir",
expectedStruct: &runfn.RunFns{
Path: "dir",
NetworkName: "bridge",
EnableStarlark: true,
Env: []string{},
},
@@ -256,7 +252,6 @@ apiVersion: v1
path: "dir",
expectedStruct: &runfn.RunFns{
Path: "dir",
NetworkName: "bridge",
ResultsDir: "foo/",
Env: []string{},
},
@@ -292,7 +287,6 @@ apiVersion: v1
path: "dir",
expectedStruct: &runfn.RunFns{
Path: "dir",
NetworkName: "bridge",
LogSteps: true,
Env: []string{},
},
@@ -303,7 +297,6 @@ apiVersion: v1
path: "dir",
expectedStruct: &runfn.RunFns{
Path: "dir",
NetworkName: "bridge",
Env: []string{"FOO=BAR", "BAR"},
},
},
@@ -362,9 +355,6 @@ apiVersion: v1
if !assert.Equal(t, tt.network, r.RunFns.Network) {
t.FailNow()
}
if !assert.Equal(t, tt.networkName, r.RunFns.NetworkName) {
t.FailNow()
}
} else {
if !assert.Equal(t, false, r.RunFns.Network) {
t.FailNow()

View File

@@ -52,9 +52,6 @@ type RunFns struct {
// Network enables network access for functions that declare it
Network bool
// NetworkName is the name of the docker network to use for the container
NetworkName string
// Output can be set to write the result to Output rather than back to the directory
Output io.Writer