Skip to content

Commit

Permalink
change param array indexing validation functions to member functions
Browse files Browse the repository at this point in the history
This commit refactors param array indexing validation to extract all
references first, then validate if references are out of bound.
Previously we traverse all references and collect invalid references
there. The benefit of this refactoring is that it would be convenient
for other validation to reuse these references.
This commit also moves validation functions into api and change them to
member functions.

Signed-off-by: Yongxuan Zhang [email protected]
  • Loading branch information
Yongxuanzhang committed Mar 2, 2023
1 parent b858d7b commit 47343d4
Show file tree
Hide file tree
Showing 24 changed files with 1,947 additions and 986 deletions.
102 changes: 64 additions & 38 deletions docs/pipeline-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -561,8 +561,8 @@ used to populate a UI.</p>
<td>
<code>params</code><br/>
<em>
<a href="#tekton.dev/v1.ParamSpec">
[]ParamSpec
<a href="#tekton.dev/v1.ParamSpecs">
ParamSpecs
</a>
</em>
</td>
Expand Down Expand Up @@ -881,8 +881,8 @@ TaskSpec
<td>
<code>params</code><br/>
<em>
<a href="#tekton.dev/v1.ParamSpec">
[]ParamSpec
<a href="#tekton.dev/v1.ParamSpecs">
ParamSpecs
</a>
</em>
</td>
Expand Down Expand Up @@ -1488,8 +1488,8 @@ TaskSpec
<td>
<code>params</code><br/>
<em>
<a href="#tekton.dev/v1.Param">
[]Param
<a href="#tekton.dev/v1.Params">
Params
</a>
</em>
</td>
Expand Down Expand Up @@ -1549,8 +1549,8 @@ string
<td>
<code>params</code><br/>
<em>
<a href="#tekton.dev/v1.Param">
[]Param
<a href="#tekton.dev/v1.Params">
Params
</a>
</em>
</td>
Expand Down Expand Up @@ -1587,7 +1587,7 @@ The names of the <code>params</code> must match the names of the <code>params</c
<h3 id="tekton.dev/v1.Param">Param
</h3>
<p>
(<em>Appears on:</em><a href="#tekton.dev/v1.Matrix">Matrix</a>, <a href="#tekton.dev/v1.MatrixInclude">MatrixInclude</a>, <a href="#tekton.dev/v1.PipelineRunSpec">PipelineRunSpec</a>, <a href="#tekton.dev/v1.PipelineTask">PipelineTask</a>, <a href="#tekton.dev/v1.ResolverRef">ResolverRef</a>, <a href="#tekton.dev/v1.TaskRunInputs">TaskRunInputs</a>, <a href="#tekton.dev/v1.TaskRunSpec">TaskRunSpec</a>)
(<em>Appears on:</em><a href="#tekton.dev/v1.PipelineRunSpec">PipelineRunSpec</a>, <a href="#tekton.dev/v1.ResolverRef">ResolverRef</a>, <a href="#tekton.dev/v1.TaskRunInputs">TaskRunInputs</a>, <a href="#tekton.dev/v1.TaskRunSpec">TaskRunSpec</a>)
</p>
<div>
<p>Param declares an ParamValues to use for the parameter called name.</p>
Expand Down Expand Up @@ -1626,9 +1626,6 @@ ParamValue
</table>
<h3 id="tekton.dev/v1.ParamSpec">ParamSpec
</h3>
<p>
(<em>Appears on:</em><a href="#tekton.dev/v1.PipelineSpec">PipelineSpec</a>, <a href="#tekton.dev/v1.TaskSpec">TaskSpec</a>)
</p>
<div>
<p>ParamSpec defines arbitrary parameters needed beyond typed inputs (such as
resources). Parameter values are provided by users as inputs on a TaskRun
Expand Down Expand Up @@ -1713,6 +1710,14 @@ parameter.</p>
</tr>
</tbody>
</table>
<h3 id="tekton.dev/v1.ParamSpecs">ParamSpecs
(<code>[]github.com/tektoncd/pipeline/pkg/apis/pipeline/v1.ParamSpec</code> alias)</h3>
<p>
(<em>Appears on:</em><a href="#tekton.dev/v1.PipelineSpec">PipelineSpec</a>, <a href="#tekton.dev/v1.TaskSpec">TaskSpec</a>)
</p>
<div>
<p>ParamSpecs is a list of ParamSpec</p>
</div>
<h3 id="tekton.dev/v1.ParamType">ParamType
(<code>string</code> alias)</h3>
<p>
Expand Down Expand Up @@ -1798,6 +1803,14 @@ map[string]string
</tr>
</tbody>
</table>
<h3 id="tekton.dev/v1.Params">Params
(<code>[]github.com/tektoncd/pipeline/pkg/apis/pipeline/v1.Param</code> alias)</h3>
<p>
(<em>Appears on:</em><a href="#tekton.dev/v1.Matrix">Matrix</a>, <a href="#tekton.dev/v1.MatrixInclude">MatrixInclude</a>, <a href="#tekton.dev/v1.PipelineTask">PipelineTask</a>)
</p>
<div>
<p>Params is a list of Param</p>
</div>
<h3 id="tekton.dev/v1.PipelineRef">PipelineRef
</h3>
<p>
Expand Down Expand Up @@ -2489,8 +2502,8 @@ used to populate a UI.</p>
<td>
<code>params</code><br/>
<em>
<a href="#tekton.dev/v1.ParamSpec">
[]ParamSpec
<a href="#tekton.dev/v1.ParamSpecs">
ParamSpecs
</a>
</em>
</td>
Expand Down Expand Up @@ -2646,8 +2659,8 @@ this Task executes. (Used to force a specific ordering in graph execution.)</p>
<td>
<code>params</code><br/>
<em>
<a href="#tekton.dev/v1.Param">
[]Param
<a href="#tekton.dev/v1.Params">
Params
</a>
</em>
</td>
Expand Down Expand Up @@ -5254,8 +5267,8 @@ Kubernetes core/v1.ResourceRequirements
<td>
<code>params</code><br/>
<em>
<a href="#tekton.dev/v1.ParamSpec">
[]ParamSpec
<a href="#tekton.dev/v1.ParamSpecs">
ParamSpecs
</a>
</em>
</td>
Expand Down Expand Up @@ -7236,8 +7249,8 @@ PipelineResources.</p>
<td>
<code>params</code><br/>
<em>
<a href="#tekton.dev/v1beta1.ParamSpec">
[]ParamSpec
<a href="#tekton.dev/v1beta1.ParamSpecs">
ParamSpecs
</a>
</em>
</td>
Expand Down Expand Up @@ -7650,8 +7663,8 @@ Pipeline&rsquo;s tasks as inputs and outputs.</p>
<td>
<code>params</code><br/>
<em>
<a href="#tekton.dev/v1beta1.ParamSpec">
[]ParamSpec
<a href="#tekton.dev/v1beta1.ParamSpecs">
ParamSpecs
</a>
</em>
</td>
Expand Down Expand Up @@ -8028,8 +8041,8 @@ PipelineResources.</p>
<td>
<code>params</code><br/>
<em>
<a href="#tekton.dev/v1beta1.ParamSpec">
[]ParamSpec
<a href="#tekton.dev/v1beta1.ParamSpecs">
ParamSpecs
</a>
</em>
</td>
Expand Down Expand Up @@ -9046,8 +9059,8 @@ TaskSpec
<td>
<code>params</code><br/>
<em>
<a href="#tekton.dev/v1beta1.Param">
[]Param
<a href="#tekton.dev/v1beta1.Params">
Params
</a>
</em>
</td>
Expand Down Expand Up @@ -9107,8 +9120,8 @@ string
<td>
<code>params</code><br/>
<em>
<a href="#tekton.dev/v1beta1.Param">
[]Param
<a href="#tekton.dev/v1beta1.Params">
Params
</a>
</em>
</td>
Expand All @@ -9130,7 +9143,7 @@ The names of the <code>params</code> must match the names of the <code>params</c
<h3 id="tekton.dev/v1beta1.Param">Param
</h3>
<p>
(<em>Appears on:</em><a href="#tekton.dev/v1alpha1.RunSpec">RunSpec</a>, <a href="#tekton.dev/v1beta1.CustomRunSpec">CustomRunSpec</a>, <a href="#tekton.dev/v1beta1.Matrix">Matrix</a>, <a href="#tekton.dev/v1beta1.MatrixInclude">MatrixInclude</a>, <a href="#tekton.dev/v1beta1.PipelineRunSpec">PipelineRunSpec</a>, <a href="#tekton.dev/v1beta1.PipelineTask">PipelineTask</a>, <a href="#tekton.dev/v1beta1.ResolverRef">ResolverRef</a>, <a href="#tekton.dev/v1beta1.TaskRunInputs">TaskRunInputs</a>, <a href="#tekton.dev/v1beta1.TaskRunSpec">TaskRunSpec</a>, <a href="#resolution.tekton.dev/v1beta1.ResolutionRequestSpec">ResolutionRequestSpec</a>)
(<em>Appears on:</em><a href="#tekton.dev/v1alpha1.RunSpec">RunSpec</a>, <a href="#tekton.dev/v1beta1.CustomRunSpec">CustomRunSpec</a>, <a href="#tekton.dev/v1beta1.PipelineRunSpec">PipelineRunSpec</a>, <a href="#tekton.dev/v1beta1.ResolverRef">ResolverRef</a>, <a href="#tekton.dev/v1beta1.TaskRunInputs">TaskRunInputs</a>, <a href="#tekton.dev/v1beta1.TaskRunSpec">TaskRunSpec</a>, <a href="#resolution.tekton.dev/v1beta1.ResolutionRequestSpec">ResolutionRequestSpec</a>)
</p>
<div>
<p>Param declares an ParamValues to use for the parameter called name.</p>
Expand Down Expand Up @@ -9169,9 +9182,6 @@ ParamValue
</table>
<h3 id="tekton.dev/v1beta1.ParamSpec">ParamSpec
</h3>
<p>
(<em>Appears on:</em><a href="#tekton.dev/v1beta1.PipelineSpec">PipelineSpec</a>, <a href="#tekton.dev/v1beta1.TaskSpec">TaskSpec</a>)
</p>
<div>
<p>ParamSpec defines arbitrary parameters needed beyond typed inputs (such as
resources). Parameter values are provided by users as inputs on a TaskRun
Expand Down Expand Up @@ -9256,6 +9266,14 @@ parameter.</p>
</tr>
</tbody>
</table>
<h3 id="tekton.dev/v1beta1.ParamSpecs">ParamSpecs
(<code>[]github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.ParamSpec</code> alias)</h3>
<p>
(<em>Appears on:</em><a href="#tekton.dev/v1beta1.PipelineSpec">PipelineSpec</a>, <a href="#tekton.dev/v1beta1.TaskSpec">TaskSpec</a>)
</p>
<div>
<p>ParamSpecs is a list of ParamSpec</p>
</div>
<h3 id="tekton.dev/v1beta1.ParamType">ParamType
(<code>string</code> alias)</h3>
<p>
Expand Down Expand Up @@ -9326,6 +9344,14 @@ map[string]string
</tr>
</tbody>
</table>
<h3 id="tekton.dev/v1beta1.Params">Params
(<code>[]github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.Param</code> alias)</h3>
<p>
(<em>Appears on:</em><a href="#tekton.dev/v1beta1.Matrix">Matrix</a>, <a href="#tekton.dev/v1beta1.MatrixInclude">MatrixInclude</a>, <a href="#tekton.dev/v1beta1.PipelineTask">PipelineTask</a>)
</p>
<div>
<p>Params is a list of Param</p>
</div>
<h3 id="tekton.dev/v1beta1.PipelineDeclaredResource">PipelineDeclaredResource
</h3>
<p>
Expand Down Expand Up @@ -10279,8 +10305,8 @@ Pipeline&rsquo;s tasks as inputs and outputs.</p>
<td>
<code>params</code><br/>
<em>
<a href="#tekton.dev/v1beta1.ParamSpec">
[]ParamSpec
<a href="#tekton.dev/v1beta1.ParamSpecs">
ParamSpecs
</a>
</em>
</td>
Expand Down Expand Up @@ -10451,8 +10477,8 @@ outputs.</p>
<td>
<code>params</code><br/>
<em>
<a href="#tekton.dev/v1beta1.Param">
[]Param
<a href="#tekton.dev/v1beta1.Params">
Params
</a>
</em>
</td>
Expand Down Expand Up @@ -13722,8 +13748,8 @@ PipelineResources.</p>
<td>
<code>params</code><br/>
<em>
<a href="#tekton.dev/v1beta1.ParamSpec">
[]ParamSpec
<a href="#tekton.dev/v1beta1.ParamSpecs">
ParamSpecs
</a>
</em>
</td>
Expand Down
24 changes: 12 additions & 12 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,9 @@ require github.com/benbjohnson/clock v1.1.0 // indirect

