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
a64303d0
Commit
a64303d0
authored
Jun 28, 2016
by
Michelle Noorali
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(lint): lint an archived chart
* part of #836
parent
bb875b56
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
88 additions
and
6 deletions
+88
-6
lint.go
cmd/helm/lint.go
+33
-0
lint_test.go
cmd/helm/lint_test.go
+37
-0
search_test.go
cmd/helm/search_test.go
+2
-2
foobar-index.yaml
cmd/helm/testdata/testcache/foobar-index.yaml
+0
-0
local-index.yaml
cmd/helm/testdata/testcache/local-index.yaml
+0
-0
compressedchart-0.1.0.tgz
cmd/helm/testdata/testcharts/compressedchart-0.1.0.tgz
+0
-0
.helmignore
cmd/helm/testdata/testcharts/decompressedchart/.helmignore
+5
-0
Chart.yaml
cmd/helm/testdata/testcharts/decompressedchart/Chart.yaml
+3
-0
values.yaml
cmd/helm/testdata/testcharts/decompressedchart/values.yaml
+4
-0
lint.go
pkg/lint/lint.go
+4
-4
No files found.
cmd/helm/lint.go
View file @
a64303d0
...
...
@@ -19,11 +19,14 @@ package main
import
(
"errors"
"fmt"
"io/ioutil"
"os"
"path/filepath"
"strings"
"github.com/spf13/cobra"
"k8s.io/helm/pkg/chartutil"
"k8s.io/helm/pkg/lint"
)
...
...
@@ -55,6 +58,35 @@ func lintCmd(cmd *cobra.Command, args []string) error {
path
=
args
[
0
]
}
if
err
:=
lintChart
(
path
);
err
!=
nil
{
return
err
}
return
nil
}
func
lintChart
(
path
string
)
error
{
if
strings
.
HasSuffix
(
path
,
".tgz"
)
{
tempDir
,
err
:=
ioutil
.
TempDir
(
""
,
"helm-lint"
)
if
err
!=
nil
{
return
err
}
defer
os
.
RemoveAll
(
tempDir
)
file
,
err
:=
os
.
Open
(
path
)
if
err
!=
nil
{
return
err
}
defer
file
.
Close
()
if
err
=
chartutil
.
Expand
(
tempDir
,
file
);
err
!=
nil
{
return
err
}
base
:=
strings
.
Split
(
filepath
.
Base
(
path
),
"-"
)[
0
]
path
=
filepath
.
Join
(
tempDir
,
base
)
}
// Guard: Error out of this is not a chart.
if
_
,
err
:=
os
.
Stat
(
filepath
.
Join
(
path
,
"Chart.yaml"
));
err
!=
nil
{
return
errLintNoChart
...
...
@@ -69,5 +101,6 @@ func lintCmd(cmd *cobra.Command, args []string) error {
for
_
,
i
:=
range
issues
{
fmt
.
Printf
(
"%s
\n
"
,
i
)
}
return
nil
}
cmd/helm/lint_test.go
0 → 100644
View file @
a64303d0
/*
Copyright 2016 The Kubernetes Authors All rights reserved.
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
(
"testing"
)
var
(
archivedChartPath
=
"testdata/testcharts/compressedchart-0.1.0.tgz"
chartDirPath
=
"testdata/testcharts/decompressedchart/"
)
func
TestLintChart
(
t
*
testing
.
T
)
{
if
err
:=
lintChart
(
chartDirPath
);
err
!=
nil
{
t
.
Errorf
(
"%s"
,
err
)
}
if
err
:=
lintChart
(
archivedChartPath
);
err
!=
nil
{
t
.
Errorf
(
"%s"
,
err
)
}
}
cmd/helm/search_test.go
View file @
a64303d0
...
...
@@ -22,8 +22,8 @@ import (
"k8s.io/helm/pkg/repo"
)
const
testDir
=
"testdata/"
const
testFile
=
"testdata/local-index.yaml"
const
testDir
=
"testdata/
testcache
"
const
testFile
=
"testdata/
testcache/
local-index.yaml"
type
searchTestCase
struct
{
in
string
...
...
cmd/helm/testdata/foobar-index.yaml
→
cmd/helm/testdata/
testcache/
foobar-index.yaml
View file @
a64303d0
File moved
cmd/helm/testdata/local-index.yaml
→
cmd/helm/testdata/
testcache/
local-index.yaml
View file @
a64303d0
File moved
cmd/helm/testdata/testcharts/compressedchart-0.1.0.tgz
0 → 100644
View file @
a64303d0
File added
cmd/helm/testdata/testcharts/decompressedchart/.helmignore
0 → 100644
View file @
a64303d0
# 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
.git
cmd/helm/testdata/testcharts/decompressedchart/Chart.yaml
0 → 100755
View file @
a64303d0
description
:
A Helm chart for Kubernetes
name
:
decompressedchart
version
:
0.1.0
cmd/helm/testdata/testcharts/decompressedchart/values.yaml
0 → 100644
View file @
a64303d0
# Default values for decompressedchart.
# This is a YAML-formatted file.
# Declare name/value pairs to be passed into your templates.
name
:
my-decompressed-chart
pkg/lint/lint.go
View file @
a64303d0
...
...
@@ -17,17 +17,17 @@ limitations under the License.
package
lint
import
(
"path/filepath"
"k8s.io/helm/pkg/lint/rules"
"k8s.io/helm/pkg/lint/support"
"os"
"path/filepath"
)
// All runs all of the available linters on the given base directory.
func
All
(
basedir
string
)
[]
support
.
Message
{
// Using abs path to get directory context
current
,
_
:=
os
.
Getwd
()
chartDir
:=
filepath
.
Join
(
current
,
basedir
)
chartDir
,
_
:=
filepath
.
Abs
(
basedir
)
linter
:=
support
.
Linter
{
ChartDir
:
chartDir
}
rules
.
Chartfile
(
&
linter
)
...
...
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