From c48c6ebc88ccfaf9f5b807b6c4e3932e2c2a0e56 Mon Sep 17 00:00:00 2001 From: Matt Bostock Date: Fri, 16 Jan 2015 18:50:26 +0000 Subject: [PATCH] Remove capability package It's no longer used. This commit can always be reverted later if it's needed again. --- server/capability/capability.go | 23 -------------------- server/capability/capability_test.go | 22 ------------------- server/capability/const.go | 5 ----- server/capability/context.go | 32 ---------------------------- server/main.go | 6 ------ 5 files changed, 88 deletions(-) delete mode 100644 server/capability/capability.go delete mode 100644 server/capability/capability_test.go delete mode 100644 server/capability/const.go delete mode 100644 server/capability/context.go diff --git a/server/capability/capability.go b/server/capability/capability.go deleted file mode 100644 index 704e75a0a..000000000 --- a/server/capability/capability.go +++ /dev/null @@ -1,23 +0,0 @@ -package capability - -import ( - "code.google.com/p/go.net/context" -) - -type Capability map[string]bool - -// Get the capability value from the map. -func (c Capability) Get(key string) bool { - return c[key] -} - -// Sets the capability value in the map. -func (c Capability) Set(key string, value bool) { - c[key] = value -} - -// Enabled returns true if the capability is -// enabled in the system. -func Enabled(c context.Context, key string) bool { - return FromContext(c).Get(key) -} diff --git a/server/capability/capability_test.go b/server/capability/capability_test.go deleted file mode 100644 index 25c772fe8..000000000 --- a/server/capability/capability_test.go +++ /dev/null @@ -1,22 +0,0 @@ -package capability - -import ( - "testing" - - "code.google.com/p/go.net/context" - "github.com/franela/goblin" -) - -func TestBlobstore(t *testing.T) { - caps := map[string]bool{} - - ctx := NewContext(context.Background(), caps) - - g := goblin.Goblin(t) - g.Describe("Capabilities", func() { - - g.It("Should get capabilities from context", func() { - g.Assert(Enabled(ctx, "Fake Key")).Equal(false) - }) - }) -} diff --git a/server/capability/const.go b/server/capability/const.go deleted file mode 100644 index 7d4da039c..000000000 --- a/server/capability/const.go +++ /dev/null @@ -1,5 +0,0 @@ -package capability - -const ( - Registration = "REGISTRATION" -) diff --git a/server/capability/context.go b/server/capability/context.go deleted file mode 100644 index 1f225be15..000000000 --- a/server/capability/context.go +++ /dev/null @@ -1,32 +0,0 @@ -package capability - -import ( - "code.google.com/p/go.net/context" -) - -const reqkey = "capability" - -// NewContext returns a Context whose Value method returns the -// application's Blobstore data. -func NewContext(parent context.Context, caps Capability) context.Context { - return &wrapper{parent, caps} -} - -type wrapper struct { - context.Context - caps Capability -} - -// Value returns the named key from the context. -func (c *wrapper) Value(key interface{}) interface{} { - if key == reqkey { - return c.caps - } - return c.Context.Value(key) -} - -// FromContext returns the capability map for the -// current context. -func FromContext(c context.Context) Capability { - return c.Value(reqkey).(Capability) -} diff --git a/server/main.go b/server/main.go index 73fd0637f..b5192380c 100644 --- a/server/main.go +++ b/server/main.go @@ -26,7 +26,6 @@ import ( "github.com/drone/drone/plugin/remote/gitlab" "github.com/drone/drone/plugin/remote/gogs" "github.com/drone/drone/server/blobstore" - "github.com/drone/drone/server/capability" "github.com/drone/drone/server/datastore" "github.com/drone/drone/server/datastore/database" "github.com/drone/drone/server/worker/director" @@ -66,8 +65,6 @@ var ( nodes StringArr db *sql.DB - - caps map[string]bool ) func main() { @@ -100,8 +97,6 @@ func main() { gitlab.Register() gogs.Register() - caps = map[string]bool{} - // setup the database and cancel all pending // commits in the system. db = database.MustConnect(*driver, *datasource) @@ -165,7 +160,6 @@ func ContextMiddleware(c *web.C, h http.Handler) http.Handler { ctx = pool.NewContext(ctx, workers) ctx = director.NewContext(ctx, worker) ctx = pubsub.NewContext(ctx, pub) - ctx = capability.NewContext(ctx, caps) // add the context to the goji web context webcontext.Set(c, ctx)