Skip to content

Commit d321ea1

Browse files
author
Vishal Rana
committed
Updated vendor, added expose flag
Signed-off-by: Vishal Rana <[email protected]>
1 parent fbea3ff commit d321ea1

File tree

117 files changed

+24729
-240
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

117 files changed

+24729
-240
lines changed

Gopkg.lock

+33-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Gopkg.toml

+8
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,10 @@
6565
name = "github.com/labstack/labstack-go"
6666
version = "0.22.1"
6767

68+
[[constraint]]
69+
name = "github.com/labstack/tunnel"
70+
version = "0.1.3"
71+
6872
[[constraint]]
6973
branch = "master"
7074
name = "github.com/lib/pq"
@@ -77,6 +81,10 @@
7781
branch = "master"
7882
name = "github.com/mitchellh/mapstructure"
7983

84+
[[constraint]]
85+
name = "github.com/spf13/cobra"
86+
version = "0.0.2"
87+
8088
[[constraint]]
8189
name = "github.com/stretchr/testify"
8290
version = "1.2.1"

Makefile

+4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
IMAGE = labstack/armor
22
VERSION = 0.4.5
33

4+
run:
5+
ENV=development
6+
go run cmd/armor/main.go
7+
48
publish:
59
git tag $(VERSION)
610
git push origin --tags

admin/admin.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ func Start(a *armor.Armor) {
2121
e := echo.New()
2222
e.HideBanner = true
2323
e.HidePort = true
24-
a.Colorer.Printf("⇨ admin server started on %s\n", a.Colorer.Green(a.Admin.Address))
24+
if !a.DefaultConfig {
25+
a.Colorer.Printf("⇨ admin server started on %s\n", a.Colorer.Green(a.Admin.Address))
26+
}
2527
// e.Use(middleware.BasicAuth(func(usr, pwd string, _ echo.Context) (bool, error) {
2628
// return usr == "admin" && pwd == "L@B$t@ck0709", nil
2729
// }))

armor.go

+74-18
Original file line numberDiff line numberDiff line change
@@ -8,31 +8,33 @@ import (
88

99
"github.com/labstack/armor/plugin"
1010
"github.com/labstack/armor/store"
11+
"github.com/labstack/armor/util"
1112
"github.com/labstack/echo"
1213
"github.com/labstack/gommon/color"
1314
"github.com/labstack/gommon/log"
1415
)
1516

1617
type (
1718
Armor struct {
18-
mutex sync.RWMutex
19-
Name string `json:"name"`
20-
Address string `json:"address"`
21-
TLS *TLS `json:"tls"`
22-
Admin *Admin `json:"admin"`
23-
Storm *Storm `json:"storm"`
24-
Postgres *Postgres `json:"postgres"`
25-
Cluster *Cluster `json:"cluster"`
26-
ReadTimeout time.Duration `json:"read_timeout"`
27-
WriteTimeout time.Duration `json:"write_timeout"`
28-
RawPlugins []plugin.RawPlugin `json:"plugins"`
29-
Hosts Hosts `json:"hosts"`
30-
HomeDir string `json:"-"`
31-
Store store.Store `json:"-"`
32-
Plugins []plugin.Plugin `json:"-"`
33-
Echo *echo.Echo `json:"-"`
34-
Logger *log.Logger `json:"-"`
35-
Colorer *color.Color `json:"-"`
19+
mutex sync.RWMutex
20+
Name string `json:"name"`
21+
Address string `json:"address"`
22+
TLS *TLS `json:"tls"`
23+
Admin *Admin `json:"admin"`
24+
Storm *Storm `json:"storm"`
25+
Postgres *Postgres `json:"postgres"`
26+
Cluster *Cluster `json:"cluster"`
27+
ReadTimeout time.Duration `json:"read_timeout"`
28+
WriteTimeout time.Duration `json:"write_timeout"`
29+
RawPlugins []plugin.RawPlugin `json:"plugins"`
30+
Hosts Hosts `json:"hosts"`
31+
HomeDir string `json:"-"`
32+
Store store.Store `json:"-"`
33+
Plugins []plugin.Plugin `json:"-"`
34+
Echo *echo.Echo `json:"-"`
35+
Logger *log.Logger `json:"-"`
36+
Colorer *color.Color `json:"-"`
37+
DefaultConfig bool `json:"-"`
3638
}
3739

3840
TLS struct {
@@ -177,6 +179,60 @@ func (a *Armor) LoadPlugin(p *store.Plugin, update bool) {
177179
}
178180
}
179181

182+
func (a *Armor) SavePlugins() {
183+
plugins := []*store.Plugin{}
184+
185+
// Global plugins
186+
for _, rp := range a.RawPlugins {
187+
plugins = append(plugins, &store.Plugin{
188+
Name: rp.Name(),
189+
Config: rp.JSON(),
190+
})
191+
}
192+
193+
for hn, host := range a.Hosts {
194+
// Host plugins
195+
for _, rp := range host.RawPlugins {
196+
plugins = append(plugins, &store.Plugin{
197+
Name: rp.Name(),
198+
Host: hn,
199+
Config: rp.JSON(),
200+
})
201+
}
202+
203+
for pn, path := range host.Paths {
204+
// Path plugins
205+
for _, rp := range path.RawPlugins {
206+
plugins = append(plugins, &store.Plugin{
207+
Name: rp.Name(),
208+
Host: hn,
209+
Path: pn,
210+
Config: rp.JSON(),
211+
})
212+
}
213+
}
214+
}
215+
216+
// Delete
217+
if err := a.Store.DeleteBySource("file"); err != nil {
218+
panic(err)
219+
}
220+
221+
// Save
222+
for _, p := range plugins {
223+
p.Source = store.File
224+
p.ID = util.ID()
225+
now := time.Now()
226+
p.CreatedAt = now
227+
p.UpdatedAt = now
228+
229+
// Insert
230+
if err := a.Store.AddPlugin(p); err != nil {
231+
panic(err)
232+
}
233+
}
234+
}
235+
180236
func (h *Host) FindPath(name string) (p *Path) {
181237
h.mutex.Lock()
182238
defer h.mutex.Unlock()

0 commit comments

Comments
 (0)