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