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
eadd830d
Commit
eadd830d
authored
Feb 13, 2017
by
Matt Butcher
Committed by
GitHub
Feb 13, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1940 from wilkers-steve/fix/miss_dep_warning
fix(helm): add warnings for missing chart dependencies
parents
5618afe3
91e82032
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
127 additions
and
0 deletions
+127
-0
install.go
cmd/helm/install.go
+25
-0
install_test.go
cmd/helm/install_test.go
+6
-0
package.go
cmd/helm/package.go
+4
-0
package_test.go
cmd/helm/package_test.go
+6
-0
.helmignore
cmd/helm/testdata/testcharts/chart-missing-deps/.helmignore
+21
-0
Chart.yaml
cmd/helm/testdata/testcharts/chart-missing-deps/Chart.yaml
+3
-0
.helmignore
...tcharts/chart-missing-deps/charts/reqsubchart/.helmignore
+21
-0
Chart.yaml
...stcharts/chart-missing-deps/charts/reqsubchart/Chart.yaml
+3
-0
values.yaml
...tcharts/chart-missing-deps/charts/reqsubchart/values.yaml
+4
-0
requirements.yaml
.../testdata/testcharts/chart-missing-deps/requirements.yaml
+7
-0
values.yaml
cmd/helm/testdata/testcharts/chart-missing-deps/values.yaml
+4
-0
upgrade.go
cmd/helm/upgrade.go
+8
-0
upgrade_test.go
cmd/helm/upgrade_test.go
+15
-0
No files found.
cmd/helm/install.go
View file @
eadd830d
...
...
@@ -34,9 +34,11 @@ import (
"k8s.io/helm/cmd/helm/helmpath"
"k8s.io/helm/cmd/helm/strvals"
"k8s.io/helm/pkg/chartutil"
"k8s.io/helm/pkg/downloader"
"k8s.io/helm/pkg/helm"
"k8s.io/helm/pkg/kube"
"k8s.io/helm/pkg/proto/hapi/chart"
"k8s.io/helm/pkg/proto/hapi/release"
)
...
...
@@ -199,6 +201,13 @@ func (i *installCmd) run() error {
fmt
.
Printf
(
"FINAL NAME: %s
\n
"
,
i
.
name
)
}
// Check chart requirements to make sure all dependencies are present in /charts
if
c
,
err
:=
chartutil
.
Load
(
i
.
chartPath
);
err
==
nil
{
if
req
,
err
:=
chartutil
.
LoadRequirements
(
c
);
err
==
nil
{
checkDependencies
(
c
,
req
,
i
.
out
)
}
}
res
,
err
:=
i
.
client
.
InstallRelease
(
i
.
chartPath
,
i
.
namespace
,
...
...
@@ -388,3 +397,19 @@ func defaultNamespace() string {
}
return
"default"
}
func
checkDependencies
(
ch
*
chart
.
Chart
,
reqs
*
chartutil
.
Requirements
,
out
io
.
Writer
)
{
deps
:=
ch
.
GetDependencies
()
for
_
,
r
:=
range
reqs
.
Dependencies
{
found
:=
false
for
_
,
d
:=
range
deps
{
if
d
.
Metadata
.
Name
==
r
.
Name
{
found
=
true
break
}
}
if
!
found
{
fmt
.
Fprintf
(
out
,
"Warning: %s is in requirements.yaml but not in the charts/ directory!
\n
"
,
r
.
Name
)
}
}
}
cmd/helm/install_test.go
View file @
eadd830d
...
...
@@ -132,6 +132,12 @@ func TestInstall(t *testing.T) {
args
:
[]
string
{
"testdata/testcharts/signtest-0.1.0.tgz"
},
flags
:
strings
.
Split
(
"--verify --keyring testdata/helm-test-key.pub"
,
" "
),
},
// Install, chart with missing dependencies in /charts
{
name
:
"install chart with missing dependencies"
,
args
:
[]
string
{
"testdata/testcharts/chart-missing-deps"
},
expected
:
"Warning: reqsubchart2 is in requirements.yaml but not in the charts/ directory!"
,
},
}
runReleaseCases
(
t
,
tests
,
func
(
c
*
fakeReleaseClient
,
out
io
.
Writer
)
*
cobra
.
Command
{
...
...
cmd/helm/package.go
View file @
eadd830d
...
...
@@ -125,6 +125,10 @@ func (p *packageCmd) run(cmd *cobra.Command, args []string) error {
return
fmt
.
Errorf
(
"directory name (%s) and Chart.yaml name (%s) must match"
,
filepath
.
Base
(
path
),
ch
.
Metadata
.
Name
)
}
if
reqs
,
err
:=
chartutil
.
LoadRequirements
(
ch
);
err
==
nil
{
checkDependencies
(
ch
,
reqs
,
p
.
out
)
}
// Save to the current working directory.
cwd
,
err
:=
os
.
Getwd
()
if
err
!=
nil
{
...
...
cmd/helm/package_test.go
View file @
eadd830d
...
...
@@ -101,6 +101,12 @@ func TestPackage(t *testing.T) {
expect
:
""
,
hasfile
:
"alpine-0.1.0.tgz"
,
},
{
name
:
"package testdata/testcharts/chart-missing-deps"
,
args
:
[]
string
{
"testdata/testcharts/chart-missing-deps"
},
expect
:
"Warning: reqsubchart2 is in requirements.yaml but not in the charts/ directory!
\n
"
,
hasfile
:
"chart-missing-deps-0.1.0.tgz"
,
},
}
// Because these tests are destructive, we run them in a tempdir.
...
...
cmd/helm/testdata/testcharts/chart-missing-deps/.helmignore
0 → 100644
View file @
eadd830d
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*~
# Various IDEs
.project
.idea/
*.tmproj
cmd/helm/testdata/testcharts/chart-missing-deps/Chart.yaml
0 → 100644
View file @
eadd830d
description
:
A Helm chart for Kubernetes
name
:
chart-missing-deps
version
:
0.1.0
cmd/helm/testdata/testcharts/chart-missing-deps/charts/reqsubchart/.helmignore
0 → 100644
View file @
eadd830d
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*~
# Various IDEs
.project
.idea/
*.tmproj
cmd/helm/testdata/testcharts/chart-missing-deps/charts/reqsubchart/Chart.yaml
0 → 100644
View file @
eadd830d
description
:
A Helm chart for Kubernetes
name
:
reqsubchart
version
:
0.1.0
cmd/helm/testdata/testcharts/chart-missing-deps/charts/reqsubchart/values.yaml
0 → 100644
View file @
eadd830d
# Default values for reqsubchart.
# This is a YAML-formatted file.
# Declare name/value pairs to be passed into your templates.
# name: value
cmd/helm/testdata/testcharts/chart-missing-deps/requirements.yaml
0 → 100644
View file @
eadd830d
dependencies
:
-
name
:
reqsubchart
version
:
0.1.0
repository
:
"
https://example.com/charts"
-
name
:
reqsubchart2
version
:
0.2.0
repository
:
"
https://example.com/charts"
cmd/helm/testdata/testcharts/chart-missing-deps/values.yaml
0 → 100644
View file @
eadd830d
# Default values for reqtest.
# This is a YAML-formatted file.
# Declare name/value pairs to be passed into your templates.
# name: value
cmd/helm/upgrade.go
View file @
eadd830d
...
...
@@ -26,6 +26,7 @@ import (
"github.com/spf13/cobra"
"k8s.io/helm/cmd/helm/strvals"
"k8s.io/helm/pkg/chartutil"
"k8s.io/helm/pkg/helm"
"k8s.io/helm/pkg/storage/driver"
)
...
...
@@ -160,6 +161,13 @@ func (u *upgradeCmd) run() error {
return
err
}
// Check chart requirements to make sure all dependencies are present in /charts
if
ch
,
err
:=
chartutil
.
Load
(
chartPath
);
err
==
nil
{
if
req
,
err
:=
chartutil
.
LoadRequirements
(
ch
);
err
==
nil
{
checkDependencies
(
ch
,
req
,
u
.
out
)
}
}
resp
,
err
:=
u
.
client
.
UpdateRelease
(
u
.
release
,
chartPath
,
...
...
cmd/helm/upgrade_test.go
View file @
eadd830d
...
...
@@ -20,6 +20,7 @@ import (
"io"
"io/ioutil"
"os"
"path/filepath"
"testing"
"github.com/spf13/cobra"
...
...
@@ -79,6 +80,14 @@ func TestUpgradeCmd(t *testing.T) {
t
.
Errorf
(
"Error loading updated chart: %v"
,
err
)
}
originalDepsPath
:=
filepath
.
Join
(
"testdata/testcharts/reqtest"
)
missingDepsPath
:=
filepath
.
Join
(
"testdata/testcharts/chart-missing-deps"
)
var
ch3
*
chart
.
Chart
ch3
,
err
=
chartutil
.
Load
(
originalDepsPath
)
if
err
!=
nil
{
t
.
Errorf
(
"Error loading chart with missing dependencies: %v"
,
err
)
}
tests
:=
[]
releaseCase
{
{
name
:
"upgrade a release"
,
...
...
@@ -121,6 +130,12 @@ func TestUpgradeCmd(t *testing.T) {
resp
:
releaseMock
(
&
releaseOptions
{
name
:
"crazy-bunny"
,
version
:
2
,
chart
:
ch2
}),
expected
:
"Release
\"
crazy-bunny
\"
has been upgraded. Happy Helming!
\n
"
,
},
{
name
:
"upgrade a release with missing dependencies"
,
args
:
[]
string
{
"bonkers-bunny"
,
missingDepsPath
},
resp
:
releaseMock
(
&
releaseOptions
{
name
:
"bonkers-bunny"
,
version
:
1
,
chart
:
ch3
}),
expected
:
"Warning: reqsubchart2 is in requirements.yaml but not in the charts/ directory!"
,
},
}
cmd
:=
func
(
c
*
fakeReleaseClient
,
out
io
.
Writer
)
*
cobra
.
Command
{
...
...
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