Skip to content

Commit 7560575

Browse files
committed
Rearranged code
Signed-off-by: Vishal Rana <[email protected]>
1 parent f7fc010 commit 7560575

File tree

5 files changed

+13
-18
lines changed

5 files changed

+13
-18
lines changed

Diff for: admin/api/plugin.go

+2-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66
"time"
77

88
"github.com/labstack/armor"
9-
"github.com/labstack/armor/cluster"
109
"github.com/labstack/armor/plugin"
1110
"github.com/labstack/armor/store"
1211
"github.com/labstack/armor/util"
@@ -53,7 +52,7 @@ func (h *handler) addPlugin(c echo.Context) (err error) {
5352
if err = h.store.AddPlugin(p); err != nil {
5453
return err
5554
}
56-
h.cluster.UserEvent(cluster.EventPluginLoad, []byte(p.ID), true)
55+
h.cluster.UserEvent(armor.EventPluginLoad, []byte(p.ID), true)
5756
return c.JSON(http.StatusCreated, p)
5857

5958
// hostName := c.Param("host")
@@ -128,7 +127,7 @@ func (h *handler) savePlugin(c echo.Context) (err error) {
128127
if err != nil {
129128
return
130129
}
131-
h.cluster.UserEvent(cluster.EventPluginUpdate, []byte(p.ID), true)
130+
h.cluster.UserEvent(armor.EventPluginUpdate, []byte(p.ID), true)
132131
return c.NoContent(http.StatusNoContent)
133132
}
134133

Diff for: cluster/cluster.go renamed to cluster.go

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package cluster
1+
package armor
22

33
import (
44
"log"
@@ -7,7 +7,6 @@ import (
77

88
"github.com/hashicorp/logutils"
99
"github.com/hashicorp/serf/serf"
10-
"github.com/labstack/armor"
1110
)
1211

1312
// Events
@@ -16,7 +15,7 @@ const (
1615
EventPluginUpdate = "2"
1716
)
1817

19-
func Start(a *armor.Armor) {
18+
func (a *Armor) StartCluster() {
2019
conf := serf.DefaultConfig()
2120
filter := &logutils.LevelFilter{
2221
Levels: []logutils.LogLevel{"DEBUG", "INFO", "WARN", "ERROR"},

Diff for: cmd/root.go

+3-5
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ import (
1111
"github.com/ghodss/yaml"
1212
"github.com/labstack/armor"
1313
"github.com/labstack/armor/admin"
14-
"github.com/labstack/armor/cluster"
15-
"github.com/labstack/armor/http"
1614
"github.com/labstack/armor/store"
1715
"github.com/labstack/gommon/color"
1816
"github.com/labstack/gommon/log"
@@ -133,8 +131,8 @@ func initConfig() {
133131
a.Hosts = make(armor.Hosts)
134132
}
135133

136-
// Init http
137-
h := http.Init(a)
134+
// HTTP
135+
h := a.NewHTTP()
138136

139137
// Store
140138
if a.Postgres != nil {
@@ -148,7 +146,7 @@ func initConfig() {
148146
a.SavePlugins()
149147

150148
// Start cluster
151-
go cluster.Start(a)
149+
go a.StartCluster()
152150

153151
// Start admin
154152
go admin.Start(a)

Diff for: http/http.go renamed to http.go

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
package http
1+
package armor
22

33
import (
44
"crypto/tls"
55
"net/http"
66
"path/filepath"
77
"time"
88

9-
"github.com/labstack/armor"
109
"github.com/labstack/armor/util"
1110
"github.com/labstack/echo"
1211
"github.com/labstack/gommon/log"
@@ -19,13 +18,13 @@ import (
1918

2019
type (
2120
HTTP struct {
22-
armor *armor.Armor
21+
armor *Armor
2322
echo *echo.Echo
2423
logger *log.Logger
2524
}
2625
)
2726

28-
func Init(a *armor.Armor) (h *HTTP) {
27+
func (a *Armor) NewHTTP() (h *HTTP) {
2928
e := echo.New()
3029

3130
a.Echo = e
@@ -60,7 +59,7 @@ func Init(a *armor.Armor) (h *HTTP) {
6059
e.Pre(func(next echo.HandlerFunc) echo.HandlerFunc {
6160
return func(c echo.Context) error {
6261
c.Response().Before(func() {
63-
c.Response().Header().Set(echo.HeaderServer, "armor/"+armor.Version)
62+
c.Response().Header().Set(echo.HeaderServer, "armor/"+Version)
6463
})
6564
return next(c)
6665
}

Diff for: website/layouts/partials/head.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@
1010
<meta name="twitter:creator" content="@labstack">
1111
<meta name="twitter:title" content="{{ if ne .URL "/" }}{{ .Title }} | {{ end }}{{ .Site.Title }}">
1212
<meta name="twitter:description" content="{{ if ne .URL "/" }}{{ .Description }} | {{ end }}{{ .Site.Params.description }}">
13-
<meta name="twitter:image" content="{{ .Site.BaseURL }}/images/share.png">
13+
<meta name="twitter:image" content="{{ .Site.BaseURL }}images/share.png">
1414
<meta property="og:type" content="website">
1515
<meta property="og:site_name" content="{{ .Title }}">
1616
<meta property="og:title" content="{{ if ne .URL "/" }}{{ .Title }} | {{ end }}{{ .Site.Title }}">
1717
<meta property="og:site_name" content="armor">
1818
<meta property="og:description" content="{{ if ne .URL "/" }}{{ .Description }} | {{ end }}{{ .Site.Params.description }}">
1919
<meta property="og:url" content="{{ .Site.BaseURL }}">
20-
<meta property="og:image" content="{{ .Site.BaseURL }}/images/share.png">
20+
<meta property="og:image" content="{{ .Site.BaseURL }}images/share.png">
2121
<title>
2222
{{ if ne .URL "/" }}{{ .Title }} | {{ end }}{{ .Site.Title }}
2323
</title>

0 commit comments

Comments
 (0)