Giter VIP home page Giter VIP logo

tekton-lint's Introduction

tekton-lint

A linter for Tekton resource definitions

Quick Start

Make sure you've NodeJS v18 or later installed, and run....

npx @ibm/tekton-lint@latest <glob-pattern-to-yaml-files>

To try a quick example, grab the example-task.yaml from this repo

> wget https://raw.githubusercontent.com/IBM/tekton-lint/main/example-task.yaml
> npx @ibm/tekton-lint@latest  example-task.yaml

example-task.yaml
   4:9   error    Invalid name for Task 'Task-without-params'. Names should be in lowercase, alphanumeric, kebab-case format  no-invalid-name
  10:14  warning  Invalid image: 'busybox'. Specify the image tag instead of using ':latest'                                  no-latest-image
   9:31  error    Undefined param 'contextDir' at .spec.steps[0].command[2] in 'Task-without-params'                          no-undefined-param
  11:19  error    Undefined param 'contextDir' at .spec.steps[0].workingDir in 'Task-without-params'                          no-undefined-param

✖ 4 problems (3 errors, 1 warning)

You can use the tool as a regular lint tool from the CLI or scripts; alternatively you can use it as a library via it's API or from an IDE such as VScode. (please consider both the API and IDE use as experimental features.)

History

When I first started using Tekton a few years ago, I found one of the harder things was keeping track of the dependencies between the YAML files. Comparing to say github actions, or travis, Tekton is a lot more verbose. The comparison isn't quite fair as the tools do work at slightly different levels.

Nevertheless, I was pleased to find this TektonLint tool; it was able to spot a number of the 'gotchas' before pushing the pipelines for execution. After a brief hiatus, I was using Tekton again. Bence Dányi the original author was no longer at IBM; as the tool had been useful for me I decided to take on the repo.

I've updated typescript versions, added in additional features such as custom rules, allowed for caching of standard components. Theres more still I'd like to do; but of a MVP it's at v1.

Usage - CLI

tekton-lint is parsing the passed files as yaml files, and checks the rules on the resulting document set. [More details on the pattern syntax.][pattern]

Using tekton-lint in watch mode will monitor for any changes in the provided paths and automatically run the linter again.

Be mindful if you specify a glob pattern (eg *.yaml) that this might be expanded by your shell rather than the tool itself. It'll probably be fine for the vast majority of cases.

tekton-lint [<options>]  <glob-pattern-to-yaml-files> ...

Options:
  --watch           Run tekton-lint in watch mode     [boolean] [default: false]
  --color          Forcefully enable/disable colored output
                                                       [boolean] [default: true]
  --format         Format output. Available formatters: vscode | stylish | json
            [string] [choices: "vscode", "stylish", "json"] [default: "stylish"]
  --quiet          Report errors only                 [boolean] [default: false]
  --max-warnings   Number of warnings to trigger nonzero exit code
                                                          [number] [default: -1]
  --config         location of the .tektonlintrc.yaml, defaults to cwd
                                             [string] [default: "/home/matthew"]
  --refresh-cache  If true will delete the cache directory for external tasks
                                                    [boolean] [default: "false"]
  --version        Show version number                                 [boolean]
  --help           Show help                                           [boolean]

Examples:
  tekton-lint "**/*.yaml"                   Globstar matching
  tekton-lint path/to/my/pipeline.yaml      Multiple glob patterns
  "path/to/my/tasks/*.yaml"
  tekton-lint --watch "**/*.yaml"           Watch mode

What yaml files to include?

Only the yaml files that are specified are linted; these can be defined either on the command line, or via the .tektonlintrc.yaml file.

globs:
  - example*.yaml

If both command line and the configuration file have patterns specified, both are used but the command line options come first.

Depdending on how your Tekton instance is configured sometimes you might be using task descriptions that aren't part of your project or repository. In this case you'll get linter errors that "Task XYZ can't be found" - the latest v1 version of tool has added the concept of 'external tasks'.

For example if you are using some of the OpenToolchain Tasks, you can add the following to the configuration file

