From 1266f13afadd01dfce3c57331dfb24ce815a025f Mon Sep 17 00:00:00 2001 From: Stephen J Day Date: Mon, 5 Jan 2015 15:14:11 -0800 Subject: [PATCH] Move StringSet to new collections package As part of the efforts to break up the common package before disaster strikes, a new collections package has been created. More may belong there but for now, it only includes an implementation of StringSet. Signed-off-by: Stephen J Day --- auth/token/accesscontroller.go | 6 +++--- auth/token/token.go | 6 +++--- auth/token/token_test.go | 6 +++--- auth/token/util.go | 6 +++--- {common => collections}/stringset.go | 2 +- 5 files changed, 13 insertions(+), 13 deletions(-) rename {common => collections}/stringset.go (97%) diff --git a/auth/token/accesscontroller.go b/auth/token/accesscontroller.go index ca92861ef..b1a262f40 100644 --- a/auth/token/accesscontroller.go +++ b/auth/token/accesscontroller.go @@ -14,7 +14,7 @@ import ( "github.com/docker/libtrust" "github.com/docker/distribution/auth" - "github.com/docker/distribution/common" + "github.com/docker/distribution/collections" ) // accessSet maps a typed, named resource to @@ -241,8 +241,8 @@ func (ac *accessController) Authorized(req *http.Request, accessItems ...auth.Ac } verifyOpts := VerifyOptions{ - TrustedIssuers: common.NewStringSet(ac.issuer), - AcceptedAudiences: common.NewStringSet(ac.service), + TrustedIssuers: collections.NewStringSet(ac.issuer), + AcceptedAudiences: collections.NewStringSet(ac.service), Roots: ac.rootCerts, TrustedKeys: ac.trustedKeys, } diff --git a/auth/token/token.go b/auth/token/token.go index cdbf71073..d63a45a14 100644 --- a/auth/token/token.go +++ b/auth/token/token.go @@ -14,7 +14,7 @@ import ( "github.com/docker/libtrust" "github.com/docker/distribution/auth" - "github.com/docker/distribution/common" + "github.com/docker/distribution/collections" ) const ( @@ -71,8 +71,8 @@ type Token struct { // VerifyOptions is used to specify // options when verifying a JSON Web Token. type VerifyOptions struct { - TrustedIssuers common.StringSet - AcceptedAudiences common.StringSet + TrustedIssuers collections.StringSet + AcceptedAudiences collections.StringSet Roots *x509.CertPool TrustedKeys map[string]libtrust.PublicKey } diff --git a/auth/token/token_test.go b/auth/token/token_test.go index 9c8ab6cb7..e8248217f 100644 --- a/auth/token/token_test.go +++ b/auth/token/token_test.go @@ -18,7 +18,7 @@ import ( "github.com/docker/libtrust" "github.com/docker/distribution/auth" - "github.com/docker/distribution/common" + "github.com/docker/distribution/collections" ) func makeRootKeys(numKeys int) ([]libtrust.PrivateKey, error) { @@ -196,8 +196,8 @@ func TestTokenVerify(t *testing.T) { } verifyOps := VerifyOptions{ - TrustedIssuers: common.NewStringSet(issuer), - AcceptedAudiences: common.NewStringSet(audience), + TrustedIssuers: collections.NewStringSet(issuer), + AcceptedAudiences: collections.NewStringSet(audience), Roots: rootPool, TrustedKeys: trustedKeys, } diff --git a/auth/token/util.go b/auth/token/util.go index 8aa46bac0..f90721710 100644 --- a/auth/token/util.go +++ b/auth/token/util.go @@ -5,7 +5,7 @@ import ( "errors" "strings" - "github.com/docker/distribution/common" + "github.com/docker/distribution/collections" ) // joseBase64UrlEncode encodes the given data using the standard base64 url @@ -35,11 +35,11 @@ func joseBase64UrlDecode(s string) ([]byte, error) { // actionSet is a special type of stringSet. type actionSet struct { - common.StringSet + collections.StringSet } func newActionSet(actions ...string) actionSet { - return actionSet{common.NewStringSet(actions...)} + return actionSet{collections.NewStringSet(actions...)} } // Contains calls StringSet.Contains() for diff --git a/common/stringset.go b/collections/stringset.go similarity index 97% rename from common/stringset.go rename to collections/stringset.go index 36f4ba5a6..8ce1becbc 100644 --- a/common/stringset.go +++ b/collections/stringset.go @@ -1,4 +1,4 @@ -package common +package collections // StringSet is a useful type for looking up strings. type StringSet map[string]struct{}