Skip to content

Commit

Permalink
Add const for option name
Browse files Browse the repository at this point in the history
Signed-off-by: Oleg Bulatov <[email protected]>
  • Loading branch information
Oleg Bulatov committed Mar 13, 2017
1 parent 59e2b86 commit 0184470
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
4 changes: 3 additions & 1 deletion pkg/dockerregistry/server/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ const (

RealmKey = "realm"
TokenRealmKey = "tokenrealm"

accessControllerOptionContext = "_context"
)

// RegistryClient encapsulates getting access to the OpenShift API.
Expand Down Expand Up @@ -164,7 +166,7 @@ func TokenRealm(options map[string]interface{}) (*url.URL, error) {
func newAccessController(options map[string]interface{}) (registryauth.AccessController, error) {
log.Info("Using Origin Auth handler")

ctx, ok := options["_context"].(context.Context)
ctx, ok := options[accessControllerOptionContext].(context.Context)
if !ok {
return nil, fmt.Errorf("no context provided to Origin Auth handler")
}
Expand Down
17 changes: 10 additions & 7 deletions pkg/dockerregistry/server/auth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -393,13 +393,16 @@ func TestAccessController(t *testing.T) {
}

server, actions := simulateOpenShiftMaster(test.openshiftResponses)
options["_context"] = WithRegistryClient(context.Background(), NewRegistryClient(&clientcmd.Config{
CommonConfig: restclient.Config{
Host: server.URL,
Insecure: true,
},
SkipEnv: true,
}))
options[accessControllerOptionContext] = WithRegistryClient(
context.Background(),
NewRegistryClient(&clientcmd.Config{
CommonConfig: restclient.Config{
Host: server.URL,
Insecure: true,
},
SkipEnv: true,
}),
)
accessController, err := newAccessController(options)
if err != nil {
t.Fatal(err)
Expand Down

0 comments on commit 0184470

Please sign in to comment.