---
external-tasks:
  - name: git-clone-repo
    uri: https://github.com/open-toolchain/tekton-catalog
    path: git
  - name: toolchain-extract-value
    uri: https://github.com/open-toolchain/tekton-catalog
    path: toolchain
  - name: doi-publish-build-record
    uri: https://github.com/open-toolchain/tekton-catalog
    path: devops-insights    
  - name: icr-publish
    uri: https://github.com/open-toolchain/tekton-catalog
    path: container-registry
  - name: iks-detch
    uri: https://github.com/open-toolchain/tekton-catalog
    path: kubernetes-service

This will clone the repos specified and extract the various directories to a local cache. When you lint your tools these external tasks and definitions will be included. This will prevent any errors about tasks missing; but also importantly ensure your use of the tasks is correct, eg no missed parameters.

Note that these cached files won't be linted themselves.

The cache is defined to be put to ~/.tektonlint If you wish to clear the cache, simply delete this directory - alternatively there is a cli option.

Rules

Please note that the tool assumes that the files are syntax correct YAML files, and they are following the established schema for Tekton. For example referring to a field with the wrong spelling or case will confuse the rules.

If you see an error like Pipeline 'pipeline-test-perf-tag' references task 'undefined' but the referenced task cannot be found. referencing 'undefined' this more than likely means there is a syntax error in the yaml file. This can be easily seen with casing, so using Name: .. rather than name: ..

Detecting errors

These rules are straightforward, violations indicate that there's a good chance that you won't be able to run your Pipeline

  • Missing Task definitions
  • Missing Condition definitions
  • Missing Pipeline definitions
  • Missing TriggerTemplate definitions
  • Missing TriggerBinding definitions
  • Missing parameter declarations within Tasks
  • Missing parameter declarations within Pipelines
  • Missing parameter declarations within TriggerTemplates
  • Missing volume definitions in Tasks
  • Missing Task output results
  • Missing required Pipeline parameters in TriggerTemplates
  • Missing required Task parameters in Pipelines
  • Missing required workspaces of Tasks referenced in Pipelines
  • Missing required workspaces of Pipelines referenced in TriggerTemplates
  • Extra parameters passed to Pipelines
  • Extra parameters passed to Tasks
  • Invalid runAfter conditions
  • Invalid resourceVersion key
  • Duplicate resources (of all supported resource kinds)
  • Duplicate parameters name in Tasks
  • Duplicate environment variables in Steps
  • Duplicate PipelineRun's parameters name in TriggerTemplates
  • Duplicate parameters name in TriggerBindings
  • Duplicate parameters name in TriggerTemplates
  • Duplicate parameters name in Pipelines
  • Missing Task parameter value in Pipelines
  • Invalid Task, Pipeline, TriggerTemplate, Condition parameter names (alpha-numeric characters, - and _ and can only start with alpha characters and _)
  • Invalid Task, Pipeline, TriggerTemplate parameter value types (must be string, multiline string or array of strings)
  • Invalid Task parameter syntax (using v1beta1 syntax in v1alpha1 defintions, and vice versa)
  • Invalid (undefined) Workspace references in Tasks of Pipelines
  • Missing referenced Task in another Task's parameter in Pipelines
  • Cycle detection in each pipelines task dependency graph (based on runAfters, results and resource -> inputs)

Best practices

If you violate these rules, the Pipeline is probably going to be just fine, these rules are more like a collection of best practices that we collected while we were working with tekton.

  • Unused Task parameters
  • Unused Condition parameters
  • Unused Pipeline parameters
  • Unused TriggerTemplate parameters
  • Unpinned images in Task steps
  • kebab-case and OR camelCase naming violations
  • Task & Pipeline definitions with tekton.dev/v1alpha1 apiVersion
  • Missing TriggerBinding parameter values
  • Usage of deprecated Condition instead of WhenExpression
  • Usage of deprecated resources (resources marked with tekton.dev/deprecated label)
  • Missing hashbang line from a Steps script

The default rule is for preferring kebab-case; camelCase is equally popular and many of the official examples on the Tekton website are in camel case. To use the rule that accepts camel case as well swap the rules in the .tektonrc.yaml file

