Add namespace
This commit is contained in:
parent
9d598836c3
commit
3df87510a1
@ -89,7 +89,7 @@ type Token struct {
|
|||||||
|
|
||||||
const (
|
const (
|
||||||
// DefaultNamespace used for auth
|
// DefaultNamespace used for auth
|
||||||
DefaultNamespace = "micro"
|
DefaultNamespace = "go.micro"
|
||||||
// NamespaceKey is the key used when storing the namespace in metadata
|
// NamespaceKey is the key used when storing the namespace in metadata
|
||||||
NamespaceKey = "Micro-Namespace"
|
NamespaceKey = "Micro-Namespace"
|
||||||
// MetadataKey is the key used when storing the account in metadata
|
// MetadataKey is the key used when storing the account in metadata
|
||||||
|
@ -8,6 +8,8 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type Options struct {
|
type Options struct {
|
||||||
|
// Namespace the service belongs to
|
||||||
|
Namespace string
|
||||||
// ID is the services auth ID
|
// ID is the services auth ID
|
||||||
ID string
|
ID string
|
||||||
// Secret is used to authenticate the service
|
// Secret is used to authenticate the service
|
||||||
@ -28,6 +30,13 @@ type Options struct {
|
|||||||
|
|
||||||
type Option func(o *Options)
|
type Option func(o *Options)
|
||||||
|
|
||||||
|
// Namespace the service belongs to
|
||||||
|
func Namespace(n string) Option {
|
||||||
|
return func(o *Options) {
|
||||||
|
o.Namespace = n
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Store to back auth
|
// Store to back auth
|
||||||
func Store(s store.Store) Option {
|
func Store(s store.Store) Option {
|
||||||
return func(o *Options) {
|
return func(o *Options) {
|
||||||
|
@ -314,6 +314,12 @@ var (
|
|||||||
EnvVars: []string{"MICRO_CONFIG"},
|
EnvVars: []string{"MICRO_CONFIG"},
|
||||||
Usage: "The source of the config to be used to get configuration",
|
Usage: "The source of the config to be used to get configuration",
|
||||||
},
|
},
|
||||||
|
&cli.StringFlag{
|
||||||
|
Name: "namespace",
|
||||||
|
EnvVars: []string{"MICRO_NAMESPACE"},
|
||||||
|
Usage: "The namespace the service belongs to",
|
||||||
|
Value: auth.DefaultNamespace,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
DefaultBrokers = map[string]func(...broker.Option) broker.Broker{
|
DefaultBrokers = map[string]func(...broker.Option) broker.Broker{
|
||||||
@ -678,6 +684,9 @@ func (c *cmd) Before(ctx *cli.Context) error {
|
|||||||
ctx.String("auth_id"), ctx.String("auth_secret"),
|
ctx.String("auth_id"), ctx.String("auth_secret"),
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
if len(ctx.String("namespace")) > 0 {
|
||||||
|
authOpts = append(authOpts, auth.Namespace(ctx.String("namespace")))
|
||||||
|
}
|
||||||
|
|
||||||
if len(ctx.String("auth_public_key")) > 0 {
|
if len(ctx.String("auth_public_key")) > 0 {
|
||||||
authOpts = append(authOpts, auth.PublicKey(ctx.String("auth_public_key")))
|
authOpts = append(authOpts, auth.PublicKey(ctx.String("auth_public_key")))
|
||||||
|
Loading…
Reference in New Issue
Block a user