Skip to content
This repository was archived by the owner on Mar 30, 2020. It is now read-only.

Commit d590838

Browse files
committed
http revision
1 parent 4e9a442 commit d590838

7 files changed

+42
-25
lines changed

core/config.go

+3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package core
22

33
import (
4+
"fmt"
45
. "github.com/mcuadros/dockership/logger"
56

67
"code.google.com/p/gcfg"
@@ -25,13 +26,15 @@ func (c *Config) LoadFile(filename string) error {
2526

2627
c.loadProjects()
2728
c.loadEnviroments()
29+
fmt.Println(c)
2830
return nil
2931
}
3032

3133
func (c *Config) loadProjects() {
3234
defaults.SetDefaults(c)
3335
for name, p := range c.Projects {
3436
p.Name = name
37+
fmt.Println(p.Name)
3538
defaults.SetDefaults(p)
3639
if p.GithubToken == "" {
3740
p.GithubToken = c.Global.GithubToken

core/project.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ type Project struct {
1717
Branch string `default:"master"`
1818
Dockerfile string `default:"Dockerfile"`
1919
NoCache bool
20-
UseShortRevisions bool `default:"true"`
21-
Ports []string `gcfg:"Port"`
22-
Files []string `gcfg:"File"`
23-
Enviroments map[string]*Enviroment
24-
EnviromentNames []string `gcfg:"Enviroment"`
20+
UseShortRevisions bool `default:"true"`
21+
Ports []string `gcfg:"Port"`
22+
Files []string `gcfg:"File"`
23+
Enviroments map[string]*Enviroment `json:"-"`
24+
EnviromentNames []string `gcfg:"Enviroment"`
2525
TestCommand string
26-
GithubToken string
26+
GithubToken string `json:"-"`
2727
}
2828

2929
func (p *Project) Deploy(enviroment string, force bool) (*ProjectDeployResult, error) {

http/handler_containers.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@ type ContainersRecord struct {
2626

2727
func NewHandlerContaienrs() (*HandlerContainers, error) {
2828
var config core.Config
29-
err := config.LoadFile("config.ini")
30-
if err != nil {
29+
if err := config.LoadFile("config.ini"); err != nil {
3130
panic(err)
3231
}
3332

http/handler_deploy.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ type HandlerDeploy struct {
2323

2424
func NewHandlerDeploy() (*HandlerDeploy, error) {
2525
var config core.Config
26-
config.LoadFile("config.ini")
26+
if err := config.LoadFile("config.ini"); err != nil {
27+
panic(err)
28+
}
2729

2830
return &HandlerDeploy{config: &config}, nil
2931
}

http/handler_status.go

+20-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package main
22

33
import (
4+
"fmt"
5+
46
"github.com/mcuadros/dockership/core"
57
. "github.com/mcuadros/dockership/logger"
68

@@ -18,15 +20,26 @@ type HandlerStatus struct {
1820
config *core.Config
1921
}
2022

21-
type StatusRecord struct {
23+
type StatusResult struct {
2224
Project *core.Project
23-
Status map[string]*core.ProjectStatus
25+
Status map[string]*StatusRecord
2426
Error string
2527
}
2628

29+
type StatusRecord struct {
30+
LastRevisionLabel string
31+
*core.ProjectStatus
32+
}
33+
2734
func NewHandlerStatus() (*HandlerStatus, error) {
2835
var config core.Config
29-
config.LoadFile("config.ini")
36+
if err := config.LoadFile("config.ini"); err != nil {
37+
panic(err)
38+
}
39+
40+
for k, p := range config.Projects {
41+
fmt.Println("config", k, p.Name)
42+
}
3043

3144
return &HandlerStatus{config: &config}, nil
3245
}
@@ -35,20 +48,20 @@ func (h *HandlerStatus) Run(ctx *gin.Context) {
3548
Verbose()
3649
project := ctx.Params.ByName("project")[1:]
3750

38-
r := make(map[string]*StatusRecord, 0)
51+
r := make(map[string]*StatusResult, 0)
3952
for name, p := range h.config.Projects {
4053
if project != "" && project != name {
4154
continue
4255
}
4356

44-
record := &StatusRecord{Project: p}
57+
record := &StatusResult{Project: p}
4558
sl, err := p.Status()
4659
if err != nil {
4760
record.Error = err.Error()
4861
} else {
49-
record.Status = make(map[string]*core.ProjectStatus, 0)
62+
record.Status = make(map[string]*StatusRecord, 0)
5063
for _, s := range sl {
51-
record.Status[s.Enviroment.Name] = s
64+
record.Status[s.Enviroment.Name] = &StatusRecord{s.LastRevision.Get(), s}
5265
}
5366
}
5467

http/static/app.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,10 @@ angular.module('dockership').controller(
4545

4646
$scope.isDeployable = function(status) {
4747
var running = status.RunningContainers;
48-
var commit = status.LastCommit;
48+
var revision = status.LastRevisionLabel;
4949
for (var i = running.length - 1; i >= 0; i--) {
5050
var tmp = running[i].Image.split(':');
51-
if (commit.slice(0, tmp[1].length) == tmp[1]) {
51+
if (revision.slice(0, tmp[1].length) == tmp[1]) {
5252
return false;
5353
}
5454
};

http/static/index.html

+7-7
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ <h1 id="buttons"><span class="glyphicon glyphicon-import"></span> Dockership</h1
2929
<div class="panel-heading">
3030
<b>{{p.Project.Name}}</b>&nbsp;&nbsp;
3131
<span class="label label-info">
32-
{{p.Project.Owner}}/{{p.Project.Repository}}
32+
{{p.Project.Repository}}
3333
</span>&nbsp;
3434
<span class="label label-info">
3535
{{p.Project.Branch}}
@@ -40,8 +40,8 @@ <h1 id="buttons"><span class="glyphicon glyphicon-import"></span> Dockership</h1
4040
<thead>
4141
<tr>
4242
<th class="col-md-2">Enviroment</th>
43-
<th class="col-md-2">Last Commit</th>
44-
<th class="col-md-2">Running Commit</th>
43+
<th class="col-md-2">Last Revision</th>
44+
<th class="col-md-2">Running Revision</th>
4545
<th class="col-md-2">Server</th>
4646
<th class="col-md-2">Containers</th>
4747
<th class="col-md-2">Status</th>
@@ -53,7 +53,7 @@ <h1 id="buttons"><span class="glyphicon glyphicon-import"></span> Dockership</h1
5353
s.RunningContainers.length == 0 ? 'danger' : isDeployable(s) ? 'warning': ''">
5454
<td><b>{{s.Enviroment.Name}}</b>
5555
</td>
56-
<td>{{s.LastCommit.slice(0,12)}}</td>
56+
<td>{{s.LastRevisionLabel.slice(0,12)}}</td>
5757
<td>{{s.RunningContainers[0].Image.split(':')[1]}}</td>
5858
<td>{{s.Enviroment.DockerEndPoint.slice(7, s.Enviroment.DockerEndPoint.length)}}</td>
5959
<td>
@@ -82,7 +82,7 @@ <h1 id="buttons"><span class="glyphicon glyphicon-import"></span> Dockership</h1
8282
ng-click="openDeploy(p, s.Enviroment)"
8383
class="btn btn-primary btn-xs">
8484
<span class="glyphicon glyphicon-import"></span>
85-
Deploy {{s.LastCommit.slice(0,12)}}
85+
Deploy {{s.LastRevisionLabel.slice(0,12)}}
8686
</button>
8787
</td>
8888
</tr>
@@ -102,7 +102,7 @@ <h3 class="modal-title">Containers <b>{{project.Name}}</b></h3>
102102
<table class="table">
103103
<thead>
104104
<tr>
105-
<th class="col-md-2">Commit</th>
105+
<th class="col-md-2">Revision</th>
106106
<th class="col-md-2">Container ID</th>
107107
<th class="col-md-2">Created</th>
108108
<th class="col-md-2">Command</th>
@@ -135,7 +135,7 @@ <h3 class="modal-title">Containers <b>{{project.Name}}</b></h3>
135135
<h3 class="modal-title">
136136
Deploying <b>{{project.Project.Name}}</b> @ <b>{{enviroment.Name}}</b>
137137
<small>
138-
Commit <b>{{project.Status[enviroment.Name].LastCommit}}</b>
138+
Revision <b>{{project.Status[enviroment.Name].LastRevisionLabel}}</b>
139139
</small>
140140
</h3>
141141
</div>

0 commit comments

Comments
 (0)