Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TaskSpec Params needs an Array type #207

Closed
tanner-bruce opened this issue Oct 30, 2018 · 8 comments · Fixed by #1080
Closed

TaskSpec Params needs an Array type #207

tanner-bruce opened this issue Oct 30, 2018 · 8 comments · Fixed by #1080
Assignees
Labels
design This task is about creating and discussing a design help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. meaty-juicy-coding-work This task is mostly about implementation!!! And docs and tests of course but that's a given

Comments

@tanner-bruce
Copy link

In https://github.com/knative/build-pipeline/blob/8a2b6c30efa7f4dd1fedafacc2733a0d290e12c6/examples/deploy_tasks.yaml#L21, the Input Param helmArgs is used. If one were to set helmArgs to be --set arg1=a --set arg2=b with the intention of providing multiple arguments to helm, this task would fail due to --set arg1=a --set arg2=b being interpreted as a single argument.

A couple questions that comes to mind:

  1. How do we make it obvious that '${helmArgs}' could possibly be expanded to multiple arguments, while also allowing it to have a single argument? The spread operator may be a nice fit: ${helmArgs...}

2.How should a TaskParam represent an array? Currently it just has a name field, but description and default will be added soon. How does it look supporting defaults for an array alongside a regular string?

@bobcatfish bobcatfish added design This task is about creating and discussing a design help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. labels Oct 31, 2018
@tanner-bruce
Copy link
Author

This could be done something like the following, with the idea borrowed from IntOrStr.

type ArrayOrStr struct {
	StringVal string
	ArrayVal []string
	Type Type
}

func (as ArrayOrStr) String() string {
	if as.Type == String { 
		return as.StringVal
	}
	return strings.Join(as.ArrayVal, " ")
}

type Type int

const (
	String Type = iota
	Array
)

// UnmarshalJSON implements the json.Unmarshaller interface.
func (as *ArrayOrStr) UnmarshalJSON(value []byte) error {
	if value[0] == '"' {
		as.Type = String
		return json.Unmarshal(value, &as.StringVal)
	}
	as.Type = Array
	return json.Unmarshal(value, &as.ArrayVal)
}

This could work nicely, as there is no additional field needed and is compatible with already created resources. Alongside this, introducing the spread operator, ..., in the interpolation phase would allow supporting arrays in a simple manner

I propose:

  • add this new type,ArrayOrStr
  • change the Param and TaskParam Value fields types to be ArrayOrStrs
  • add a new operator, ..., to force treating the param as an array during replacement

@bobcatfish
Copy link
Collaborator

@tanner-bruce could you show an example of what the corresponding Task yaml would look like with your proposal?

My personal preference is for the type of the param to be explicit, e.g.:

        params:
            - name: testImage
              type: string
            - name: testArgs
              type: array

And then the use would look like:

          params:
              - name: testArgs
                value:
                     - "--set"
                     - "arg1=a"

