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
39ba728b
Commit
39ba728b
authored
Aug 01, 2016
by
Adam Reese
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ref(cmd): refactor init command
parent
a1fffc69
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
36 deletions
+34
-36
helm.go
cmd/helm/helm.go
+4
-3
init.go
cmd/helm/init.go
+30
-33
No files found.
cmd/helm/helm.go
View file @
39ba728b
...
@@ -84,12 +84,13 @@ func newRootCmd(out io.Writer) *cobra.Command {
...
@@ -84,12 +84,13 @@ func newRootCmd(out io.Writer) *cobra.Command {
cmd
.
AddCommand
(
cmd
.
AddCommand
(
newCreateCmd
(
out
),
newCreateCmd
(
out
),
newDeleteCmd
(
nil
,
out
),
newGetCmd
(
nil
,
out
),
newGetCmd
(
nil
,
out
),
newInitCmd
(
out
),
newInspectCmd
(
nil
,
out
),
newInstallCmd
(
nil
,
out
),
newListCmd
(
nil
,
out
),
newListCmd
(
nil
,
out
),
newStatusCmd
(
nil
,
out
),
newStatusCmd
(
nil
,
out
),
newInstallCmd
(
nil
,
out
),
newDeleteCmd
(
nil
,
out
),
newInspectCmd
(
nil
,
out
),
newUpgradeCmd
(
nil
,
out
),
newUpgradeCmd
(
nil
,
out
),
)
)
return
cmd
return
cmd
...
...
cmd/helm/init.go
View file @
39ba728b
...
@@ -19,6 +19,7 @@ package main
...
@@ -19,6 +19,7 @@ package main
import
(
import
(
"errors"
"errors"
"fmt"
"fmt"
"io"
"os"
"os"
"github.com/spf13/cobra"
"github.com/spf13/cobra"
...
@@ -32,58 +33,54 @@ Kubernetes Cluster and sets up local configuration in $HELM_HOME (default: ~/.he
...
@@ -32,58 +33,54 @@ Kubernetes Cluster and sets up local configuration in $HELM_HOME (default: ~/.he
`
`
var
(
var
(
tillerImg
string
clientOnly
bool
defaultRepository
=
"kubernetes-charts"
defaultRepository
=
"kubernetes-charts"
defaultRepositoryURL
=
"http://storage.googleapis.com/kubernetes-charts"
defaultRepositoryURL
=
"http://storage.googleapis.com/kubernetes-charts"
)
)
func
init
()
{
type
initCmd
struct
{
f
:=
initCmd
.
Flags
()
image
string
f
.
StringVarP
(
&
tillerImg
,
"tiller-image"
,
"i"
,
""
,
"override tiller image"
)
clientOnly
bool
f
.
BoolVarP
(
&
clientOnly
,
"client-only"
,
"c"
,
false
,
"If set does not install tiller"
)
out
io
.
Writer
RootCommand
.
AddCommand
(
initCmd
)
}
}
var
initCmd
=
&
cobra
.
Command
{
func
newInitCmd
(
out
io
.
Writer
)
*
cobra
.
Command
{
Use
:
"init"
,
i
:=
&
initCmd
{
Short
:
"initialize Helm on both client and server"
,
out
:
out
,
Long
:
initDesc
,
}
RunE
:
runInit
,
cmd
:=
&
cobra
.
Command
{
Use
:
"init"
,
Short
:
"initialize Helm on both client and server"
,
Long
:
initDesc
,
RunE
:
func
(
cmd
*
cobra
.
Command
,
args
[]
string
)
error
{
if
len
(
args
)
!=
0
{
return
errors
.
New
(
"This command does not accept arguments"
)
}
return
i
.
run
()
},
}
cmd
.
Flags
()
.
StringVarP
(
&
i
.
image
,
"tiller-image"
,
"i"
,
""
,
"override tiller image"
)
cmd
.
Flags
()
.
BoolVarP
(
&
i
.
clientOnly
,
"client-only"
,
"c"
,
false
,
"If set does not install tiller"
)
return
cmd
}
}
// runInit initializes local config and installs tiller to Kubernetes Cluster
// runInit initializes local config and installs tiller to Kubernetes Cluster
func
runInit
(
cmd
*
cobra
.
Command
,
args
[]
string
)
error
{
func
(
i
*
initCmd
)
run
()
error
{
if
len
(
args
)
!=
0
{
return
errors
.
New
(
"This command does not accept arguments.
\n
"
)
}
if
err
:=
ensureHome
();
err
!=
nil
{
if
err
:=
ensureHome
();
err
!=
nil
{
return
err
return
err
}
}
if
!
clientOnly
{
if
!
i
.
clientOnly
{
if
err
:=
installTiller
(
);
err
!=
nil
{
if
err
:=
client
.
Install
(
tillerNamespace
,
i
.
image
,
flagDebug
);
err
!=
nil
{
return
err
return
fmt
.
Errorf
(
"error installing: %s"
,
err
)
}
}
fmt
.
Fprintln
(
i
.
out
,
"
\n
Tiller (the helm server side component) has been installed into your Kubernetes Cluster."
)
}
else
{
}
else
{
fmt
.
Println
(
"Not installing tiller due to 'client-only' flag having been set"
)
fmt
.
Fprintln
(
i
.
out
,
"Not installing tiller due to 'client-only' flag having been set"
)
}
}
fmt
.
Fprintln
(
i
.
out
,
"Happy Helming!"
)
fmt
.
Println
(
"Happy Helming!"
)
return
nil
}
func
installTiller
()
error
{
if
err
:=
client
.
Install
(
tillerNamespace
,
tillerImg
,
flagDebug
);
err
!=
nil
{
return
fmt
.
Errorf
(
"error installing: %s"
,
err
)
}
fmt
.
Println
(
"
\n
Tiller (the helm server side component) has been installed into your Kubernetes Cluster."
)
return
nil
return
nil
}
}
// requireHome checks to see if $HELM_HOME exists, and returns an error if it does not.
func
requireHome
()
error
{
func
requireHome
()
error
{
dirs
:=
[]
string
{
homePath
(),
repositoryDirectory
(),
cacheDirectory
(),
localRepoDirectory
()}
dirs
:=
[]
string
{
homePath
(),
repositoryDirectory
(),
cacheDirectory
(),
localRepoDirectory
()}
for
_
,
d
:=
range
dirs
{
for
_
,
d
:=
range
dirs
{
...
...
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