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
b4ff4d2f
Unverified
Commit
b4ff4d2f
authored
May 14, 2019
by
Matt Farina
Committed by
GitHub
May 14, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #5729 from mattfarina/fix-lint-apiversion
Adding lint check for apiVersion which is a required field
parents
9a0d016a
d4053b38
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
32 additions
and
8 deletions
+32
-8
lint_test.go
pkg/lint/lint_test.go
+7
-3
chartfile.go
pkg/lint/rules/chartfile.go
+13
-0
chartfile_test.go
pkg/lint/rules/chartfile_test.go
+9
-5
Chart.yaml
pkg/lint/rules/testdata/albatross/Chart.yaml
+1
-0
Chart.yaml
pkg/lint/rules/testdata/badvaluesfile/Chart.yaml
+1
-0
Chart.yaml
pkg/lint/rules/testdata/goodone/Chart.yaml
+1
-0
No files found.
pkg/lint/lint_test.go
View file @
b4ff4d2f
...
...
@@ -37,12 +37,12 @@ const (
func
TestBadChart
(
t
*
testing
.
T
)
{
m
:=
All
(
badChartDir
,
values
,
namespace
,
strict
)
.
Messages
if
len
(
m
)
!=
5
{
if
len
(
m
)
!=
6
{
t
.
Errorf
(
"Number of errors %v"
,
len
(
m
))
t
.
Errorf
(
"All didn't fail with expected errors, got %#v"
,
m
)
}
// There should be one INFO, 2 WARNINGs and one ERROR messages, check for them
var
i
,
w
,
e
,
e2
,
e3
bool
var
i
,
w
,
e
,
e2
,
e3
,
e4
bool
for
_
,
msg
:=
range
m
{
if
msg
.
Severity
==
support
.
InfoSev
{
if
strings
.
Contains
(
msg
.
Err
.
Error
(),
"icon is recommended"
)
{
...
...
@@ -64,9 +64,13 @@ func TestBadChart(t *testing.T) {
if
strings
.
Contains
(
msg
.
Err
.
Error
(),
"directory name (badchartfile) and chart name () must be the same"
)
{
e3
=
true
}
if
strings
.
Contains
(
msg
.
Err
.
Error
(),
"apiVersion is required"
)
{
e4
=
true
}
}
}
if
!
e
||
!
e2
||
!
e3
||
!
w
||
!
i
{
if
!
e
||
!
e2
||
!
e3
||
!
e4
||
!
w
||
!
i
{
t
.
Errorf
(
"Didn't find all the expected errors, got %#v"
,
m
)
}
}
...
...
pkg/lint/rules/chartfile.go
View file @
b4ff4d2f
...
...
@@ -51,6 +51,7 @@ func Chartfile(linter *support.Linter) {
linter
.
RunLinterRule
(
support
.
ErrorSev
,
chartFileName
,
validateChartNameDirMatch
(
linter
.
ChartDir
,
chartFile
))
// Chart metadata
linter
.
RunLinterRule
(
support
.
ErrorSev
,
chartFileName
,
validateChartApiVersion
(
chartFile
))
linter
.
RunLinterRule
(
support
.
ErrorSev
,
chartFileName
,
validateChartVersion
(
chartFile
))
linter
.
RunLinterRule
(
support
.
ErrorSev
,
chartFileName
,
validateChartEngine
(
chartFile
))
linter
.
RunLinterRule
(
support
.
ErrorSev
,
chartFileName
,
validateChartMaintainer
(
chartFile
))
...
...
@@ -96,6 +97,18 @@ func validateChartNameDirMatch(chartDir string, cf *chart.Metadata) error {
return
nil
}
func
validateChartApiVersion
(
cf
*
chart
.
Metadata
)
error
{
if
cf
.
ApiVersion
==
""
{
return
errors
.
New
(
"apiVersion is required"
)
}
if
cf
.
ApiVersion
!=
"v1"
{
return
fmt
.
Errorf
(
"apiVersion '%s' is not valid. The value must be
\"
v1
\"
"
,
cf
.
ApiVersion
)
}
return
nil
}
func
validateChartVersion
(
cf
*
chart
.
Metadata
)
error
{
if
cf
.
Version
==
""
{
return
errors
.
New
(
"version is required"
)
...
...
pkg/lint/rules/chartfile_test.go
View file @
b4ff4d2f
...
...
@@ -236,8 +236,8 @@ func TestChartfile(t *testing.T) {
Chartfile
(
&
linter
)
msgs
:=
linter
.
Messages
if
len
(
msgs
)
!=
4
{
t
.
Errorf
(
"Expected
3
errors, got %d"
,
len
(
msgs
))
if
len
(
msgs
)
!=
5
{
t
.
Errorf
(
"Expected
4
errors, got %d"
,
len
(
msgs
))
}
if
!
strings
.
Contains
(
msgs
[
0
]
.
Err
.
Error
(),
"name is required"
)
{
...
...
@@ -248,12 +248,16 @@ func TestChartfile(t *testing.T) {
t
.
Errorf
(
"Unexpected message 1: %s"
,
msgs
[
1
]
.
Err
)
}
if
!
strings
.
Contains
(
msgs
[
2
]
.
Err
.
Error
(),
"
version 0.0.0 is less than or equal to 0
"
)
{
if
!
strings
.
Contains
(
msgs
[
2
]
.
Err
.
Error
(),
"
apiVersion is required
"
)
{
t
.
Errorf
(
"Unexpected message 2: %s"
,
msgs
[
2
]
.
Err
)
}
if
!
strings
.
Contains
(
msgs
[
3
]
.
Err
.
Error
(),
"icon is recommended"
)
{
t
.
Errorf
(
"Unexpected message 3: %s"
,
msgs
[
3
]
.
Err
)
if
!
strings
.
Contains
(
msgs
[
3
]
.
Err
.
Error
(),
"version 0.0.0 is less than or equal to 0"
)
{
t
.
Errorf
(
"Unexpected message 3: %s"
,
msgs
[
2
]
.
Err
)
}
if
!
strings
.
Contains
(
msgs
[
4
]
.
Err
.
Error
(),
"icon is recommended"
)
{
t
.
Errorf
(
"Unexpected message 4: %s"
,
msgs
[
3
]
.
Err
)
}
}
pkg/lint/rules/testdata/albatross/Chart.yaml
View file @
b4ff4d2f
apiVersion
:
v1
name
:
albatross
description
:
testing chart
version
:
199.44.12345-Alpha.1+cafe009
...
...
pkg/lint/rules/testdata/badvaluesfile/Chart.yaml
View file @
b4ff4d2f
apiVersion
:
v1
name
:
badvaluesfile
description
:
A Helm chart for Kubernetes
version
:
0.0.1
...
...
pkg/lint/rules/testdata/goodone/Chart.yaml
View file @
b4ff4d2f
apiVersion
:
v1
name
:
goodone
description
:
good testing chart
version
:
199.44.12345-Alpha.1+cafe009
...
...
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