forked from TrueCloudLab/distribution
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 <stephen.day@docker.com>
This commit is contained in:
parent
c08c6c506e
commit
1266f13afa
5 changed files with 13 additions and 13 deletions
|
@ -14,7 +14,7 @@ import (
|
||||||
"github.com/docker/libtrust"
|
"github.com/docker/libtrust"
|
||||||
|
|
||||||
"github.com/docker/distribution/auth"
|
"github.com/docker/distribution/auth"
|
||||||
"github.com/docker/distribution/common"
|
"github.com/docker/distribution/collections"
|
||||||
)
|
)
|
||||||
|
|
||||||
// accessSet maps a typed, named resource to
|
// accessSet maps a typed, named resource to
|
||||||
|
@ -241,8 +241,8 @@ func (ac *accessController) Authorized(req *http.Request, accessItems ...auth.Ac
|
||||||
}
|
}
|
||||||
|
|
||||||
verifyOpts := VerifyOptions{
|
verifyOpts := VerifyOptions{
|
||||||
TrustedIssuers: common.NewStringSet(ac.issuer),
|
TrustedIssuers: collections.NewStringSet(ac.issuer),
|
||||||
AcceptedAudiences: common.NewStringSet(ac.service),
|
AcceptedAudiences: collections.NewStringSet(ac.service),
|
||||||
Roots: ac.rootCerts,
|
Roots: ac.rootCerts,
|
||||||
TrustedKeys: ac.trustedKeys,
|
TrustedKeys: ac.trustedKeys,
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@ import (
|
||||||
"github.com/docker/libtrust"
|
"github.com/docker/libtrust"
|
||||||
|
|
||||||
"github.com/docker/distribution/auth"
|
"github.com/docker/distribution/auth"
|
||||||
"github.com/docker/distribution/common"
|
"github.com/docker/distribution/collections"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -71,8 +71,8 @@ type Token struct {
|
||||||
// VerifyOptions is used to specify
|
// VerifyOptions is used to specify
|
||||||
// options when verifying a JSON Web Token.
|
// options when verifying a JSON Web Token.
|
||||||
type VerifyOptions struct {
|
type VerifyOptions struct {
|
||||||
TrustedIssuers common.StringSet
|
TrustedIssuers collections.StringSet
|
||||||
AcceptedAudiences common.StringSet
|
AcceptedAudiences collections.StringSet
|
||||||
Roots *x509.CertPool
|
Roots *x509.CertPool
|
||||||
TrustedKeys map[string]libtrust.PublicKey
|
TrustedKeys map[string]libtrust.PublicKey
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@ import (
|
||||||
"github.com/docker/libtrust"
|
"github.com/docker/libtrust"
|
||||||
|
|
||||||
"github.com/docker/distribution/auth"
|
"github.com/docker/distribution/auth"
|
||||||
"github.com/docker/distribution/common"
|
"github.com/docker/distribution/collections"
|
||||||
)
|
)
|
||||||
|
|
||||||
func makeRootKeys(numKeys int) ([]libtrust.PrivateKey, error) {
|
func makeRootKeys(numKeys int) ([]libtrust.PrivateKey, error) {
|
||||||
|
@ -196,8 +196,8 @@ func TestTokenVerify(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
verifyOps := VerifyOptions{
|
verifyOps := VerifyOptions{
|
||||||
TrustedIssuers: common.NewStringSet(issuer),
|
TrustedIssuers: collections.NewStringSet(issuer),
|
||||||
AcceptedAudiences: common.NewStringSet(audience),
|
AcceptedAudiences: collections.NewStringSet(audience),
|
||||||
Roots: rootPool,
|
Roots: rootPool,
|
||||||
TrustedKeys: trustedKeys,
|
TrustedKeys: trustedKeys,
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@ import (
|
||||||
"errors"
|
"errors"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/docker/distribution/common"
|
"github.com/docker/distribution/collections"
|
||||||
)
|
)
|
||||||
|
|
||||||
// joseBase64UrlEncode encodes the given data using the standard base64 url
|
// 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.
|
// actionSet is a special type of stringSet.
|
||||||
type actionSet struct {
|
type actionSet struct {
|
||||||
common.StringSet
|
collections.StringSet
|
||||||
}
|
}
|
||||||
|
|
||||||
func newActionSet(actions ...string) actionSet {
|
func newActionSet(actions ...string) actionSet {
|
||||||
return actionSet{common.NewStringSet(actions...)}
|
return actionSet{collections.NewStringSet(actions...)}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Contains calls StringSet.Contains() for
|
// Contains calls StringSet.Contains() for
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package common
|
package collections
|
||||||
|
|
||||||
// StringSet is a useful type for looking up strings.
|
// StringSet is a useful type for looking up strings.
|
||||||
type StringSet map[string]struct{}
|
type StringSet map[string]struct{}
|
Loading…
Reference in a new issue