---
rules: # error | warning | off
  prefer-kebab-case: off
  prefer-camel-kebab-case: warning

Configuring tekton-lint

You can configure tekton-lint with a configuration file (.tektonlintrc.yaml). You can decide which rules are enabled and at what error level. In addition you can specify external tekton tasks defined in a git repository; for example OpenToolChain provides a set of tasks that are helpful. But if you lint just your own tekton files there will be errors about not being able to find git-clone-repo for example. Not will any checks be made to see if your usage is correct.

Any task defined in the external-tasks section will be clone from git, into a local cache (defaults to ~/.tektonlint). Please make sure that you can git clone before running.

The configuration file should follow this format:

---
rules:
  rule-name: error | warning | off
external-tasks:
  - name: <tasks name>
    uri: http://github.com/....
    path: <sub dir of repo>

Example .tektonlintrc.yaml file:

---
rules:
  no-duplicate-param: error
  no-unused-param: warning
  no-deprecated-resource: off
external-tasks:
  - name: git-clone-repo
    uri: https://github.com/open-toolchain/tekton-catalog
    path: git
  - name: toolchain-extract-value
    uri: https://github.com/open-toolchain/tekton-catalog
    path: toolchain
  - name: doi-publish-build-record
    uri: https://github.com/open-toolchain/tekton-catalog
    path: devops-insights    
  - name: icr-publish
    uri: https://github.com/open-toolchain/tekton-catalog
    path: container-registry
  - name: iks-detch
    uri: https://github.com/open-toolchain/tekton-catalog
    path: kubernetes-service  

Search path for .tektonlintrc.yaml

  • location specified on the command line with the --config option
  • current working directory
  • default values used if nothing else found

Custom Rules

In additional the default set of rules, custom rules can provided as node modules; the mechanism is similar that used by tools such as eslint.

An example is provided in custom_rules, and will be used in the examples below. Notes on writing rules are also in the README.md

Configuring

In the .tektonrc.yaml file add an object with names of the rules and node module that provides it. To load rules exported by the module custom_rules, and named under my_rules add the custom field to the yaml file.

---
rules:
  ....
external:tasks:
  ...
custom: 
 my_rules: custom_rules 
 # For debug and test, refer directly to the js file
 # my_rules: ../customer_rules/my_rules.js

Reporting

A module may report more than one rule. There is one rule in the example, and this flags up any task that starts with the work 'Task' (not meant to be serious rule, but an example!)

Running on the example-task.yaml file with the example configured adds a 4th report

./example-task.yaml
  10:14  warning  Invalid image: 'busybox'. Specify the image tag instead of using ':latest'          no-latest-image
   9:31  error    Undefined param 'contextDir' at .spec.steps[0].command[2] in 'Task-without-params'  no-undefined-param
  11:19  error    Undefined param 'contextDir' at .spec.steps[0].workingDir in 'Task-without-params'  no-undefined-param
   1:1   error    Tasks should not start with word 'Task'                                             my_rules#no-tasks-called-task

✖ 4 problems (3 errors, 1 warning)

Within the representation of the rule name here my_rules#no-tasks-called-task; if you want to turn off this rule, then you can adjust the list of rules in the .tektonrc.yaml as for another rule; Note that # in the name.

rules:
  ...
  my_rules#no-tasks-called-task: off

Issues?

Please raise an issue in the usual manner, please try and include a short sample Tekton file that shows the problem.

There is an internal logging system you can enable via setting and environment variable

TL_DEBUG=true tekton-lint <file.yaml>

This will write out a app.log file in pino json format - use pino-pretty to view

tekton-lint's People

Contributors

bhartshorn avatar leandrof-ciandt avatar madbence avatar markkovari avatar mbwhite avatar tails128 avatar verebecske avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

tekton-lint's Issues

Add support for matrix parameters

Is your feature request related to a problem? Please describe.
Running tekton-lint against a pipeline using matrix parameters it does not seem to detect the matrix parameters and raises an error about missing parameters.

Describe the solution you'd like
It would be great if tekton-lint could detect matrix parameter definitions.