require (
code.gitea.io/sdk/gitea v0.15.1
github.com/cenkalti/backoff/v3 v3.2.2
github.com/goccy/kpoward v0.1.0
github.com/google/go-containerregistry/pkg/authn/k8schain v0.0.0-20221030203717-1711cefd7eec
github.com/hashicorp/go-cleanhttp v0.5.2
github.com/hashicorp/go-retryablehttp v0.7.1
github.com/hashicorp/go-rootcerts v1.0.2
github.com/hashicorp/go-secure-stdlib/parseutil v0.1.7
github.com/hashicorp/go-secure-stdlib/strutil v0.1.2
github.com/hashicorp/go-sockaddr v1.0.2
github.com/hashicorp/hcl v1.0.0
github.com/letsencrypt/boulder v0.0.0-20221109233200-85aa52084eaf
github.com/mitchellh/mapstructure v1.5.0
github.com/ryanuber/go-glob v1.0.0
github.com/titanous/rocacheck v0.0.0-20171023193734-afe73141d399
go.opentelemetry.io/otel v1.14.0
go.opentelemetry.io/otel/exporters/jaeger v1.14.0
Expand Down Expand Up @@ -83,6 +73,7 @@ require (
github.com/Azure/go-autorest/autorest/validation v0.3.1 // indirect
github.com/aws/aws-sdk-go-v2/service/kms v1.20.4 // indirect
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.14.3 // indirect
github.com/cenkalti/backoff/v3 v3.2.2 // indirect
github.com/cloudflare/circl v1.1.0 // indirect
github.com/emicklei/go-restful/v3 v3.9.0 // indirect
github.com/fatih/color v1.13.0 // indirect
Expand All @@ -92,12 +83,21 @@ require (
github.com/googleapis/enterprise-certificate-proxy v0.2.3 // indirect
github.com/googleapis/gax-go/v2 v2.7.0 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.11.3 // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
github.com/hashicorp/go-retryablehttp v0.7.1 // indirect
github.com/hashicorp/go-rootcerts v1.0.2 // indirect
github.com/hashicorp/go-secure-stdlib/parseutil v0.1.7 // indirect
github.com/hashicorp/go-secure-stdlib/strutil v0.1.2 // indirect
github.com/hashicorp/go-sockaddr v1.0.2 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/hashicorp/vault/api v1.9.0 // indirect
github.com/jellydator/ttlcache/v2 v2.11.1 // indirect
github.com/kr/pretty v0.3.0 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/pjbgf/sha1cd v0.2.3 // indirect
github.com/rogpeppe/go-internal v1.8.0 // indirect
github.com/ryanuber/go-glob v1.0.0 // indirect
github.com/skeema/knownhosts v1.1.0 // indirect
github.com/theupdateframework/go-tuf v0.5.2-0.20220930112810-3890c1e7ace4 // indirect
github.com/zeebo/errs v1.3.0 // indirect
Expand Down Expand Up @@ -193,12 +193,12 @@ require (
go.uber.org/multierr v1.8.0 // indirect
golang.org/x/crypto v0.6.0
golang.org/x/mod v0.7.0 // indirect
golang.org/x/net v0.7.0
golang.org/x/net v0.7.0 // indirect
golang.org/x/sync v0.1.0
golang.org/x/sys v0.5.0 // indirect
golang.org/x/term v0.5.0 // indirect
golang.org/x/text v0.7.0 // indirect
golang.org/x/time v0.2.0
golang.org/x/time v0.2.0 // indirect
golang.org/x/tools v0.5.0 // indirect
google.golang.org/api v0.110.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
Expand Down
Loading

0 comments on commit 47343d4

Please sign in to comment.