Merge pull request #3012 from Shell32-Natsu/remove-network-name

remove --network-name flag from kpt fn run
This commit is contained in:
Kubernetes Prow Robot
2020-09-18 16:48:27 -07:00
committed by GitHub
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
}{
{
@@ -95,34 +94,32 @@ apiVersion: v1
`,
},
{
name: "network enabled",
args: []string{"run", "dir", "--image", "foo:bar", "--network"},
path: "dir",
network: true,
networkName: "bridge",
name: "network enabled",
args: []string{"run", "dir", "--image", "foo:bar", "--network"},
path: "dir",
network: true,
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
`,
},
{
name: "with network name",
args: []string{"run", "dir", "--image", "foo:bar", "--network", "--network-name", "foo"},
path: "dir",
network: true,
networkName: "foo",
name: "with network name",
args: []string{"run", "dir", "--image", "foo:bar", "--network"},
path: "dir",
network: true,
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{},
},
@@ -255,10 +251,9 @@ apiVersion: v1
args: []string{"run", "dir", "--results-dir", "foo/", "--image", "foo:bar", "--", "a=b", "c=d", "e=f"},
path: "dir",
expectedStruct: &runfn.RunFns{
Path: "dir",
NetworkName: "bridge",
ResultsDir: "foo/",
Env: []string{},
Path: "dir",
ResultsDir: "foo/",
Env: []string{},
},
expected: `
metadata:
@@ -291,10 +286,9 @@ apiVersion: v1
args: []string{"run", "dir", "--log-steps"},
path: "dir",
expectedStruct: &runfn.RunFns{
Path: "dir",
NetworkName: "bridge",
LogSteps: true,
Env: []string{},
Path: "dir",
LogSteps: true,
Env: []string{},
},
},
{
@@ -302,9 +296,8 @@ apiVersion: v1
args: []string{"run", "dir", "--env", "FOO=BAR", "-e", "BAR"},
path: "dir",
expectedStruct: &runfn.RunFns{
Path: "dir",
NetworkName: "bridge",
Env: []string{"FOO=BAR", "BAR"},
Path: "dir",
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