Describe alternatives you've considered
n/a

Additional context
https://tekton.dev/docs/pipelines/matrix/

allow custom rules

Is your feature request related to a problem? Please describe.
At the moment the tool supports only some pre-defined rules defined here https://github.com/IBM/tekton-lint/blob/main/src/rule-loader.ts
It would be great if users could provide (and leave them to maintain) their custom rule implementations and specify how to treat the findings (e.g. error, warning, etc..).

An example would be like the following:

const forbidPipelinesWithoutRequiredAnnotation = (docs, tekton, report) => {
    for (const pipeline of Object.values(tekton.pipelines)) {

        const pipelineAnnotations = Object.keys(pipeline.metadata.annotations);

        if (!pipelineAnnotations.includes('my/required-annotation')) {
            report(
                `Pipeline '${pipeline.metadata.name}' does not specify the 'my/required-annotation' annotation`,
            );
        }
    }
};

module.exports = {
    rules: {
        'no-required-annotations': 'error'
    },
    customRules: {
        'no-required-annotations': forbidPipelinesWithoutRequiredAnnotation
    }
}

Describe the solution you'd like
Support (on top of the yaml configuration) a JS (or TS) configuration file as well, e.g. .tektonlintrc.js where it is possible to define a set of custom rules or provide a specific rule as a function (instead of providing a string 'error' or 'warning', and leave the implementation to handle it).

Describe alternatives you've considered
At the moment there is no way to provide custom rules since they are specified in the mentioned file above

Additional context
Add JS File loader in the ./src/config.ts main constructor. An example below:

if (fs.lstatSync(user_tektonlintrc).isDirectory()) {
    user_tektonlintrc = path.join(user_tektonlintrc, '.tektonlintrc.yaml');
}

if (fs.lstatSync(user_tektonlintjs).isDirectory()) {
    user_tektonlintjs = path.join(user_tektonlintjs, '.tektonlintrc.js');
}

let customRcConfig = {
    ...defaultConfig
};

if (fs.existsSync(user_tektonlintrc)) {
    const customRcFile = fs.readFileSync(user_tektonlintrc, 'utf8');
    customRcConfig = yaml.parse(customRcFile);

    logger.info('Using .tektonlintrc.yaml at %s', user_tektonlintrc);
    logger.info('customConfig %o', customRcConfig);
} else if (fs.existsSync(user_tektonlintjs)) {
    customRcConfig = require(user_tektonlintjs);

    logger.info('Using .tektonlintrc.js at %s', user_tektonlintrc);
    logger.info('customConfig %o', customRcConfig);
} else {
    logger.warn('Unable to find configuration - using defaults');
}

this._rulesConfig = { ...customRcConfig };
this._rulesConfig.rules = { ...customRcConfig.rules };
this._rulesConfig.customRules = { ...customRcConfig.customRules };
this._globs = [...cliConfig['_'], ...(customRcConfig.globs ? customRcConfig.globs : ['_'])];

ClusterTasks are being ignored

As you can see below we have a ClusterTask being used at our pipelines and tekton-lint shows it's reference as missing, but it is defined

/workdir # tekton-lint tasks/* pipelines/pipeline.yml  --quiet
pipelines/pipeline-confluence-docs-default.yml:
error   (38,15,38,28): Pipeline 'docs-default' references task 'webhook-debug' but the referenced task cannot be found. To fix this, include all the task definitions to the lint task for this pipeline.


/workdir # head -n5 tasks/cluster-task-webhook-debug.yml 
---
apiVersion: tekton.dev/v1beta1
kind: ClusterTask
metadata:
  name: webhook-debug

/workdir # grep 'webhook-debug' -C1 pipelines/pipeline-docs.yml 
      taskRef:
        name: webhook-debug
        kind: ClusterTask

Report missing parameter in TaskSpec (inline tasks)

In 0.5.2 we should report missing parameters in taskSpec tasks

