mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-11 17:12:51 +00:00
remove --network-name flag from kpt fn run
This commit is contained in:
@@ -62,8 +62,6 @@ func GetRunFnRunner(name string) *RunFnRunner {
|
|||||||
|
|
||||||
r.Command.Flags().BoolVar(
|
r.Command.Flags().BoolVar(
|
||||||
&r.Network, "network", false, "enable network access for functions that declare it")
|
&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.Command.Flags().StringArrayVar(
|
||||||
&r.Mounts, "mount", []string{},
|
&r.Mounts, "mount", []string{},
|
||||||
"a list of storage options read from the filesystem")
|
"a list of storage options read from the filesystem")
|
||||||
@@ -96,7 +94,6 @@ type RunFnRunner struct {
|
|||||||
RunFns runfn.RunFns
|
RunFns runfn.RunFns
|
||||||
ResultsDir string
|
ResultsDir string
|
||||||
Network bool
|
Network bool
|
||||||
NetworkName string
|
|
||||||
Mounts []string
|
Mounts []string
|
||||||
LogSteps bool
|
LogSteps bool
|
||||||
Env []string
|
Env []string
|
||||||
@@ -133,8 +130,8 @@ func (r *RunFnRunner) getContainerFunctions(c *cobra.Command, dataItems []string
|
|||||||
}
|
}
|
||||||
if r.Network {
|
if r.Network {
|
||||||
err = fn.PipeE(
|
err = fn.PipeE(
|
||||||
yaml.LookupCreate(yaml.MappingNode, "container", "network"),
|
yaml.Lookup("container"),
|
||||||
yaml.SetField("required", yaml.NewScalarRNode("true")))
|
yaml.SetField("network", yaml.NewScalarRNode("true")))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -309,7 +306,6 @@ func (r *RunFnRunner) preRunE(c *cobra.Command, args []string) error {
|
|||||||
Input: input,
|
Input: input,
|
||||||
Path: path,
|
Path: path,
|
||||||
Network: r.Network,
|
Network: r.Network,
|
||||||
NetworkName: r.NetworkName,
|
|
||||||
EnableStarlark: r.EnableStar,
|
EnableStarlark: r.EnableStar,
|
||||||
EnableExec: r.EnableExec,
|
EnableExec: r.EnableExec,
|
||||||
StorageMounts: storageMounts,
|
StorageMounts: storageMounts,
|
||||||
|
|||||||
@@ -29,7 +29,6 @@ func TestRunFnCommand_preRunE(t *testing.T) {
|
|||||||
output io.Writer
|
output io.Writer
|
||||||
functionPaths []string
|
functionPaths []string
|
||||||
network bool
|
network bool
|
||||||
networkName string
|
|
||||||
mount []string
|
mount []string
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
@@ -95,34 +94,32 @@ apiVersion: v1
|
|||||||
`,
|
`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "network enabled",
|
name: "network enabled",
|
||||||
args: []string{"run", "dir", "--image", "foo:bar", "--network"},
|
args: []string{"run", "dir", "--image", "foo:bar", "--network"},
|
||||||
path: "dir",
|
path: "dir",
|
||||||
network: true,
|
network: true,
|
||||||
networkName: "bridge",
|
|
||||||
expected: `
|
expected: `
|
||||||
metadata:
|
metadata:
|
||||||
name: function-input
|
name: function-input
|
||||||
annotations:
|
annotations:
|
||||||
config.kubernetes.io/function: |
|
config.kubernetes.io/function: |
|
||||||
container: {image: 'foo:bar', network: {required: true}}
|
container: {image: 'foo:bar', network: true}
|
||||||
data: {}
|
data: {}
|
||||||
kind: ConfigMap
|
kind: ConfigMap
|
||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
`,
|
`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "with network name",
|
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",
|
path: "dir",
|
||||||
network: true,
|
network: true,
|
||||||
networkName: "foo",
|
|
||||||
expected: `
|
expected: `
|
||||||
metadata:
|
metadata:
|
||||||
name: function-input
|
name: function-input
|
||||||
annotations:
|
annotations:
|
||||||
config.kubernetes.io/function: |
|
config.kubernetes.io/function: |
|
||||||
container: {image: 'foo:bar', network: {required: true}}
|
container: {image: 'foo:bar', network: true}
|
||||||
data: {}
|
data: {}
|
||||||
kind: ConfigMap
|
kind: ConfigMap
|
||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
@@ -202,7 +199,6 @@ apiVersion: v1
|
|||||||
path: "dir",
|
path: "dir",
|
||||||
expectedStruct: &runfn.RunFns{
|
expectedStruct: &runfn.RunFns{
|
||||||
Path: "dir",
|
Path: "dir",
|
||||||
NetworkName: "bridge",
|
|
||||||
EnableStarlark: true,
|
EnableStarlark: true,
|
||||||
Env: []string{},
|
Env: []string{},
|
||||||
},
|
},
|
||||||
@@ -255,10 +251,9 @@ apiVersion: v1
|
|||||||
args: []string{"run", "dir", "--results-dir", "foo/", "--image", "foo:bar", "--", "a=b", "c=d", "e=f"},
|
args: []string{"run", "dir", "--results-dir", "foo/", "--image", "foo:bar", "--", "a=b", "c=d", "e=f"},
|
||||||
path: "dir",
|
path: "dir",
|
||||||
expectedStruct: &runfn.RunFns{
|
expectedStruct: &runfn.RunFns{
|
||||||
Path: "dir",
|
Path: "dir",
|
||||||
NetworkName: "bridge",
|
ResultsDir: "foo/",
|
||||||
ResultsDir: "foo/",
|
Env: []string{},
|
||||||
Env: []string{},
|
|
||||||
},
|
},
|
||||||
expected: `
|
expected: `
|
||||||
metadata:
|
metadata:
|
||||||
@@ -291,10 +286,9 @@ apiVersion: v1
|
|||||||
args: []string{"run", "dir", "--log-steps"},
|
args: []string{"run", "dir", "--log-steps"},
|
||||||
path: "dir",
|
path: "dir",
|
||||||
expectedStruct: &runfn.RunFns{
|
expectedStruct: &runfn.RunFns{
|
||||||
Path: "dir",
|
Path: "dir",
|
||||||
NetworkName: "bridge",
|
LogSteps: true,
|
||||||
LogSteps: true,
|
Env: []string{},
|
||||||
Env: []string{},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -302,9 +296,8 @@ apiVersion: v1
|
|||||||
args: []string{"run", "dir", "--env", "FOO=BAR", "-e", "BAR"},
|
args: []string{"run", "dir", "--env", "FOO=BAR", "-e", "BAR"},
|
||||||
path: "dir",
|
path: "dir",
|
||||||
expectedStruct: &runfn.RunFns{
|
expectedStruct: &runfn.RunFns{
|
||||||
Path: "dir",
|
Path: "dir",
|
||||||
NetworkName: "bridge",
|
Env: []string{"FOO=BAR", "BAR"},
|
||||||
Env: []string{"FOO=BAR", "BAR"},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@@ -362,9 +355,6 @@ apiVersion: v1
|
|||||||
if !assert.Equal(t, tt.network, r.RunFns.Network) {
|
if !assert.Equal(t, tt.network, r.RunFns.Network) {
|
||||||
t.FailNow()
|
t.FailNow()
|
||||||
}
|
}
|
||||||
if !assert.Equal(t, tt.networkName, r.RunFns.NetworkName) {
|
|
||||||
t.FailNow()
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if !assert.Equal(t, false, r.RunFns.Network) {
|
if !assert.Equal(t, false, r.RunFns.Network) {
|
||||||
t.FailNow()
|
t.FailNow()
|
||||||
|
|||||||
@@ -52,9 +52,6 @@ type RunFns struct {
|
|||||||
// Network enables network access for functions that declare it
|
// Network enables network access for functions that declare it
|
||||||
Network bool
|
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 can be set to write the result to Output rather than back to the directory
|
||||||
Output io.Writer
|
Output io.Writer
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user