Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
H
helm3
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
helm3
Commits
7dd6eb22
Commit
7dd6eb22
authored
May 26, 2017
by
Taylor Thomas
Committed by
GitHub
May 26, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2486 from sushilkm/issues/2383
Adds alias for dependencies
parents
e45d93fb
351dfea5
Hide whitespace changes
Inline
Side-by-side
Showing
25 changed files
with
233 additions
and
1 deletion
+233
-1
charts.md
docs/charts.md
+32
-0
requirements.go
pkg/chartutil/requirements.go
+39
-0
requirements_test.go
pkg/chartutil/requirements_test.go
+56
-0
.helmignore
pkg/chartutil/testdata/dependent-chart-alias/.helmignore
+1
-0
Chart.yaml
pkg/chartutil/testdata/dependent-chart-alias/Chart.yaml
+17
-0
INSTALL.txt
pkg/chartutil/testdata/dependent-chart-alias/INSTALL.txt
+1
-0
LICENSE
pkg/chartutil/testdata/dependent-chart-alias/LICENSE
+1
-0
README.md
pkg/chartutil/testdata/dependent-chart-alias/README.md
+11
-0
_ignore_me
...hartutil/testdata/dependent-chart-alias/charts/_ignore_me
+1
-0
Chart.yaml
...l/testdata/dependent-chart-alias/charts/alpine/Chart.yaml
+4
-0
README.md
...il/testdata/dependent-chart-alias/charts/alpine/README.md
+9
-0
Chart.yaml
...pendent-chart-alias/charts/alpine/charts/mast1/Chart.yaml
+4
-0
values.yaml
...endent-chart-alias/charts/alpine/charts/mast1/values.yaml
+4
-0
mast2-0.1.0.tgz
...ependent-chart-alias/charts/alpine/charts/mast2-0.1.0.tgz
+0
-0
alpine-pod.yaml
...ndent-chart-alias/charts/alpine/templates/alpine-pod.yaml
+16
-0
values.yaml
.../testdata/dependent-chart-alias/charts/alpine/values.yaml
+2
-0
mariner-4.3.2.tgz
...l/testdata/dependent-chart-alias/charts/mariner-4.3.2.tgz
+0
-0
README.md
pkg/chartutil/testdata/dependent-chart-alias/docs/README.md
+1
-0
icon.svg
pkg/chartutil/testdata/dependent-chart-alias/icon.svg
+8
-0
me.txt
pkg/chartutil/testdata/dependent-chart-alias/ignore/me.txt
+0
-0
requirements.lock
...hartutil/testdata/dependent-chart-alias/requirements.lock
+8
-0
requirements.yaml
...hartutil/testdata/dependent-chart-alias/requirements.yaml
+10
-0
template.tpl
...til/testdata/dependent-chart-alias/templates/template.tpl
+1
-0
values.yaml
pkg/chartutil/testdata/dependent-chart-alias/values.yaml
+6
-0
resolver_test.go
pkg/resolver/resolver_test.go
+1
-1
No files found.
docs/charts.md
View file @
7dd6eb22
...
...
@@ -229,6 +229,38 @@ Managing charts with `requirements.yaml` is a good way to easily keep
charts updated, and also share requirements information throughout a
team.
#### Alias field in requirements.yaml
In addition to the other fields above, each requirements entry may contain
the optional field
`alias`
.
Adding an alias for a dependency chart would add another copy
of the chart as a new depdendency using alias as name of new dependency.
One can use
`alias`
in cases where they need multiple copies of same chart
as dependencies all independent of one another.
```
`
# parentchart/requirements.yaml
dependencies:
- name: subchart
repository: http://localhost:10191
version: 0.1.0
alias:
- one-more-subchart
- another-subchart
```
`
In the above example we will get 3 depenendencies in all for `
parentchart
`
```
subchart
one-more-subchart
another-subchart
```
Manual way of achieving this is copy/pasting same chart in
`
charts/
` directory multiple times with different name.
#### Tags and Condition fields in requirements.yaml
In addition to the other fields above, each requirements entry may contain
...
...
pkg/chartutil/requirements.go
View file @
7dd6eb22
...
...
@@ -65,6 +65,8 @@ type Dependency struct {
// ImportValues holds the mapping of source values to parent key to be imported. Each item can be a
// string or pair of child/parent sublist items.
ImportValues
[]
interface
{}
`json:"import-values"`
// Alias usable alias to be used for the chart
Alias
[]
string
`json:"alias"`
}
// ErrNoRequirementsFile to detect error condition
...
...
@@ -216,6 +218,28 @@ func ProcessRequirementsTags(reqs *Requirements, cvals Values) {
}
func
copyChartAsAlias
(
charts
[]
*
chart
.
Chart
,
dependentChart
,
aliasChart
string
)
*
chart
.
Chart
{
var
chartFound
chart
.
Chart
for
_
,
existingChart
:=
range
charts
{
if
existingChart
==
nil
{
continue
}
if
existingChart
.
Metadata
==
nil
{
continue
}
if
existingChart
.
Metadata
.
Name
!=
dependentChart
{
continue
}
chartFound
=
*
existingChart
newMetadata
:=
*
existingChart
.
Metadata
newMetadata
.
Name
=
aliasChart
chartFound
.
Metadata
=
&
newMetadata
return
&
chartFound
}
return
nil
}
// ProcessRequirementsEnabled removes disabled charts from dependencies
func
ProcessRequirementsEnabled
(
c
*
chart
.
Chart
,
v
*
chart
.
Config
)
error
{
reqs
,
err
:=
LoadRequirements
(
c
)
...
...
@@ -228,6 +252,21 @@ func ProcessRequirementsEnabled(c *chart.Chart, v *chart.Config) error {
// no requirements to process
return
nil
}
for
_
,
req
:=
range
reqs
.
Dependencies
{
for
_
,
alias
:=
range
req
.
Alias
{
aliasDependency
:=
copyChartAsAlias
(
c
.
Dependencies
,
req
.
Name
,
alias
)
if
aliasDependency
==
nil
{
break
}
c
.
Dependencies
=
append
(
c
.
Dependencies
,
aliasDependency
)
origReqName
:=
req
.
Name
req
.
Name
=
alias
reqs
.
Dependencies
=
append
(
reqs
.
Dependencies
,
req
)
req
.
Name
=
origReqName
}
}
// set all to true
for
_
,
lr
:=
range
reqs
.
Dependencies
{
lr
.
Enabled
=
true
...
...
pkg/chartutil/requirements_test.go
View file @
7dd6eb22
...
...
@@ -320,3 +320,59 @@ func verifyRequirementsImportValues(t *testing.T, c *chart.Chart, v *chart.Confi
}
}
func
TestCopyChartAsAlias
(
t
*
testing
.
T
)
{
c
,
err
:=
Load
(
"testdata/frobnitz"
)
if
err
!=
nil
{
t
.
Fatalf
(
"Failed to load testdata: %s"
,
err
)
}
if
aliasChart
:=
copyChartAsAlias
(
c
.
Dependencies
,
"mariners"
,
"another-mariner"
);
aliasChart
!=
nil
{
t
.
Fatalf
(
"expected no chart but got %s"
,
aliasChart
.
Metadata
.
Name
)
}
aliasChart
:=
copyChartAsAlias
(
c
.
Dependencies
,
"mariner"
,
"another-mariner"
)
if
aliasChart
==
nil
{
t
.
Fatal
(
"Failed to find dependent chart"
)
}
if
aliasChart
.
Metadata
.
Name
!=
"another-mariner"
{
t
.
Fatal
(
`Failed to update chart-name for alias "dependent chart`
)
}
}
func
TestDependentChartAliases
(
t
*
testing
.
T
)
{
c
,
err
:=
Load
(
"testdata/dependent-chart-alias"
)
if
err
!=
nil
{
t
.
Fatalf
(
"Failed to load testdata: %s"
,
err
)
}
if
len
(
c
.
Dependencies
)
==
0
{
t
.
Fatal
(
"There are no dependencies to run this test"
)
}
origLength
:=
len
(
c
.
Dependencies
)
if
err
:=
ProcessRequirementsEnabled
(
c
,
c
.
Values
);
err
!=
nil
{
t
.
Fatalf
(
"Expected no errors but got %q"
,
err
)
}
if
len
(
c
.
Dependencies
)
==
origLength
{
t
.
Fatal
(
"Expected alias dependencies to be added, but did not got that"
)
}
reqmts
,
err
:=
LoadRequirements
(
c
)
if
err
!=
nil
{
t
.
Fatalf
(
"Cannot load requirements for test chart, %v"
,
err
)
}
var
expectedDependencyCharts
int
for
_
,
reqmt
:=
range
reqmts
.
Dependencies
{
expectedDependencyCharts
++
if
len
(
reqmt
.
Alias
)
>=
0
{
expectedDependencyCharts
+=
len
(
reqmt
.
Alias
)
}
}
if
len
(
c
.
Dependencies
)
!=
expectedDependencyCharts
{
t
.
Fatalf
(
"Expected number of chart dependencies %d, but got %d"
,
expectedDependencyCharts
,
len
(
c
.
Dependencies
))
}
}
pkg/chartutil/testdata/dependent-chart-alias/.helmignore
0 → 100644
View file @
7dd6eb22
ignore/
pkg/chartutil/testdata/dependent-chart-alias/Chart.yaml
0 → 100644
View file @
7dd6eb22
apiVersion
:
v1
name
:
frobnitz
description
:
This is a frobnitz.
version
:
"
1.2.3"
keywords
:
-
frobnitz
-
sprocket
-
dodad
maintainers
:
-
name
:
The Helm Team
email
:
helm@example.com
-
name
:
Someone Else
email
:
nobody@example.com
sources
:
-
https://example.com/foo/bar
home
:
http://example.com
icon
:
https://example.com/64x64.png
pkg/chartutil/testdata/dependent-chart-alias/INSTALL.txt
0 → 100644
View file @
7dd6eb22
This is an install document. The client may display this.
pkg/chartutil/testdata/dependent-chart-alias/LICENSE
0 → 100644
View file @
7dd6eb22
LICENSE placeholder.
pkg/chartutil/testdata/dependent-chart-alias/README.md
0 → 100644
View file @
7dd6eb22
# Frobnitz
This is an example chart.
## Usage
This is an example. It has no usage.
## Development
For developer info, see the top-level repository.
pkg/chartutil/testdata/dependent-chart-alias/charts/_ignore_me
0 → 100644
View file @
7dd6eb22
This should be ignored by the loader, but may be included in a chart.
pkg/chartutil/testdata/dependent-chart-alias/charts/alpine/Chart.yaml
0 → 100644
View file @
7dd6eb22
name
:
alpine
description
:
Deploy a basic Alpine Linux pod
version
:
0.1.0
home
:
https://k8s.io/helm
pkg/chartutil/testdata/dependent-chart-alias/charts/alpine/README.md
0 → 100644
View file @
7dd6eb22
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.toml`
file contains the default values for the
`alpine-pod.yaml`
template.
You can install this example using
`helm install docs/examples/alpine`
.
pkg/chartutil/testdata/dependent-chart-alias/charts/alpine/charts/mast1/Chart.yaml
0 → 100644
View file @
7dd6eb22
name
:
mast1
description
:
A Helm chart for Kubernetes
version
:
0.1.0
home
:
"
"
pkg/chartutil/testdata/dependent-chart-alias/charts/alpine/charts/mast1/values.yaml
0 → 100644
View file @
7dd6eb22
# Default values for mast1.
# This is a YAML-formatted file.
# Declare name/value pairs to be passed into your templates.
# name = "value"
pkg/chartutil/testdata/dependent-chart-alias/charts/alpine/charts/mast2-0.1.0.tgz
0 → 100644
View file @
7dd6eb22
File added
pkg/chartutil/testdata/dependent-chart-alias/charts/alpine/templates/alpine-pod.yaml
0 → 100644
View file @
7dd6eb22
apiVersion
:
v1
kind
:
Pod
metadata
:
name
:
{{
.Release.Name
}}
-{{.Chart.Name}}
labels
:
heritage
:
{{
.Release.Service
}}
chartName
:
{{
.Chart.Name
}}
chartVersion
:
{{
.Chart.Version | quote
}}
annotations
:
"
helm.sh/created"
:
"
{{.Release.Time.Seconds}}"
spec
:
restartPolicy
:
{{
default "Never" .restart_policy
}}
containers
:
-
name
:
waiter
image
:
"
alpine:3.3"
command
:
[
"
/bin/sleep"
,
"
9000"
]
pkg/chartutil/testdata/dependent-chart-alias/charts/alpine/values.yaml
0 → 100644
View file @
7dd6eb22
# The pod name
name
:
"
my-alpine"
pkg/chartutil/testdata/dependent-chart-alias/charts/mariner-4.3.2.tgz
0 → 100644
View file @
7dd6eb22
File added
pkg/chartutil/testdata/dependent-chart-alias/docs/README.md
0 → 100644
View file @
7dd6eb22
This is a placeholder for documentation.
pkg/chartutil/testdata/dependent-chart-alias/icon.svg
0 → 100644
View file @
7dd6eb22
<?xml version="1.0"?>
<svg
xmlns:svg=
"http://www.w3.org/2000/svg"
xmlns=
"http://www.w3.org/2000/svg"
xmlns:xlink=
"http://www.w3.org/1999/xlink"
version=
"1.0"
width=
"256"
height=
"256"
id=
"test"
>
<desc>
Example icon
</desc>
<rect
id=
"first"
x=
"2"
y=
"2"
width=
"40"
height=
"60"
fill=
"navy"
/>
<rect
id=
"second"
x=
"15"
y=
"4"
width=
"40"
height=
"60"
fill=
"red"
/>
</svg>
pkg/chartutil/testdata/dependent-chart-alias/ignore/me.txt
0 → 100644
View file @
7dd6eb22
pkg/chartutil/testdata/dependent-chart-alias/requirements.lock
0 → 100644
View file @
7dd6eb22
dependencies:
- name: alpine
version: "0.1.0"
repository: https://example.com/charts
- name: mariner
version: "4.3.2"
repository: https://example.com/charts
digest: invalid
pkg/chartutil/testdata/dependent-chart-alias/requirements.yaml
0 → 100644
View file @
7dd6eb22
dependencies
:
-
name
:
alpine
version
:
"
0.1.0"
repository
:
https://example.com/charts
-
name
:
mariner
version
:
"
4.3.2"
repository
:
https://example.com/charts
alias
:
-
mariners1
-
mariners2
pkg/chartutil/testdata/dependent-chart-alias/templates/template.tpl
0 → 100644
View file @
7dd6eb22
Hello {{.Name | default "world"}}
pkg/chartutil/testdata/dependent-chart-alias/values.yaml
0 → 100644
View file @
7dd6eb22
# A values file contains configuration.
name
:
"
Some
Name"
section
:
name
:
"
Name
in
a
section"
pkg/resolver/resolver_test.go
View file @
7dd6eb22
...
...
@@ -146,7 +146,7 @@ func TestResolve(t *testing.T) {
}
func
TestHashReq
(
t
*
testing
.
T
)
{
expect
:=
"sha256:
1feffe2016ca113f64159d91c1f77d6a83bcd23510b171d9264741bf9d63f741
"
expect
:=
"sha256:
917e251ddba291096889f81eb7de713ab4e1afbbb07c576dfd7d66ba9300b12b
"
req
:=
&
chartutil
.
Requirements
{
Dependencies
:
[]
*
chartutil
.
Dependency
{
{
Name
:
"alpine"
,
Version
:
"0.1.0"
,
Repository
:
"http://localhost:8879/charts"
},
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment