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
8d6007a7
Commit
8d6007a7
authored
Jan 07, 2016
by
Matt Butcher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(*): install DM
parent
9e1dbeaa
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
70 additions
and
5 deletions
+70
-5
helm.go
cmd/helm.go
+13
-1
install.go
cmd/install.go
+14
-2
install.go
dm/install.go
+13
-0
messages.go
format/messages.go
+2
-2
get.go
kubectl/get.go
+21
-0
kubectl.go
kubectl/kubectl.go
+7
-0
No files found.
cmd/helm.go
View file @
8d6007a7
...
...
@@ -4,6 +4,7 @@ import (
"os"
"github.com/codegangsta/cli"
"github.com/deis/helm-dm/format"
)
var
version
=
"0.0.1"
...
...
@@ -24,7 +25,18 @@ func commands() []cli.Command {
Name
:
"install"
,
Usage
:
"Initialize the client and install DM on Kubernetes."
,
Description
:
``
,
Action
:
func
(
c
*
cli
.
Context
)
{
install
()
},
Flags
:
[]
cli
.
Flag
{
cli
.
BoolFlag
{
Name
:
"dry-run"
,
Usage
:
"Show what would be installed, but don't install anything."
,
},
},
Action
:
func
(
c
*
cli
.
Context
)
{
if
err
:=
install
(
c
.
Bool
(
"dry-run"
));
err
!=
nil
{
format
.
Error
(
err
.
Error
())
os
.
Exit
(
1
)
}
},
},
{
Name
:
"target"
,
...
...
cmd/install.go
View file @
8d6007a7
package
main
import
(
"errors"
"github.com/deis/helm-dm/dm"
"github.com/deis/helm-dm/format"
"github.com/deis/helm-dm/kubectl"
)
func
install
()
error
{
runner
:=
&
kubectl
.
PrintRunner
{}
var
ErrAlreadyInstalled
error
=
errors
.
New
(
"Already Installed"
)
func
install
(
dryRun
bool
)
error
{
var
runner
kubectl
.
Runner
if
dryRun
{
runner
=
&
kubectl
.
PrintRunner
{}
}
else
{
runner
=
&
kubectl
.
RealRunner
{}
if
dm
.
IsInstalled
(
runner
)
{
return
ErrAlreadyInstalled
}
}
out
,
err
:=
dm
.
Install
(
runner
)
if
err
!=
nil
{
format
.
Error
(
"Error installing: %s %s"
,
out
,
err
)
...
...
dm/install.go
View file @
8d6007a7
package
dm
import
(
"github.com/deis/helm-dm/format"
"github.com/deis/helm-dm/kubectl"
)
...
...
@@ -13,6 +14,18 @@ func Install(runner kubectl.Runner) (string, error) {
return
string
(
o
),
err
}
// IsInstalled checks whether DM has been installed.
func
IsInstalled
(
runner
kubectl
.
Runner
)
bool
{
// Basically, we test "all-or-nothing" here: if this returns without error
// we know that we have both the namespace and the manager API server.
out
,
err
:=
runner
.
GetByKind
(
"rc"
,
"manager-rc"
,
"dm"
)
if
err
!=
nil
{
format
.
Error
(
"Installation not found: %s %s"
,
out
,
err
)
return
false
}
return
true
}
// InstallYAML is the installation YAML for DM.
const
InstallYAML
=
`
######################################################################
...
...
format/messages.go
View file @
8d6007a7
...
...
@@ -8,12 +8,12 @@ import (
// This is all just placeholder.
func
Error
(
msg
string
,
v
...
interface
{})
{
msg
=
"[ERROR]"
+
msg
+
"
\n
"
msg
=
"[ERROR]
"
+
msg
+
"
\n
"
fmt
.
Fprintf
(
os
.
Stderr
,
msg
,
v
...
)
}
func
Info
(
msg
string
,
v
...
interface
{})
{
msg
=
"[INFO]"
+
msg
+
"
\n
"
msg
=
"[INFO]
"
+
msg
+
"
\n
"
fmt
.
Fprintf
(
os
.
Stdout
,
msg
,
v
...
)
}
...
...
kubectl/get.go
View file @
8d6007a7
...
...
@@ -13,6 +13,17 @@ func (r RealRunner) Get(stdin []byte, ns string) ([]byte, error) {
return
cmd
.
CombinedOutput
()
}
func
(
r
RealRunner
)
GetByKind
(
kind
,
name
,
ns
string
)
(
string
,
error
)
{
args
:=
[]
string
{
"get"
,
kind
,
name
}
if
ns
!=
""
{
args
=
append
([]
string
{
"--namespace="
+
ns
},
args
...
)
}
cmd
:=
command
(
args
...
)
o
,
err
:=
cmd
.
CombinedOutput
()
return
string
(
o
),
err
}
// Get returns the commands to kubectl
func
(
r
PrintRunner
)
Get
(
stdin
[]
byte
,
ns
string
)
([]
byte
,
error
)
{
args
:=
[]
string
{
"get"
,
"-f"
,
"-"
}
...
...
@@ -25,3 +36,13 @@ func (r PrintRunner) Get(stdin []byte, ns string) ([]byte, error) {
return
[]
byte
(
cmd
.
String
()),
nil
}
func
(
r
PrintRunner
)
GetByKind
(
kind
,
name
,
ns
string
)
(
string
,
error
)
{
args
:=
[]
string
{
"get"
,
kind
,
name
}
if
ns
!=
""
{
args
=
append
([]
string
{
"--namespace="
+
ns
},
args
...
)
}
cmd
:=
command
(
args
...
)
return
cmd
.
String
(),
nil
}
kubectl/kubectl.go
View file @
8d6007a7
...
...
@@ -13,6 +13,13 @@ type Runner interface {
Delete
(
string
,
string
,
string
)
([]
byte
,
error
)
// Get returns Kubernetes resources
Get
([]
byte
,
string
)
([]
byte
,
error
)
// GetByKind gets an entry by kind, name, and namespace.
//
// If name is omitted, all entries of that kind are returned.
//
// If NS is omitted, the default NS is assumed.
GetByKind
(
kind
,
name
,
ns
string
)
(
string
,
error
)
}
// RealRunner implements Runner to execute kubectl commands
...
...
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