Example:

    - name: inline-task
      params:
        - name: pipeline-debug
          value: $(params.pipeline-debug)
      workspaces:
        - name: secrets
          workspace: artifacts
      taskSpec:
        workspaces:
          - name: secrets
            mountPath: /secrets
        params:
          - name: pipeline-debug
        stepTemplate:
          env:
            - name: PIPELINE_RUN_ID
              valueFrom:
                fieldRef:
                  fieldPath: metadata.annotations['devops.cloud.ibm.com/tekton-pipeline']
        steps:
          - name: setup
            image: node:alpine
            script: |
              #!/bin/bash

              set -e -o pipefail

              if [ $PIPELINE_DEBUG == 1 ]; then
                pwd
                env
                trap env EXIT
                set -x
              fi

              export TOKEN=$(cat "/secrets/$(params.token)")

The line
export TOKEN=$(cat "/secrets/$(params.token)") use a parameter token which was not added nor provided for the task, the linter is missing this.

Add a license file to the repository

The tekton-lint npm package seems to have an "Apache-2.0" license in NPM, since it is specified in the package.json.
However, it would make it even more clearer to have a LICENSE file in the repository, so the GitHub interface could show the license and could also be returned by the GitHub API.

It is trivial to add a license on GitHub. The easiest way is through the web interface: Go to "Add file" then "Create new file", enter LICENSE as the file name, then a new button appears with "Choose a license template". Select the Apache 2.0, and finish up and commit. I added my own screenshots below, but some help is also available in the GitHub docs here:
https://docs.github.com/en/communities/setting-up-your-project-for-healthy-contributions/adding-a-license-to-a-repository

I could make a pull request too, but I think it's more appropriate to have it committed by the owners or maintainers.

Thanks!


  1. image
  2. image
  3. image
  4. image

Warning on a parameter not used in the spec but used in the finally

We have a bunch of pipelines with the finally section.
The problem is that we see warning like the following:
warning (15,7,17,1): Pipeline 'pipeline-xx-yy-zzz' defines parameter 'example', but it's not used anywhere in the spec
and in the pipeline we have:

  finally:
    - name: yyyyyyy
      taskRef:
        name: task-yyyyyy
      params:
        - name: example
          value: $(params.example)
      workspaces:
        - name: task-pvc
          workspace: pipeline-pvc

Is any way to fix this?

Workspaces defined on Tasks in a Pipeline assume workspace field

Given this example... it will fail as the workspace defined in the task just uses the name field - code is assuming that the workspace field is present instead

apiVersion: tekton.dev/v1
kind: Pipeline
metadata:
  name:  run-checks
spec:
  params:
  workspaces:
    - name: workspace-checks
  tasks:
    - name: run-checks
      taskRef:
        name: task-run-checks
      workspaces:
        - name: workspace-checks

Documentation here indicates that workspace is optional
https://tekton.dev/docs/pipelines/pipeline-api/#tekton.dev/v1.WorkspacePipelineTaskBinding

Adjusting the code so that if workspace is specified it must match up with the one defined in the pipeline, if it's not present the name must match up instead.

Feat: Support for Object Parameters in Tekton Pipelines

Is your feature request related to a problem? Please describe.

Currently, the tekton-lint tool does not properly handle parameters of type object in Tekton pipeline definitions. This causes issues when parameters of this type are used in tasks, resulting in incorrect warnings and errors.

For example, given a parameter defined as:

- name: gitRepository
  description: Git Repository.
  type: object
  properties:
    defaultBranch:
      type: string
    name:
      type: string
    owner:
      type: string

And its usage in a task:

- name: repositoryName
  value: $(params.gitRepository.name)

The tool incorrectly reports:

Undefined param 'gitRepository.name' at .spec.tasks[2].params[8].value in 'git-clone'

Describe the solution you'd like
The tool should correctly recognize and handle parameters of type object and their properties, without reporting them as undefined.

Describe alternatives you've considered

Additional context
https://tekton.dev/docs/pipelines/tasks/#object-type

Cannot read property 'spec' of undefined

First off, congratulations on your open source release! That's momentous!

Now, on to the error. Linting my pipeline results in the following:

