From 2c40defadadd549b72e03c4289476d6a438e0ba0 Mon Sep 17 00:00:00 2001 From: Tarun Date: Wed, 22 Jan 2025 12:22:49 +0530 Subject: [PATCH 1/3] Added ct-lint --- .pre-commit-config.yaml | 10 +++++++++ README.md | 45 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 .pre-commit-config.yaml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 00000000..7008e4b1 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,10 @@ +repos: + - repo: local + hooks: + - id: ct-lint + name: Chart Testing Lint + entry: ct lint --all --check-version-increment=false --use-helmignore + language: system + pass_filenames: false + files: ^charts/ + always_run: true diff --git a/README.md b/README.md index 370e766d..fd5aaf5c 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,8 @@ [This Repository](https://github.com/open-metadata/openmetadata-helm-charts) houses Kubernetes [Helm](https://helm.sh) charts for deploying [Open Metadata](https://github.com/open-metadata/OpenMetadata) and it's dependencies (Elastic Search and MySQL) on a Kubernetes Cluster. +--- + ## Setup @@ -29,6 +31,8 @@ Install the below tools: - [Kubectl](https://kubernetes.io/docs/tasks/tools/) to manage Kubernetes Resources - [Helm](https://helm.sh) to deploy resources based on Helm Charts from this repository. Note, we only support Helm 3 +--- + ## Quickstart Assuming kubectl context points to the correct kubernetes cluster, first create kubernetes secrets that contain MySQL and Airflow passwords as secrets. @@ -103,6 +107,47 @@ To expose the Openmetadata UI locally, run the below command - kubectl port-forward deployment/openmetadata 8585:8585 ``` +--- + +## Setting Up Chart Testing Lint with Pre-commit Hook +#### Why Chart Testing Lint? +When working with Helm charts, it's important to ensure that they meet best practices, are free from errors, and follow the defined guidelines. **Chart Testing (ct) Lint** is a tool designed to automate this process by linting your Helm charts before committing them to the repository. It helps to: +- Catch errors early. +- Enforce best practices in chart development. +- Automatically validate changes to Helm charts during pull requests or commits. + + +This guide will show you how to integrate `chart-testing` linting into your pre-commit hooks to automatically lint charts before committing them. It also allows you to manually trigger linting when needed. + +#### Prerequisites +Before setting up the pre-commit hook, make sure you have the following dependencies installed: + +##### 1. Install `chart-testing` +`chart-testing` is a command-line tool used to lint and validate Helm charts. It can be installed using **Homebrew** on macOS. + +To install `chart-testing`, run the following command: + +```bash +brew install chart-testing +``` +##### 2. Install `pre-commit` +To install the pre-commit tool, run: +```bash +pip install pre-commit +``` +#### Setting Up Pre-commit Hook for Chart Testing Lint +##### 1. Install the Pre-commit Hook +Once the dependencies are installed, navigate to your repository and run the following command to install the pre-commit hook: +```bash +pre-commit install +``` +This will set up the pre-commit hook in the .git/hooks directory of your repository. +##### 2. Manually Trigger the Linting Process +If you need to manually trigger the linting of charts at any time, navigate to the root of your repository and run: +```bash +ct lint --all --check-version-increment=false --use-helmignore +``` +--- ## Documentation and Support Check out [OpenMetadata documentation](https://docs.open-metadata.org/) for a complete description of OpenMetadata's features. From 65b6d36d9d05e6b56e0b102a04d8396ef94b3721 Mon Sep 17 00:00:00 2001 From: Tarun Date: Thu, 30 Jan 2025 15:05:26 +0530 Subject: [PATCH 2/3] Updated the version of setup-python to solve the workflow issue --- .github/workflows/lint-test.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/lint-test.yaml b/.github/workflows/lint-test.yaml index d26e73a6..813be1ac 100644 --- a/.github/workflows/lint-test.yaml +++ b/.github/workflows/lint-test.yaml @@ -41,7 +41,7 @@ jobs: - uses: actions/setup-python@v2 with: - python-version: 3.7 + python-version: 3.8 - name: Install chart-testing uses: helm/chart-testing-action@v2.0.1 From b07c4e59fe318bf1c11446a02dd8eae4001afcc0 Mon Sep 17 00:00:00 2001 From: Tarun Date: Thu, 30 Jan 2025 15:07:07 +0530 Subject: [PATCH 3/3] Updated the version of setup-python to solve the workflow issue --- .github/workflows/lint-test.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/lint-test.yaml b/.github/workflows/lint-test.yaml index 813be1ac..d106e595 100644 --- a/.github/workflows/lint-test.yaml +++ b/.github/workflows/lint-test.yaml @@ -41,7 +41,7 @@ jobs: - uses: actions/setup-python@v2 with: - python-version: 3.8 + python-version: 3.9 - name: Install chart-testing uses: helm/chart-testing-action@v2.0.1