Remove capability package

It's no longer used. This commit can always be reverted later if it's
needed again.
This commit is contained in:
Matt Bostock 2015-01-16 18:50:26 +00:00
parent 307aed12bc
commit c48c6ebc88
5 changed files with 0 additions and 88 deletions

View file

@ -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)
}

View file

@ -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)
})
})
}

View file

@ -1,5 +0,0 @@
package capability
const (
Registration = "REGISTRATION"
)

View file

@ -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)
}

View file

@ -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)