-
Notifications
You must be signed in to change notification settings - Fork 94
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
Fix typo, improve destination validations #832
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
efe3cd6
Fix typo, improve destination validations
petewall b29759d
Improve linting and testing
petewall 4f2a209
Also prevent multiple platform tests from running at the same time.
petewall 1adf6dd
Need to set something that evaluates to something, even if the matrix…
petewall File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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 |
---|---|---|
|
@@ -7,6 +7,7 @@ | |
## Values | ||
|
||
```yaml | ||
--- | ||
cluster: | ||
name: remote-config-example-cluster | ||
|
||
|
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
--- | ||
cluster: | ||
name: remote-config-example-cluster | ||
|
||
|
8 changes: 8 additions & 0 deletions
8
charts/k8s-monitoring/schema-mods/definitions/invalid-destination.schema.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,8 @@ | ||
{ | ||
"type": "object", | ||
"properties": { | ||
"type": { | ||
"type": "string" | ||
} | ||
} | ||
} |
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
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Doing the destination validation before feature validation to catch these issues earlier.
The error message will say that Cluster Metrics requires a metrics destination, not that "prom" is not a valid destination type. |
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
77 changes: 77 additions & 0 deletions
77
charts/k8s-monitoring/tests/destination_validations_test.yaml
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,77 @@ | ||
# yamllint disable rule:document-start rule:line-length rule:trailing-spaces | ||
suite: Test destination validations | ||
templates: | ||
- validations.yaml | ||
tests: | ||
- it: asks you to set the name of a destination | ||
set: | ||
cluster: {name: test-cluster} | ||
clusterMetrics: {enabled: true} | ||
destinations: | ||
- type: prometheus | ||
asserts: | ||
- failedTemplate: | ||
errorMessage: |- | ||
execution error at (k8s-monitoring/templates/validations.yaml:4:4): | ||
Destination #0 does not have a name. | ||
Please set: | ||
destinations: | ||
- name: my-destination-name | ||
|
||
- it: asks you to set a valid name for the destination | ||
set: | ||
cluster: {name: test-cluster} | ||
clusterMetrics: {enabled: true} | ||
destinations: | ||
- name: prøm3thüs! | ||
type: prometheus | ||
asserts: | ||
- failedTemplate: | ||
errorMessage: |- | ||
execution error at (k8s-monitoring/templates/validations.yaml:4:4): | ||
Destination #0 (prøm3thüs!) has invalid characters in its name. | ||
Please only use alphanumeric, underscores, dashes, or spaces | ||
|
||
- it: requires a destination type | ||
set: | ||
cluster: {name: test-cluster} | ||
clusterMetrics: {enabled: true} | ||
destinations: | ||
- name: a destination with no type | ||
asserts: | ||
- failedTemplate: | ||
errorMessage: |- | ||
execution error at (k8s-monitoring/templates/validations.yaml:4:4): | ||
Destination #0 (a destination with no type) does not have a type. | ||
Please set: | ||
destinations: | ||
- name: a destination with no type | ||
type: loki, otlp, prometheus, or pyroscope | ||
|
||
- it: validates the destination type | ||
set: | ||
cluster: {name: test-cluster} | ||
clusterMetrics: {enabled: true} | ||
destinations: | ||
- name: a destination with an invalid type | ||
type: invalidType | ||
asserts: | ||
- failedTemplate: | ||
errorMessage: |- | ||
execution error at (k8s-monitoring/templates/validations.yaml:4:4): | ||
Destination #0 (a destination with an invalid type) is using an unknown type (invalidType). | ||
Please set: | ||
destinations: | ||
- name: a destination with an invalid type | ||
type: "[loki, otlp, prometheus, or pyroscope]" | ||
|
||
- it: allows destination names with alphanumeric, underscores, dashes, and spaces | ||
set: | ||
cluster: {name: test-cluster} | ||
clusterMetrics: {enabled: true} | ||
alloy-metrics: {enabled: true} | ||
destinations: | ||
- name: This is my _Prometheus_ destination-1 | ||
type: prometheus | ||
asserts: | ||
- notFailedTemplate: {} |
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This allows for invalid types to pass schema validation... only to be caught by the template validation. It greatly improves the quality of the error message if you're missing a type or use an invalid type.