mirror of https://github.com/knative/client.git
make command as array instead of string (#1380)
* make command as array instead of string * make command as array instead of string * make command as array instead of string * make command as array instead of string * make command as array instead of string * make command as array instead of string
This commit is contained in:
parent
536d1f13c1
commit
0c3e236006
|
|
@ -12,6 +12,16 @@
|
||||||
| https://github.com/knative/client/pull/[#]
|
| https://github.com/knative/client/pull/[#]
|
||||||
////
|
////
|
||||||
|
|
||||||
|
## Unreleased
|
||||||
|
[cols="1,10,3", options="header", width="100%"]
|
||||||
|
|===
|
||||||
|
| | Description | PR
|
||||||
|
|
||||||
|
| ✨
|
||||||
|
| make --cmd flag as an array instead of string
|
||||||
|
| https://github.com/knative/client/pull/1380[#1380]
|
||||||
|
|===
|
||||||
|
|
||||||
## v0.24.0 (2021-06-29)
|
## v0.24.0 (2021-06-29)
|
||||||
[cols="1,10,3", options="header", width="100%"]
|
[cols="1,10,3", options="header", width="100%"]
|
||||||
|===
|
|===
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ kn service apply s0 --filename my-svc.yml
|
||||||
--arg stringArray Add argument to the container command. Example: --arg myArg1 --arg --myArg2 --arg myArg3=3. You can use this flag multiple times.
|
--arg stringArray Add argument to the container command. Example: --arg myArg1 --arg --myArg2 --arg myArg3=3. You can use this flag multiple times.
|
||||||
--autoscale-window string Duration to look back for making auto-scaling decisions. The service is scaled to zero if no request was received in during that time. (eg: 10s)
|
--autoscale-window string Duration to look back for making auto-scaling decisions. The service is scaled to zero if no request was received in during that time. (eg: 10s)
|
||||||
--cluster-local Specify that the service be private. (--no-cluster-local will make the service publicly available)
|
--cluster-local Specify that the service be private. (--no-cluster-local will make the service publicly available)
|
||||||
--cmd string Specify command to be used as entrypoint instead of default one. Example: --cmd /app/start or --cmd /app/start --arg myArg to pass additional arguments.
|
--cmd stringArray Specify command to be used as entrypoint instead of default one. Example: --cmd /app/start or --cmd sh --cmd /app/start.sh or --cmd /app/start --arg myArg to pass additional arguments.
|
||||||
--concurrency-limit int Hard Limit of concurrent requests to be processed by a single replica.
|
--concurrency-limit int Hard Limit of concurrent requests to be processed by a single replica.
|
||||||
--concurrency-target int Recommendation for when to scale up based on the concurrent number of incoming request. Defaults to --concurrency-limit when given.
|
--concurrency-target int Recommendation for when to scale up based on the concurrent number of incoming request. Defaults to --concurrency-limit when given.
|
||||||
--concurrency-utilization int Percentage of concurrent requests utilization before scaling up. (default 70)
|
--concurrency-utilization int Percentage of concurrent requests utilization before scaling up. (default 70)
|
||||||
|
|
|
||||||
|
|
@ -60,7 +60,7 @@ kn service create NAME --image IMAGE
|
||||||
--arg stringArray Add argument to the container command. Example: --arg myArg1 --arg --myArg2 --arg myArg3=3. You can use this flag multiple times.
|
--arg stringArray Add argument to the container command. Example: --arg myArg1 --arg --myArg2 --arg myArg3=3. You can use this flag multiple times.
|
||||||
--autoscale-window string Duration to look back for making auto-scaling decisions. The service is scaled to zero if no request was received in during that time. (eg: 10s)
|
--autoscale-window string Duration to look back for making auto-scaling decisions. The service is scaled to zero if no request was received in during that time. (eg: 10s)
|
||||||
--cluster-local Specify that the service be private. (--no-cluster-local will make the service publicly available)
|
--cluster-local Specify that the service be private. (--no-cluster-local will make the service publicly available)
|
||||||
--cmd string Specify command to be used as entrypoint instead of default one. Example: --cmd /app/start or --cmd /app/start --arg myArg to pass additional arguments.
|
--cmd stringArray Specify command to be used as entrypoint instead of default one. Example: --cmd /app/start or --cmd sh --cmd /app/start.sh or --cmd /app/start --arg myArg to pass additional arguments.
|
||||||
--concurrency-limit int Hard Limit of concurrent requests to be processed by a single replica.
|
--concurrency-limit int Hard Limit of concurrent requests to be processed by a single replica.
|
||||||
--concurrency-target int Recommendation for when to scale up based on the concurrent number of incoming request. Defaults to --concurrency-limit when given.
|
--concurrency-target int Recommendation for when to scale up based on the concurrent number of incoming request. Defaults to --concurrency-limit when given.
|
||||||
--concurrency-utilization int Percentage of concurrent requests utilization before scaling up. (default 70)
|
--concurrency-utilization int Percentage of concurrent requests utilization before scaling up. (default 70)
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,7 @@ kn service update NAME
|
||||||
--arg stringArray Add argument to the container command. Example: --arg myArg1 --arg --myArg2 --arg myArg3=3. You can use this flag multiple times.
|
--arg stringArray Add argument to the container command. Example: --arg myArg1 --arg --myArg2 --arg myArg3=3. You can use this flag multiple times.
|
||||||
--autoscale-window string Duration to look back for making auto-scaling decisions. The service is scaled to zero if no request was received in during that time. (eg: 10s)
|
--autoscale-window string Duration to look back for making auto-scaling decisions. The service is scaled to zero if no request was received in during that time. (eg: 10s)
|
||||||
--cluster-local Specify that the service be private. (--no-cluster-local will make the service publicly available)
|
--cluster-local Specify that the service be private. (--no-cluster-local will make the service publicly available)
|
||||||
--cmd string Specify command to be used as entrypoint instead of default one. Example: --cmd /app/start or --cmd /app/start --arg myArg to pass additional arguments.
|
--cmd stringArray Specify command to be used as entrypoint instead of default one. Example: --cmd /app/start or --cmd sh --cmd /app/start.sh or --cmd /app/start --arg myArg to pass additional arguments.
|
||||||
--concurrency-limit int Hard Limit of concurrent requests to be processed by a single replica.
|
--concurrency-limit int Hard Limit of concurrent requests to be processed by a single replica.
|
||||||
--concurrency-target int Recommendation for when to scale up based on the concurrent number of incoming request. Defaults to --concurrency-limit when given.
|
--concurrency-target int Recommendation for when to scale up based on the concurrent number of incoming request. Defaults to --concurrency-limit when given.
|
||||||
--concurrency-utilization int Percentage of concurrent requests utilization before scaling up. (default 70)
|
--concurrency-utilization int Percentage of concurrent requests utilization before scaling up. (default 70)
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ kn source container create NAME --image IMAGE --sink SINK
|
||||||
|
|
||||||
```
|
```
|
||||||
--arg stringArray Add argument to the container command. Example: --arg myArg1 --arg --myArg2 --arg myArg3=3. You can use this flag multiple times.
|
--arg stringArray Add argument to the container command. Example: --arg myArg1 --arg --myArg2 --arg myArg3=3. You can use this flag multiple times.
|
||||||
--cmd string Specify command to be used as entrypoint instead of default one. Example: --cmd /app/start or --cmd /app/start --arg myArg to pass additional arguments.
|
--cmd stringArray Specify command to be used as entrypoint instead of default one. Example: --cmd /app/start or --cmd sh --cmd /app/start.sh or --cmd /app/start --arg myArg to pass additional arguments.
|
||||||
-e, --env stringArray Environment variable to set. NAME=value; you may provide this flag any number of times to set multiple environment variables. To unset, specify the environment variable name followed by a "-" (e.g., NAME-).
|
-e, --env stringArray Environment variable to set. NAME=value; you may provide this flag any number of times to set multiple environment variables. To unset, specify the environment variable name followed by a "-" (e.g., NAME-).
|
||||||
--env-from stringArray Add environment variables from a ConfigMap (prefix cm: or config-map:) or a Secret (prefix secret:). Example: --env-from cm:myconfigmap or --env-from secret:mysecret. You can use this flag multiple times. To unset a ConfigMap/Secret reference, append "-" to the name, e.g. --env-from cm:myconfigmap-.
|
--env-from stringArray Add environment variables from a ConfigMap (prefix cm: or config-map:) or a Secret (prefix secret:). Example: --env-from cm:myconfigmap or --env-from secret:mysecret. You can use this flag multiple times. To unset a ConfigMap/Secret reference, append "-" to the name, e.g. --env-from cm:myconfigmap-.
|
||||||
--env-value-from stringArray Add environment variable from a value of key in ConfigMap (prefix cm: or config-map:) or a Secret (prefix sc: or secret:). Example: --env-value-from NAME=cm:myconfigmap:key or --env-value-from NAME=secret:mysecret:key. You can use this flag multiple times. To unset a value from a ConfigMap/Secret key reference, append "-" to the key, e.g. --env-value-from ENV-.
|
--env-value-from stringArray Add environment variable from a value of key in ConfigMap (prefix cm: or config-map:) or a Secret (prefix sc: or secret:). Example: --env-value-from NAME=cm:myconfigmap:key or --env-value-from NAME=secret:mysecret:key. You can use this flag multiple times. To unset a value from a ConfigMap/Secret key reference, append "-" to the key, e.g. --env-value-from ENV-.
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ kn source container update NAME --image IMAGE
|
||||||
|
|
||||||
```
|
```
|
||||||
--arg stringArray Add argument to the container command. Example: --arg myArg1 --arg --myArg2 --arg myArg3=3. You can use this flag multiple times.
|
--arg stringArray Add argument to the container command. Example: --arg myArg1 --arg --myArg2 --arg myArg3=3. You can use this flag multiple times.
|
||||||
--cmd string Specify command to be used as entrypoint instead of default one. Example: --cmd /app/start or --cmd /app/start --arg myArg to pass additional arguments.
|
--cmd stringArray Specify command to be used as entrypoint instead of default one. Example: --cmd /app/start or --cmd sh --cmd /app/start.sh or --cmd /app/start --arg myArg to pass additional arguments.
|
||||||
-e, --env stringArray Environment variable to set. NAME=value; you may provide this flag any number of times to set multiple environment variables. To unset, specify the environment variable name followed by a "-" (e.g., NAME-).
|
-e, --env stringArray Environment variable to set. NAME=value; you may provide this flag any number of times to set multiple environment variables. To unset, specify the environment variable name followed by a "-" (e.g., NAME-).
|
||||||
--env-from stringArray Add environment variables from a ConfigMap (prefix cm: or config-map:) or a Secret (prefix secret:). Example: --env-from cm:myconfigmap or --env-from secret:mysecret. You can use this flag multiple times. To unset a ConfigMap/Secret reference, append "-" to the name, e.g. --env-from cm:myconfigmap-.
|
--env-from stringArray Add environment variables from a ConfigMap (prefix cm: or config-map:) or a Secret (prefix secret:). Example: --env-from cm:myconfigmap or --env-from secret:mysecret. You can use this flag multiple times. To unset a ConfigMap/Secret reference, append "-" to the name, e.g. --env-from cm:myconfigmap-.
|
||||||
--env-value-from stringArray Add environment variable from a value of key in ConfigMap (prefix cm: or config-map:) or a Secret (prefix sc: or secret:). Example: --env-value-from NAME=cm:myconfigmap:key or --env-value-from NAME=secret:mysecret:key. You can use this flag multiple times. To unset a value from a ConfigMap/Secret key reference, append "-" to the key, e.g. --env-value-from ENV-.
|
--env-value-from stringArray Add environment variable from a value of key in ConfigMap (prefix cm: or config-map:) or a Secret (prefix sc: or secret:). Example: --env-value-from NAME=cm:myconfigmap:key or --env-value-from NAME=secret:mysecret:key. You can use this flag multiple times. To unset a value from a ConfigMap/Secret key reference, append "-" to the key, e.g. --env-value-from ENV-.
|
||||||
|
|
|
||||||
|
|
@ -182,13 +182,13 @@ func TestServiceCreateImageSync(t *testing.T) {
|
||||||
|
|
||||||
func TestServiceCreateCommand(t *testing.T) {
|
func TestServiceCreateCommand(t *testing.T) {
|
||||||
action, created, _, err := fakeServiceCreate([]string{
|
action, created, _, err := fakeServiceCreate([]string{
|
||||||
"service", "create", "foo", "--image", "gcr.io/foo/bar:baz", "--cmd", "/app/start", "--no-wait"}, false)
|
"service", "create", "foo", "--image", "gcr.io/foo/bar:baz", "--cmd", "sh", "--cmd", "/app/start.sh", "--no-wait"}, false)
|
||||||
assert.NilError(t, err)
|
assert.NilError(t, err)
|
||||||
assert.Assert(t, action.Matches("create", "services"))
|
assert.Assert(t, action.Matches("create", "services"))
|
||||||
|
|
||||||
template := &created.Spec.Template
|
template := &created.Spec.Template
|
||||||
assert.NilError(t, err)
|
assert.NilError(t, err)
|
||||||
assert.DeepEqual(t, template.Spec.Containers[0].Command, []string{"/app/start"})
|
assert.DeepEqual(t, template.Spec.Containers[0].Command, []string{"sh", "/app/start.sh"})
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestServiceCreateArg(t *testing.T) {
|
func TestServiceCreateArg(t *testing.T) {
|
||||||
|
|
|
||||||
|
|
@ -219,7 +219,7 @@ func TestServiceUpdateCommand(t *testing.T) {
|
||||||
|
|
||||||
origTemplate := &orig.Spec.Template
|
origTemplate := &orig.Spec.Template
|
||||||
|
|
||||||
err := flags.UpdateContainerCommand(&origTemplate.Spec.PodSpec, "./start")
|
err := flags.UpdateContainerCommand(&origTemplate.Spec.PodSpec, []string{"./start"})
|
||||||
assert.NilError(t, err)
|
assert.NilError(t, err)
|
||||||
|
|
||||||
action, updated, _, err := fakeServiceUpdate(orig, []string{
|
action, updated, _, err := fakeServiceUpdate(orig, []string{
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ type PodSpecFlags struct {
|
||||||
Mount []string
|
Mount []string
|
||||||
Volume []string
|
Volume []string
|
||||||
|
|
||||||
Command string
|
Command []string
|
||||||
Arg []string
|
Arg []string
|
||||||
|
|
||||||
Resources ResourceOptions
|
Resources ResourceOptions
|
||||||
|
|
@ -112,9 +112,9 @@ func (p *PodSpecFlags) AddFlags(flagset *pflag.FlagSet) []string {
|
||||||
"To unset a ConfigMap/Secret reference, append \"-\" to the name, e.g. --volume myvolume-.")
|
"To unset a ConfigMap/Secret reference, append \"-\" to the name, e.g. --volume myvolume-.")
|
||||||
flagNames = append(flagNames, "volume")
|
flagNames = append(flagNames, "volume")
|
||||||
|
|
||||||
flagset.StringVarP(&p.Command, "cmd", "", "",
|
flagset.StringArrayVarP(&p.Command, "cmd", "", []string{},
|
||||||
"Specify command to be used as entrypoint instead of default one. "+
|
"Specify command to be used as entrypoint instead of default one. "+
|
||||||
"Example: --cmd /app/start or --cmd /app/start --arg myArg to pass additional arguments.")
|
"Example: --cmd /app/start or --cmd sh --cmd /app/start.sh or --cmd /app/start --arg myArg to pass additional arguments.")
|
||||||
flagNames = append(flagNames, "cmd")
|
flagNames = append(flagNames, "cmd")
|
||||||
|
|
||||||
flagset.StringArrayVarP(&p.Arg, "arg", "", []string{},
|
flagset.StringArrayVarP(&p.Arg, "arg", "", []string{},
|
||||||
|
|
|
||||||
|
|
@ -154,9 +154,9 @@ func UpdateImage(spec *corev1.PodSpec, image string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// UpdateContainerCommand updates container with a given argument
|
// UpdateContainerCommand updates container with a given argument
|
||||||
func UpdateContainerCommand(spec *corev1.PodSpec, command string) error {
|
func UpdateContainerCommand(spec *corev1.PodSpec, command []string) error {
|
||||||
container := containerOfPodSpec(spec)
|
container := containerOfPodSpec(spec)
|
||||||
container.Command = []string{command}
|
container.Command = command
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -352,13 +352,13 @@ func checkContainerImage(t *testing.T, spec *corev1.PodSpec, image string) {
|
||||||
|
|
||||||
func TestUpdateContainerCommand(t *testing.T) {
|
func TestUpdateContainerCommand(t *testing.T) {
|
||||||
spec, _ := getPodSpec()
|
spec, _ := getPodSpec()
|
||||||
err := UpdateContainerCommand(spec, "/app/start")
|
err := UpdateContainerCommand(spec, []string{"/app/start"})
|
||||||
assert.NilError(t, err)
|
assert.NilError(t, err)
|
||||||
assert.DeepEqual(t, spec.Containers[0].Command, []string{"/app/start"})
|
assert.DeepEqual(t, spec.Containers[0].Command, []string{"/app/start"})
|
||||||
|
|
||||||
err = UpdateContainerCommand(spec, "/app/latest")
|
err = UpdateContainerCommand(spec, []string{"sh", "/app/latest.sh"})
|
||||||
assert.NilError(t, err)
|
assert.NilError(t, err)
|
||||||
assert.DeepEqual(t, spec.Containers[0].Command, []string{"/app/latest"})
|
assert.DeepEqual(t, spec.Containers[0].Command, []string{"sh", "/app/latest.sh"})
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestUpdateContainerArg(t *testing.T) {
|
func TestUpdateContainerArg(t *testing.T) {
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,7 @@ func TestPodSpecFlags(t *testing.T) {
|
||||||
Mount: []string{},
|
Mount: []string{},
|
||||||
Volume: []string{},
|
Volume: []string{},
|
||||||
Arg: []string{},
|
Arg: []string{},
|
||||||
|
Command: []string{},
|
||||||
}
|
}
|
||||||
flags := &PodSpecFlags{}
|
flags := &PodSpecFlags{}
|
||||||
testCmd := &cobra.Command{
|
testCmd := &cobra.Command{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue