Skip to content

Commit

Permalink
fix: optional workspaces in tasks not reported as errors
Browse files Browse the repository at this point in the history
Signed-off-by: mbwhite <whitemat@uk.ibm.com>
  • Loading branch information
mbwhite committed Jan 3, 2024
1 parent 9140cde commit 56780a6
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 34 deletions.
41 changes: 22 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,26 +21,29 @@ 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.

```sh
Options:
$ tekton-lint --watch # Run tekton-lint in watch mode
$ tekton-lint --version # Show version number
$ tekton-lint --help # Show help
$ tekton-lint --color / --no-color # Forcefully enable/disable colored output
$ tekton-lint --format # Format output. Available formatters: vscode (default) | stylish | json
$ tekton-lint --quiet # Report errors only - default: false
$ tekton-lint --max-warnings <Int> # Number of warnings to trigger nonzero exit code - default: -1

# exact file path
$ tekton-lint my-pipeline.yaml my-task.yaml

# globstar matching (note the quotes around the glob expression)
$ tekton-lint '**/*.yaml'
tekton-lint [<options>] <glob-pattern-to-yaml-files> ...

# multiple glob patterns
$ tekton-lint path/to/my/pipeline.yaml 'path/to/my/tasks/*.yaml'

# Watch mode
$ tekton-lint --watch '**/*.yaml'
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
```

### IDE Integration
Expand Down
16 changes: 3 additions & 13 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@
"source-map-support": "^0.5.21",
"strip-ansi": "^6.0.1",
"text-table": "^0.2.0",
"yaml": "^2.3.4"
"yaml": "^2.3.4",
"yargs": "^17.7.2"
},
"devDependencies": {
"@commitlint/cli": "^18.4.3",
Expand Down
2 changes: 2 additions & 0 deletions src/lint.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#! /usr/bin/env node

import yargs from 'yargs/yargs';
import * as fs from 'node:fs';
import * as path from 'node:path';
Expand Down
2 changes: 1 addition & 1 deletion src/rules/no-missing-workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ export default (docs, tekton, report) => {
for (const task of Object.values<any>(tekton.tasks)) {
if (!task.spec.workspaces) continue;
const taskName = task.metadata.name;
const requiredWorkspaces = task.spec.workspaces.map((ws) => ws.name);
const requiredWorkspaces = task.spec.workspaces.filter((ws) => !ws.optional).map((ws) => ws.name);

for (const pipeline of Object.values<any>(tekton.pipelines)) {
const matchingTaskRefs = pipeline.spec.tasks.filter(
Expand Down

0 comments on commit 56780a6

Please sign in to comment.