fix repocard issues (#20)
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
parent
dd78ae8658
commit
8076e410a9
@ -46,7 +46,7 @@ func (r *Resolver) Domain(req *http.Request) string {
|
||||
return ""
|
||||
}
|
||||
|
||||
// check for dev enviroment
|
||||
// check for dev environment
|
||||
if host == "localhost" || host == "127.0.0.1" {
|
||||
return ""
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ func OnDemand(b bool) Option {
|
||||
|
||||
// Cache provides a cache / storage interface to the underlying ACME library
|
||||
// as there is no standard, this needs to be validated by the underlying
|
||||
// implentation.
|
||||
// implementation
|
||||
func Cache(c interface{}) Option {
|
||||
return func(o *Options) {
|
||||
o.Cache = c
|
||||
|
@ -213,7 +213,7 @@ func NewTokenOptions(opts ...TokenOption) TokenOptions {
|
||||
o(&options)
|
||||
}
|
||||
|
||||
// set defualt expiry of token
|
||||
// set default expiry of token
|
||||
if options.Expiry == 0 {
|
||||
options.Expiry = time.Minute
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ func TestVerify(t *testing.T) {
|
||||
Account: &Account{},
|
||||
Resource: srvResource,
|
||||
Rules: []*Rule{
|
||||
&Rule{
|
||||
{
|
||||
Scope: "",
|
||||
Resource: catchallResource,
|
||||
},
|
||||
@ -52,7 +52,7 @@ func TestVerify(t *testing.T) {
|
||||
Name: "CatchallPublicNoAccount",
|
||||
Resource: srvResource,
|
||||
Rules: []*Rule{
|
||||
&Rule{
|
||||
{
|
||||
Scope: "",
|
||||
Resource: catchallResource,
|
||||
},
|
||||
@ -63,7 +63,7 @@ func TestVerify(t *testing.T) {
|
||||
Account: &Account{},
|
||||
Resource: srvResource,
|
||||
Rules: []*Rule{
|
||||
&Rule{
|
||||
{
|
||||
Scope: "*",
|
||||
Resource: catchallResource,
|
||||
},
|
||||
@ -73,7 +73,7 @@ func TestVerify(t *testing.T) {
|
||||
Name: "CatchallPrivateNoAccount",
|
||||
Resource: srvResource,
|
||||
Rules: []*Rule{
|
||||
&Rule{
|
||||
{
|
||||
Scope: "*",
|
||||
Resource: catchallResource,
|
||||
},
|
||||
@ -85,7 +85,7 @@ func TestVerify(t *testing.T) {
|
||||
Resource: srvResource,
|
||||
Account: &Account{},
|
||||
Rules: []*Rule{
|
||||
&Rule{
|
||||
{
|
||||
Scope: "*",
|
||||
Resource: &Resource{
|
||||
Type: srvResource.Type,
|
||||
@ -100,7 +100,7 @@ func TestVerify(t *testing.T) {
|
||||
Resource: srvResource,
|
||||
Account: &Account{},
|
||||
Rules: []*Rule{
|
||||
&Rule{
|
||||
{
|
||||
Scope: "*",
|
||||
Resource: &Resource{
|
||||
Type: srvResource.Type,
|
||||
@ -118,7 +118,7 @@ func TestVerify(t *testing.T) {
|
||||
Scopes: []string{"neededscope"},
|
||||
},
|
||||
Rules: []*Rule{
|
||||
&Rule{
|
||||
{
|
||||
Scope: "neededscope",
|
||||
Resource: srvResource,
|
||||
},
|
||||
@ -131,7 +131,7 @@ func TestVerify(t *testing.T) {
|
||||
Scopes: []string{"neededscope"},
|
||||
},
|
||||
Rules: []*Rule{
|
||||
&Rule{
|
||||
{
|
||||
Scope: "invalidscope",
|
||||
Resource: srvResource,
|
||||
},
|
||||
@ -143,7 +143,7 @@ func TestVerify(t *testing.T) {
|
||||
Resource: srvResource,
|
||||
Account: &Account{},
|
||||
Rules: []*Rule{
|
||||
&Rule{
|
||||
{
|
||||
Scope: "*",
|
||||
Resource: catchallResource,
|
||||
Access: AccessDenied,
|
||||
@ -156,7 +156,7 @@ func TestVerify(t *testing.T) {
|
||||
Resource: srvResource,
|
||||
Account: &Account{},
|
||||
Rules: []*Rule{
|
||||
&Rule{
|
||||
{
|
||||
Scope: "*",
|
||||
Resource: catchallResource,
|
||||
Access: AccessDenied,
|
||||
@ -169,13 +169,13 @@ func TestVerify(t *testing.T) {
|
||||
Resource: srvResource,
|
||||
Account: &Account{},
|
||||
Rules: []*Rule{
|
||||
&Rule{
|
||||
{
|
||||
Scope: "*",
|
||||
Resource: catchallResource,
|
||||
Access: AccessGranted,
|
||||
Priority: 1,
|
||||
},
|
||||
&Rule{
|
||||
{
|
||||
Scope: "*",
|
||||
Resource: catchallResource,
|
||||
Access: AccessDenied,
|
||||
@ -188,13 +188,13 @@ func TestVerify(t *testing.T) {
|
||||
Resource: srvResource,
|
||||
Account: &Account{},
|
||||
Rules: []*Rule{
|
||||
&Rule{
|
||||
{
|
||||
Scope: "*",
|
||||
Resource: catchallResource,
|
||||
Access: AccessGranted,
|
||||
Priority: 0,
|
||||
},
|
||||
&Rule{
|
||||
{
|
||||
Scope: "*",
|
||||
Resource: catchallResource,
|
||||
Access: AccessDenied,
|
||||
@ -208,7 +208,7 @@ func TestVerify(t *testing.T) {
|
||||
Resource: webResource,
|
||||
Account: &Account{},
|
||||
Rules: []*Rule{
|
||||
&Rule{
|
||||
{
|
||||
Scope: "*",
|
||||
Resource: webResource,
|
||||
},
|
||||
@ -219,7 +219,7 @@ func TestVerify(t *testing.T) {
|
||||
Resource: webResource,
|
||||
Account: &Account{},
|
||||
Rules: []*Rule{
|
||||
&Rule{
|
||||
{
|
||||
Scope: "*",
|
||||
Resource: &Resource{
|
||||
Type: webResource.Type,
|
||||
@ -235,7 +235,7 @@ func TestVerify(t *testing.T) {
|
||||
Resource: webResource,
|
||||
Account: &Account{},
|
||||
Rules: []*Rule{
|
||||
&Rule{
|
||||
{
|
||||
Scope: "*",
|
||||
Resource: &Resource{
|
||||
Type: webResource.Type,
|
||||
@ -250,7 +250,7 @@ func TestVerify(t *testing.T) {
|
||||
Resource: webResource,
|
||||
Account: &Account{},
|
||||
Rules: []*Rule{
|
||||
&Rule{
|
||||
{
|
||||
Scope: "*",
|
||||
Resource: &Resource{
|
||||
Type: webResource.Type,
|
||||
@ -265,7 +265,7 @@ func TestVerify(t *testing.T) {
|
||||
Resource: webResource,
|
||||
Account: &Account{},
|
||||
Rules: []*Rule{
|
||||
&Rule{
|
||||
{
|
||||
Scope: "*",
|
||||
Resource: &Resource{
|
||||
Type: webResource.Type,
|
||||
|
@ -16,6 +16,7 @@ type Broker interface {
|
||||
// Handler is used to process messages via a subscription of a topic.
|
||||
type Handler func(*Message) error
|
||||
|
||||
// Message is used to transfer data
|
||||
type Message struct {
|
||||
Header map[string]string
|
||||
Body []byte
|
||||
|
@ -6,7 +6,7 @@ import (
|
||||
"github.com/unistack-org/micro/v3/errors"
|
||||
)
|
||||
|
||||
// note that returning either false or a non-nil error will result in the call not being retried
|
||||
// RetryFunc that returning either false or a non-nil error will result in the call not being retried
|
||||
type RetryFunc func(ctx context.Context, req Request, retryCount int, err error) (bool, error)
|
||||
|
||||
// RetryAlways always retry on error
|
||||
|
@ -160,7 +160,7 @@ func TestConfigWatcherDirtyOverrite(t *testing.T) {
|
||||
}
|
||||
runtime.Gosched()
|
||||
|
||||
for i, _ := range ss {
|
||||
for i := range ss {
|
||||
k := fmt.Sprintf("key%d", i)
|
||||
v := fmt.Sprintf("val%d", i)
|
||||
equalS(t, conf.Get(k).String(""), v)
|
||||
|
@ -57,7 +57,7 @@ func WithStartAtTime(t time.Time) SubscribeOption {
|
||||
// WriteOptions contains all the options which can be provided when writing an event to a store
|
||||
type WriteOptions struct {
|
||||
// TTL is the duration the event should be recorded for, a zero value TTL indicates the event should
|
||||
// be stored indefinately
|
||||
// be stored indefinitely
|
||||
TTL time.Duration
|
||||
}
|
||||
|
||||
|
@ -6,6 +6,7 @@ import (
|
||||
"github.com/unistack-org/micro/v3/router"
|
||||
)
|
||||
|
||||
// Options for proxy
|
||||
type Options struct {
|
||||
// Specific endpoint to always call
|
||||
Endpoint string
|
||||
@ -17,6 +18,7 @@ type Options struct {
|
||||
Links map[string]client.Client
|
||||
}
|
||||
|
||||
// Option func signature
|
||||
type Option func(o *Options)
|
||||
|
||||
// WithEndpoint sets a proxy endpoint
|
||||
|
@ -13,9 +13,9 @@ const (
|
||||
)
|
||||
|
||||
var (
|
||||
// Not found error when GetService is called
|
||||
// ErrNotFound returned when GetService is called and no services found
|
||||
ErrNotFound = errors.New("service not found")
|
||||
// Watcher stopped error when watcher is stopped
|
||||
// ErrWatcherStopped returned when when watcher is stopped
|
||||
ErrWatcherStopped = errors.New("watcher stopped")
|
||||
)
|
||||
|
||||
@ -33,6 +33,7 @@ type Registry interface {
|
||||
String() string
|
||||
}
|
||||
|
||||
// Service holds service registry info
|
||||
type Service struct {
|
||||
Name string `json:"name"`
|
||||
Version string `json:"version"`
|
||||
@ -41,12 +42,14 @@ type Service struct {
|
||||
Nodes []*Node `json:"nodes"`
|
||||
}
|
||||
|
||||
// Node holds node registry info
|
||||
type Node struct {
|
||||
Id string `json:"id"`
|
||||
Address string `json:"address"`
|
||||
Metadata map[string]string `json:"metadata"`
|
||||
}
|
||||
|
||||
// Endpoint holds endpoint registry info
|
||||
type Endpoint struct {
|
||||
Name string `json:"name"`
|
||||
Request *Value `json:"request"`
|
||||
@ -54,20 +57,27 @@ type Endpoint struct {
|
||||
Metadata map[string]string `json:"metadata"`
|
||||
}
|
||||
|
||||
// Valud holds additional kv stuff
|
||||
type Value struct {
|
||||
Name string `json:"name"`
|
||||
Type string `json:"type"`
|
||||
Values []*Value `json:"values"`
|
||||
}
|
||||
|
||||
// Option func signature
|
||||
type Option func(*Options)
|
||||
|
||||
// RegisterOption option is used to register service
|
||||
type RegisterOption func(*RegisterOptions)
|
||||
|
||||
// WatchOption option is used to watch service changes
|
||||
type WatchOption func(*WatchOptions)
|
||||
|
||||
// DeregisterOption option is used to deregister service
|
||||
type DeregisterOption func(*DeregisterOptions)
|
||||
|
||||
// GetOption option is used to get service
|
||||
type GetOption func(*GetOptions)
|
||||
|
||||
// ListOption option is used to list services
|
||||
type ListOption func(*ListOptions)
|
||||
|
@ -58,7 +58,7 @@ func TestDelete(t *testing.T) {
|
||||
t.Fatalf("error adding route: %s", err)
|
||||
}
|
||||
|
||||
// should fail to delete non-existant route
|
||||
// should fail to delete non-existent route
|
||||
prevSvc := route.Service
|
||||
route.Service = "randDest"
|
||||
|
||||
|
@ -71,7 +71,7 @@ func (t *table) Query(opts ...router.QueryOption) ([]router.Route, error) {
|
||||
options := router.NewQuery(opts...)
|
||||
|
||||
return []router.Route{
|
||||
router.Route{
|
||||
{
|
||||
Address: options.Service,
|
||||
Service: options.Address,
|
||||
Gateway: options.Gateway,
|
||||
|
@ -157,7 +157,7 @@ func WithArgs(args ...string) CreateOption {
|
||||
}
|
||||
}
|
||||
|
||||
// WithRetries sets the max retries attemps
|
||||
// WithRetries sets the max retries attempts
|
||||
func WithRetries(retries int) CreateOption {
|
||||
return func(o *CreateOptions) {
|
||||
o.Retries = retries
|
||||
|
@ -13,7 +13,7 @@ type Options struct {
|
||||
Nodes []string
|
||||
// Database allows multiple isolated stores to be kept in one backend, if supported.
|
||||
Database string
|
||||
// Table is analagous to a table in database backends or a key prefix in KV backends
|
||||
// Table is analag for a table in database backends or a key prefix in KV backends
|
||||
Table string
|
||||
// Context should contain all implementation specific options, using context.WithValue.
|
||||
Context context.Context
|
||||
@ -38,7 +38,7 @@ func Database(db string) Option {
|
||||
}
|
||||
}
|
||||
|
||||
// Table is analagous to a table in database backends or a key prefix in KV backends
|
||||
// Table is analag for a table in database backends or a key prefix in KV backends
|
||||
func Table(t string) Option {
|
||||
return func(o *Options) {
|
||||
o.Table = t
|
||||
|
@ -383,11 +383,11 @@ func expiryTests(s store.Store, t *testing.T) {
|
||||
func suffixPrefixExpiryTests(s store.Store, t *testing.T) {
|
||||
// Write 3 records with various expiry and get with Prefix
|
||||
records := []*store.Record{
|
||||
&store.Record{
|
||||
{
|
||||
Key: "foo",
|
||||
Value: []byte("foofoo"),
|
||||
},
|
||||
&store.Record{
|
||||
{
|
||||
Key: "foobar",
|
||||
Value: []byte("foobarfoobar"),
|
||||
Expiry: time.Millisecond * 100,
|
||||
@ -431,17 +431,17 @@ func suffixPrefixExpiryTests(s store.Store, t *testing.T) {
|
||||
|
||||
// Write 3 records with various expiry and get with Suffix
|
||||
records = []*store.Record{
|
||||
&store.Record{
|
||||
{
|
||||
Key: "foo",
|
||||
Value: []byte("foofoo"),
|
||||
},
|
||||
&store.Record{
|
||||
{
|
||||
Key: "barfoo",
|
||||
Value: []byte("barfoobarfoo"),
|
||||
|
||||
Expiry: time.Millisecond * 100,
|
||||
},
|
||||
&store.Record{
|
||||
{
|
||||
Key: "bazbarfoo",
|
||||
Value: []byte("bazbarfoobazbarfoo"),
|
||||
Expiry: 2 * time.Millisecond * 100,
|
||||
|
@ -16,11 +16,13 @@ type Transport interface {
|
||||
String() string
|
||||
}
|
||||
|
||||
// Message is used to transfer data
|
||||
type Message struct {
|
||||
Header map[string]string
|
||||
Body []byte
|
||||
}
|
||||
|
||||
// Socket bastraction interface
|
||||
type Socket interface {
|
||||
Recv(*Message) error
|
||||
Send(*Message) error
|
||||
@ -29,22 +31,28 @@ type Socket interface {
|
||||
Remote() string
|
||||
}
|
||||
|
||||
// Client is the socket owner
|
||||
type Client interface {
|
||||
Socket
|
||||
}
|
||||
|
||||
// Listener is the interface for stream oriented messaging
|
||||
type Listener interface {
|
||||
Addr() string
|
||||
Close() error
|
||||
Accept(func(Socket)) error
|
||||
}
|
||||
|
||||
// Option is the option signature
|
||||
type Option func(*Options)
|
||||
|
||||
// DialOption is the option signature
|
||||
type DialOption func(*DialOptions)
|
||||
|
||||
// ListenOption is the option signature
|
||||
type ListenOption func(*ListenOptions)
|
||||
|
||||
var (
|
||||
// Default dial timeout
|
||||
DefaultDialTimeout = time.Second * 5
|
||||
)
|
||||
|
@ -19,49 +19,49 @@ type testcase struct {
|
||||
}
|
||||
|
||||
var tests = []testcase{
|
||||
testcase{
|
||||
{
|
||||
ReqFn: func(opts *Options) *Request {
|
||||
return NewRequest(opts).Get().Resource("service")
|
||||
},
|
||||
Method: "GET",
|
||||
URI: "/api/v1/namespaces/default/services/",
|
||||
},
|
||||
testcase{
|
||||
{
|
||||
ReqFn: func(opts *Options) *Request {
|
||||
return NewRequest(opts).Get().Resource("service").Name("foo")
|
||||
},
|
||||
Method: "GET",
|
||||
URI: "/api/v1/namespaces/default/services/foo",
|
||||
},
|
||||
testcase{
|
||||
{
|
||||
ReqFn: func(opts *Options) *Request {
|
||||
return NewRequest(opts).Get().Resource("service").Namespace("test").Name("bar")
|
||||
},
|
||||
Method: "GET",
|
||||
URI: "/api/v1/namespaces/test/services/bar",
|
||||
},
|
||||
testcase{
|
||||
{
|
||||
ReqFn: func(opts *Options) *Request {
|
||||
return NewRequest(opts).Get().Resource("deployment").Name("foo")
|
||||
},
|
||||
Method: "GET",
|
||||
URI: "/apis/apps/v1/namespaces/default/deployments/foo",
|
||||
},
|
||||
testcase{
|
||||
{
|
||||
ReqFn: func(opts *Options) *Request {
|
||||
return NewRequest(opts).Get().Resource("deployment").Namespace("test").Name("foo")
|
||||
},
|
||||
Method: "GET",
|
||||
URI: "/apis/apps/v1/namespaces/test/deployments/foo",
|
||||
},
|
||||
testcase{
|
||||
{
|
||||
ReqFn: func(opts *Options) *Request {
|
||||
return NewRequest(opts).Get().Resource("pod").Params(&Params{LabelSelector: map[string]string{"foo": "bar"}})
|
||||
},
|
||||
Method: "GET",
|
||||
URI: "/api/v1/namespaces/default/pods/?labelSelector=foo%3Dbar",
|
||||
},
|
||||
testcase{
|
||||
{
|
||||
ReqFn: func(opts *Options) *Request {
|
||||
return NewRequest(opts).Post().Resource("service").Name("foo").Body(map[string]string{"foo": "bar"})
|
||||
},
|
||||
@ -69,7 +69,7 @@ var tests = []testcase{
|
||||
URI: "/api/v1/namespaces/default/services/foo",
|
||||
Body: map[string]string{"foo": "bar"},
|
||||
},
|
||||
testcase{
|
||||
{
|
||||
ReqFn: func(opts *Options) *Request {
|
||||
return NewRequest(opts).Post().Resource("deployment").Namespace("test").Name("foo").Body(map[string]string{"foo": "bar"})
|
||||
},
|
||||
@ -77,7 +77,7 @@ var tests = []testcase{
|
||||
URI: "/apis/apps/v1/namespaces/test/deployments/foo",
|
||||
Body: map[string]string{"foo": "bar"},
|
||||
},
|
||||
testcase{
|
||||
{
|
||||
ReqFn: func(opts *Options) *Request {
|
||||
return NewRequest(opts).Put().Resource("endpoint").Name("baz").Body(map[string]string{"bam": "bar"})
|
||||
},
|
||||
@ -85,7 +85,7 @@ var tests = []testcase{
|
||||
URI: "/api/v1/namespaces/default/endpoints/baz",
|
||||
Body: map[string]string{"bam": "bar"},
|
||||
},
|
||||
testcase{
|
||||
{
|
||||
ReqFn: func(opts *Options) *Request {
|
||||
return NewRequest(opts).Patch().Resource("endpoint").Name("baz").Body(map[string]string{"bam": "bar"})
|
||||
},
|
||||
@ -93,7 +93,7 @@ var tests = []testcase{
|
||||
URI: "/api/v1/namespaces/default/endpoints/baz",
|
||||
Body: map[string]string{"bam": "bar"},
|
||||
},
|
||||
testcase{
|
||||
{
|
||||
ReqFn: func(opts *Options) *Request {
|
||||
return NewRequest(opts).Patch().Resource("endpoint").Name("baz").SetHeader("foo", "bar")
|
||||
},
|
||||
@ -101,7 +101,7 @@ var tests = []testcase{
|
||||
URI: "/api/v1/namespaces/default/endpoints/baz",
|
||||
Header: map[string]string{"foo": "bar"},
|
||||
},
|
||||
testcase{
|
||||
{
|
||||
ReqFn: func(opts *Options) *Request {
|
||||
return NewRequest(opts).Patch().Resource("deployment").Name("baz").SetHeader("foo", "bar")
|
||||
},
|
||||
@ -109,7 +109,7 @@ var tests = []testcase{
|
||||
URI: "/apis/apps/v1/namespaces/default/deployments/baz",
|
||||
Header: map[string]string{"foo": "bar"},
|
||||
},
|
||||
testcase{
|
||||
{
|
||||
ReqFn: func(opts *Options) *Request {
|
||||
return NewRequest(opts).
|
||||
Get().
|
||||
|
@ -282,7 +282,7 @@ func (c *client) Close() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// setInterface is used to set the query interface, uses sytem
|
||||
// setInterface is used to set the query interface, uses system
|
||||
// default if not provided
|
||||
func (c *client) setInterface(iface *net.Interface, loopback bool) error {
|
||||
p := ipv4.NewPacketConn(c.ipv4UnicastConn)
|
||||
|
Loading…
Reference in New Issue
Block a user