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

[8.x](backport #5535) [Helm] Implement values.schema.json #5581

Merged
merged 1 commit into from
Sep 26, 2024

Conversation

mergify[bot]
Copy link
Contributor

@mergify mergify bot commented Sep 20, 2024

What does this PR do?

This PR does the following:

  • introduces a value.schema.json inside the chart which is used by Helm to validate the input values.yaml
  • splits ESPlainAuth output type into ESPlainAuthBasic and ESPlainAuthAPI types, favouring explicitness, for better validation and
  • introduces hostNetwork as an option in an Agent preset

Why is it important?

By having a value.schema.json we can reduce validation checks inside the templates of the Helm chart (less ifs inside templates). Furthermore, many text editors/IDEs offer the capability to import the schema and hence get hints and proposal write writing a values.yaml for the Helm chart

Checklist

  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have made corresponding change to the default configuration files
  • I have added tests that prove my fix is effective or that my feature works
  • I have added an entry in ./changelog/fragments using the changelog tool
  • I have added an integration test or an E2E test

Disruptive User Impact

N/A

How to test this PR locally

Checking validation

run the following which is actually missing required values

helm template test ./deploy/helm/elastic-agent --set kubernetes.enabled=true  --set outputs.default.type=ESSecretAuthBasic  --set agent.fleet.enabled=true --set agent.fleet.token=""

you should see the following errors

Error: values don't meet the specifications of the schema(s) in the following chart(s):
elastic-agent:
- agent.fleet: Must validate "then" as "if" was valid
- agent.fleet: Must validate at least one schema (anyOf)
- agent.fleet.url: Does not match format 'uri'
- agent.fleet.kibanaHost: Does not match format 'uri'
- agent.fleet.kibanaUser: String length must be greater than or equal to 1
- agent.fleet.kibanaPassword: String length must be greater than or equal to 1
- outputs.default: Must validate "then" as "if" was valid
- outputs.default.secretName: String length must be greater than or equal to 1
- outputs.default: Must validate all the schemas (allOf)

Checking hints

  1. Create a new values.yaml file with your text editor/IDE (tested with vscode)
  2. Add on top this comment
    # yaml-language-server: $schema=elastic-agent/deploy/helm/elastic-agent/values.schema.json
  3. For any fields you add below the above line you should get hints

Related issues

N/A


This is an automatic backport of pull request #5535 done by [Mergify](https://mergify.com).

@mergify mergify bot requested a review from a team as a code owner September 20, 2024 13:09
@mergify mergify bot added the backport label Sep 20, 2024
@mergify mergify bot requested review from blakerouse and andrzej-stencel and removed request for a team September 20, 2024 13:09
@pierrehilbert pierrehilbert added the Team:Elastic-Agent-Control-Plane Label for the Agent Control Plane team label Sep 20, 2024
@elasticmachine
Copy link
Contributor

Pinging @elastic/elastic-agent-control-plane (Team:Elastic-Agent-Control-Plane)

Copy link
Contributor Author

mergify bot commented Sep 23, 2024

This pull request has not been merged yet. Could you please review and merge it @pkoutsovasilis? 🙏

* feat: implement values.schema.json for elastic-agent helm chart

* fix: update rendered examples to latest elastic-agent version

* feat: split ESPlainAuth into ESPlainAuthBasic and ESPlainAuthAPI for better validation

* fix: omit redundant keys for ESSecretAuthBasic and ESSecretAuthAPI

* fix: update output type in TestKubernetesAgentHelm according to new values.schema.json

(cherry picked from commit 5c24129)
@ycombinator ycombinator force-pushed the mergify/bp/8.x/pr-5535 branch from 2ee34d3 to f75392c Compare September 23, 2024 17:23
Copy link

@pierrehilbert pierrehilbert merged commit d2a8d43 into 8.x Sep 26, 2024
14 checks passed
@pierrehilbert pierrehilbert deleted the mergify/bp/8.x/pr-5535 branch September 26, 2024 10:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport Team:Elastic-Agent-Control-Plane Label for the Agent Control Plane team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants