refactor(cmd): move all `helm dep list` methods and tests to the right packages

conflicts resolved

Signed-off-by: Yonatan Kahana <yonatankahana.il@gmail.com>
pull/8077/head
Yonatan Kahana 5 years ago
commit 525b39b990

@ -9,7 +9,7 @@ jobs:
environment: environment:
GOCACHE: "/tmp/go/cache" GOCACHE: "/tmp/go/cache"
GOLANGCI_LINT_VERSION: "1.21.0" GOLANGCI_LINT_VERSION: "1.27.0"
steps: steps:
- checkout - checkout

@ -1,21 +1,22 @@
# Contributing Guidelines # Contributing Guidelines
The Helm project accepts contributions via GitHub pull requests. This document outlines the process to help get your contribution accepted. The Helm project accepts contributions via GitHub pull requests. This document outlines the process
to help get your contribution accepted.
## Reporting a Security Issue ## Reporting a Security Issue
Most of the time, when you find a bug in Helm, it should be reported Most of the time, when you find a bug in Helm, it should be reported using [GitHub
using [GitHub issues](https://github.com/helm/helm/issues). However, if issues](https://github.com/helm/helm/issues). However, if you are reporting a _security
you are reporting a _security vulnerability_, please email a report to vulnerability_, please email a report to
[cncf-kubernetes-helm-security@lists.cncf.io](mailto:cncf-kubernetes-helm-security@lists.cncf.io). This will give [cncf-helm-security@lists.cncf.io](mailto:cncf-helm-security@lists.cncf.io). This will give us a
us a chance to try to fix the issue before it is exploited in the wild. chance to try to fix the issue before it is exploited in the wild.
## Sign Your Work ## Sign Your Work
The sign-off is a simple line at the end of the explanation for a commit. All The sign-off is a simple line at the end of the explanation for a commit. All commits needs to be
commits needs to be signed. Your signature certifies that you wrote the patch or signed. Your signature certifies that you wrote the patch or otherwise have the right to contribute
otherwise have the right to contribute the material. The rules are pretty simple, the material. The rules are pretty simple, if you can certify the below (from
if you can certify the below (from [developercertificate.org](https://developercertificate.org/)): [developercertificate.org](https://developercertificate.org/)):
``` ```
Developer Certificate of Origin Developer Certificate of Origin
@ -62,11 +63,11 @@ Then you just add a line to every git commit message:
Use your real name (sorry, no pseudonyms or anonymous contributions.) Use your real name (sorry, no pseudonyms or anonymous contributions.)
If you set your `user.name` and `user.email` git configs, you can sign your If you set your `user.name` and `user.email` git configs, you can sign your commit automatically
commit automatically with `git commit -s`. with `git commit -s`.
Note: If your git config information is set properly then viewing the Note: If your git config information is set properly then viewing the `git log` information for your
`git log` information for your commit will look something like this: commit will look something like this:
``` ```
Author: Joe Smith <joe.smith@example.com> Author: Joe Smith <joe.smith@example.com>
@ -77,8 +78,8 @@ Date: Thu Feb 2 11:41:15 2018 -0800
Signed-off-by: Joe Smith <joe.smith@example.com> Signed-off-by: Joe Smith <joe.smith@example.com>
``` ```
Notice the `Author` and `Signed-off-by` lines match. If they don't Notice the `Author` and `Signed-off-by` lines match. If they don't your PR will be rejected by the
your PR will be rejected by the automated DCO check. automated DCO check.
## Support Channels ## Support Channels
@ -89,49 +90,69 @@ Whether you are a user or contributor, official support channels include:
- User: [#helm-users](https://kubernetes.slack.com/messages/C0NH30761/details/) - User: [#helm-users](https://kubernetes.slack.com/messages/C0NH30761/details/)
- Contributor: [#helm-dev](https://kubernetes.slack.com/messages/C51E88VDG/) - Contributor: [#helm-dev](https://kubernetes.slack.com/messages/C51E88VDG/)
Before opening a new issue or submitting a new pull request, it's helpful to search the project - it's likely that another user has already reported the issue you're facing, or it's a known issue that we're already aware of. It is also worth asking on the Slack channels. Before opening a new issue or submitting a new pull request, it's helpful to search the project -
it's likely that another user has already reported the issue you're facing, or it's a known issue
that we're already aware of. It is also worth asking on the Slack channels.
## Milestones ## Milestones
We use milestones to track progress of releases. There are also 2 special milestones We use milestones to track progress of releases. There are also 2 special milestones used for
used for helping us keep work organized: `Upcoming - Minor` and `Upcoming - Major` helping us keep work organized: `Upcoming - Minor` and `Upcoming - Major`
`Upcoming - Minor` is used for keeping track of issues that aren't assigned to a specific `Upcoming - Minor` is used for keeping track of issues that aren't assigned to a specific release
release but could easily be addressed in a minor release. `Upcoming - Major` keeps track but could easily be addressed in a minor release. `Upcoming - Major` keeps track of issues that will
of issues that will need to be addressed in a major release. For example, if the current need to be addressed in a major release. For example, if the current version is `3.2.0` an issue/PR
version is `3.2.0` an issue/PR could fall in to one of 4 different active milestones: could fall in to one of 4 different active milestones: `3.2.1`, `3.3.0`, `Upcoming - Minor`, or
`3.2.1`, `3.3.0`, `Upcoming - Minor`, or `Upcoming - Major`. If an issue pertains to a `Upcoming - Major`. If an issue pertains to a specific upcoming bug or minor release, it would go
specific upcoming bug or minor release, it would go into `3.2.1` or `3.3.0`. If the issue/PR into `3.2.1` or `3.3.0`. If the issue/PR does not have a specific milestone yet, but it is likely
does not have a specific milestone yet, but it is likely that it will land in a `3.X` release, that it will land in a `3.X` release, it should go into `Upcoming - Minor`. If the issue/PR is a
it should go into `Upcoming - Minor`. If the issue/PR is a large functionality add or change large functionality add or change and/or it breaks compatibility, then it should be added to the
and/or it breaks compatibility, then it should be added to the `Upcoming - Major` milestone. `Upcoming - Major` milestone. An issue that we are not sure we will be doing will not be added to
An issue that we are not sure we will be doing will not be added to any milestone. any milestone.
A milestone (and hence release) is considered done when all outstanding issues/PRs have been closed or moved to another milestone. A milestone (and hence release) is considered done when all outstanding issues/PRs have been closed
or moved to another milestone.
## Semantic Versioning ## Semantic Versioning
Helm maintains a strong commitment to backward compatibility. All of our changes to protocols and formats are backward compatible from one major release to the next. No features, flags, or commands are removed or substantially modified (unless we need to fix a security issue). Helm maintains a strong commitment to backward compatibility. All of our changes to protocols and
formats are backward compatible from one major release to the next. No features, flags, or commands
are removed or substantially modified (unless we need to fix a security issue).
We also try very hard to not change publicly accessible Go library definitions inside of the `pkg/` directory of our source code. We also try very hard to not change publicly accessible Go library definitions inside of the `pkg/`
directory of our source code.
For a quick summary of our backward compatibility guidelines for releases between 3.0 and 4.0: For a quick summary of our backward compatibility guidelines for releases between 3.0 and 4.0:
- Command line commands, flags, and arguments MUST be backward compatible - Command line commands, flags, and arguments MUST be backward compatible
- File formats (such as Chart.yaml) MUST be backward compatible - File formats (such as Chart.yaml) MUST be backward compatible
- Any chart that worked on a previous version of Helm 3 MUST work on a new version of Helm 3 (barring the cases where (a) Kubernetes itself changed, and (b) the chart worked because it exploited a bug) - Any chart that worked on a previous version of Helm 3 MUST work on a new version of Helm 3
(barring the cases where (a) Kubernetes itself changed, and (b) the chart worked because it
exploited a bug)
- Chart repository functionality MUST be backward compatible - Chart repository functionality MUST be backward compatible
- Go libraries inside of `pkg/` SHOULD remain backward compatible, though code inside of `cmd/` and `internal/` may be changed from release to release without notice. - Go libraries inside of `pkg/` SHOULD remain backward compatible, though code inside of `cmd/` and
`internal/` may be changed from release to release without notice.
## Support Contract for Helm 2 ## Support Contract for Helm 2
With Helm 2's current release schedule, we want to take into account any migration issues for users due to the upcoming holiday shopping season and tax season. We also want to clarify what actions may occur after the support contract ends for Helm 2, so that users will not be surprised or caught off guard. With Helm 2's current release schedule, we want to take into account any migration issues for users
due to the upcoming holiday shopping season and tax season. We also want to clarify what actions may
occur after the support contract ends for Helm 2, so that users will not be surprised or caught off
guard.
After Helm 2.15.0 is released, Helm 2 will go into "maintenance mode". We will continue to accept bug fixes and fix any security issues that arise, but no new features will be accepted for Helm 2. All feature development will be moved over to Helm 3. After Helm 2.15.0 is released, Helm 2 will go into "maintenance mode". We will continue to accept
bug fixes and fix any security issues that arise, but no new features will be accepted for Helm 2.
All feature development will be moved over to Helm 3.
6 months after Helm 3.0.0's public release, Helm 2 will stop accepting bug fixes. Only security issues will be accepted. 6 months after Helm 3.0.0's public release, Helm 2 will stop accepting bug fixes. Only security
issues will be accepted.
12 months after Helm 3.0.0's public release, support for Helm 2 will formally end. Download links for the Helm 2 client through Google Cloud Storage, the Docker image for Tiller stored in Google Container Registry, and the Google Cloud buckets for the stable and incubator chart repositories may no longer work at any point. Client downloads through `get.helm.sh` will continue to work, and we will distribute a Tiller image that will be made available at an alternative location which can be updated with `helm init --tiller-image`. 12 months after Helm 3.0.0's public release, support for Helm 2 will formally end. Download links
for the Helm 2 client through Google Cloud Storage, the Docker image for Tiller stored in Google
Container Registry, and the Google Cloud buckets for the stable and incubator chart repositories may
no longer work at any point. Client downloads through `get.helm.sh` will continue to work, and we
will distribute a Tiller image that will be made available at an alternative location which can be
updated with `helm init --tiller-image`.
## Issues ## Issues
@ -141,45 +162,46 @@ Issues are used as the primary method for tracking anything to do with the Helm
There are 5 types of issues (each with their own corresponding [label](#labels)): There are 5 types of issues (each with their own corresponding [label](#labels)):
- `question/support`: These are support or functionality inquiries that we want to have a record of for - `question/support`: These are support or functionality inquiries that we want to have a record of
future reference. Generally these are questions that are too complex or large to store in the for future reference. Generally these are questions that are too complex or large to store in the
Slack channel or have particular interest to the community as a whole. Depending on the discussion, Slack channel or have particular interest to the community as a whole. Depending on the
these can turn into `feature` or `bug` issues. discussion, these can turn into `feature` or `bug` issues.
- `proposal`: Used for items (like this one) that propose a new ideas or functionality that require - `proposal`: Used for items (like this one) that propose a new ideas or functionality that require
a larger community discussion. This allows for feedback from others in the community before a a larger community discussion. This allows for feedback from others in the community before a
feature is actually developed. This is not needed for small additions. Final word on whether or feature is actually developed. This is not needed for small additions. Final word on whether or
not a feature needs a proposal is up to the core maintainers. All issues that are proposals should not a feature needs a proposal is up to the core maintainers. All issues that are proposals should
both have a label and an issue title of "Proposal: [the rest of the title]." A proposal can become both have a label and an issue title of "Proposal: [the rest of the title]." A proposal can become
a `feature` and does not require a milestone. a `feature` and does not require a milestone.
- `feature`: These track specific feature requests and ideas until they are complete. They can evolve - `feature`: These track specific feature requests and ideas until they are complete. They can
from a `proposal` or can be submitted individually depending on the size. evolve from a `proposal` or can be submitted individually depending on the size.
- `bug`: These track bugs with the code - `bug`: These track bugs with the code
- `docs`: These track problems with the documentation (i.e. missing or incomplete) - `docs`: These track problems with the documentation (i.e. missing or incomplete)
### Issue Lifecycle ### Issue Lifecycle
The issue lifecycle is mainly driven by the core maintainers, but is good information for those The issue lifecycle is mainly driven by the core maintainers, but is good information for those
contributing to Helm. All issue types follow the same general lifecycle. Differences are noted below. contributing to Helm. All issue types follow the same general lifecycle. Differences are noted
below.
1. Issue creation 1. Issue creation
2. Triage 2. Triage
- The maintainer in charge of triaging will apply the proper labels for the issue. This - The maintainer in charge of triaging will apply the proper labels for the issue. This includes
includes labels for priority, type, and metadata (such as `good first issue`). The only issue labels for priority, type, and metadata (such as `good first issue`). The only issue priority
priority we will be tracking is whether or not the issue is "critical." If additional we will be tracking is whether or not the issue is "critical." If additional levels are needed
levels are needed in the future, we will add them. in the future, we will add them.
- (If needed) Clean up the title to succinctly and clearly state the issue. Also ensure - (If needed) Clean up the title to succinctly and clearly state the issue. Also ensure that
that proposals are prefaced with "Proposal: [the rest of the title]". proposals are prefaced with "Proposal: [the rest of the title]".
- Add the issue to the correct milestone. If any questions come up, don't worry about - Add the issue to the correct milestone. If any questions come up, don't worry about adding the
adding the issue to a milestone until the questions are answered. issue to a milestone until the questions are answered.
- We attempt to do this process at least once per work day. - We attempt to do this process at least once per work day.
3. Discussion 3. Discussion
- issues that are labeled as `feature` or `bug` should be connected to the PR that resolves it. - issues that are labeled as `feature` or `bug` should be connected to the PR that resolves it.
- Whoever is working on a `feature` or `bug` issue (whether a maintainer or someone from - Whoever is working on a `feature` or `bug` issue (whether a maintainer or someone from the
the community), should either assign the issue to themself or make a comment in the issue community), should either assign the issue to themself or make a comment in the issue saying
saying that they are taking it. that they are taking it.
- `proposal` and `support/question` issues should stay open until resolved or if they have not been - `proposal` and `support/question` issues should stay open until resolved or if they have not
active for more than 30 days. This will help keep the issue queue to a manageable size and been active for more than 30 days. This will help keep the issue queue to a manageable size
reduce noise. Should the issue need to stay open, the `keep open` label can be added. and reduce noise. Should the issue need to stay open, the `keep open` label can be added.
4. Issue closure 4. Issue closure
## How to Contribute a Patch ## How to Contribute a Patch
@ -188,7 +210,8 @@ contributing to Helm. All issue types follow the same general lifecycle. Differe
2. Fork the desired repo; develop and test your code changes. 2. Fork the desired repo; develop and test your code changes.
3. Submit a pull request, making sure to sign your work and link the related issue. 3. Submit a pull request, making sure to sign your work and link the related issue.
Coding conventions and standards are explained in the [official developer docs](https://helm.sh/docs/developers/). Coding conventions and standards are explained in the [official developer
docs](https://helm.sh/docs/developers/).
## Pull Requests ## Pull Requests
@ -200,36 +223,37 @@ Like any good open source project, we use Pull Requests (PRs) to track code chan
- PRs are usually created to fix or else be a subset of other PRs that fix a particular issue. - PRs are usually created to fix or else be a subset of other PRs that fix a particular issue.
- We more than welcome PRs that are currently in progress. They are a great way to keep track of - We more than welcome PRs that are currently in progress. They are a great way to keep track of
important work that is in-flight, but useful for others to see. If a PR is a work in progress, important work that is in-flight, but useful for others to see. If a PR is a work in progress,
it **must** be prefaced with "WIP: [title]". Once the PR is ready for review, remove "WIP" from it **must** be prefaced with "WIP: [title]". Once the PR is ready for review, remove "WIP"
the title. from the title.
- It is preferred, but not required, to have a PR tied to a specific issue. There can be - It is preferred, but not required, to have a PR tied to a specific issue. There can be
circumstances where if it is a quick fix then an issue might be overkill. The details provided circumstances where if it is a quick fix then an issue might be overkill. The details provided
in the PR description would suffice in this case. in the PR description would suffice in this case.
2. Triage 2. Triage
- The maintainer in charge of triaging will apply the proper labels for the issue. This should - The maintainer in charge of triaging will apply the proper labels for the issue. This should
include at least a size label, `bug` or `feature`, and `awaiting review` once all labels are applied. include at least a size label, `bug` or `feature`, and `awaiting review` once all labels are
See the [Labels section](#labels) for full details on the definitions of labels. applied. See the [Labels section](#labels) for full details on the definitions of labels.
- Add the PR to the correct milestone. This should be the same as the issue the PR closes. - Add the PR to the correct milestone. This should be the same as the issue the PR closes.
3. Assigning reviews 3. Assigning reviews
- Once a review has the `awaiting review` label, maintainers will review them as schedule permits. - Once a review has the `awaiting review` label, maintainers will review them as schedule
The maintainer who takes the issue should self-request a review. permits. The maintainer who takes the issue should self-request a review.
- Any PR with the `size/large` label requires 2 review approvals from maintainers before it can be - Any PR with the `size/large` label requires 2 review approvals from maintainers before it can
merged. Those with `size/medium` or `size/small` are per the judgement of the maintainers. be merged. Those with `size/medium` or `size/small` are per the judgement of the maintainers.
4. Reviewing/Discussion 4. Reviewing/Discussion
- All reviews will be completed using Github review tool. - All reviews will be completed using Github review tool.
- A "Comment" review should be used when there are questions about the code that should be - A "Comment" review should be used when there are questions about the code that should be
answered, but that don't involve code changes. This type of review does not count as approval. answered, but that don't involve code changes. This type of review does not count as approval.
- A "Changes Requested" review indicates that changes to the code need to be made before they will be merged. - A "Changes Requested" review indicates that changes to the code need to be made before they
will be merged.
- Reviewers should update labels as needed (such as `needs rebase`) - Reviewers should update labels as needed (such as `needs rebase`)
5. Address comments by answering questions or changing code 5. Address comments by answering questions or changing code
6. LGTM (Looks good to me) 6. LGTM (Looks good to me)
- Once a Reviewer has completed a review and the code looks ready to merge, an "Approve" review is used - Once a Reviewer has completed a review and the code looks ready to merge, an "Approve" review
to signal to the contributor and to other maintainers that you have reviewed the code and feel that it is is used to signal to the contributor and to other maintainers that you have reviewed the code
ready to be merged. and feel that it is ready to be merged.
7. Merge or close 7. Merge or close
- PRs should stay open until merged or if they have not been active for more than 30 days. - PRs should stay open until merged or if they have not been active for more than 30 days. This
This will help keep the PR queue to a manageable size and reduce noise. Should the PR need will help keep the PR queue to a manageable size and reduce noise. Should the PR need to stay
to stay open (like in the case of a WIP), the `keep open` label can be added. open (like in the case of a WIP), the `keep open` label can be added.
- Before merging a PR, refer to the topic on [Size Labels](#size-labels) below to determine if - Before merging a PR, refer to the topic on [Size Labels](#size-labels) below to determine if
the PR requires more than one LGTM to merge. the PR requires more than one LGTM to merge.
- If the owner of the PR is listed in the `OWNERS` file, that user **must** merge their own PRs - If the owner of the PR is listed in the `OWNERS` file, that user **must** merge their own PRs
@ -286,12 +310,12 @@ The following tables define all label types used for Helm. It is split up by cat
#### Size labels #### Size labels
Size labels are used to indicate how "dangerous" a PR is. The guidelines below are used to assign the Size labels are used to indicate how "dangerous" a PR is. The guidelines below are used to assign
labels, but ultimately this can be changed by the maintainers. For example, even if a PR only makes the labels, but ultimately this can be changed by the maintainers. For example, even if a PR only
30 lines of changes in 1 file, but it changes key functionality, it will likely be labeled as `size/L` makes 30 lines of changes in 1 file, but it changes key functionality, it will likely be labeled as
because it requires sign off from multiple people. Conversely, a PR that adds a small feature, but requires `size/L` because it requires sign off from multiple people. Conversely, a PR that adds a small
another 150 lines of tests to cover all cases, could be labeled as `size/S` even though the number of feature, but requires another 150 lines of tests to cover all cases, could be labeled as `size/S`
lines is greater than defined below. even though the number of lines is greater than defined below.
PRs submitted by a core maintainer, regardless of size, only requires approval from one additional PRs submitted by a core maintainer, regardless of size, only requires approval from one additional
maintainer. This ensures there are at least two maintainers who are aware of any significant PRs maintainer. This ensures there are at least two maintainers who are aware of any significant PRs

@ -17,13 +17,10 @@ package main
import ( import (
"io" "io"
"path/filepath"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"helm.sh/helm/v3/cmd/helm/require" "helm.sh/helm/v3/cmd/helm/require"
"helm.sh/helm/v3/pkg/action"
"helm.sh/helm/v3/pkg/cli/output"
) )
const dependencyDesc = ` const dependencyDesc = `
@ -98,25 +95,3 @@ func newDependencyCmd(out io.Writer) *cobra.Command {
return cmd return cmd
} }
func newDependencyListCmd(out io.Writer) *cobra.Command {
var outfmt output.Format
cmd := &cobra.Command{
Use: "list CHART",
Aliases: []string{"ls"},
Short: "list the dependencies for the given chart",
Long: dependencyListDesc,
Args: require.MaximumNArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
chartpath := "."
if len(args) > 0 {
chartpath = filepath.Clean(args[0])
}
return outfmt.Write(out, &action.DependencyListWriter{Chartpath: chartpath})
},
}
bindOutputFlag(cmd, &outfmt)
return cmd
}

@ -0,0 +1,164 @@
/*
Copyright The Helm Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package main
import (
"fmt"
"io"
"os"
"path/filepath"
"github.com/gosuri/uitable"
"github.com/spf13/cobra"
"helm.sh/helm/v3/cmd/helm/require"
"helm.sh/helm/v3/pkg/action"
"helm.sh/helm/v3/pkg/chart"
"helm.sh/helm/v3/pkg/chart/loader"
"helm.sh/helm/v3/pkg/cli/output"
)
func newDependencyListCmd(out io.Writer) *cobra.Command {
var outfmt output.Format
cmd := &cobra.Command{
Use: "list CHART",
Aliases: []string{"ls"},
Short: "list the dependencies for the given chart",
Long: dependencyListDesc,
Args: require.MaximumNArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
chartpath := "."
if len(args) > 0 {
chartpath = filepath.Clean(args[0])
}
return outfmt.Write(out, &dependencyListWriter{chartpath: chartpath})
},
}
bindOutputFlag(cmd, &outfmt)
return cmd
}
// dependencyListElement is a single element in json/yaml array of dependencies
type dependencyListElement struct {
Name string `json:"name"`
Version string `json:"version"`
Repository string `json:"repository"`
Status string `json:"status"`
}
// dependencyListWriter implements 'output.Format' interface
type dependencyListWriter struct {
chartpath string
}
func (w *dependencyListWriter) WriteTable(out io.Writer) error {
c, err := loader.Load(w.chartpath)
if err != nil {
return err
}
if c.Metadata.Dependencies == nil {
fmt.Fprintf(out, "WARNING: no dependencies at %s\n", filepath.Join(w.chartpath, "charts"))
return nil
}
w.printDependenciesTable(w.chartpath, out, c)
fmt.Fprintln(out)
w.printMissing(w.chartpath, out, c.Metadata.Dependencies)
return nil
}
func (w *dependencyListWriter) WriteJSON(out io.Writer) error {
return w.encodeByFormat(out, output.JSON)
}
func (w *dependencyListWriter) WriteYAML(out io.Writer) error {
return w.encodeByFormat(out, output.YAML)
}
func (w *dependencyListWriter) encodeByFormat(out io.Writer, format output.Format) error {
c, err := loader.Load(w.chartpath)
if err != nil {
return err
}
// Initialize the array so no results returns an empty array instead of null
elements := make([]dependencyListElement, 0, len(c.Metadata.Dependencies))
for _, d := range c.Metadata.Dependencies {
elements = append(elements, dependencyListElement{Name: d.Name, Repository: d.Repository, Status: action.DependencyStatus(w.chartpath, d, c), Version: d.Version})
}
switch format {
case output.JSON:
return output.EncodeJSON(out, elements)
case output.YAML:
return output.EncodeYAML(out, elements)
}
return nil
}
// printDependenciesTable prints all of the dependencies for Table output format.
func (w *dependencyListWriter) printDependenciesTable(chartpath string, out io.Writer, c *chart.Chart) {
table := uitable.New()
table.MaxColWidth = 80
table.AddRow("NAME", "VERSION", "REPOSITORY", "STATUS")
for _, row := range c.Metadata.Dependencies {
table.AddRow(row.Name, row.Version, row.Repository, action.DependencyStatus(chartpath, row, c))
}
fmt.Fprintln(out, table)
}
// printMissing prints warnings about charts that are present on disk, but are
// not in Charts.yaml for Table output format.
func (w *dependencyListWriter) printMissing(chartpath string, out io.Writer, reqs []*chart.Dependency) {
folder := filepath.Join(chartpath, "charts/*")
files, err := filepath.Glob(folder)
if err != nil {
fmt.Fprintln(out, err)
return
}
for _, f := range files {
fi, err := os.Stat(f)
if err != nil {
fmt.Fprintf(out, "WARNING: %s\n", err)
}
// Skip anything that is not a directory and not a tgz file.
if !fi.IsDir() && filepath.Ext(f) != ".tgz" {
continue
}
c, err := loader.Load(f)
if err != nil {
fmt.Fprintf(out, "WARNING: %q is not a chart.\n", f)
continue
}
found := false
for _, d := range reqs {
if d.Name == c.Name() {
found = true
break
}
}
if !found {
fmt.Fprintf(out, "WARNING: %q is not in Chart.yaml.\n", f)
}
}
}

@ -0,0 +1,128 @@
/*
Copyright The Helm Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package main
import (
"runtime"
"testing"
)
func TestDependencyListCmdNew(t *testing.T) {
noSuchChart := cmdTestCase{
name: "No such chart",
cmd: "dependency list /no/such/chart",
golden: "output/dependency-list-no-chart-linux.txt",
wantError: true,
}
noDependencies := cmdTestCase{
name: "No dependencies",
cmd: "dependency list testdata/testcharts/alpine",
golden: "output/dependency-list-no-requirements-linux.txt",
}
if runtime.GOOS == "windows" {
noSuchChart.golden = "output/dependency-list-no-chart-windows.txt"
noDependencies.golden = "output/dependency-list-no-requirements-windows.txt"
}
tests := []cmdTestCase{
noSuchChart,
noDependencies, {
name: "Dependencies in chart dir",
cmd: "dependency list testdata/testcharts/reqtest",
golden: "output/dependency-list.txt",
}, {
name: "Dependencies in chart archive",
cmd: "dependency list testdata/testcharts/reqtest-0.1.0.tgz",
golden: "output/dependency-list-archive.txt",
},
{
name: "Dependency list with compressed dependencies from chart folder",
cmd: "dep list testdata/testcharts/chart-with-compressed-dependencies",
golden: "output/dependency-list-compressed-deps.txt",
},
{
name: "Dependency list with compressed dependencies from chart folder with json output format",
cmd: "dep list testdata/testcharts/chart-with-compressed-dependencies --output json",
golden: "output/dependency-list-compressed-deps.json",
},
{
name: "Dependency list with compressed dependencies from chart folder with yaml output format",
cmd: "dep list testdata/testcharts/chart-with-compressed-dependencies --output yaml",
golden: "output/dependency-list-compressed-deps.yaml",
},
{
name: "Dependency list with compressed dependencies from chart archive",
cmd: "dep list testdata/testcharts/chart-with-compressed-dependencies-2.1.8.tgz",
golden: "output/dependency-list-compressed-deps-tgz.txt",
},
{
name: "Dependency list with compressed dependencies from chart archive with json format output",
cmd: "dep list testdata/testcharts/chart-with-compressed-dependencies-2.1.8.tgz --output json",
golden: "output/dependency-list-compressed-deps-tgz.json",
},
{
name: "Dependency list with compressed dependencies from chart archive with yaml format output",
cmd: "dep list testdata/testcharts/chart-with-compressed-dependencies-2.1.8.tgz --output yaml",
golden: "output/dependency-list-compressed-deps-tgz.yaml",
},
{
name: "Dependency list with uncompressed dependencies from chart folder",
cmd: "dep list testdata/testcharts/chart-with-uncompressed-dependencies",
golden: "output/dependency-list-uncompressed-deps.txt",
},
{
name: "Dependency list with uncompressed dependencies from chart folder with json output format",
cmd: "dep list testdata/testcharts/chart-with-uncompressed-dependencies --output json",
golden: "output/dependency-list-uncompressed-deps.json",
},
{
name: "Dependency list with uncompressed dependencies from chart folder with yaml output format",
cmd: "dep list testdata/testcharts/chart-with-uncompressed-dependencies --output yaml",
golden: "output/dependency-list-uncompressed-deps.yaml",
},
{
name: "Dependency list with uncompressed dependencies from chart archive",
cmd: "dep list testdata/testcharts/chart-with-uncompressed-dependencies-2.1.8.tgz",
golden: "output/dependency-list-uncompressed-deps-tgz.txt",
},
{
name: "Dependency list with uncompressed dependencies from chart archive with json output format",
cmd: "dep list testdata/testcharts/chart-with-uncompressed-dependencies-2.1.8.tgz --output json",
golden: "output/dependency-list-uncompressed-deps-tgz.json",
},
{
name: "Dependency list with uncompressed dependencies from chart archive with yaml output format",
cmd: "dep list testdata/testcharts/chart-with-uncompressed-dependencies-2.1.8.tgz --output yaml",
golden: "output/dependency-list-uncompressed-deps-tgz.yaml",
},
{
name: "Dependency list of chart with missing dependencies",
cmd: "dep list testdata/testcharts/chart-missing-dep",
golden: "output/dependency-list-missing-dep.txt",
},
{
name: "Dependency list of chart with missing dependencies with json output format",
cmd: "dep list testdata/testcharts/chart-missing-dep --output json",
golden: "output/dependency-list-missing-dep.json",
},
{
name: "Dependency list of chart with missing dependencies with yaml output format",
cmd: "dep list testdata/testcharts/chart-missing-dep --output yaml",
golden: "output/dependency-list-missing-dep.yaml",
},
}
runTestCmd(t, tests)
}

@ -1,53 +0,0 @@
/*
Copyright The Helm Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package main
import (
"runtime"
"testing"
)
func TestDependencyListCmd(t *testing.T) {
noSuchChart := cmdTestCase{
name: "No such chart",
cmd: "dependency list /no/such/chart",
golden: "output/dependency-list-no-chart-linux.txt",
wantError: true,
}
noDependencies := cmdTestCase{
name: "No dependencies",
cmd: "dependency list testdata/testcharts/alpine",
golden: "output/dependency-list-no-requirements-linux.txt",
}
if runtime.GOOS == "windows" {
noSuchChart.golden = "output/dependency-list-no-chart-windows.txt"
noDependencies.golden = "output/dependency-list-no-requirements-windows.txt"
}
tests := []cmdTestCase{noSuchChart,
noDependencies, {
name: "Dependencies in chart dir",
cmd: "dependency list testdata/testcharts/reqtest",
golden: "output/dependency-list.txt",
}, {
name: "Dependencies in chart archive",
cmd: "dependency list testdata/testcharts/reqtest-0.1.0.tgz",
golden: "output/dependency-list-archive.txt",
}}
runTestCmd(t, tests)
}

@ -48,7 +48,7 @@ func newDocsCmd(out io.Writer) *cobra.Command {
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "docs", Use: "docs",
Short: "Generate documentation as markdown or man pages", Short: "generate documentation as markdown or man pages",
Long: docsDesc, Long: docsDesc,
Hidden: true, Hidden: true,
Args: require.NoArgs, Args: require.NoArgs,

@ -60,6 +60,7 @@ or
$ helm install --set-string long_int=1234567890 myredis ./redis $ helm install --set-string long_int=1234567890 myredis ./redis
or or
$ helm install --set-file my_script=dothings.sh myredis ./redis $ helm install --set-file my_script=dothings.sh myredis ./redis
You can specify the '--values'/'-f' flag multiple times. The priority will be given to the You can specify the '--values'/'-f' flag multiple times. The priority will be given to the

@ -195,6 +195,11 @@ func TestInstall(t *testing.T) {
cmd: "install aeneas testdata/testcharts/deprecated --namespace default", cmd: "install aeneas testdata/testcharts/deprecated --namespace default",
golden: "output/deprecated-chart.txt", golden: "output/deprecated-chart.txt",
}, },
// Install chart with only crds
{
name: "install chart with only crds",
cmd: "install crd-test testdata/testcharts/chart-with-only-crds --namespace default",
},
} }
runTestActionCmd(t, tests) runTestActionCmd(t, tests)

@ -46,7 +46,7 @@ func newLintCmd(out io.Writer) *cobra.Command {
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "lint PATH", Use: "lint PATH",
Short: "examines a chart for possible issues", Short: "examine a chart for possible issues",
Long: longLintHelp, Long: longLintHelp,
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
paths := []string{"."} paths := []string{"."}

@ -64,21 +64,6 @@ func loadPlugins(baseCmd *cobra.Command, out io.Writer) {
return return
} }
processParent := func(cmd *cobra.Command, args []string) ([]string, error) {
k, u := manuallyProcessArgs(args)
if err := cmd.Parent().ParseFlags(k); err != nil {
return nil, err
}
return u, nil
}
// If we are dealing with the completion command, we try to load more details about the plugins
// if available, so as to allow for command and flag completion
if subCmd, _, err := baseCmd.Find(os.Args[1:]); err == nil && subCmd.Name() == "completion" {
loadPluginsForCompletion(baseCmd, found)
return
}
// Now we create commands for all of these. // Now we create commands for all of these.
for _, plug := range found { for _, plug := range found {
plug := plug plug := plug
@ -87,33 +72,6 @@ func loadPlugins(baseCmd *cobra.Command, out io.Writer) {
md.Usage = fmt.Sprintf("the %q plugin", md.Name) md.Usage = fmt.Sprintf("the %q plugin", md.Name)
} }
// This function is used to setup the environment for the plugin and then
// call the executable specified by the parameter 'main'
callPluginExecutable := func(cmd *cobra.Command, main string, argv []string, out io.Writer) error {
env := os.Environ()
for k, v := range settings.EnvVars() {
env = append(env, fmt.Sprintf("%s=%s", k, v))
}
prog := exec.Command(main, argv...)
prog.Env = env
prog.Stdin = os.Stdin
prog.Stdout = out
prog.Stderr = os.Stderr
if err := prog.Run(); err != nil {
if eerr, ok := err.(*exec.ExitError); ok {
os.Stderr.Write(eerr.Stderr)
status := eerr.Sys().(syscall.WaitStatus)
return pluginError{
error: errors.Errorf("plugin %q exited with error", md.Name),
code: status.ExitStatus(),
}
}
return err
}
return nil
}
c := &cobra.Command{ c := &cobra.Command{
Use: md.Name, Use: md.Name,
Short: md.Usage, Short: md.Usage,
@ -134,62 +92,59 @@ func loadPlugins(baseCmd *cobra.Command, out io.Writer) {
return errors.Errorf("plugin %q exited with error", md.Name) return errors.Errorf("plugin %q exited with error", md.Name)
} }
return callPluginExecutable(cmd, main, argv, out) return callPluginExecutable(md.Name, main, argv, out)
}, },
// This passes all the flags to the subcommand. // This passes all the flags to the subcommand.
DisableFlagParsing: true, DisableFlagParsing: true,
} }
// TODO: Make sure a command with this name does not already exist.
baseCmd.AddCommand(c)
// Setup dynamic completion for the plugin // For completion, we try to load more details about the plugins so as to allow for command and
completion.RegisterValidArgsFunc(c, func(cmd *cobra.Command, args []string, toComplete string) ([]string, completion.BashCompDirective) { // flag completion of the plugin itself.
u, err := processParent(cmd, args) // We only do this when necessary (for the "completion" and "__complete" commands) to avoid the
if err != nil { // risk of a rogue plugin affecting Helm's normal behavior.
return nil, completion.BashCompDirectiveError subCmd, _, err := baseCmd.Find(os.Args[1:])
if (err == nil && (subCmd.Name() == "completion" || subCmd.Name() == completion.CompRequestCmd)) ||
/* for the tests */ subCmd == baseCmd.Root() {
loadCompletionForPlugin(c, plug)
} }
// We will call the dynamic completion script of the plugin
main := strings.Join([]string{plug.Dir, pluginDynamicCompletionExecutable}, string(filepath.Separator))
argv := []string{}
if !md.IgnoreFlags {
argv = append(argv, u...)
argv = append(argv, toComplete)
} }
plugin.SetupPluginEnv(settings, md.Name, plug.Dir) }
completion.CompDebugln(fmt.Sprintf("calling %s with args %v", main, argv)) func processParent(cmd *cobra.Command, args []string) ([]string, error) {
buf := new(bytes.Buffer) k, u := manuallyProcessArgs(args)
if err := callPluginExecutable(cmd, main, argv, buf); err != nil { if err := cmd.Parent().ParseFlags(k); err != nil {
return nil, completion.BashCompDirectiveError return nil, err
} }
return u, nil
}
var completions []string // This function is used to setup the environment for the plugin and then
for _, comp := range strings.Split(buf.String(), "\n") { // call the executable specified by the parameter 'main'
// Remove any empty lines func callPluginExecutable(pluginName string, main string, argv []string, out io.Writer) error {
if len(comp) > 0 { env := os.Environ()
completions = append(completions, comp) for k, v := range settings.EnvVars() {
} env = append(env, fmt.Sprintf("%s=%s", k, v))
} }
// Check if the last line of output is of the form :<integer>, which prog := exec.Command(main, argv...)
// indicates the BashCompletionDirective. prog.Env = env
directive := completion.BashCompDirectiveDefault prog.Stdin = os.Stdin
if len(completions) > 0 { prog.Stdout = out
lastLine := completions[len(completions)-1] prog.Stderr = os.Stderr
if len(lastLine) > 1 && lastLine[0] == ':' { if err := prog.Run(); err != nil {
if strInt, err := strconv.Atoi(lastLine[1:]); err == nil { if eerr, ok := err.(*exec.ExitError); ok {
directive = completion.BashCompDirective(strInt) os.Stderr.Write(eerr.Stderr)
completions = completions[:len(completions)-1] status := eerr.Sys().(syscall.WaitStatus)
} return pluginError{
error: errors.Errorf("plugin %q exited with error", pluginName),
code: status.ExitStatus(),
} }
} }
return err
return completions, directive
})
// TODO: Make sure a command with this name does not already exist.
baseCmd.AddCommand(c)
} }
return nil
} }
// manuallyProcessArgs processes an arg array, removing special args. // manuallyProcessArgs processes an arg array, removing special args.
@ -246,35 +201,31 @@ type pluginCommand struct {
Commands []pluginCommand `json:"commands"` Commands []pluginCommand `json:"commands"`
} }
// loadPluginsForCompletion will load and parse any completion.yaml provided by the plugins // loadCompletionForPlugin will load and parse any completion.yaml provided by the plugin
func loadPluginsForCompletion(baseCmd *cobra.Command, plugins []*plugin.Plugin) { // and add the dynamic completion hook to call the optional plugin.complete
for _, plug := range plugins { func loadCompletionForPlugin(pluginCmd *cobra.Command, plugin *plugin.Plugin) {
// Parse the yaml file providing the plugin's subcmds and flags // Parse the yaml file providing the plugin's sub-commands and flags
cmds, err := loadFile(strings.Join( cmds, err := loadFile(strings.Join(
[]string{plug.Dir, pluginStaticCompletionFile}, string(filepath.Separator))) []string{plugin.Dir, pluginStaticCompletionFile}, string(filepath.Separator)))
if err != nil { if err != nil {
// The file could be missing or invalid. Either way, we at least create the command // The file could be missing or invalid. No static completion for this plugin.
// for the plugin name.
if settings.Debug { if settings.Debug {
log.Output(2, fmt.Sprintf("[info] %s\n", err.Error())) log.Output(2, fmt.Sprintf("[info] %s\n", err.Error()))
} }
cmds = &pluginCommand{Name: plug.Metadata.Name} // Continue to setup dynamic completion.
cmds = &pluginCommand{}
} }
// We know what the plugin name must be. // Preserve the Usage string specified for the plugin
// Let's set it in case the Name field was not specified correctly in the file. cmds.Name = pluginCmd.Use
// This insures that we will at least get the plugin name to complete, even if
// there is a problem with the completion.yaml file
cmds.Name = plug.Metadata.Name
addPluginCommands(baseCmd, cmds) addPluginCommands(plugin, pluginCmd, cmds)
}
} }
// addPluginCommands is a recursive method that adds the different levels // addPluginCommands is a recursive method that adds each different level
// of sub-commands and flags for the plugins that provide such information // of sub-commands and flags for the plugins that have provided such information
func addPluginCommands(baseCmd *cobra.Command, cmds *pluginCommand) { func addPluginCommands(plugin *plugin.Plugin, baseCmd *cobra.Command, cmds *pluginCommand) {
if cmds == nil { if cmds == nil {
return return
} }
@ -287,14 +238,19 @@ func addPluginCommands(baseCmd *cobra.Command, cmds *pluginCommand) {
return return
} }
// Create a fake command just so the completion script will include it baseCmd.Use = cmds.Name
c := &cobra.Command{ baseCmd.ValidArgs = cmds.ValidArgs
Use: cmds.Name, // Setup the same dynamic completion for each plugin sub-command.
ValidArgs: cmds.ValidArgs, // This is because if dynamic completion is triggered, there is a single executable
// A Run is required for it to be a valid command without subcommands // to call (plugin.complete), so every sub-commands calls it in the same fashion.
Run: func(cmd *cobra.Command, args []string) {}, if cmds.Commands == nil {
// Only setup dynamic completion if there are no sub-commands. This avoids
// calling plugin.complete at every completion, which greatly simplifies
// development of plugin.complete for plugin developers.
completion.RegisterValidArgsFunc(baseCmd, func(cmd *cobra.Command, args []string, toComplete string) ([]string, completion.BashCompDirective) {
return pluginDynamicComp(plugin, cmd, args, toComplete)
})
} }
baseCmd.AddCommand(c)
// Create fake flags. // Create fake flags.
if len(cmds.Flags) > 0 { if len(cmds.Flags) > 0 {
@ -314,7 +270,7 @@ func addPluginCommands(baseCmd *cobra.Command, cmds *pluginCommand) {
} }
} }
f := c.Flags() f := baseCmd.Flags()
if len(longs) >= len(shorts) { if len(longs) >= len(shorts) {
for i := range longs { for i := range longs {
if i < len(shorts) { if i < len(shorts) {
@ -338,7 +294,16 @@ func addPluginCommands(baseCmd *cobra.Command, cmds *pluginCommand) {
// Recursively add any sub-commands // Recursively add any sub-commands
for _, cmd := range cmds.Commands { for _, cmd := range cmds.Commands {
addPluginCommands(c, &cmd) // Create a fake command so that completion can be done for the sub-commands of the plugin
subCmd := &cobra.Command{
// This prevents Cobra from removing the flags. We want to keep the flags to pass them
// to the dynamic completion script of the plugin.
DisableFlagParsing: true,
// A Run is required for it to be a valid command without subcommands
Run: func(cmd *cobra.Command, args []string) {},
}
baseCmd.AddCommand(subCmd)
addPluginCommands(plugin, subCmd, &cmd)
} }
} }
@ -353,3 +318,59 @@ func loadFile(path string) (*pluginCommand, error) {
err = yaml.Unmarshal(b, cmds) err = yaml.Unmarshal(b, cmds)
return cmds, err return cmds, err
} }
// pluginDynamicComp call the plugin.complete script of the plugin (if available)
// to obtain the dynamic completion choices. It must pass all the flags and sub-commands
// specified in the command-line to the plugin.complete executable (except helm's global flags)
func pluginDynamicComp(plug *plugin.Plugin, cmd *cobra.Command, args []string, toComplete string) ([]string, completion.BashCompDirective) {
md := plug.Metadata
u, err := processParent(cmd, args)
if err != nil {
return nil, completion.BashCompDirectiveError
}
// We will call the dynamic completion script of the plugin
main := strings.Join([]string{plug.Dir, pluginDynamicCompletionExecutable}, string(filepath.Separator))
// We must include all sub-commands passed on the command-line.
// To do that, we pass-in the entire CommandPath, except the first two elements
// which are 'helm' and 'pluginName'.
argv := strings.Split(cmd.CommandPath(), " ")[2:]
if !md.IgnoreFlags {
argv = append(argv, u...)
argv = append(argv, toComplete)
}
plugin.SetupPluginEnv(settings, md.Name, plug.Dir)
completion.CompDebugln(fmt.Sprintf("calling %s with args %v", main, argv))
buf := new(bytes.Buffer)
if err := callPluginExecutable(md.Name, main, argv, buf); err != nil {
// The dynamic completion file is optional for a plugin, so this error is ok.
completion.CompDebugln(fmt.Sprintf("Unable to call %s: %v", main, err.Error()))
return nil, completion.BashCompDirectiveDefault
}
var completions []string
for _, comp := range strings.Split(buf.String(), "\n") {
// Remove any empty lines
if len(comp) > 0 {
completions = append(completions, comp)
}
}
// Check if the last line of output is of the form :<integer>, which
// indicates the BashCompletionDirective.
directive := completion.BashCompDirectiveDefault
if len(completions) > 0 {
lastLine := completions[len(completions)-1]
if len(lastLine) > 1 && lastLine[0] == ':' {
if strInt, err := strconv.Atoi(lastLine[1:]); err == nil {
directive = completion.BashCompDirective(strInt)
completions = completions[:len(completions)-1]
}
}
}
return completions, directive
}

@ -130,6 +130,9 @@ func (o *repoAddOptions) run(out io.Writer) error {
return err return err
} }
if o.repoCache != "" {
r.CachePath = o.repoCache
}
if _, err := r.DownloadIndexFile(); err != nil { if _, err := r.DownloadIndexFile(); err != nil {
return errors.Wrapf(err, "looks like %q is not a valid chart repository or cannot be reached", o.url) return errors.Wrapf(err, "looks like %q is not a valid chart repository or cannot be reached", o.url)
} }

@ -38,7 +38,7 @@ func newRepoListCmd(out io.Writer) *cobra.Command {
Args: require.NoArgs, Args: require.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
f, err := repo.LoadFile(settings.RepositoryConfig) f, err := repo.LoadFile(settings.RepositoryConfig)
if isNotExist(err) || len(f.Repositories) == 0 { if isNotExist(err) || (len(f.Repositories) == 0 && !(outfmt == output.JSON || outfmt == output.YAML)) {
return errors.New("no repositories to show") return errors.New("no repositories to show")
} }

@ -39,6 +39,7 @@ var errNoRepositories = errors.New("no repositories found. You must add one befo
type repoUpdateOptions struct { type repoUpdateOptions struct {
update func([]*repo.ChartRepository, io.Writer) update func([]*repo.ChartRepository, io.Writer)
repoFile string repoFile string
repoCache string
} }
func newRepoUpdateCmd(out io.Writer) *cobra.Command { func newRepoUpdateCmd(out io.Writer) *cobra.Command {
@ -52,6 +53,7 @@ func newRepoUpdateCmd(out io.Writer) *cobra.Command {
Args: require.NoArgs, Args: require.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
o.repoFile = settings.RepositoryConfig o.repoFile = settings.RepositoryConfig
o.repoCache = settings.RepositoryCache
return o.run(out) return o.run(out)
}, },
} }
@ -69,6 +71,9 @@ func (o *repoUpdateOptions) run(out io.Writer) error {
if err != nil { if err != nil {
return err return err
} }
if o.repoCache != "" {
r.CachePath = o.repoCache
}
repos = append(repos, r) repos = append(repos, r)
} }

@ -19,6 +19,8 @@ import (
"bytes" "bytes"
"fmt" "fmt"
"io" "io"
"os"
"path/filepath"
"strings" "strings"
"testing" "testing"
@ -50,6 +52,25 @@ func TestUpdateCmd(t *testing.T) {
} }
} }
func TestUpdateCustomCacheCmd(t *testing.T) {
var out bytes.Buffer
rootDir := ensure.TempDir(t)
cachePath := filepath.Join(rootDir, "updcustomcache")
_ = os.Mkdir(cachePath, os.ModePerm)
defer os.RemoveAll(cachePath)
o := &repoUpdateOptions{
update: updateCharts,
repoFile: "testdata/repositories.yaml",
repoCache: cachePath,
}
if err := o.run(&out); err != nil {
t.Fatal(err)
}
if _, err := os.Stat(filepath.Join(cachePath, "charts-index.yaml")); err != nil {
t.Fatalf("error finding created index file in custom cache: %#v", err)
}
}
func TestUpdateCharts(t *testing.T) { func TestUpdateCharts(t *testing.T) {
defer resetEnv()() defer resetEnv()()
defer ensure.HelmHome(t)() defer ensure.HelmHome(t)()

@ -43,33 +43,29 @@ Common actions for Helm:
Environment variables: Environment variables:
+------------------+--------------------------------------------------------------------------------------------------------+
| Name | Description | | Name | Description |
+------------------+--------------------------------------------------------------------------------------------------------+ |------------------------------------|-----------------------------------------------------------------------------------|
| $XDG_CACHE_HOME | set an alternative location for storing cached files. | | $HELM_CACHE_HOME | set an alternative location for storing cached files. |
| $XDG_CONFIG_HOME | set an alternative location for storing Helm configuration. | | $HELM_CONFIG_HOME | set an alternative location for storing Helm configuration. |
| $XDG_DATA_HOME | set an alternative location for storing Helm data. | | $HELM_DATA_HOME | set an alternative location for storing Helm data. |
| $HELM_DRIVER | set the backend storage driver. Values are: configmap, secret, memory, postgres | | $HELM_DRIVER | set the backend storage driver. Values are: configmap, secret, memory, postgres |
| $HELM_DRIVER_SQL_CONNECTION_STRING | set the connection string the SQL storage driver should use. | | $HELM_DRIVER_SQL_CONNECTION_STRING | set the connection string the SQL storage driver should use. |
| $HELM_NO_PLUGINS | disable plugins. Set HELM_NO_PLUGINS=1 to disable plugins. | | $HELM_NO_PLUGINS | disable plugins. Set HELM_NO_PLUGINS=1 to disable plugins. |
| $KUBECONFIG | set an alternative Kubernetes configuration file (default "~/.kube/config") | | $KUBECONFIG | set an alternative Kubernetes configuration file (default "~/.kube/config") |
+------------------+--------------------------------------------------------------------------------------------------------+
Helm stores configuration based on the XDG base directory specification, so Helm stores cache, configuration, and data based on the following configuration order:
- cached files are stored in $XDG_CACHE_HOME/helm - If a HELM_*_HOME environment variable is set, it will be used
- configuration is stored in $XDG_CONFIG_HOME/helm - Otherwise, on systems supporting the XDG base directory specification, the XDG variables will be used
- data is stored in $XDG_DATA_HOME/helm - When no other location is set a default location will be used based on the operating system
By default, the default directories depend on the Operating System. The defaults are listed below: By default, the default directories depend on the Operating System. The defaults are listed below:
+------------------+---------------------------+--------------------------------+-------------------------+
| Operating System | Cache Path | Configuration Path | Data Path | | Operating System | Cache Path | Configuration Path | Data Path |
+------------------+---------------------------+--------------------------------+-------------------------+ |------------------|---------------------------|--------------------------------|-------------------------|
| Linux | $HOME/.cache/helm | $HOME/.config/helm | $HOME/.local/share/helm | | Linux | $HOME/.cache/helm | $HOME/.config/helm | $HOME/.local/share/helm |
| macOS | $HOME/Library/Caches/helm | $HOME/Library/Preferences/helm | $HOME/Library/helm | | macOS | $HOME/Library/Caches/helm | $HOME/Library/Preferences/helm | $HOME/Library/helm |
| Windows | %TEMP%\helm | %APPDATA%\helm | %APPDATA%\helm | | Windows | %TEMP%\helm | %APPDATA%\helm | %APPDATA%\helm |
+------------------+---------------------------+--------------------------------+-------------------------+
` `
func newRootCmd(actionConfig *action.Configuration, out io.Writer, args []string) *cobra.Command { func newRootCmd(actionConfig *action.Configuration, out io.Writer, args []string) *cobra.Command {

@ -55,6 +55,24 @@ func TestRootCmd(t *testing.T) {
envvars: map[string]string{xdg.DataHomeEnvVar: "/bar"}, envvars: map[string]string{xdg.DataHomeEnvVar: "/bar"},
dataPath: "/bar/helm", dataPath: "/bar/helm",
}, },
{
name: "with $HELM_CACHE_HOME set",
args: "env",
envvars: map[string]string{helmpath.CacheHomeEnvVar: "/foo/helm"},
cachePath: "/foo/helm",
},
{
name: "with $HELM_CONFIG_HOME set",
args: "env",
envvars: map[string]string{helmpath.ConfigHomeEnvVar: "/foo/helm"},
configPath: "/foo/helm",
},
{
name: "with $HELM_DATA_HOME set",
args: "env",
envvars: map[string]string{helmpath.DataHomeEnvVar: "/foo/helm"},
dataPath: "/foo/helm",
},
} }
for _, tt := range tests { for _, tt := range tests {

@ -72,7 +72,7 @@ func newShowCmd(out io.Writer) *cobra.Command {
all := &cobra.Command{ all := &cobra.Command{
Use: "all [CHART]", Use: "all [CHART]",
Short: "shows all information of the chart", Short: "show all information of the chart",
Long: showAllDesc, Long: showAllDesc,
Args: require.ExactArgs(1), Args: require.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
@ -88,7 +88,7 @@ func newShowCmd(out io.Writer) *cobra.Command {
valuesSubCmd := &cobra.Command{ valuesSubCmd := &cobra.Command{
Use: "values [CHART]", Use: "values [CHART]",
Short: "shows the chart's values", Short: "show the chart's values",
Long: showValuesDesc, Long: showValuesDesc,
Args: require.ExactArgs(1), Args: require.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
@ -104,7 +104,7 @@ func newShowCmd(out io.Writer) *cobra.Command {
chartSubCmd := &cobra.Command{ chartSubCmd := &cobra.Command{
Use: "chart [CHART]", Use: "chart [CHART]",
Short: "shows the chart's definition", Short: "show the chart's definition",
Long: showChartDesc, Long: showChartDesc,
Args: require.ExactArgs(1), Args: require.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
@ -120,7 +120,7 @@ func newShowCmd(out io.Writer) *cobra.Command {
readmeSubCmd := &cobra.Command{ readmeSubCmd := &cobra.Command{
Use: "readme [CHART]", Use: "readme [CHART]",
Short: "shows the chart's README", Short: "show the chart's README",
Long: readmeChartDesc, Long: readmeChartDesc,
Args: require.ExactArgs(1), Args: require.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {

@ -50,7 +50,7 @@ func newStatusCmd(cfg *action.Configuration, out io.Writer) *cobra.Command {
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "status RELEASE_NAME", Use: "status RELEASE_NAME",
Short: "displays the status of the named release", Short: "display the status of the named release",
Long: statusHelp, Long: statusHelp,
Args: require.ExactArgs(1), Args: require.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {

@ -22,7 +22,7 @@ import (
"testing" "testing"
) )
var chartPath = "./../../pkg/chartutil/testdata/subpop/charts/subchart1" var chartPath = "testdata/testcharts/subchart"
func TestTemplateCmd(t *testing.T) { func TestTemplateCmd(t *testing.T) {
tests := []cmdTestCase{ tests := []cmdTestCase{

@ -1,34 +1,34 @@
--- ---
# Source: subchart1/templates/subdir/serviceaccount.yaml # Source: subchart/templates/subdir/serviceaccount.yaml
apiVersion: v1 apiVersion: v1
kind: ServiceAccount kind: ServiceAccount
metadata: metadata:
name: subchart1-sa name: subchart-sa
--- ---
# Source: subchart1/templates/subdir/role.yaml # Source: subchart/templates/subdir/role.yaml
apiVersion: rbac.authorization.k8s.io/v1 apiVersion: rbac.authorization.k8s.io/v1
kind: Role kind: Role
metadata: metadata:
name: subchart1-role name: subchart-role
rules: rules:
- resources: ["*"] - resources: ["*"]
verbs: ["get","list","watch"] verbs: ["get","list","watch"]
--- ---
# Source: subchart1/templates/subdir/rolebinding.yaml # Source: subchart/templates/subdir/rolebinding.yaml
apiVersion: rbac.authorization.k8s.io/v1 apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding kind: RoleBinding
metadata: metadata:
name: subchart1-binding name: subchart-binding
roleRef: roleRef:
apiGroup: rbac.authorization.k8s.io apiGroup: rbac.authorization.k8s.io
kind: Role kind: Role
name: subchart1-role name: subchart-role
subjects: subjects:
- kind: ServiceAccount - kind: ServiceAccount
name: subchart1-sa name: subchart-sa
namespace: default namespace: default
--- ---
# Source: subchart1/charts/subcharta/templates/service.yaml # Source: subchart/charts/subcharta/templates/service.yaml
apiVersion: v1 apiVersion: v1
kind: Service kind: Service
metadata: metadata:
@ -45,7 +45,7 @@ spec:
selector: selector:
app.kubernetes.io/name: subcharta app.kubernetes.io/name: subcharta
--- ---
# Source: subchart1/charts/subchartb/templates/service.yaml # Source: subchart/charts/subchartb/templates/service.yaml
apiVersion: v1 apiVersion: v1
kind: Service kind: Service
metadata: metadata:
@ -62,17 +62,17 @@ spec:
selector: selector:
app.kubernetes.io/name: subchartb app.kubernetes.io/name: subchartb
--- ---
# Source: subchart1/templates/service.yaml # Source: subchart/templates/service.yaml
apiVersion: v1 apiVersion: v1
kind: Service kind: Service
metadata: metadata:
name: subchart1 name: subchart
labels: labels:
helm.sh/chart: "subchart1-0.1.0" helm.sh/chart: "subchart-0.1.0"
app.kubernetes.io/instance: "foobar-YWJj-baz" app.kubernetes.io/instance: "foobar-YWJj-baz"
kube-version/major: "1" kube-version/major: "1"
kube-version/minor: "16" kube-version/minor: "18"
kube-version/version: "v1.16.0" kube-version/version: "v1.18.0"
spec: spec:
type: ClusterIP type: ClusterIP
ports: ports:
@ -81,4 +81,4 @@ spec:
protocol: TCP protocol: TCP
name: nginx name: nginx
selector: selector:
app.kubernetes.io/name: subchart1 app.kubernetes.io/name: subchart

@ -1,34 +1,34 @@
--- ---
# Source: subchart1/templates/subdir/serviceaccount.yaml # Source: subchart/templates/subdir/serviceaccount.yaml
apiVersion: v1 apiVersion: v1
kind: ServiceAccount kind: ServiceAccount
metadata: metadata:
name: subchart1-sa name: subchart-sa
--- ---
# Source: subchart1/templates/subdir/role.yaml # Source: subchart/templates/subdir/role.yaml
apiVersion: rbac.authorization.k8s.io/v1 apiVersion: rbac.authorization.k8s.io/v1
kind: Role kind: Role
metadata: metadata:
name: subchart1-role name: subchart-role
rules: rules:
- resources: ["*"] - resources: ["*"]
verbs: ["get","list","watch"] verbs: ["get","list","watch"]
--- ---
# Source: subchart1/templates/subdir/rolebinding.yaml # Source: subchart/templates/subdir/rolebinding.yaml
apiVersion: rbac.authorization.k8s.io/v1 apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding kind: RoleBinding
metadata: metadata:
name: subchart1-binding name: subchart-binding
roleRef: roleRef:
apiGroup: rbac.authorization.k8s.io apiGroup: rbac.authorization.k8s.io
kind: Role kind: Role
name: subchart1-role name: subchart-role
subjects: subjects:
- kind: ServiceAccount - kind: ServiceAccount
name: subchart1-sa name: subchart-sa
namespace: default namespace: default
--- ---
# Source: subchart1/charts/subcharta/templates/service.yaml # Source: subchart/charts/subcharta/templates/service.yaml
apiVersion: v1 apiVersion: v1
kind: Service kind: Service
metadata: metadata:
@ -45,7 +45,7 @@ spec:
selector: selector:
app.kubernetes.io/name: subcharta app.kubernetes.io/name: subcharta
--- ---
# Source: subchart1/charts/subchartb/templates/service.yaml # Source: subchart/charts/subchartb/templates/service.yaml
apiVersion: v1 apiVersion: v1
kind: Service kind: Service
metadata: metadata:
@ -62,17 +62,17 @@ spec:
selector: selector:
app.kubernetes.io/name: subchartb app.kubernetes.io/name: subchartb
--- ---
# Source: subchart1/templates/service.yaml # Source: subchart/templates/service.yaml
apiVersion: v1 apiVersion: v1
kind: Service kind: Service
metadata: metadata:
name: subchart1 name: subchart
labels: labels:
helm.sh/chart: "subchart1-0.1.0" helm.sh/chart: "subchart-0.1.0"
app.kubernetes.io/instance: "RELEASE-NAME" app.kubernetes.io/instance: "RELEASE-NAME"
kube-version/major: "1" kube-version/major: "1"
kube-version/minor: "16" kube-version/minor: "18"
kube-version/version: "v1.16.0" kube-version/version: "v1.18.0"
spec: spec:
type: ClusterIP type: ClusterIP
ports: ports:
@ -81,4 +81,4 @@ spec:
protocol: TCP protocol: TCP
name: apache name: apache
selector: selector:
app.kubernetes.io/name: subchart1 app.kubernetes.io/name: subchart

@ -1,23 +1,23 @@
--- ---
# Source: subchart1/templates/subdir/role.yaml # Source: subchart/templates/subdir/role.yaml
apiVersion: rbac.authorization.k8s.io/v1 apiVersion: rbac.authorization.k8s.io/v1
kind: Role kind: Role
metadata: metadata:
name: subchart1-role name: subchart-role
rules: rules:
- resources: ["*"] - resources: ["*"]
verbs: ["get","list","watch"] verbs: ["get","list","watch"]
--- ---
# Source: subchart1/templates/subdir/rolebinding.yaml # Source: subchart/templates/subdir/rolebinding.yaml
apiVersion: rbac.authorization.k8s.io/v1 apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding kind: RoleBinding
metadata: metadata:
name: subchart1-binding name: subchart-binding
roleRef: roleRef:
apiGroup: rbac.authorization.k8s.io apiGroup: rbac.authorization.k8s.io
kind: Role kind: Role
name: subchart1-role name: subchart-role
subjects: subjects:
- kind: ServiceAccount - kind: ServiceAccount
name: subchart1-sa name: subchart-sa
namespace: default namespace: default

@ -1,15 +1,15 @@
--- ---
# Source: subchart1/templates/service.yaml # Source: subchart/templates/service.yaml
apiVersion: v1 apiVersion: v1
kind: Service kind: Service
metadata: metadata:
name: subchart1 name: subchart
labels: labels:
helm.sh/chart: "subchart1-0.1.0" helm.sh/chart: "subchart-0.1.0"
app.kubernetes.io/instance: "RELEASE-NAME" app.kubernetes.io/instance: "RELEASE-NAME"
kube-version/major: "1" kube-version/major: "1"
kube-version/minor: "16" kube-version/minor: "18"
kube-version/version: "v1.16.0" kube-version/version: "v1.18.0"
kube-api-version/test: v1 kube-api-version/test: v1
spec: spec:
type: ClusterIP type: ClusterIP
@ -19,9 +19,9 @@ spec:
protocol: TCP protocol: TCP
name: nginx name: nginx
selector: selector:
app.kubernetes.io/name: subchart1 app.kubernetes.io/name: subchart
--- ---
# Source: subchart1/charts/subcharta/templates/service.yaml # Source: subchart/charts/subcharta/templates/service.yaml
apiVersion: v1 apiVersion: v1
kind: Service kind: Service
metadata: metadata:

@ -1,15 +1,15 @@
--- ---
# Source: subchart1/templates/service.yaml # Source: subchart/templates/service.yaml
apiVersion: v1 apiVersion: v1
kind: Service kind: Service
metadata: metadata:
name: subchart1 name: subchart
labels: labels:
helm.sh/chart: "subchart1-0.1.0" helm.sh/chart: "subchart-0.1.0"
app.kubernetes.io/instance: "RELEASE-NAME" app.kubernetes.io/instance: "RELEASE-NAME"
kube-version/major: "1" kube-version/major: "1"
kube-version/minor: "16" kube-version/minor: "18"
kube-version/version: "v1.16.0" kube-version/version: "v1.18.0"
kube-api-version/test: v1 kube-api-version/test: v1
spec: spec:
type: ClusterIP type: ClusterIP
@ -19,4 +19,4 @@ spec:
protocol: TCP protocol: TCP
name: nginx name: nginx
selector: selector:
app.kubernetes.io/name: subchart1 app.kubernetes.io/name: subchart

@ -1,34 +1,34 @@
--- ---
# Source: subchart1/templates/subdir/serviceaccount.yaml # Source: subchart/templates/subdir/serviceaccount.yaml
apiVersion: v1 apiVersion: v1
kind: ServiceAccount kind: ServiceAccount
metadata: metadata:
name: subchart1-sa name: subchart-sa
--- ---
# Source: subchart1/templates/subdir/role.yaml # Source: subchart/templates/subdir/role.yaml
apiVersion: rbac.authorization.k8s.io/v1 apiVersion: rbac.authorization.k8s.io/v1
kind: Role kind: Role
metadata: metadata:
name: subchart1-role name: subchart-role
rules: rules:
- resources: ["*"] - resources: ["*"]
verbs: ["get","list","watch"] verbs: ["get","list","watch"]
--- ---
# Source: subchart1/templates/subdir/rolebinding.yaml # Source: subchart/templates/subdir/rolebinding.yaml
apiVersion: rbac.authorization.k8s.io/v1 apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding kind: RoleBinding
metadata: metadata:
name: subchart1-binding name: subchart-binding
roleRef: roleRef:
apiGroup: rbac.authorization.k8s.io apiGroup: rbac.authorization.k8s.io
kind: Role kind: Role
name: subchart1-role name: subchart-role
subjects: subjects:
- kind: ServiceAccount - kind: ServiceAccount
name: subchart1-sa name: subchart-sa
namespace: default namespace: default
--- ---
# Source: subchart1/charts/subcharta/templates/service.yaml # Source: subchart/charts/subcharta/templates/service.yaml
apiVersion: v1 apiVersion: v1
kind: Service kind: Service
metadata: metadata:
@ -45,7 +45,7 @@ spec:
selector: selector:
app.kubernetes.io/name: subcharta app.kubernetes.io/name: subcharta
--- ---
# Source: subchart1/charts/subchartb/templates/service.yaml # Source: subchart/charts/subchartb/templates/service.yaml
apiVersion: v1 apiVersion: v1
kind: Service kind: Service
metadata: metadata:
@ -62,17 +62,17 @@ spec:
selector: selector:
app.kubernetes.io/name: subchartb app.kubernetes.io/name: subchartb
--- ---
# Source: subchart1/templates/service.yaml # Source: subchart/templates/service.yaml
apiVersion: v1 apiVersion: v1
kind: Service kind: Service
metadata: metadata:
name: subchart1 name: subchart
labels: labels:
helm.sh/chart: "subchart1-0.1.0" helm.sh/chart: "subchart-0.1.0"
app.kubernetes.io/instance: "RELEASE-NAME" app.kubernetes.io/instance: "RELEASE-NAME"
kube-version/major: "1" kube-version/major: "1"
kube-version/minor: "16" kube-version/minor: "18"
kube-version/version: "v1.16.0" kube-version/version: "v1.18.0"
spec: spec:
type: ClusterIP type: ClusterIP
ports: ports:
@ -81,4 +81,4 @@ spec:
protocol: TCP protocol: TCP
name: apache name: apache
selector: selector:
app.kubernetes.io/name: subchart1 app.kubernetes.io/name: subchart

@ -1,34 +1,34 @@
--- ---
# Source: subchart1/templates/subdir/serviceaccount.yaml # Source: subchart/templates/subdir/serviceaccount.yaml
apiVersion: v1 apiVersion: v1
kind: ServiceAccount kind: ServiceAccount
metadata: metadata:
name: subchart1-sa name: subchart-sa
--- ---
# Source: subchart1/templates/subdir/role.yaml # Source: subchart/templates/subdir/role.yaml
apiVersion: rbac.authorization.k8s.io/v1 apiVersion: rbac.authorization.k8s.io/v1
kind: Role kind: Role
metadata: metadata:
name: subchart1-role name: subchart-role
rules: rules:
- resources: ["*"] - resources: ["*"]
verbs: ["get","list","watch"] verbs: ["get","list","watch"]
--- ---
# Source: subchart1/templates/subdir/rolebinding.yaml # Source: subchart/templates/subdir/rolebinding.yaml
apiVersion: rbac.authorization.k8s.io/v1 apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding kind: RoleBinding
metadata: metadata:
name: subchart1-binding name: subchart-binding
roleRef: roleRef:
apiGroup: rbac.authorization.k8s.io apiGroup: rbac.authorization.k8s.io
kind: Role kind: Role
name: subchart1-role name: subchart-role
subjects: subjects:
- kind: ServiceAccount - kind: ServiceAccount
name: subchart1-sa name: subchart-sa
namespace: default namespace: default
--- ---
# Source: subchart1/charts/subcharta/templates/service.yaml # Source: subchart/charts/subcharta/templates/service.yaml
apiVersion: v1 apiVersion: v1
kind: Service kind: Service
metadata: metadata:
@ -45,7 +45,7 @@ spec:
selector: selector:
app.kubernetes.io/name: subcharta app.kubernetes.io/name: subcharta
--- ---
# Source: subchart1/charts/subchartb/templates/service.yaml # Source: subchart/charts/subchartb/templates/service.yaml
apiVersion: v1 apiVersion: v1
kind: Service kind: Service
metadata: metadata:
@ -62,17 +62,17 @@ spec:
selector: selector:
app.kubernetes.io/name: subchartb app.kubernetes.io/name: subchartb
--- ---
# Source: subchart1/templates/service.yaml # Source: subchart/templates/service.yaml
apiVersion: v1 apiVersion: v1
kind: Service kind: Service
metadata: metadata:
name: subchart1 name: subchart
labels: labels:
helm.sh/chart: "subchart1-0.1.0" helm.sh/chart: "subchart-0.1.0"
app.kubernetes.io/instance: "RELEASE-NAME" app.kubernetes.io/instance: "RELEASE-NAME"
kube-version/major: "1" kube-version/major: "1"
kube-version/minor: "16" kube-version/minor: "18"
kube-version/version: "v1.16.0" kube-version/version: "v1.18.0"
kube-api-version/test: v1 kube-api-version/test: v1
spec: spec:
type: ClusterIP type: ClusterIP
@ -82,4 +82,4 @@ spec:
protocol: TCP protocol: TCP
name: nginx name: nginx
selector: selector:
app.kubernetes.io/name: subchart1 app.kubernetes.io/name: subchart

@ -15,36 +15,36 @@ spec:
singular: authconfig singular: authconfig
--- ---
# Source: subchart1/templates/subdir/serviceaccount.yaml # Source: subchart/templates/subdir/serviceaccount.yaml
apiVersion: v1 apiVersion: v1
kind: ServiceAccount kind: ServiceAccount
metadata: metadata:
name: subchart1-sa name: subchart-sa
--- ---
# Source: subchart1/templates/subdir/role.yaml # Source: subchart/templates/subdir/role.yaml
apiVersion: rbac.authorization.k8s.io/v1 apiVersion: rbac.authorization.k8s.io/v1
kind: Role kind: Role
metadata: metadata:
name: subchart1-role name: subchart-role
rules: rules:
- resources: ["*"] - resources: ["*"]
verbs: ["get","list","watch"] verbs: ["get","list","watch"]
--- ---
# Source: subchart1/templates/subdir/rolebinding.yaml # Source: subchart/templates/subdir/rolebinding.yaml
apiVersion: rbac.authorization.k8s.io/v1 apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding kind: RoleBinding
metadata: metadata:
name: subchart1-binding name: subchart-binding
roleRef: roleRef:
apiGroup: rbac.authorization.k8s.io apiGroup: rbac.authorization.k8s.io
kind: Role kind: Role
name: subchart1-role name: subchart-role
subjects: subjects:
- kind: ServiceAccount - kind: ServiceAccount
name: subchart1-sa name: subchart-sa
namespace: default namespace: default
--- ---
# Source: subchart1/charts/subcharta/templates/service.yaml # Source: subchart/charts/subcharta/templates/service.yaml
apiVersion: v1 apiVersion: v1
kind: Service kind: Service
metadata: metadata:
@ -61,7 +61,7 @@ spec:
selector: selector:
app.kubernetes.io/name: subcharta app.kubernetes.io/name: subcharta
--- ---
# Source: subchart1/charts/subchartb/templates/service.yaml # Source: subchart/charts/subchartb/templates/service.yaml
apiVersion: v1 apiVersion: v1
kind: Service kind: Service
metadata: metadata:
@ -78,17 +78,17 @@ spec:
selector: selector:
app.kubernetes.io/name: subchartb app.kubernetes.io/name: subchartb
--- ---
# Source: subchart1/templates/service.yaml # Source: subchart/templates/service.yaml
apiVersion: v1 apiVersion: v1
kind: Service kind: Service
metadata: metadata:
name: subchart1 name: subchart
labels: labels:
helm.sh/chart: "subchart1-0.1.0" helm.sh/chart: "subchart-0.1.0"
app.kubernetes.io/instance: "RELEASE-NAME" app.kubernetes.io/instance: "RELEASE-NAME"
kube-version/major: "1" kube-version/major: "1"
kube-version/minor: "16" kube-version/minor: "18"
kube-version/version: "v1.16.0" kube-version/version: "v1.18.0"
kube-api-version/test: v1 kube-api-version/test: v1
spec: spec:
type: ClusterIP type: ClusterIP
@ -98,4 +98,4 @@ spec:
protocol: TCP protocol: TCP
name: nginx name: nginx
selector: selector:
app.kubernetes.io/name: subchart1 app.kubernetes.io/name: subchart

@ -1,34 +1,34 @@
--- ---
# Source: subchart1/templates/subdir/serviceaccount.yaml # Source: subchart/templates/subdir/serviceaccount.yaml
apiVersion: v1 apiVersion: v1
kind: ServiceAccount kind: ServiceAccount
metadata: metadata:
name: subchart1-sa name: subchart-sa
--- ---
# Source: subchart1/templates/subdir/role.yaml # Source: subchart/templates/subdir/role.yaml
apiVersion: rbac.authorization.k8s.io/v1 apiVersion: rbac.authorization.k8s.io/v1
kind: Role kind: Role
metadata: metadata:
name: subchart1-role name: subchart-role
rules: rules:
- resources: ["*"] - resources: ["*"]
verbs: ["get","list","watch"] verbs: ["get","list","watch"]
--- ---
# Source: subchart1/templates/subdir/rolebinding.yaml # Source: subchart/templates/subdir/rolebinding.yaml
apiVersion: rbac.authorization.k8s.io/v1 apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding kind: RoleBinding
metadata: metadata:
name: subchart1-binding name: subchart-binding
roleRef: roleRef:
apiGroup: rbac.authorization.k8s.io apiGroup: rbac.authorization.k8s.io
kind: Role kind: Role
name: subchart1-role name: subchart-role
subjects: subjects:
- kind: ServiceAccount - kind: ServiceAccount
name: subchart1-sa name: subchart-sa
namespace: default namespace: default
--- ---
# Source: subchart1/charts/subcharta/templates/service.yaml # Source: subchart/charts/subcharta/templates/service.yaml
apiVersion: v1 apiVersion: v1
kind: Service kind: Service
metadata: metadata:
@ -45,7 +45,7 @@ spec:
selector: selector:
app.kubernetes.io/name: subcharta app.kubernetes.io/name: subcharta
--- ---
# Source: subchart1/charts/subchartb/templates/service.yaml # Source: subchart/charts/subchartb/templates/service.yaml
apiVersion: v1 apiVersion: v1
kind: Service kind: Service
metadata: metadata:
@ -62,17 +62,17 @@ spec:
selector: selector:
app.kubernetes.io/name: subchartb app.kubernetes.io/name: subchartb
--- ---
# Source: subchart1/templates/service.yaml # Source: subchart/templates/service.yaml
apiVersion: v1 apiVersion: v1
kind: Service kind: Service
metadata: metadata:
name: subchart1 name: subchart
labels: labels:
helm.sh/chart: "subchart1-0.1.0" helm.sh/chart: "subchart-0.1.0"
app.kubernetes.io/instance: "RELEASE-NAME" app.kubernetes.io/instance: "RELEASE-NAME"
kube-version/major: "1" kube-version/major: "1"
kube-version/minor: "16" kube-version/minor: "18"
kube-version/version: "v1.16.0" kube-version/version: "v1.18.0"
spec: spec:
type: ClusterIP type: ClusterIP
ports: ports:
@ -81,4 +81,4 @@ spec:
protocol: TCP protocol: TCP
name: nginx name: nginx
selector: selector:
app.kubernetes.io/name: subchart1 app.kubernetes.io/name: subchart

@ -1 +1 @@
version.BuildInfo{Version:"v3.1", GitCommit:"", GitTreeState:"", GoVersion:""} version.BuildInfo{Version:"v3.2", GitCommit:"", GitTreeState:"", GoVersion:""}

@ -1 +1 @@
version.BuildInfo{Version:"v3.1", GitCommit:"", GitTreeState:"", GoVersion:""} version.BuildInfo{Version:"v3.2", GitCommit:"", GitTreeState:"", GoVersion:""}

@ -1 +1 @@
Version: v3.1 Version: v3.2

@ -1 +1 @@
version.BuildInfo{Version:"v3.1", GitCommit:"", GitTreeState:"", GoVersion:""} version.BuildInfo{Version:"v3.2", GitCommit:"", GitTreeState:"", GoVersion:""}

@ -0,0 +1,2 @@
name: chart-with-missing-deps
version: 2.1.8

@ -0,0 +1,2 @@
name: chart-with-compressed-dependencies
version: 2.1.8

@ -1 +0,0 @@
justAValue: "an example chart here"

@ -2,4 +2,22 @@
# This supports shell glob matching, relative path matching, and # This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line. # negation (prefixed with !). Only one pattern per line.
.DS_Store .DS_Store
.git # Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/

@ -0,0 +1,21 @@
apiVersion: v2
name: crd-test
description: A Helm chart for Kubernetes
# A chart can be either an 'application' or a 'library' chart.
#
# Application charts are a collection of templates that can be packaged into versioned archives
# to be deployed.
#
# Library charts provide useful utilities or functions for the chart developer. They're included as
# a dependency of application charts to inject those utilities and functions into the rendering
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
version: 0.1.0
# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application.
appVersion: 1.16.0

@ -0,0 +1,19 @@
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
name: tests.test.io
spec:
group: test.io
names:
kind: Test
listKind: TestList
plural: tests
singular: test
scope: Namespaced
versions:
- name : v1alpha2
served: true
storage: true
- name : v1alpha1
served: true
storage: false

@ -1,8 +0,0 @@
apiVersion: v1
description: Deploy a basic Alpine Linux pod
home: https://helm.sh/helm
name: novals
sources:
- https://github.com/helm/helm
version: 0.2.0
appVersion: 3.3

@ -1,13 +0,0 @@
#Alpine: A simple Helm chart
Run a single pod of Alpine Linux.
This example was generated using the command `helm create alpine`.
The `templates/` directory contains a very simple pod resource with a
couple of parameters.
The `values.yaml` file contains the default values for the
`alpine-pod.yaml` template.
You can install this example using `helm install ./alpine`.

@ -1,28 +0,0 @@
apiVersion: v1
kind: Pod
metadata:
name: "{{.Release.Name}}-{{.Values.Name}}"
labels:
# The "app.kubernetes.io/managed-by" label is used to track which tool
# deployed a given chart. It is useful for admins who want to see what
# releases a particular tool is responsible for.
app.kubernetes.io/managed-by: {{.Release.Service | quote }}
# The "app.kubernetes.io/instance" convention makes it easy to tie a release
# to all of the Kubernetes resources that were created as part of that
# release.
app.kubernetes.io/instance: {{.Release.Name | quote }}
app.kubernetes.io/version: {{ .Chart.AppVersion }}
# This makes it easy to audit chart usage.
helm.sh/chart: "{{.Chart.Name}}-{{.Chart.Version}}"
annotations:
"helm.sh/created": {{.Release.Time.Seconds | quote }}
spec:
# This shows how to use a simple value. This will look for a passed-in value
# called restartPolicy. If it is not found, it will use the default value.
# {{default "Never" .restartPolicy}} is a slightly optimized version of the
# more conventional syntax: {{.restartPolicy | default "Never"}}
restartPolicy: {{default "Never" .Values.restartPolicy}}
containers:
- name: waiter
image: "alpine:3.3"
command: ["/bin/sleep","9000"]

@ -0,0 +1,36 @@
apiVersion: v1
description: A Helm chart for Kubernetes
name: subchart
version: 0.1.0
dependencies:
- name: subcharta
repository: http://localhost:10191
version: 0.1.0
condition: subcharta.enabled
tags:
- front-end
- subcharta
import-values:
- child: SCAdata
parent: imported-chartA
- child: SCAdata
parent: overridden-chartA
- child: SCAdata
parent: imported-chartA-B
- name: subchartb
repository: http://localhost:10191
version: 0.1.0
condition: subchartb.enabled
import-values:
- child: SCBdata
parent: imported-chartB
- child: SCBdata
parent: imported-chartA-B
- child: exports.SCBexported2
parent: exports.SCBexported2
- SCBexported1
tags:
- front-end
- subchartb

@ -1,4 +1,4 @@
apiVersion: v1 apiVersion: v1
description: A Helm chart for Kubernetes description: A Helm chart for Kubernetes
name: ahab name: subcharta
version: 0.1.0 version: 0.1.0

@ -0,0 +1,15 @@
apiVersion: v1
kind: Service
metadata:
name: {{ .Chart.Name }}
labels:
helm.sh/chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
spec:
type: {{ .Values.service.type }}
ports:
- port: {{ .Values.service.externalPort }}
targetPort: {{ .Values.service.internalPort }}
protocol: TCP
name: {{ .Values.service.name }}
selector:
app.kubernetes.io/name: {{ .Chart.Name }}

@ -0,0 +1,17 @@
# Default values for subchart.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.
# subchartA
service:
name: apache
type: ClusterIP
externalPort: 80
internalPort: 80
SCAdata:
SCAbool: false
SCAfloat: 3.1
SCAint: 55
SCAstring: "jabba"
SCAnested1:
SCAnested2: true

@ -1,4 +1,4 @@
apiVersion: v1 apiVersion: v1
description: A Helm chart for Kubernetes description: A Helm chart for Kubernetes
name: spouter name: subchartb
version: 0.1.0 version: 0.1.0

@ -0,0 +1,15 @@
apiVersion: v1
kind: Service
metadata:
name: {{ .Chart.Name }}
labels:
helm.sh/chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
spec:
type: {{ .Values.service.type }}
ports:
- port: {{ .Values.service.externalPort }}
targetPort: {{ .Values.service.internalPort }}
protocol: TCP
name: {{ .Values.service.name }}
selector:
app.kubernetes.io/name: {{ .Chart.Name }}

@ -0,0 +1,35 @@
# Default values for subchart.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.
service:
name: nginx
type: ClusterIP
externalPort: 80
internalPort: 80
SCBdata:
SCBbool: true
SCBfloat: 7.77
SCBint: 33
SCBstring: "boba"
exports:
SCBexported1:
SCBexported1A:
SCBexported1B: 1965
SCBexported2:
SCBexported2A: "blaster"
global:
kolla:
nova:
api:
all:
port: 8774
metadata:
all:
port: 8775

@ -0,0 +1,13 @@
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
name: testCRDs
spec:
group: testCRDGroups
names:
kind: TestCRD
listKind: TestCRDList
plural: TestCRDs
shortNames:
- tc
singular: authconfig

@ -0,0 +1 @@
Sample notes for {{ .Chart.Name }}

@ -0,0 +1,22 @@
apiVersion: v1
kind: Service
metadata:
name: {{ .Chart.Name }}
labels:
helm.sh/chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
app.kubernetes.io/instance: "{{ .Release.Name }}"
kube-version/major: "{{ .Capabilities.KubeVersion.Major }}"
kube-version/minor: "{{ .Capabilities.KubeVersion.Minor }}"
kube-version/version: "v{{ .Capabilities.KubeVersion.Major }}.{{ .Capabilities.KubeVersion.Minor }}.0"
{{- if .Capabilities.APIVersions.Has "helm.k8s.io/test" }}
kube-api-version/test: v1
{{- end }}
spec:
type: {{ .Values.service.type }}
ports:
- port: {{ .Values.service.externalPort }}
targetPort: {{ .Values.service.internalPort }}
protocol: TCP
name: {{ .Values.service.name }}
selector:
app.kubernetes.io/name: {{ .Chart.Name }}

@ -0,0 +1,7 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: {{ .Chart.Name }}-role
rules:
- resources: ["*"]
verbs: ["get","list","watch"]

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save