Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
devtool
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
10
Issues
10
List
Boards
Labels
Service Desk
Milestones
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
k8s
devtool
Commits
7c1cc6b0
Commit
7c1cc6b0
authored
Mar 22, 2019
by
Christopher Harm
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixing logging and adding kubectl config
parent
b4cdb18f
Pipeline
#29410
passed with stages
in 55 seconds
Changes
8
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
63 additions
and
34 deletions
+63
-34
cmd/build.go
cmd/build.go
+8
-5
cmd/ci.go
cmd/ci.go
+4
-1
cmd/ci_build.go
cmd/ci_build.go
+11
-5
cmd/ci_deploy.go
cmd/ci_deploy.go
+3
-3
cmd/config_init.go
cmd/config_init.go
+2
-2
cmd/config_list.go
cmd/config_list.go
+1
-1
cmd/run.go
cmd/run.go
+6
-3
cmd/start.go
cmd/start.go
+28
-14
No files found.
cmd/build.go
View file @
7c1cc6b0
...
...
@@ -46,7 +46,7 @@ var buildCmd = &cobra.Command{
conf
,
err
:=
config
.
New
(
configFile
)
if
err
!=
nil
{
color
.
New
(
color
.
FgRed
)
.
Print
Func
()(
"Error reading configuration file: %s
"
,
configFile
)
color
.
New
(
color
.
FgRed
)
.
Print
f
(
"Error reading configuration file: %s
\n
"
,
configFile
)
return
}
...
...
@@ -102,7 +102,7 @@ func build(config config.Config) error {
case
"go"
:
environment
.
RunRequired
(
true
,
"make"
,
"build"
)
default
:
color
.
New
(
color
.
FgRed
)
.
Print
Func
()(
"devtool doesn't support the '%s' language yet.
"
,
lang
)
color
.
New
(
color
.
FgRed
)
.
Print
f
(
"devtool doesn't support the '%s' language yet.
\n
"
,
lang
)
return
errors
.
New
(
"Language not supported"
)
}
return
nil
...
...
@@ -128,7 +128,7 @@ func buildDockerAndDeploy(config config.Config) error {
fmt
.
Println
(
dockerRootDir
)
}
color
.
New
(
color
.
FgGreen
)
.
Print
Func
()(
"Building
"
,
dockerTag
)
color
.
New
(
color
.
FgGreen
)
.
Print
f
(
"Building: %s
\n
"
,
dockerTag
)
err
=
environment
.
Run
(
true
,
"docker"
,
"build"
,
"-t"
,
dockerTag
,
"-f"
,
dockerfile
,
dockerRootDir
)
if
err
!=
nil
{
return
err
...
...
@@ -154,12 +154,15 @@ func buildDockerAndDeploy(config config.Config) error {
err
=
environment
.
Run
(
true
,
"helm"
,
args
...
)
if
err
!=
nil
{
color
.
New
(
color
.
FgRed
)
.
Print
Func
()(
"helm error. try running 'helm del --purge %s'
"
,
releaseName
)
color
.
New
(
color
.
FgRed
)
.
Print
f
(
"helm error. try running 'helm del --purge %s'
\n
"
,
releaseName
)
return
err
}
if
openServices
{
environment
.
Run
(
true
,
"minikube"
,
"service"
,
releaseName
)
err
=
environment
.
Run
(
true
,
"minikube"
,
"service"
,
releaseName
)
if
err
!=
nil
{
return
err
}
}
}
return
nil
...
...
cmd/ci.go
View file @
7c1cc6b0
...
...
@@ -41,7 +41,10 @@ func init() {
ciCmd
.
PersistentFlags
()
.
StringVarP
(
&
imageTag
,
"image-tag"
,
"i"
,
""
,
"image tag for docker"
)
ciCmd
.
PersistentFlags
()
.
StringVarP
(
&
environmentSuffix
,
"environment"
,
"e"
,
""
,
"environment suffix to append to helm release name"
)
ciCmd
.
MarkPersistentFlagRequired
(
"image-tag"
)
err
:=
ciCmd
.
MarkPersistentFlagRequired
(
"image-tag"
)
if
err
!=
nil
{
panic
(
"invalid arg"
)
}
// Cobra supports local flags which will only run when this command
// is called directly, e.g.:
...
...
cmd/ci_build.go
View file @
7c1cc6b0
...
...
@@ -31,7 +31,7 @@ var ciBuildCmd = &cobra.Command{
RunE
:
func
(
cmd
*
cobra
.
Command
,
args
[]
string
)
error
{
conf
,
err
:=
config
.
New
(
configFile
)
if
err
!=
nil
{
color
.
New
(
color
.
FgRed
)
.
Print
Func
()(
"Error reading configuration file: %s
"
,
configFile
)
color
.
New
(
color
.
FgRed
)
.
Print
f
(
"Error reading configuration file: %s
\n
"
,
configFile
)
return
err
}
...
...
@@ -59,8 +59,14 @@ func init() {
ciBuildCmd
.
Flags
()
.
StringVarP
(
&
dockerRegistry
,
"registry"
,
"r"
,
""
,
"url of the docker registry"
)
ciBuildCmd
.
Flags
()
.
StringVarP
(
&
dockerRegistryNamespace
,
"registry-namespace"
,
"n"
,
""
,
"namespace in the docker registry"
)
ciBuildCmd
.
MarkFlagRequired
(
"registry"
)
ciBuildCmd
.
MarkFlagRequired
(
"registry-namespace"
)
err
:=
ciBuildCmd
.
MarkFlagRequired
(
"registry"
)
if
err
!=
nil
{
panic
(
"invalid arg"
)
}
err
=
ciBuildCmd
.
MarkFlagRequired
(
"registry-namespace"
)
if
err
!=
nil
{
panic
(
"invalid arg"
)
}
}
func
buildCiDocker
(
config
config
.
Config
)
error
{
...
...
@@ -73,13 +79,13 @@ func buildCiDocker(config config.Config) error {
dockerImage
:=
dockerRegistry
+
"/"
+
dockerRegistryNamespace
+
"/"
+
image
dockerTag
:=
dockerImage
+
":"
+
imageTag
color
.
New
(
color
.
FgGreen
)
.
Print
Func
()(
"Building:
"
,
dockerTag
)
color
.
New
(
color
.
FgGreen
)
.
Print
f
(
"Building: %s
\n
"
,
dockerTag
)
err
:=
environment
.
Run
(
true
,
"docker"
,
"build"
,
"-t"
,
dockerTag
,
"-f"
,
dockerfile
,
"."
)
if
err
!=
nil
{
return
err
}
color
.
New
(
color
.
FgGreen
)
.
Print
Func
()(
"Pushing Docker image:
"
,
dockerTag
)
color
.
New
(
color
.
FgGreen
)
.
Print
f
(
"Pushing Docker image: %s
\n
"
,
dockerTag
)
err
=
environment
.
Run
(
true
,
"docker"
,
"push"
,
dockerImage
)
if
err
!=
nil
{
return
err
...
...
cmd/ci_deploy.go
View file @
7c1cc6b0
...
...
@@ -30,7 +30,7 @@ var ciDeployCmd = &cobra.Command{
RunE
:
func
(
cmd
*
cobra
.
Command
,
args
[]
string
)
error
{
conf
,
err
:=
config
.
New
(
configFile
)
if
err
!=
nil
{
color
.
New
(
color
.
FgRed
)
.
Print
Func
()(
"Error reading configuration file: %s
"
,
configFile
)
color
.
New
(
color
.
FgRed
)
.
Print
f
(
"Error reading configuration file: %s
\n
"
,
configFile
)
return
err
}
...
...
@@ -69,14 +69,14 @@ func fluxDeployCi(config config.Config) error {
}
else
{
releaseName
=
deployable
.
Name
+
"-"
+
environmentSuffix
}
color
.
Blue
(
"Updating Flux Release:"
+
releaseName
)
color
.
New
(
color
.
FgBlue
)
.
Printf
(
"Updating Flux Release: %s
\n
"
,
releaseName
)
os
.
Setenv
(
"KUBE_SERVICE_NAME"
,
releaseName
)
os
.
Setenv
(
"CI_PROJECT_NAME"
,
image
)
err
:=
environment
.
Run
(
true
,
"fluxhelmrelease"
)
if
err
!=
nil
{
color
.
Red
(
"fluxhelmrelease error
."
)
color
.
Red
(
"fluxhelmrelease error
: %s"
,
err
)
return
err
}
}
...
...
cmd/config_init.go
View file @
7c1cc6b0
...
...
@@ -88,7 +88,7 @@ var initCmd = &cobra.Command{
dockerfiles
:=
findDockerfiles
()
for
_
,
file
:=
range
dockerfiles
{
color
.
New
(
color
.
FgYellow
)
.
Printf
(
"Found Dockerfile: %s"
,
file
)
color
.
New
(
color
.
FgYellow
)
.
Printf
(
"Found Dockerfile: %s
\n
"
,
file
)
prompt
:=
promptui
.
Prompt
{
Label
:
"Include in config"
,
Default
:
"Yes"
,
...
...
@@ -181,7 +181,7 @@ var initCmd = &cobra.Command{
err
=
conf
.
Write
(
configFile
)
if
err
!=
nil
{
color
.
New
(
color
.
FgRed
)
.
Printf
(
"Error writing configuration file: %s"
,
configFile
)
color
.
New
(
color
.
FgRed
)
.
Printf
(
"Error writing configuration file: %s
\n
"
,
configFile
)
}
},
...
...
cmd/config_list.go
View file @
7c1cc6b0
...
...
@@ -29,7 +29,7 @@ var listCmd = &cobra.Command{
Run
:
func
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
conf
,
err
:=
config
.
New
(
configFile
)
if
err
!=
nil
{
color
.
New
(
color
.
FgRed
)
.
Print
Func
()(
"Error reading configuration file: "
,
configFile
,
"
\n
"
)
color
.
New
(
color
.
FgRed
)
.
Print
f
(
"Error reading configuration file: %s
\n
"
,
configFile
)
return
}
fmt
.
Println
(
"Project Configuration"
)
...
...
cmd/run.go
View file @
7c1cc6b0
...
...
@@ -36,7 +36,7 @@ var runCmd = &cobra.Command{
conf
,
err
:=
config
.
New
(
configFile
)
if
err
!=
nil
{
color
.
New
(
color
.
FgYellow
)
.
Printf
Func
()
(
"WARNING: no project configuration exists: %s
\n
"
,
configFile
)
color
.
New
(
color
.
FgYellow
)
.
Printf
(
"WARNING: no project configuration exists: %s
\n
"
,
configFile
)
}
localConfig
:=
selectLocalConfig
(
conf
.
Deployables
)
...
...
@@ -45,7 +45,7 @@ var runCmd = &cobra.Command{
var
helmValues
config
.
HelmValues
helmValues
,
err
=
config
.
ReadHelmValues
(
localConfig
)
if
err
!=
nil
{
color
.
Red
(
"Error reading local config file: "
+
localConfig
)
color
.
New
(
color
.
FgRed
)
.
Printf
(
"Error reading local config file: %s
\n
"
,
localConfig
)
}
for
k
,
v
:=
range
helmValues
.
EnvironmentVariables
{
os
.
Setenv
(
k
,
v
)
...
...
@@ -70,7 +70,10 @@ func init() {
// is called directly, e.g.:
runCmd
.
Flags
()
.
StringVarP
(
&
command
,
"command"
,
"c"
,
""
,
"The command to run"
)
runCmd
.
MarkFlagRequired
(
"command"
)
err
:=
runCmd
.
MarkFlagRequired
(
"command"
)
if
err
!=
nil
{
panic
(
"invalid arg"
)
}
}
func
selectLocalConfig
(
deployables
[]
config
.
Deployable
)
string
{
...
...
cmd/start.go
View file @
7c1cc6b0
...
...
@@ -16,7 +16,6 @@ package cmd
import
(
"fmt"
"os"
"os/exec"
"strings"
"time"
...
...
@@ -78,15 +77,9 @@ func start(memory, cpu string) {
environment
.
RunRequired
(
true
,
"minikube"
,
"start"
,
"--memory"
,
memory
,
"--cpus"
,
cpu
)
}
checkInstallTiller
()
environment
.
EvalDockerEnv
()
fixKubectlContext
()
color
.
Blue
(
"Environment Variables:"
)
for
_
,
e
:=
range
os
.
Environ
()
{
fmt
.
Println
(
e
)
}
checkInstallTiller
()
}
...
...
@@ -113,13 +106,31 @@ func checkLocalSetup() bool {
func
checkInstalled
(
app
string
)
error
{
path
,
err
:=
exec
.
LookPath
(
app
)
if
err
!=
nil
{
color
.
New
(
color
.
FgYellow
)
.
Printf
Func
()
(
"%s is not installed
\n
"
,
app
)
color
.
New
(
color
.
FgYellow
)
.
Printf
(
"%s is not installed
\n
"
,
app
)
}
else
{
fmt
.
Printf
(
"%s: %s
\n
"
,
app
,
path
)
}
return
err
}
func
fixKubectlContext
()
{
color
.
Blue
(
"setting kubectl context."
)
_
,
err
:=
exec
.
LookPath
(
"kubectx"
)
if
err
!=
nil
{
color
.
New
(
color
.
FgYellow
)
.
Printf
(
"kubectx is not installed"
)
}
else
{
environment
.
RunRequired
(
true
,
"kubectx"
,
"minikube"
)
}
_
,
err
=
exec
.
LookPath
(
"kubens"
)
if
err
!=
nil
{
color
.
New
(
color
.
FgYellow
)
.
Printf
(
"kubens is not installed"
)
}
else
{
environment
.
RunRequired
(
true
,
"kubens"
,
"default"
)
}
}
func
checkInstallTiller
()
{
color
.
Blue
(
"Checking if Tiller is installed."
)
...
...
@@ -133,15 +144,18 @@ func checkInstallTiller() {
time
.
Sleep
(
10
*
time
.
Second
)
serverVersionOutput
,
err
=
environment
.
RunAndGetOutput
(
"helm"
,
"version"
,
"--server"
,
"--short"
)
if
err
!=
nil
{
color
.
Red
(
"Cannot determin helm server version"
)
}
}
clientVersion
:=
strings
.
TrimPrefix
(
clientVersionOutput
[
0
],
"Client: "
)
serverVersion
:=
strings
.
TrimPrefix
(
serverVersionOutput
[
0
],
"Server: "
)
if
clientVersion
!=
serverVersion
{
warn
:=
color
.
New
(
color
.
FgYellow
)
.
PrintFunc
()
warn
(
"Helm version mismatch between client and server"
)
warn
(
"Client Version: %s
\n
"
,
clientVersion
)
warn
(
"Server Version: %s
\n
"
,
serverVersion
)
warn
:=
color
.
New
(
color
.
FgYellow
)
.
Print
f
Func
()
warn
(
"Helm version mismatch between client and server
\n
"
)
warn
(
"
Client Version: %s
\n
"
,
clientVersion
)
warn
(
"
Server Version: %s
\n
"
,
serverVersion
)
}
}
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