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

Disable yamllint by default #43

Merged
merged 1 commit into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Changed
- Disable yamllint image due to image is not longer maintained

## [0.6.0](https://github.com/cloudogu/gitops-build-lib/releases/tag/0.6.0) - 2024-08-26

### Changed
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -774,10 +774,10 @@ class GitHub extends SCMProvider {
## Validators

The library itself provides three validators `yamllint`, `kubeval` and `helmKubeval` to validate the generated resources.
You can disable the built-in operators and/or add your own.
You can enable the built-in operators and/or add your own.
The operators are processed sequentially in no particular order.

Example: Disable all built-ins and add a custom validator.
Example: Enable `yamllint`, `kubeval` and add a custom validator.

```groovy
node {
Expand All @@ -787,10 +787,10 @@ node {
// ...
validators : [
yamllint: [
enabled : false,
enabled : enable,
],
kubeval: [
enabled : false,
enabled : enable,
],
myVali: [
validator: new MyValidator(this),
Expand Down
16 changes: 9 additions & 7 deletions test/com/cloudogu/gitopsbuildlib/DeployViaGitopsTest.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class DeployViaGitopsTest extends BasePipelineTest {
validators : [
kubeval : [
validator: new Kubeval(deployViaGitops),
enabled : true,
enabled : false,
config : [
// We use the helm image (that also contains kubeval plugin) to speed up builds by allowing to reuse image
image : 'ghcr.io/cloudogu/helm:3.4.1-1',
Expand All @@ -68,7 +68,7 @@ class DeployViaGitopsTest extends BasePipelineTest {
],
yamllint: [
validator: new Yamllint(deployViaGitops),
enabled : true,
enabled : false,
config : [
image : 'cytopia/yamllint:1.25-0.9',
// Default to relaxed profile because it's feasible for mere mortalYAML programmers.
Expand Down Expand Up @@ -221,10 +221,10 @@ spec:


@Test
void 'default validator can be disabled'() {
void 'default validator can be enabled'() {

deployViaGitops.metaClass.validateConfig = { Map actualGitOpsConfig ->
assertThat(actualGitOpsConfig.validators.kubeval.enabled).isEqualTo(false)
assertThat(actualGitOpsConfig.validators.kubeval.enabled).isEqualTo(true)
assertThat(actualGitOpsConfig.validators.kubeval.validator).isNotNull()
assertThat(actualGitOpsConfig.validators.yamllint.enabled).isEqualTo(true)
}
Expand All @@ -233,7 +233,10 @@ spec:
deployViaGitops([
validators: [
kubeval: [
enabled: false
enabled: true
],
yamllint: [
enabled: true
]
]
])
Expand All @@ -244,8 +247,7 @@ spec:

deployViaGitops.metaClass.validateConfig = { Map actualGitOpsConfig ->
assertThat(actualGitOpsConfig.validators.myVali.config.a).isEqualTo('b')
assertThat(actualGitOpsConfig.validators.yamllint.enabled).isEqualTo(true)
assertThat(actualGitOpsConfig.validators.yamllint.enabled).isEqualTo(true)
assertThat(actualGitOpsConfig.validators.myVali.enabled).isEqualTo(true)
}
deployViaGitops.metaClass.deploy = {Map actualGitOpsConfig ->} // Stop after validation

Expand Down
3 changes: 2 additions & 1 deletion vars/deployViaGitops.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ Map createDefaultConfig(String k8sVersion) {
],
yamllint : [
validator: new Yamllint(this),
enabled : true,
//disabled due to image is not longer maintained
enabled : false,
config : [
imageRef : 'yamllint',
// Default to relaxed profile because it's feasible for mere mortalYAML programmers.
Expand Down