TypeError: Cannot read property 'spec' of undefined
    at /mnt/c/Users/JAMESTANNER/Development/microservices-build-agent/node_modules/tekton-lint/rules/no-undefined-result.js:14:83

I think that this happens because I've got an external task which is loaded separately from the catalog. So it's not included in the files being linted. So there's a taskref in the pipeline, but no task to match against.

I'd expect the behavior here to be a warning, or perhaps a displayed error, about the missing task. But I'd expect the linter to complete rather than throwing an internal error.

If you have access to the IBM internal github, the pipeline in question is here: https://github.ibm.com/TAAS/microservices-builds/blob/main/tekton-pipeline/pipeline-push.yaml
From some extra logging I injected into the code, it looks like it fails on the fetch-from-git task.

tekton-lint complaining about TriggerBinding and EventListener with same name

tekton-lint (5.0) is complaining on the following file: https://github.com/open-toolchain/tekton-catalog/blob/master/git/sample-skip-ci/listener-skip-ci.yaml

git/sample-skip-ci/listener-skip-ci.yaml:
error   (54,9,54,22): 'github-commit' is already defined (as a 'TriggerBinding')
error   (69,9,69,22): 'github-commit' is already defined (as a 'EventListener')
...

AFAIK nothing prevent to use same name for different K8S resources/Tekton resources as long as they are of different types

Report invalid object names

Names (ie. metadata.name) must be DNS subdomain names.

apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
name: -no-invalid-name # not ok
spec:
steps: []

apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
name: no-invalid-name- # not ok
spec:
steps: []

apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
name: .no-invalid-name # not ok
spec:
steps: []

apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
name: no-invalid-name. # not ok
spec:
steps: []

- apiVersion: tekton.dev/v1beta1
kind: PipelineRun
metadata:
name: -run-$(uid) # not ok
spec:
pipelineRef:
name: no-invalid-name

These should be reported by no-invalid-name

Github action support/integration

Is your feature request related to a problem? Please describe.

make a github action for this tool.

Describe the solution you'd like

make a github action support for this tool so that we can easily integrate this tool with open source project.

Describe alternatives you've considered

Additional context

Add rule "no-deprecated"

Tekton CD TEP 003 suggests a deprecation label be used on Resources that are to be marked as deprecated in a catalog.

Linter should watch for the label tekton.dev/deprecated: true and show a warning (or error if the user override the rule severity with their custom config).

Example for non-deprecated resource

---
apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
  name: some-task
  labels:
    app.kubernetes.io/version: "1.0.3"
spec:

Example for a deprecated resource

---
apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
  name: some-task
  labels:
    app.kubernetes.io/version: "1.0.3"
    tekton.dev/deprecated: true
spec:

Prefer `script` over `command` and `args`

tekton-lint should have a rule which checks how a Task is used. Either with:

  • script
  • command & args

Developers should follow a convention and use only one of these consistently. We should add a rule which checks this and warns the developers if they are mixed.

Add pre-commit hook configuration for other projects to use

I recently started using pre-commit to manage the installation and running of linters in one of my projects. Basically (read their docs for more info) developers on projects can save references to linters/checkers/etc in a .pre-commit-config.yaml file in their repository, and new developers can get them installed more quickly and consistently - plus they can be configured to run on every git commit.

Some of the linters "supported" by pre-commit are in mirrors of the main projects (for example: prettier), but other projects have added the required hook definitions to their repositories directly (for example: go-jsonnet). I think it would be great if we supported using tekton-lint through pre-commit.

To "support" using pre-commit with this project, we would just need to add a .pre-commit-hooks.yaml file, with some specific information. I've made a simple fork to test this out, and it looks good - although more tests might be needed: https://github.com/JustinKuli/tekton-lint/blob/main/.pre-commit-hooks.yaml. I'd be happy to open a PR based on that if there is interest.

To be clear, I'm not proposing that this project should start using/enforcing use of pre-commit in its own development workflow. This issue is focused on making tekton-lint easier for other projects to use via pre-commit.

Missing Task should fail linter

Hey All!

Im trying to add the Tekton-lint to the GitHub Super-Linter and have 1 ask for improvement.

