diff --git a/admission/admission.go b/admission/admission.go index bfdcdac..8d51fd3 100644 --- a/admission/admission.go +++ b/admission/admission.go @@ -2,8 +2,11 @@ package admission import "context" +type Options struct{} +type Option func(opts *Options) + type Admission interface { - Admit(ctx context.Context, addr string) bool + Admit(ctx context.Context, addr string, opts ...Option) bool } type admissionGroup struct { @@ -16,9 +19,9 @@ func AdmissionGroup(admissions ...Admission) Admission { } } -func (p *admissionGroup) Admit(ctx context.Context, addr string) bool { +func (p *admissionGroup) Admit(ctx context.Context, addr string, opts ...Option) bool { for _, admission := range p.admissions { - if admission != nil && !admission.Admit(ctx, addr) { + if admission != nil && !admission.Admit(ctx, addr, opts...) { return false } } diff --git a/auth/auth.go b/auth/auth.go index 56f48f6..adfa2b5 100644 --- a/auth/auth.go +++ b/auth/auth.go @@ -2,9 +2,13 @@ package auth import "context" +type Options struct{} + +type Option func(opts *Options) + // Authenticator is an interface for user authentication. type Authenticator interface { - Authenticate(ctx context.Context, user, password string) (id string, ok bool) + Authenticate(ctx context.Context, user, password string, opts ...Option) (id string, ok bool) } type authenticatorGroup struct { @@ -17,7 +21,7 @@ func AuthenticatorGroup(authers ...Authenticator) Authenticator { } } -func (p *authenticatorGroup) Authenticate(ctx context.Context, user, password string) (string, bool) { +func (p *authenticatorGroup) Authenticate(ctx context.Context, user, password string, opts ...Option) (string, bool) { if len(p.authers) == 0 { return "", false } @@ -26,7 +30,7 @@ func (p *authenticatorGroup) Authenticate(ctx context.Context, user, password st continue } - if id, ok := auther.Authenticate(ctx, user, password); ok { + if id, ok := auther.Authenticate(ctx, user, password, opts...); ok { return id, ok } } diff --git a/hosts/hosts.go b/hosts/hosts.go index 2286d4b..83dc031 100644 --- a/hosts/hosts.go +++ b/hosts/hosts.go @@ -5,7 +5,11 @@ import ( "net" ) +type Options struct{} + +type Option func(opts *Options) + // HostMapper is a mapping from hostname to IP. type HostMapper interface { - Lookup(ctx context.Context, network, host string) ([]net.IP, bool) + Lookup(ctx context.Context, network, host string, opts ...Option) ([]net.IP, bool) } diff --git a/ingress/ingress.go b/ingress/ingress.go index f2d81ff..592dfbc 100644 --- a/ingress/ingress.go +++ b/ingress/ingress.go @@ -2,7 +2,15 @@ package ingress import "context" +type GetOptions struct{} + +type GetOption func(opts *GetOptions) + +type SetOptions struct{} + +type SetOption func(opts *SetOptions) + type Ingress interface { - Get(ctx context.Context, host string) string - Set(ctx context.Context, host, endpoint string) + Get(ctx context.Context, host string, opts ...GetOption) string + Set(ctx context.Context, host, endpoint string, opts ...SetOption) } diff --git a/recorder/recorder.go b/recorder/recorder.go index 698ebb1..2125167 100644 --- a/recorder/recorder.go +++ b/recorder/recorder.go @@ -4,8 +4,11 @@ import ( "context" ) +type RecordOptions struct{} +type RecordOption func(opts *RecordOptions) + type Recorder interface { - Record(ctx context.Context, b []byte) error + Record(ctx context.Context, b []byte, opts ...RecordOption) error } type RecorderObject struct { diff --git a/resolver/resolver.go b/resolver/resolver.go index b8a7354..fe0b8b3 100644 --- a/resolver/resolver.go +++ b/resolver/resolver.go @@ -10,8 +10,12 @@ var ( ErrInvalid = errors.New("invalid resolver") ) +type Options struct{} + +type Option func(opts *Options) + type Resolver interface { // Resolve returns a slice of the host's IPv4 and IPv6 addresses. // The network should be 'ip', 'ip4' or 'ip6', default network is 'ip'. - Resolve(ctx context.Context, network, host string) ([]net.IP, error) + Resolve(ctx context.Context, network, host string, opts ...Option) ([]net.IP, error) }