-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: MBWhite <[email protected]>
- Loading branch information
Showing
10 changed files
with
247 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
rules: # error | warning | off | ||
prefer-kebab-case: off | ||
prefer-camel-kebab-case: warning | ||
|
||
# custom: | ||
# my_rules: custom_rules | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
apiVersion: tekton.dev/v1beta1 | ||
kind: Pipeline | ||
metadata: | ||
name: ace-pipeline | ||
spec: | ||
params: | ||
- name: outputRegistry | ||
type: string | ||
- name: url | ||
type: string | ||
default: "https://github.com/ot4i/ace-demo-pipeline" | ||
- name: revision | ||
type: string | ||
default: "main" | ||
- name: buildImage | ||
type: string | ||
- name: runtimeBaseImage | ||
type: string | ||
- name: knativeDeploy | ||
type: string | ||
default: "false" | ||
tasks: | ||
- name: build-from-source | ||
taskRef: | ||
name: aceBuild | ||
params: | ||
- name: outputRegistry | ||
value: $(params.outputRegistry) | ||
- name: url | ||
value: $(params.url) | ||
- name: revision | ||
value: $(params.revision) | ||
- name: buildImage | ||
value: $(params.buildImage) | ||
- name: runtimeBaseImage | ||
value: $(params.runtimeBaseImage) | ||
- name: deploy-to-cluster | ||
taskRef: | ||
name: deploy-to-cluster | ||
params: | ||
- name: dockerRegistry | ||
value: $(params.outputRegistry) | ||
- name: url | ||
value: $(params.url) | ||
- name: revision | ||
value: $(params.revision) | ||
- name: tag | ||
value: "$(tasks.build-from-source.results.tag)" | ||
runAfter: | ||
- build-from-source | ||
when: | ||
- input: "$(params.knativeDeploy)" | ||
operator: in | ||
values: ["false"] | ||
- name: deploy-knative-to-cluster | ||
taskRef: | ||
name: knative-deploy | ||
params: | ||
- name: dockerRegistry | ||
value: $(params.outputRegistry) | ||
- name: url | ||
value: $(params.url) | ||
- name: revision | ||
value: $(params.revision) | ||
- name: tag | ||
value: "$(tasks.build-from-source.results.tag)" | ||
runAfter: | ||
- build-from-source | ||
when: | ||
- input: "$(params.knativeDeploy)" | ||
operator: in | ||
values: ["true"] |
53 changes: 53 additions & 0 deletions
53
regression-tests/customconfig/ace-pipeline.yaml.expect.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
[ | ||
{ | ||
"message": "Pipeline 'ace-pipeline' references task 'aceBuild' but the referenced task cannot be found. To fix this, include all the task definitions to the lint task for this pipeline.", | ||
"rule": "no-missing-resource", | ||
"level": "error", | ||
"path": "./regression-tests/customconfig/ace-pipeline.yaml", | ||
"loc": { | ||
"range": [ | ||
521, | ||
529, | ||
530 | ||
], | ||
"startLine": 25, | ||
"startColumn": 15, | ||
"endLine": 25, | ||
"endColumn": 23 | ||
} | ||
}, | ||
{ | ||
"message": "Pipeline 'ace-pipeline' references task 'deploy-to-cluster' but the referenced task cannot be found. To fix this, include all the task definitions to the lint task for this pipeline.", | ||
"rule": "no-missing-resource", | ||
"level": "error", | ||
"path": "./regression-tests/customconfig/ace-pipeline.yaml", | ||
"loc": { | ||
"range": [ | ||
930, | ||
947, | ||
948 | ||
], | ||
"startLine": 39, | ||
"startColumn": 15, | ||
"endLine": 39, | ||
"endColumn": 32 | ||
} | ||
}, | ||
{ | ||
"message": "Pipeline 'ace-pipeline' references task 'knative-deploy' but the referenced task cannot be found. To fix this, include all the task definitions to the lint task for this pipeline.", | ||
"rule": "no-missing-resource", | ||
"level": "error", | ||
"path": "./regression-tests/customconfig/ace-pipeline.yaml", | ||
"loc": { | ||
"range": [ | ||
1442, | ||
1456, | ||
1457 | ||
], | ||
"startLine": 57, | ||
"startColumn": 15, | ||
"endLine": 57, | ||
"endColumn": 29 | ||
} | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import { walk, pathToString } from '../walk.js'; | ||
|
||
const isValidKebabName = (name) => { | ||
const valid = new RegExp('^[a-z0-9-()$.]*$'); | ||
return valid.test(name); | ||
}; | ||
|
||
const isValidCamelName = (name) => { | ||
const valid = new RegExp('^[a-z_][a-z0-9A-Z()$.]*$'); | ||
return valid.test(name); | ||
}; | ||
|
||
const isValidName = (name) => { | ||
return isValidKebabName(name) || isValidCamelName(name); | ||
}; | ||
|
||
const naming = (resource, prefix, report) => (node, path, parent) => { | ||
let name = node; | ||
const isNameDefinition = /.name$/.test(path); | ||
|
||
if (path.includes('env') && path.includes('name')) return; | ||
|
||
if (isNameDefinition && !isValidName(name)) { | ||
report( | ||
`Invalid name for '${name}' at ${pathToString( | ||
path, | ||
)} in '${resource}'. Names should be in lowercase, alphanumeric, kebab-case or camelCase format.`, | ||
parent, | ||
'name', | ||
); | ||
return; | ||
} | ||
|
||
const parameterPlacementRx = new RegExp(`\\$\\(${prefix}.(.*?)\\)`); | ||
const m = node && node.toString().match(parameterPlacementRx); | ||
|
||
if (m) { | ||
name = m[1]; | ||
if (!isValidName(name)) { | ||
report( | ||
`Invalid name for '${name}' at ${pathToString( | ||
path, | ||
)} in '${resource}'. Names should be in lowercase, alphanumeric, kebab-case or camelCase format.`, | ||
parent, | ||
path[path.length - 1], | ||
); | ||
} | ||
} | ||
}; | ||
|
||
export default (docs, tekton, report) => { | ||
for (const pipeline of Object.values<any>(tekton.pipelines)) { | ||
walk(pipeline.spec.tasks, ['spec', 'tasks'], naming(pipeline.metadata.name, 'params', report)); | ||
walk(pipeline.spec.finally, ['spec', 'finally'], naming(pipeline.metadata.name, 'params', report)); | ||
} | ||
|
||
for (const pipeline of Object.values<any>(tekton.pipelineRuns)) { | ||
walk(pipeline.spec.tasks, ['spec', 'pipelineSpec', 'tasks'], naming(pipeline.metadata.name, 'params', report)); | ||
walk( | ||
pipeline.spec.finally, | ||
['spec', 'pipelineSpec', 'finally'], | ||
naming(pipeline.metadata.name, 'params', report), | ||
); | ||
} | ||
}; |