Currently, if you run the following code:

apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
  name: example-task-name
spec:
  params:
    - name: pathToDockerFile
      type: string
      description: The path to the dockerfile to build
      default: /workspace/workspace/Dockerfile
  resources:
    inputs:
      - name: workspace
        type: git
    outputs:
      - name: builtImage
        type: image
  steps:
    - name: ubuntu-example
      image: ubuntu
      args: ["ubuntu-build-example", "SECRETS-example.md"]
    - image: gcr.io/example-builders/build-example
      command: ["echo"]
      args: ["$(params.pathToDockerFile)"]
    - name: dockerfile-pushexample
      image: gcr.io/example-builders/push-example
      args: ["push", "$(resources.outputs.builtImage.url)"]
      volumeMounts:
        - name: example-volume
          mountPath: /var/run/docker.sock
  volumes:
    - name: example-volume
      emptyDir: {}

It will complete successfully with error code 0

But if i remove the line:

kind: Task

It will run and show no output, and exit with exit code 0... Can this be set to exit with error code if it fails to read the data?

thanks!

Getting 'is already defined' errors when defined in different folders

Hi there,

Just tried out your new lint tool (congrats!) and I got many errors like the following:
error (4,9,4,20): 'ci-template' is already defined (as a 'TriggerTemplate')

The reason is that I've multiple folders containing tekton definitions and sometimes they have the same name used in another folder. This is fine for my use as my toolchains only pulls in one of these folders. Can we have a switch that only checks for dupe names within the same folder... maybe there already is?

Restructure regression tests

Each rule should have its own test file:

  • no-deprecated-resource #55
  • no-duplicate-env #32
  • no-duplicate-param #35
  • no-duplicate-resource
  • no-extra-param #41
  • no-invalid-name #56
  • no-invalid-param-type
  • no-latest-image
  • no-missing-param
  • no-missing-resource
  • no-missing-workspace
  • no-pipeline-missing-task
  • no-pipeline-task-cycle
  • no-resourceversion
  • no-undefined-param
  • no-undefined-result
  • no-undefined-volume
  • no-unused-param
  • prefer-beta
  • prefer-kebab-case
  • prefer-when-expression #52

Bindings need to be an array not object

Describe the bug

I received a 500 from the backend with this syntax:

spec:
  triggers:
    - bindings:
        name: github-pr-binding
      template:
        name: pr-template
with pipelineId: c2cd6a8d-ea5a-47b0-913e-cd172d63833f, transactionId: d0a52994-03da-4841-9a45-8e6d375fbb19, error: (trigger.bindings || (trigger.binding && [trigger.binding]) || []).forEach is not a function at TypeError: (trigger.bindings || (trigger.binding && [trigger.binding]) || []).forEach is not a function
    at Object.getTemplatedResources (/home/node/lib/pipelineutil.js:708:76)

To Reproduce

spec:
  triggers:
    - bindings:
        name: github-pr-binding
      template:
        name: pr-template

Expected behavior

I expected a linting error.
I expected a proper error handling in the backend.

The fix

spec:
  triggers:
    - bindings:
        - name: github-pr-binding
      template:
        name: pr-template

Thank you :)

Support definition groups

It's a common pattern to bundle a Pipeline + TriggerBinding + TriggerTemplate + EventListener into a subfolder, where these resources have the same name, but they live in different namespaces.

.
├── foo/
│   ├── listener.yaml
│   ├── trigger.yaml
│   ├── binding.yaml
│   └── pipeline.yaml
├── bar/
│   ├── listener.yaml
│   ├── trigger.yaml
│   ├── binding.yaml
│   └── pipeline.yaml
└── tasks/
    ├── task-1.yaml
    └── task-2.yaml

The linter should be able to handle these definitions.

original issue: #4

Task workspaces marked as optional are treated as required.

For example a task with workspaces defined as

    - name: secrets
      description: |
        What directory contains the secrets required for this task?
      optional: true
      readOnly: true
      mountPath: /run/pipeline/secrets

when used would report an error if the optional workspace wasn't specified.

Updated to only report mandatory workspaces

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.