(maybe this is the same thing you're suggesting!)

Alongside this, introducing the spread operator, ..., in the interpolation phase would allow supporting arrays in a simple manner

I'd like to understand a bit more about why we need the spread operator, in my mind using the args was {$testArgs} still makes sense, without introducing the spread operator?

(Sorry for the push back @tanner-bruce , I think we might need a bit more back and forth on this one before we're all clear on it, thanks for working on this ❤️ !)

@tanner-bruce
Copy link
Author

@bobcatfish The main reason for ... was to allow the user to treat the array as a single string, however I've been trying to think of a use case for that, and can't.

Thinking more about it, adding the type field to the Task, would allow better, more explicit validation of the Task and TaskRun and likely lead to less user/runtime errors.

With that, I would change my proposal to be:

  1. add the ArrayOrStr type for use with the value and default fields in TaskParam
  2. add a ParamType type, and add it to input params. This would only be used during validation, as the type can also be gotten from ArrayOrStr
  3. change the interpolation mechanisms to expand out array type params

@bobcatfish bobcatfish added this to the 0.0.1 Alpha release milestone Nov 3, 2018
@bobcatfish
Copy link
Collaborator

@tanner-bruce sounds good to me! Lets do it :D

@bobcatfish bobcatfish added the meaty-juicy-coding-work This task is mostly about implementation!!! And docs and tests of course but that's a given label Nov 6, 2018
@vdemeester
Copy link
Member

/assign

@vdemeester
Copy link
Member

/assign EliZucker
@EliZucker assigning this to you (given your comment on #1037)

bobcatfish added a commit to bobcatfish/pipeline that referenced this issue Jul 4, 2019
In tektoncd#1043 @EliZucker updated the package names of the v1alpha1 tests to
be `v1alpha1_test`. He did this b/c he wanted to use a function he was
adding to the builder test package for the work he is doing in tektoncd#207, but
this has the nice side effect of making it so that we can use more
builders in these tests! (We couldn't before b/c the builders themselves
have to import and use `v1alpha1`). This commit updates many of these
tests to use builders.
bobcatfish added a commit to bobcatfish/pipeline that referenced this issue Jul 4, 2019
In tektoncd#1043 @EliZucker updated the package names of the v1alpha1 tests to
be `v1alpha1_test`. He did this b/c he wanted to use a function he was
adding to the builder test package for the work he is doing in tektoncd#207, but
this has the nice side effect of making it so that we can use more
builders in these tests! (We couldn't before b/c the builders themselves
have to import and use `v1alpha1`). This commit updates many of these
tests to use builders.
tekton-robot pushed a commit that referenced this issue Jul 4, 2019
In #1043 @EliZucker updated the package names of the v1alpha1 tests to
be `v1alpha1_test`. He did this b/c he wanted to use a function he was
adding to the builder test package for the work he is doing in #207, but
this has the nice side effect of making it so that we can use more
builders in these tests! (We couldn't before b/c the builders themselves
have to import and use `v1alpha1`). This commit updates many of these
tests to use builders.
@xihaLong
Copy link

I gave some feedback on the design document. I do not see a link to the design document here yet, so: https://docs.google.com/document/d/1A_4wWFGQ6puNk1KpM_cuyVRnES2JP6-5XjceYenUh2g

@bobcatfish bobcatfish added this to the Pipelines 0.6 🐱 milestone Jul 15, 2019
EliZucker added a commit to EliZucker/pipeline that referenced this issue Jul 16, 2019
Instead of just strings, add support for users to supply parameters in
the form of an array. Also include appropriate type validation and
defaulting to support backwards-compatibility. Fixes tektoncd#207.

The size of a user-supplied array is not specified anywhere in the
corresponding ParamSpec, which is useful for defining tasks that
require a dynamic number of strings used as distinct elements in
an array. For instance, one might use an array parameter in an
image-building task that feeds in a dynamic number of flags via the
args field for a particular step.

The implementation is defined such that an Array parameter can only be
used if the replacement string is completely isolated and within a field
that is an array of strings (currently eligible fields are 'command'
and 'args'). For instance, the webhook will prevent an array parameter
from being used in the 'image' field. Similarly, an array parameter used
in a composite string, like 'value=${array}', is invalid and will be
caught. The decision was made to completely prevent any use of array
parameters as strings because it clutters Tekton with unnecessary
functionality and is naturally extensible beyond the intended scope.
For instance, if the behavior was defined such that array parameters
used in the context of strings were automatically converted by
separating them with a space, then that relatively arbitrary
implementation could be questioned and eventually lead to needing to
specify a custom delimiter (like commas), and so on.

Another implementation detail to note is that the ArrayOrString type was
necessary, in combination with implementing json.Marshaller, to support
backwards-compatibility with strings. This is based off IntOrString from
kubernetes/apimachinery, and allows the value-type to be immediately
parsed and decided through the webhook.

Lastly, a possibly unintuitive design decision is that if an EMPTY array
parameter properly replaces an array element, then that string in the
original array will be completely removed.
EliZucker added a commit to EliZucker/pipeline that referenced this issue Jul 16, 2019
Instead of just strings, add support for users to supply parameters in
the form of an array. Also include appropriate type validation and
defaulting to support backwards-compatibility. Fixes tektoncd#207.

The size of a user-supplied array is not specified anywhere in the
corresponding ParamSpec, which is useful for defining tasks that
require a dynamic number of strings used as distinct elements in
an array. For instance, one might use an array parameter in an
image-building task that feeds in a dynamic number of flags via the
args field for a particular step.

The implementation is defined such that an Array parameter can only be
used if the replacement string is completely isolated and within a field
that is an array of strings (currently eligible fields are 'command'
and 'args'). For instance, the webhook will prevent an array parameter
from being used in the 'image' field. Similarly, an array parameter used
in a composite string, like 'value=${array}', is invalid and will be
caught. The decision was made to completely prevent any use of array
parameters as strings because it clutters Tekton with unnecessary
functionality and is naturally extensible beyond the intended scope.
For instance, if the behavior was defined such that array parameters
used in the context of strings were automatically converted by
separating them with a space, then that relatively arbitrary
implementation could be questioned and eventually lead to needing to
specify a custom delimiter (like commas), and so on.

Another implementation detail to note is that the ArrayOrString type was
necessary, in combination with implementing json.Marshaller, to support
backwards-compatibility with strings. This is based off IntOrString from
kubernetes/apimachinery, and allows the value-type to be immediately
parsed and decided through the webhook.

Lastly, a possibly unintuitive design decision is that if an EMPTY array
parameter properly replaces an array element, then that string in the
original array will be completely removed.
EliZucker added a commit to EliZucker/pipeline that referenced this issue Jul 16, 2019
Instead of just strings, add support for users to supply parameters in
the form of an array. Also include appropriate type validation and
defaulting to support backwards-compatibility. Fixes tektoncd#207.

The size of a user-supplied array is not specified anywhere in the
corresponding ParamSpec, which is useful for defining tasks that
require a dynamic number of strings used as distinct elements in
an array. For instance, one might use an array parameter in an
image-building task that feeds in a dynamic number of flags via the
args field for a particular step.

The implementation is defined such that an Array parameter can only be
used if the replacement string is completely isolated and within a field
that is an array of strings (currently eligible fields are 'command'
and 'args'). For instance, the webhook will prevent an array parameter
from being used in the 'image' field. Similarly, an array parameter used
in a composite string, like 'value=${array}', is invalid and will be
caught. The decision was made to completely prevent any use of array
parameters as strings because it clutters Tekton with unnecessary
functionality and is naturally extensible beyond the intended scope.
For instance, if the behavior was defined such that array parameters
used in the context of strings were automatically converted by
separating them with a space, then that relatively arbitrary
implementation could be questioned and eventually lead to needing to
specify a custom delimiter (like commas), and so on.

Another implementation detail to note is that the ArrayOrString type was
necessary, in combination with implementing json.Marshaller, to support
backwards-compatibility with strings. This is based off IntOrString from
kubernetes/apimachinery, and allows the value-type to be immediately
parsed and decided through the webhook.

Lastly, a possibly unintuitive design decision is that if an EMPTY array
parameter properly replaces an array element, then that string in the
original array will be completely removed.
EliZucker added a commit to EliZucker/pipeline that referenced this issue Jul 16, 2019
Instead of just strings, add support for users to supply parameters in
the form of an array. Also include appropriate type validation and
defaulting to support backwards-compatibility. Fixes tektoncd#207.

The size of a user-supplied array is not specified anywhere in the
corresponding ParamSpec, which is useful for defining tasks that
require a dynamic number of strings used as distinct elements in
an array. For instance, one might use an array parameter in an
image-building task that feeds in a dynamic number of flags via the
args field for a particular step.

The implementation is defined such that an Array parameter can only be
used if the replacement string is completely isolated and within a field
that is an array of strings (currently eligible fields are 'command'
and 'args'). For instance, the webhook will prevent an array parameter
from being used in the 'image' field. Similarly, an array parameter used
in a composite string, like 'value=${array}', is invalid and will be
caught. The decision was made to completely prevent any use of array
parameters as strings because it clutters Tekton with unnecessary
functionality and is naturally extensible beyond the intended scope.
For instance, if the behavior was defined such that array parameters
used in the context of strings were automatically converted by
separating them with a space, then that relatively arbitrary
implementation could be questioned and eventually lead to needing to
specify a custom delimiter (like commas), and so on.

Another implementation detail to note is that the ArrayOrString type was
necessary, in combination with implementing json.Marshaller, to support
backwards-compatibility with strings. This is based off IntOrString from
kubernetes/apimachinery, and allows the value-type to be immediately
parsed and decided through the webhook.

Lastly, a possibly unintuitive design decision is that if an EMPTY array
parameter properly replaces an array element, then that string in the
original array will be completely removed.
EliZucker added a commit to EliZucker/pipeline that referenced this issue Jul 17, 2019
Instead of just strings, add support for users to supply parameters in
the form of an array. Also include appropriate type validation and
defaulting to support backwards-compatibility. Fixes tektoncd#207.

The size of a user-supplied array is not specified anywhere in the
corresponding ParamSpec, which is useful for defining tasks that
require a dynamic number of strings used as distinct elements in
an array. For instance, one might use an array parameter in an
image-building task that feeds in a dynamic number of flags via the
args field for a particular step.

The implementation is defined such that an Array parameter can only be
used if the replacement string is completely isolated and within a field
that is an array of strings (currently eligible fields are 'command'
and 'args'). For instance, the webhook will prevent an array parameter
from being used in the 'image' field. Similarly, an array parameter used
in a composite string, like 'value=${array}', is invalid and will be
caught. The decision was made to completely prevent any use of array
parameters as strings because it clutters Tekton with unnecessary
functionality and is naturally extensible beyond the intended scope.
For instance, if the behavior was defined such that array parameters
used in the context of strings were automatically converted by
separating them with a space, then that relatively arbitrary
implementation could be questioned and eventually lead to needing to
specify a custom delimiter (like commas), and so on.

Another implementation detail to note is that the ArrayOrString type was
necessary, in combination with implementing json.Marshaller, to support
backwards-compatibility with strings. This is based off IntOrString from
kubernetes/apimachinery, and allows the value-type to be immediately
parsed and decided through the webhook.

Lastly, a possibly unintuitive design decision is that if an EMPTY array
parameter properly replaces an array element, then that string in the
original array will be completely removed.
EliZucker added a commit to EliZucker/pipeline that referenced this issue Jul 18, 2019
Instead of just strings, add support for users to supply parameters in
the form of an array. Also include appropriate type validation and
defaulting to support backwards-compatibility. Fixes tektoncd#207.

The size of a user-supplied array is not specified anywhere in the
corresponding ParamSpec, which is useful for defining tasks that
require a dynamic number of strings used as distinct elements in
an array. For instance, one might use an array parameter in an
image-building task that feeds in a dynamic number of flags via the
args field for a particular step.

The implementation is defined such that an Array parameter can only be
used if the replacement string is completely isolated and within a field
that is an array of strings (currently eligible fields are 'command'
and 'args'). For instance, the webhook will prevent an array parameter
from being used in the 'image' field. Similarly, an array parameter used
in a composite string, like 'value=${array}', is invalid and will be
caught. The decision was made to completely prevent any use of array
parameters as strings because it clutters Tekton with unnecessary
functionality and is naturally extensible beyond the intended scope.
For instance, if the behavior was defined such that array parameters
used in the context of strings were automatically converted by
separating them with a space, then that relatively arbitrary
implementation could be questioned and eventually lead to needing to
specify a custom delimiter (like commas), and so on.

Another implementation detail to note is that the ArrayOrString type was
necessary, in combination with implementing json.Marshaller, to support
backwards-compatibility with strings. This is based off IntOrString from
kubernetes/apimachinery, and allows the value-type to be immediately
parsed and decided through the webhook.

Lastly, a possibly unintuitive design decision is that if an EMPTY array
parameter properly replaces an array element, then that string in the
original array will be completely removed.
EliZucker added a commit to EliZucker/pipeline that referenced this issue Jul 19, 2019
Instead of just strings, add support for users to supply parameters in
the form of an array. Also include appropriate type validation and
defaulting to support backwards-compatibility. Fixes tektoncd#207.

The size of a user-supplied array is not specified anywhere in the
corresponding ParamSpec, which is useful for defining tasks that
require a dynamic number of strings used as distinct elements in
an array. For instance, one might use an array parameter in an
image-building task that feeds in a dynamic number of flags via the
args field for a particular step.

The implementation is defined such that an Array parameter can only be
used if the replacement string is completely isolated and within a field
that is an array of strings (currently eligible fields are 'command'
and 'args'). For instance, the webhook will prevent an array parameter
from being used in the 'image' field. Similarly, an array parameter used
in a composite string, like 'value=${array}', is invalid and will be
caught. The decision was made to completely prevent any use of array
parameters as strings because it clutters Tekton with unnecessary
functionality and is naturally extensible beyond the intended scope.
For instance, if the behavior was defined such that array parameters
used in the context of strings were automatically converted by
separating them with a space, then that relatively arbitrary
implementation could be questioned and eventually lead to needing to
specify a custom delimiter (like commas), and so on.

Another implementation detail to note is that the ArrayOrString type was
necessary, in combination with implementing json.Marshaller, to support
backwards-compatibility with strings. This is based off IntOrString from
kubernetes/apimachinery, and allows the value-type to be immediately
parsed and decided through the webhook.

Lastly, a possibly unintuitive design decision is that if an EMPTY array
parameter properly replaces an array element, then that string in the
original array will be completely removed.
EliZucker added a commit to EliZucker/pipeline that referenced this issue Jul 19, 2019
Instead of just strings, add support for users to supply parameters in
the form of an array. Also include appropriate type validation and
defaulting to support backwards-compatibility. Fixes tektoncd#207.

The size of a user-supplied array is not specified anywhere in the
corresponding ParamSpec, which is useful for defining tasks that
require a dynamic number of strings used as distinct elements in
an array. For instance, one might use an array parameter in an
image-building task that feeds in a dynamic number of flags via the
args field for a particular step.

The implementation is defined such that an Array parameter can only be
used if the replacement string is completely isolated and within a field
that is an array of strings (currently eligible fields are 'command'
and 'args'). For instance, the webhook will prevent an array parameter
from being used in the 'image' field. Similarly, an array parameter used
in a composite string, like 'value=${array}', is invalid and will be
caught. The decision was made to completely prevent any use of array
parameters as strings because it clutters Tekton with unnecessary
functionality and is naturally extensible beyond the intended scope.
For instance, if the behavior was defined such that array parameters
used in the context of strings were automatically converted by
separating them with a space, then that relatively arbitrary
implementation could be questioned and eventually lead to needing to
specify a custom delimiter (like commas), and so on.

Another implementation detail to note is that the ArrayOrString type was
necessary, in combination with implementing json.Marshaller, to support
backwards-compatibility with strings. This is based off IntOrString from
kubernetes/apimachinery, and allows the value-type to be immediately
parsed and decided through the webhook.

Lastly, a possibly unintuitive design decision is that if an EMPTY array
parameter properly replaces an array element, then that string in the
original array will be completely removed.
EliZucker added a commit to EliZucker/pipeline that referenced this issue Jul 19, 2019
Instead of just strings, add support for users to supply parameters in
the form of an array. Also include appropriate type validation and
defaulting to support backwards-compatibility. Fixes tektoncd#207.

The size of a user-supplied array is not specified anywhere in the
corresponding ParamSpec, which is useful for defining tasks that
require a dynamic number of strings used as distinct elements in
an array. For instance, one might use an array parameter in an
image-building task that feeds in a dynamic number of flags via the
args field for a particular step.

The implementation is defined such that an Array parameter can only be
used if the replacement string is completely isolated and within a field
that is an array of strings (currently eligible fields are 'command'
and 'args'). For instance, the webhook will prevent an array parameter
from being used in the 'image' field. Similarly, an array parameter used
in a composite string, like 'value=${array}', is invalid and will be
caught. The decision was made to completely prevent any use of array
parameters as strings because it clutters Tekton with unnecessary
functionality and is naturally extensible beyond the intended scope.
For instance, if the behavior was defined such that array parameters
used in the context of strings were automatically converted by
separating them with a space, then that relatively arbitrary
implementation could be questioned and eventually lead to needing to
specify a custom delimiter (like commas), and so on.

Another implementation detail to note is that the ArrayOrString type was
necessary, in combination with implementing json.Marshaller, to support
backwards-compatibility with strings. This is based off IntOrString from
kubernetes/apimachinery, and allows the value-type to be immediately
parsed and decided through the webhook.

Lastly, a possibly unintuitive design decision is that if an EMPTY array
parameter properly replaces an array element, then that string in the
original array will be completely removed.
EliZucker added a commit to EliZucker/pipeline that referenced this issue Jul 22, 2019
Instead of just strings, add support for users to supply parameters in
the form of an array. Also include appropriate type validation and
defaulting to support backwards-compatibility. Fixes tektoncd#207.

The size of a user-supplied array is not specified anywhere in the
corresponding ParamSpec, which is useful for defining tasks that
require a dynamic number of strings used as distinct elements in
an array. For instance, one might use an array parameter in an
image-building task that feeds in a dynamic number of flags via the
args field for a particular step.

The implementation is defined such that an Array parameter can only be
used if the replacement string is completely isolated and within a field
that is an array of strings (currently eligible fields are 'command'
and 'args'). For instance, the webhook will prevent an array parameter
from being used in the 'image' field. Similarly, an array parameter used
in a composite string, like 'value=${array}', is invalid and will be
caught. The decision was made to completely prevent any use of array
parameters as strings because it clutters Tekton with unnecessary
functionality and is naturally extensible beyond the intended scope.
For instance, if the behavior was defined such that array parameters
used in the context of strings were automatically converted by
separating them with a space, then that relatively arbitrary
implementation could be questioned and eventually lead to needing to
specify a custom delimiter (like commas), and so on.

Another implementation detail to note is that the ArrayOrString type was
necessary, in combination with implementing json.Marshaller, to support
backwards-compatibility with strings. This is based off IntOrString from
kubernetes/apimachinery, and allows the value-type to be immediately
parsed and decided through the webhook.

Lastly, a possibly unintuitive design decision is that if an EMPTY array
parameter properly replaces an array element, then that string in the
original array will be completely removed.
EliZucker added a commit to EliZucker/pipeline that referenced this issue Jul 23, 2019
Instead of just strings, add support for users to supply parameters in
the form of an array. Also include appropriate type validation and
defaulting to support backwards-compatibility. Fixes tektoncd#207.

The size of a user-supplied array is not specified anywhere in the
corresponding ParamSpec, which is useful for defining tasks that
require a dynamic number of strings used as distinct elements in
an array. For instance, one might use an array parameter in an
image-building task that feeds in a dynamic number of flags via the
args field for a particular step.

The implementation is defined such that an Array parameter can only be
used if the replacement string is completely isolated and within a field
that is an array of strings (currently eligible fields are 'command'
and 'args'). For instance, the webhook will prevent an array parameter
from being used in the 'image' field. Similarly, an array parameter used
in a composite string, like 'value=${array}', is invalid and will be
caught. The decision was made to completely prevent any use of array
parameters as strings because it clutters Tekton with unnecessary
functionality and is naturally extensible beyond the intended scope.
For instance, if the behavior was defined such that array parameters
used in the context of strings were automatically converted by
separating them with a space, then that relatively arbitrary
implementation could be questioned and eventually lead to needing to
specify a custom delimiter (like commas), and so on.

Another implementation detail to note is that the ArrayOrString type was
necessary, in combination with implementing json.Marshaller, to support
backwards-compatibility with strings. This is based off IntOrString from
kubernetes/apimachinery, and allows the value-type to be immediately
parsed and decided through the webhook.

Lastly, a possibly unintuitive design decision is that if an EMPTY array
parameter properly replaces an array element, then that string in the
original array will be completely removed.
EliZucker added a commit to EliZucker/pipeline that referenced this issue Jul 23, 2019
Instead of just strings, add support for users to supply parameters in
the form of an array. Also include appropriate type validation and
defaulting to support backwards-compatibility. Fixes tektoncd#207.

The size of a user-supplied array is not specified anywhere in the
corresponding ParamSpec, which is useful for defining tasks that
require a dynamic number of strings used as distinct elements in
an array. For instance, one might use an array parameter in an
image-building task that feeds in a dynamic number of flags via the
args field for a particular step.

The implementation is defined such that an Array parameter can only be
used if the replacement string is completely isolated and within a field
that is an array of strings (currently eligible fields are 'command'
and 'args'). For instance, the webhook will prevent an array parameter
from being used in the 'image' field. Similarly, an array parameter used
in a composite string, like 'value=${array}', is invalid and will be
caught. The decision was made to completely prevent any use of array
parameters as strings because it clutters Tekton with unnecessary
functionality and is naturally extensible beyond the intended scope.
For instance, if the behavior was defined such that array parameters
used in the context of strings were automatically converted by
separating them with a space, then that relatively arbitrary
implementation could be questioned and eventually lead to needing to
specify a custom delimiter (like commas), and so on.

Another implementation detail to note is that the ArrayOrString type was
necessary, in combination with implementing json.Marshaller, to support
backwards-compatibility with strings. This is based off IntOrString from
kubernetes/apimachinery, and allows the value-type to be immediately
parsed and decided through the webhook.

Lastly, a possibly unintuitive design decision is that if an EMPTY array
parameter properly replaces an array element, then that string in the
original array will be completely removed.
EliZucker added a commit to EliZucker/pipeline that referenced this issue Jul 23, 2019
Instead of just strings, add support for users to supply parameters in
the form of an array. Also include appropriate type validation and
defaulting to support backwards-compatibility. Fixes tektoncd#207.

The size of a user-supplied array is not specified anywhere in the
corresponding ParamSpec, which is useful for defining tasks that
require a dynamic number of strings used as distinct elements in
an array. For instance, one might use an array parameter in an
image-building task that feeds in a dynamic number of flags via the
args field for a particular step.

The implementation is defined such that an Array parameter can only be
used if the replacement string is completely isolated and within a field
that is an array of strings (currently eligible fields are 'command'
and 'args'). For instance, the webhook will prevent an array parameter
from being used in the 'image' field. Similarly, an array parameter used
in a composite string, like 'value=${array}', is invalid and will be
caught. The decision was made to completely prevent any use of array
parameters as strings because it clutters Tekton with unnecessary
functionality and is naturally extensible beyond the intended scope.
For instance, if the behavior was defined such that array parameters
used in the context of strings were automatically converted by
separating them with a space, then that relatively arbitrary
implementation could be questioned and eventually lead to needing to
specify a custom delimiter (like commas), and so on.

Another implementation detail to note is that the ArrayOrString type was
necessary, in combination with implementing json.Marshaller, to support
backwards-compatibility with strings. This is based off IntOrString from
kubernetes/apimachinery, and allows the value-type to be immediately
parsed and decided through the webhook.

Lastly, a possibly unintuitive design decision is that if an EMPTY array
parameter properly replaces an array element, then that string in the
original array will be completely removed.
EliZucker added a commit to EliZucker/pipeline that referenced this issue Jul 25, 2019
Instead of just strings, add support for users to supply parameters in
the form of an array. Also include appropriate type validation and
defaulting to support backwards-compatibility. Fixes tektoncd#207.

The size of a user-supplied array is not specified anywhere in the
corresponding ParamSpec, which is useful for defining tasks that
require a dynamic number of strings used as distinct elements in
an array. For instance, one might use an array parameter in an
image-building task that feeds in a dynamic number of flags via the
args field for a particular step.

The implementation is defined such that an Array parameter can only be
used if the replacement string is completely isolated and within a field
that is an array of strings (currently eligible fields are 'command'
and 'args'). For instance, the webhook will prevent an array parameter
from being used in the 'image' field. Similarly, an array parameter used
in a composite string, like 'value=${array}', is invalid and will be
caught. The decision was made to completely prevent any use of array
parameters as strings because it clutters Tekton with unnecessary
functionality and is naturally extensible beyond the intended scope.
For instance, if the behavior was defined such that array parameters
used in the context of strings were automatically converted by
separating them with a space, then that relatively arbitrary
implementation could be questioned and eventually lead to needing to
specify a custom delimiter (like commas), and so on.

Another implementation detail to note is that the ArrayOrString type was
necessary, in combination with implementing json.Marshaller, to support
backwards-compatibility with strings. This is based off IntOrString from
kubernetes/apimachinery, and allows the value-type to be immediately
parsed and decided through the webhook.

Lastly, a possibly unintuitive design decision is that if an EMPTY array
parameter properly replaces an array element, then that string in the
original array will be completely removed.
EliZucker added a commit to EliZucker/pipeline that referenced this issue Jul 30, 2019
Instead of just strings, add support for users to supply parameters in
the form of an array. Also include appropriate type validation and
defaulting to support backwards-compatibility. Fixes tektoncd#207.

The size of a user-supplied array is not specified anywhere in the
corresponding ParamSpec, which is useful for defining tasks that
require a dynamic number of strings used as distinct elements in
an array. For instance, one might use an array parameter in an
image-building task that feeds in a dynamic number of flags via the
args field for a particular step.

The implementation is defined such that an Array parameter can only be
used if the replacement string is completely isolated and within a field
that is an array of strings (currently eligible fields are 'command'
and 'args'). For instance, the webhook will prevent an array parameter
from being used in the 'image' field. Similarly, an array parameter used
in a composite string, like 'value=${array}', is invalid and will be
caught. The decision was made to completely prevent any use of array
parameters as strings because it clutters Tekton with unnecessary
functionality and is naturally extensible beyond the intended scope.
For instance, if the behavior was defined such that array parameters
used in the context of strings were automatically converted by
separating them with a space, then that relatively arbitrary
implementation could be questioned and eventually lead to needing to
specify a custom delimiter (like commas), and so on.

Another implementation detail to note is that the ArrayOrString type was
necessary, in combination with implementing json.Marshaller, to support
backwards-compatibility with strings. This is based off IntOrString from
kubernetes/apimachinery, and allows the value-type to be immediately
parsed and decided through the webhook.

Lastly, a possibly unintuitive design decision is that if an EMPTY array
parameter properly replaces an array element, then that string in the
original array will be completely removed.
tekton-robot pushed a commit that referenced this issue Jul 30, 2019
Instead of just strings, add support for users to supply parameters in
the form of an array. Also include appropriate type validation and
defaulting to support backwards-compatibility. Fixes #207.

The size of a user-supplied array is not specified anywhere in the
corresponding ParamSpec, which is useful for defining tasks that
require a dynamic number of strings used as distinct elements in
an array. For instance, one might use an array parameter in an
image-building task that feeds in a dynamic number of flags via the
args field for a particular step.

The implementation is defined such that an Array parameter can only be
used if the replacement string is completely isolated and within a field
that is an array of strings (currently eligible fields are 'command'
and 'args'). For instance, the webhook will prevent an array parameter
from being used in the 'image' field. Similarly, an array parameter used
in a composite string, like 'value=${array}', is invalid and will be
caught. The decision was made to completely prevent any use of array
parameters as strings because it clutters Tekton with unnecessary
functionality and is naturally extensible beyond the intended scope.
For instance, if the behavior was defined such that array parameters
used in the context of strings were automatically converted by
separating them with a space, then that relatively arbitrary
implementation could be questioned and eventually lead to needing to
specify a custom delimiter (like commas), and so on.

Another implementation detail to note is that the ArrayOrString type was
necessary, in combination with implementing json.Marshaller, to support
backwards-compatibility with strings. This is based off IntOrString from
kubernetes/apimachinery, and allows the value-type to be immediately
parsed and decided through the webhook.

Lastly, a possibly unintuitive design decision is that if an EMPTY array
parameter properly replaces an array element, then that string in the
original array will be completely removed.
@skaegi
Copy link
Contributor

skaegi commented Aug 8, 2019

@EliZucker I'm sorry to pick on a closed issue but I think there are a few things here that we need to think about... (perhaps a few already have an answer)

  1. How do we represent an array parameter with a CLI
  2. Is args the only use-case? This is not something the container spec's env/arg based substitution supports so we should be careful. If we want to get param values "from" configmaps or secrets in the future only strings are supported there too.
  3. Context based type conversion has a history of being a footgun -- e.g. docker run $(IMAGE) - we might consider an operator ( e.g. $(...MYARRAY) or $(MYARRAY[@]) to make the conversion explicit even if correct use of "type" might prevent problems
    --
    I understand the use-case and I'm very interested in getting params right but I think array support is something we might want to take a bit of time to make sure is right and also make certain is not a mis-feature. Although perhaps not as nice looking this can be solved in user space with a shell script that parses out a delimiter in a param or in a preprocessor that directly populates args with a merged array.

sthaha pushed a commit to sthaha/build-pipeline that referenced this issue Nov 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
design This task is about creating and discussing a design help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. meaty-juicy-coding-work This task is mostly about implementation!!! And docs and tests of course but that's a given
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants