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

How to test charts in a local directory? #138

Closed
KIVagant opened this issue Mar 29, 2019 · 9 comments · Fixed by #389
Closed

How to test charts in a local directory? #138

KIVagant opened this issue Mar 29, 2019 · 9 comments · Fixed by #389

Comments

@KIVagant
Copy link

KIVagant commented Mar 29, 2019

Is this a request for help?:

Yes

Is this a BUG REPORT or FEATURE REQUEST? (choose one):
No

Version of Helm and Kubernetes:

Client: &version.Version{SemVer:"v2.12.3", GitCommit:"eecf22f77df5f65c823aacd2dbd30ae6c65f186e", GitTreeState:"clean"}
Server: &version.Version{SemVer:"v2.12.3", GitCommit:"eecf22f77df5f65c823aacd2dbd30ae6c65f186e", GitTreeState:"clean"}
Client Version: version.Info{Major:"1", Minor:"13", GitVersion:"v1.13.3", GitCommit:"721bfa751924da8d1680787490c54b9179b1fed0", GitTreeState:"clean", BuildDate:"2019-02-04T04:48:55Z", GoVersion:"go1.11.5", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"11+", GitVersion:"v1.11.8-eks-7c34c0", GitCommit:"7c34c0d2f2d0f11f397d55a46945193a0e22d8f3", GitTreeState:"clean", BuildDate:"2019-03-01T22:49:39Z", GoVersion:"go1.10.8", Compiler:"gc", Platform:"linux/amd64"}
Version:	 unreleased
Git commit:	 unknown
Date:		 unknown
License:	 Apache 2.0

What happened:

$ ct lint-and-install   --chart-dirs .
Linting and installing charts...
Error loading configuration: 'chart_schema.yaml' neither specified nor found in default locations

What you expected to happen:

It should lint charts in the local directory. I have no idea how the chart_schema.yaml should look like.

How to reproduce it (as minimally and precisely as possible):

  1. Create a dir.
  2. Create a chart inside the dir.
  3. Run ct lint --chart-dirs .

Thank you!

Update Same for lintconf.yaml. I believe the program should not require any specific configs to run it locally but just use some predefined settings.

@jlegrone
Copy link
Member

@KIVagant I agree that we should define defaults for both of these that are shipped with the binary.

In the mean time, you could either use the docker image (which also comes with yamllint and yamale installed) or use ct with the example config files found here:

https://github.com/helm/chart-testing/tree/b060fc83f292a1ef7ea6f9db5a5834eb8a83b152/etc

@ChristianWeissCG
Copy link

As a newbe to "chart-testing" i think you could use this one-liner:
docker run -it --rm --name ct --volume $(pwd):/data quay.io/helmpack/chart-testing:v2.3.0 sh -c "ct lint --all --debug --chart-dirs /data/"

(after you did docker pull quay.io/helmpack/chart-testing:v2.3.0)

My expectation is that "charts-testing" searches for charts within that folder and in all sub-folders and i expect that it lists all found charts in the results:

Linting charts...
Version increment checking disabled.
------------------------------------------------------------------------------------------------------------------------
 Configuration
------------------------------------------------------------------------------------------------------------------------
Remote: origin
TargetBranch: master
BuildId: 
LintConf: /etc/ct/lintconf.yaml
ChartYamlSchema: /etc/ct/chart_schema.yaml
ValidateMaintainers: true
ValidateChartSchema: true
ValidateYaml: true
CheckVersionIncrement: false
ProcessAllCharts: true
Charts: []
ChartRepos: []
ChartDirs: [/data/]
ExcludedCharts: []
HelmExtraArgs: 
HelmRepoExtraArgs: []
Debug: true
Upgrade: false
SkipMissingValues: false
Namespace: 
ReleaseLabel: 
------------------------------------------------------------------------------------------------------------------------
All charts linted successfully
------------------------------------------------------------------------------------------------------------------------
No chart changes detected.
------------------------------------------------------------------------------------------------------------------------

So i guess i miss something.

What command worked for you?

@v-avdeev
Copy link

Actual question for me too. I want to check local charts In CI.
I tried to use ct binary like:

ct lint --charts charts/* --chart-dirs charts/ --chart-yaml-schema helm_default_chart_schema.yml --lint-conf helm_lint_config.yaml --debug

In result I need to have running local helm repo for it.

So, my general idea to check resources/requests for each places where possible (deployment templates, replicationcontroller templates, daemonset templates, etc..) in CI. Maybe someone know how to do it quickly?

@varac
Copy link

varac commented Sep 27, 2019

Please add the option to lint a local chart. I want to lint changes to my chart before I commit push to any remote/local chart repo.

@varac
Copy link

varac commented Sep 27, 2019

Maybe I'd like to make mysewlf clearer: Afaik, chart-testing needs a remote chart repository which it can compare changes to right ? (Please provide a documentation which explains the basic principles)
I'd like to test a local chart without any remotes, a chart which has never been push to any repository.
Is this possible ?

@ctron
Copy link

ctron commented Dec 19, 2019

I would also be interested in this.

@HaveFun83
Copy link

+1

@caleb15
Copy link

caleb15 commented Dec 4, 2020

I got it working locally by using docker and playing around with @ChristianWeissCG 's command:

First grab the image: docker pull quay.io/helmpack/chart-testing:v3.3.1

Then Inside the root of my repo I ran this command:

docker run -it --rm --name ct --volume $(pwd):/data quay.io/helmpack/chart-testing sh -c "cd /data; ct lint --config .circleci/chart-testing.yaml"

The repo looks somewhat like this:

.
├── .circleci
│   ├── chart-testing.yaml
│   ├── config.yml
├── my-chart
│   ├── Chart.yaml
│   ├── templates (folder, files not shown)
│   └── values.yaml

chart-testing.yaml:

chart-dirs:
  - my-chart
charts:
  - my-chart

The section of my circleci config I use for CI testing:

  lint-charts:
    docker:
      - image: quay.io/helmpack/chart-testing:v3.3.1
    steps:
      - checkout
      - run:
          name: lint
          command: |
            ct lint --config .circleci/chart-testing.yaml

@nvtkaszpir
Copy link
Contributor

nvtkaszpir commented Feb 1, 2022

if you have a chart in current directory and ct installed on the host then you can run:

ct install --chart-dirs . --charts .

With docker it works with:

docker run -it --workdir=/data --volume ~/.kube/config:/root/.kube/config:ro --volume $(pwd):/data quay.io/helmpack/chart-testing:v3.5.0 ct install --chart-dirs . --charts .

notice that workdir param is important and must be the same as volume mounted

k8s-ci-robot pushed a commit to kubernetes-sigs/security-profiles-operator that referenced this issue Jul 27, 2022
Also added yaml lint config and chart_schema files from:
https://github.com/helm/chart-testing/tree/b060fc83f292a1ef7ea6f9db5a5834eb8a83b152/etc

These files are required by chart-test's "lint" command.
There does not appear to be any documentation about this.

Refer to the following GitHub issue for more information:
helm/chart-testing#138
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants