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
4e8063b1
Unverified
Commit
4e8063b1
authored
Oct 04, 2019
by
Taylor Thomas
Committed by
GitHub
Oct 04, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #5177 from adshmh/5150-lint-development-version-flag
Allow lint command to parse pre-release charts
parents
730e8f3e
764c3187
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
65 additions
and
31 deletions
+65
-31
lint.go
cmd/helm/lint.go
+8
-5
lint_test.go
cmd/helm/lint_test.go
+44
-26
pre-release-chart-0.1.0-alpha.tgz
...elm/testdata/testcharts/pre-release-chart-0.1.0-alpha.tgz
+0
-0
expand_test.go
pkg/chartutil/expand_test.go
+13
-0
No files found.
cmd/helm/lint.go
View file @
4e8063b1
...
...
@@ -156,12 +156,15 @@ func lintChart(path string, vals []byte, namespace string, strict bool) (support
return
linter
,
err
}
lastHyphenIndex
:=
strings
.
LastIndex
(
filepath
.
Base
(
path
),
"-"
)
if
lastHyphenIndex
<=
0
{
return
linter
,
fmt
.
Errorf
(
"unable to parse chart archive %q, missing '-'"
,
filepath
.
Base
(
path
))
files
,
err
:=
ioutil
.
ReadDir
(
tempDir
)
if
err
!=
nil
{
return
linter
,
fmt
.
Errorf
(
"unable to read temporary output directory %s"
,
tempDir
)
}
if
!
files
[
0
]
.
IsDir
()
{
return
linter
,
fmt
.
Errorf
(
"unexpected file %s in temporary output directory %s"
,
files
[
0
]
.
Name
(),
tempDir
)
}
base
:=
filepath
.
Base
(
path
)[
:
lastHyphenIndex
]
chartPath
=
filepath
.
Join
(
tempDir
,
base
)
chartPath
=
filepath
.
Join
(
tempDir
,
files
[
0
]
.
Name
()
)
}
else
{
chartPath
=
path
}
...
...
cmd/helm/lint_test.go
View file @
4e8063b1
...
...
@@ -20,35 +20,53 @@ import (
"testing"
)
var
(
values
=
[]
byte
{}
namespace
=
"testNamespace"
strict
=
false
archivedChartPath
=
"testdata/testcharts/compressedchart-0.1.0.tgz"
archivedChartPathWithHyphens
=
"testdata/testcharts/compressedchart-with-hyphens-0.1.0.tgz"
invalidArchivedChartPath
=
"testdata/testcharts/invalidcompressedchart0.1.0.tgz"
chartDirPath
=
"testdata/testcharts/decompressedchart/"
chartMissingManifest
=
"testdata/testcharts/chart-missing-manifest"
)
func
TestLintChart
(
t
*
testing
.
T
)
{
if
_
,
err
:=
lintChart
(
chartDirPath
,
values
,
namespace
,
strict
);
err
!=
nil
{
t
.
Errorf
(
"%s"
,
err
)
}
if
_
,
err
:=
lintChart
(
archivedChartPath
,
values
,
namespace
,
strict
);
err
!=
nil
{
t
.
Errorf
(
"%s"
,
err
)
tests
:=
[]
struct
{
name
string
chartPath
string
err
bool
}{
{
name
:
"decompressed-chart"
,
chartPath
:
"testdata/testcharts/decompressedchart/"
,
},
{
name
:
"archived-chart-path"
,
chartPath
:
"testdata/testcharts/compressedchart-0.1.0.tgz"
,
},
{
name
:
"archived-chart-path-with-hyphens"
,
chartPath
:
"testdata/testcharts/compressedchart-with-hyphens-0.1.0.tgz"
,
},
{
name
:
"pre-release-chart"
,
chartPath
:
"testdata/testcharts/pre-release-chart-0.1.0-alpha.tgz"
,
},
{
name
:
"invalid-archived-chart-path"
,
chartPath
:
"testdata/testcharts/invalidcompressedchart0.1.0.tgz"
,
err
:
true
,
},
{
name
:
"chart-missing-manifest"
,
chartPath
:
"testdata/testcharts/chart-missing-manifest"
,
err
:
true
,
},
}
if
_
,
err
:=
lintChart
(
archivedChartPathWithHyphens
,
values
,
namespace
,
strict
);
err
!=
nil
{
t
.
Errorf
(
"%s"
,
err
)
}
if
_
,
err
:=
lintChart
(
invalidArchivedChartPath
,
values
,
namespace
,
strict
);
err
==
nil
{
t
.
Errorf
(
"Expected a chart parsing error"
)
}
values
:=
[]
byte
{}
namespace
:=
"testNamespace"
strict
:=
false
if
_
,
err
:=
lintChart
(
chartMissingManifest
,
values
,
namespace
,
strict
);
err
==
nil
{
t
.
Errorf
(
"Expected a chart parsing error"
)
for
_
,
tt
:=
range
tests
{
t
.
Run
(
tt
.
name
,
func
(
t
*
testing
.
T
)
{
_
,
err
:=
lintChart
(
tt
.
chartPath
,
values
,
namespace
,
strict
)
switch
{
case
err
!=
nil
&&
!
tt
.
err
:
t
.
Errorf
(
"%s"
,
err
)
case
err
==
nil
&&
tt
.
err
:
t
.
Errorf
(
"Expected a chart parsing error"
)
}
})
}
}
cmd/helm/testdata/testcharts/pre-release-chart-0.1.0-alpha.tgz
0 → 100644
View file @
4e8063b1
File added
pkg/chartutil/expand_test.go
View file @
4e8063b1
...
...
@@ -39,6 +39,19 @@ func TestExpand(t *testing.T) {
t
.
Fatal
(
err
)
}
files
,
err
:=
ioutil
.
ReadDir
(
dest
)
if
err
!=
nil
{
t
.
Fatalf
(
"error reading output directory %s: %s"
,
dest
,
err
)
}
if
len
(
files
)
!=
1
{
t
.
Fatalf
(
"expected a single chart directory in output directory %s"
,
dest
)
}
if
!
files
[
0
]
.
IsDir
()
{
t
.
Fatalf
(
"expected a chart directory in output directory %s"
,
dest
)
}
expectedChartPath
:=
filepath
.
Join
(
dest
,
"frobnitz"
)
fi
,
err
:=
os
.
Stat
(
expectedChartPath
)
if
err
!=
nil
{
...
...
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