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
854f3e0b
Commit
854f3e0b
authored
Oct 03, 2016
by
Adam Reese
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ref(helm): refactor {home,lint,serve} commands
parent
95a358de
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
73 additions
and
57 deletions
+73
-57
helm.go
cmd/helm/helm.go
+11
-11
home.go
cmd/helm/home.go
+13
-13
lint.go
cmd/helm/lint.go
+27
-19
serve.go
cmd/helm/serve.go
+22
-14
No files found.
cmd/helm/helm.go
View file @
854f3e0b
...
@@ -86,31 +86,31 @@ func newRootCmd(out io.Writer) *cobra.Command {
...
@@ -86,31 +86,31 @@ func newRootCmd(out io.Writer) *cobra.Command {
cmd
.
AddCommand
(
cmd
.
AddCommand
(
newCreateCmd
(
out
),
newCreateCmd
(
out
),
newDeleteCmd
(
nil
,
out
),
newDeleteCmd
(
nil
,
out
),
newDependencyCmd
(
out
),
newFetchCmd
(
out
),
newGetCmd
(
nil
,
out
),
newGetCmd
(
nil
,
out
),
newHomeCmd
(
out
),
newInitCmd
(
out
),
newInitCmd
(
out
),
newInspectCmd
(
nil
,
out
),
newInspectCmd
(
nil
,
out
),
newInstallCmd
(
nil
,
out
),
newInstallCmd
(
nil
,
out
),
newLintCmd
(
out
),
newListCmd
(
nil
,
out
),
newListCmd
(
nil
,
out
),
newPackageCmd
(
nil
,
out
),
newRepoCmd
(
out
),
newRollbackCmd
(
nil
,
out
),
newSearchCmd
(
out
),
newServeCmd
(
out
),
newStatusCmd
(
nil
,
out
),
newStatusCmd
(
nil
,
out
),
newUpdateCmd
(
out
),
newUpgradeCmd
(
nil
,
out
),
newUpgradeCmd
(
nil
,
out
),
newRollbackCmd
(
nil
,
out
),
newPackageCmd
(
nil
,
out
),
newFetchCmd
(
out
),
newVerifyCmd
(
out
),
newVerifyCmd
(
out
),
newUpdateCmd
(
out
),
newVersionCmd
(
nil
,
out
),
newVersionCmd
(
nil
,
out
),
newRepoCmd
(
out
),
newDependencyCmd
(
out
),
newSearchCmd
(
out
),
)
)
return
cmd
return
cmd
}
}
// RootCommand is the top-level command for Helm.
var
RootCommand
=
newRootCmd
(
os
.
Stdout
)
func
main
()
{
func
main
()
{
cmd
:=
RootCommand
cmd
:=
newRootCmd
(
os
.
Stdout
)
if
err
:=
cmd
.
Execute
();
err
!=
nil
{
if
err
:=
cmd
.
Execute
();
err
!=
nil
{
os
.
Exit
(
1
)
os
.
Exit
(
1
)
}
}
...
...
cmd/helm/home.go
View file @
854f3e0b
...
@@ -17,6 +17,9 @@ limitations under the License.
...
@@ -17,6 +17,9 @@ limitations under the License.
package
main
package
main
import
(
import
(
"fmt"
"io"
"github.com/spf13/cobra"
"github.com/spf13/cobra"
)
)
...
@@ -25,17 +28,14 @@ This command displays the location of HELM_HOME. This is where
...
@@ -25,17 +28,14 @@ This command displays the location of HELM_HOME. This is where
any helm configuration files live.
any helm configuration files live.
`
`
var
homeCommand
=
&
cobra
.
Command
{
func
newHomeCmd
(
out
io
.
Writer
)
*
cobra
.
Command
{
Use
:
"home"
,
cmd
:=
&
cobra
.
Command
{
Short
:
"displays the location of HELM_HOME"
,
Use
:
"home"
,
Long
:
longHomeHelp
,
Short
:
"displays the location of HELM_HOME"
,
Run
:
home
,
Long
:
longHomeHelp
,
}
Run
:
func
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
fmt
.
Fprintf
(
out
,
homePath
()
+
"
\n
"
)
func
init
()
{
},
RootCommand
.
AddCommand
(
homeCommand
)
}
}
return
cmd
func
home
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
cmd
.
Printf
(
homePath
()
+
"
\n
"
)
}
}
cmd/helm/lint.go
View file @
854f3e0b
...
@@ -19,6 +19,7 @@ package main
...
@@ -19,6 +19,7 @@ package main
import
(
import
(
"errors"
"errors"
"fmt"
"fmt"
"io"
"io/ioutil"
"io/ioutil"
"os"
"os"
"path/filepath"
"path/filepath"
...
@@ -40,30 +41,37 @@ it will emit [ERROR] messages. If it encounters issues that break with conventio
...
@@ -40,30 +41,37 @@ it will emit [ERROR] messages. If it encounters issues that break with conventio
or recommendation, it will emit [WARNING] messages.
or recommendation, it will emit [WARNING] messages.
`
`
var
lintCommand
=
&
cobra
.
Command
{
type
lintCmd
struct
{
Use
:
"lint [flags] PATH"
,
strict
bool
Short
:
"examines a chart for possible issues"
,
paths
[]
string
Long
:
longLintHelp
,
out
io
.
Writer
RunE
:
lintCmd
,
}
}
var
flagStrict
bool
func
newLintCmd
(
out
io
.
Writer
)
*
cobra
.
Command
{
l
:=
&
lintCmd
{
func
init
()
{
paths
:
[]
string
{
"."
},
lintCommand
.
Flags
()
.
BoolVarP
(
&
flagStrict
,
"strict"
,
""
,
false
,
"fail on lint warnings"
)
out
:
out
,
RootCommand
.
AddCommand
(
lintCommand
)
}
cmd
:=
&
cobra
.
Command
{
Use
:
"lint [flags] PATH"
,
Short
:
"examines a chart for possible issues"
,
Long
:
longLintHelp
,
RunE
:
func
(
cmd
*
cobra
.
Command
,
args
[]
string
)
error
{
if
len
(
args
)
>
0
{
l
.
paths
=
args
}
return
l
.
run
()
},
}
cmd
.
Flags
()
.
BoolVar
(
&
l
.
strict
,
"strict"
,
false
,
"fail on lint warnings"
)
return
cmd
}
}
var
errLintNoChart
=
errors
.
New
(
"No chart found for linting (missing Chart.yaml)"
)
var
errLintNoChart
=
errors
.
New
(
"No chart found for linting (missing Chart.yaml)"
)
func
lintCmd
(
cmd
*
cobra
.
Command
,
args
[]
string
)
error
{
func
(
l
*
lintCmd
)
run
()
error
{
paths
:=
[]
string
{
"."
}
if
len
(
args
)
>
0
{
paths
=
args
}
var
lowestTolerance
int
var
lowestTolerance
int
if
flagS
trict
{
if
l
.
s
trict
{
lowestTolerance
=
support
.
WarningSev
lowestTolerance
=
support
.
WarningSev
}
else
{
}
else
{
lowestTolerance
=
support
.
ErrorSev
lowestTolerance
=
support
.
ErrorSev
...
@@ -71,7 +79,7 @@ func lintCmd(cmd *cobra.Command, args []string) error {
...
@@ -71,7 +79,7 @@ func lintCmd(cmd *cobra.Command, args []string) error {
var
total
int
var
total
int
var
failures
int
var
failures
int
for
_
,
path
:=
range
paths
{
for
_
,
path
:=
range
l
.
paths
{
if
linter
,
err
:=
lintChart
(
path
);
err
!=
nil
{
if
linter
,
err
:=
lintChart
(
path
);
err
!=
nil
{
fmt
.
Println
(
"==> Skipping"
,
path
)
fmt
.
Println
(
"==> Skipping"
,
path
)
fmt
.
Println
(
err
)
fmt
.
Println
(
err
)
...
@@ -99,7 +107,7 @@ func lintCmd(cmd *cobra.Command, args []string) error {
...
@@ -99,7 +107,7 @@ func lintCmd(cmd *cobra.Command, args []string) error {
return
fmt
.
Errorf
(
"%s, %d chart(s) failed"
,
msg
,
failures
)
return
fmt
.
Errorf
(
"%s, %d chart(s) failed"
,
msg
,
failures
)
}
}
fmt
.
Printf
(
"%s, no failures
\n
"
,
msg
)
fmt
.
Fprintf
(
l
.
out
,
"%s, no failures
\n
"
,
msg
)
return
nil
return
nil
}
}
...
...
cmd/helm/serve.go
View file @
854f3e0b
...
@@ -17,6 +17,7 @@ limitations under the License.
...
@@ -17,6 +17,7 @@ limitations under the License.
package
main
package
main
import
(
import
(
"io"
"os"
"os"
"path/filepath"
"path/filepath"
...
@@ -25,24 +26,31 @@ import (
...
@@ -25,24 +26,31 @@ import (
"k8s.io/helm/pkg/repo"
"k8s.io/helm/pkg/repo"
)
)
var
serveDesc
=
`This command starts a local chart repository server that serves charts from a local directory.`
const
serveDesc
=
`This command starts a local chart repository server that serves charts from a local directory.`
var
repoPath
string
func
init
()
{
type
serveCmd
struct
{
serveCmd
.
Flags
()
.
StringVar
(
&
repoPath
,
"repo-path"
,
localRepoDirectory
(),
"The local directory path from which to serve charts."
)
repoPath
string
RootCommand
.
AddCommand
(
serveCmd
)
out
io
.
Writer
}
}
var
serveCmd
=
&
cobra
.
Command
{
func
newServeCmd
(
out
io
.
Writer
)
*
cobra
.
Command
{
Use
:
"serve"
,
s
:=
&
serveCmd
{
Short
:
"start a local http web server"
,
out
:
out
,
Long
:
serveDesc
,
}
RunE
:
serve
,
cmd
:=
&
cobra
.
Command
{
Use
:
"serve"
,
Short
:
"start a local http web server"
,
Long
:
serveDesc
,
RunE
:
func
(
cmd
*
cobra
.
Command
,
args
[]
string
)
error
{
return
s
.
run
()
},
}
cmd
.
Flags
()
.
StringVar
(
&
s
.
repoPath
,
"repo-path"
,
localRepoDirectory
(),
"The local directory path from which to serve charts."
)
return
cmd
}
}
func
serve
(
cmd
*
cobra
.
Command
,
args
[]
string
)
error
{
func
(
s
*
serveCmd
)
run
()
error
{
repoPath
,
err
:=
filepath
.
Abs
(
s
.
repoPath
)
repoPath
,
err
:=
filepath
.
Abs
(
repoPath
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
@@ -50,6 +58,6 @@ func serve(cmd *cobra.Command, args []string) error {
...
@@ -50,6 +58,6 @@ func serve(cmd *cobra.Command, args []string) error {
return
err
return
err
}
}
repo
.
StartLocalRepo
(
repoPath
)
repo
.
StartLocalRepo
(
s
.
repoPath
)
return
nil
return
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