policy

package
v0.0.0-...-c2bd595 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 11, 2019 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultPort for the backend service.
	DefaultPort = 1071
)

Variables

View Source
var (
	ErrInvalidLengthConfig = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowConfig   = fmt.Errorf("proto: integer overflow")
)
View Source
var (
	ErrInvalidLengthController = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowController   = fmt.Errorf("proto: integer overflow")
)

Functions

func RegisterControllerServiceServer

func RegisterControllerServiceServer(s *grpc.Server, srv ControllerServiceServer)

Types

type Backend

type Backend struct {
	// contains filtered or unexported fields
}

Backend is the implementation of a Fake policy backend. It can be ran either in a cluster or locally.

func NewPolicyBackend

func NewPolicyBackend(port int) *Backend

NewPolicyBackend returns a new instance of Backend.

func (*Backend) Close

func (b *Backend) Close() error

Close closes the gRPC backend and the associated listener.

func (*Backend) CloseSession

CloseSession is an implementation InfrastructureBackendServer.CloseSession.

func (*Backend) CreateSession

CreateSession is an implementation InfrastructureBackendServer.CreateSession.

func (*Backend) GetReports

func (b *Backend) GetReports(ctx context.Context, req *GetReportsRequest) (*GetReportsResponse, error)

GetReports method of the control service.

func (*Backend) HandleCheckNothing

HandleCheckNothing is an implementation of HandleCheckNothingServiceServer.HandleCheckNothing.

func (*Backend) HandleKeyval

HandleKeyval is an implementation of HandleKeyvalServiceServer.HandleKeyval.

func (*Backend) HandleMetric

HandleMetric is an implementation HandleMetricServiceServer.HandleMetric.

func (*Backend) Port

func (b *Backend) Port() int

Port returns the port number of the backend.

func (*Backend) Reset

func (b *Backend) Reset(ctx context.Context, req *ResetRequest) (*ResetResponse, error)

Reset the internal state of the service.

func (*Backend) Set

func (b *Backend) Set(ctx context.Context, req *SetRequest) (*SetResponse, error)

Set method of the control service.

func (*Backend) Start

func (b *Backend) Start() error

Start the gRPC service for the policy backend.

func (*Backend) Validate

Validate is an implementation InfrastructureBackendServer.Validate.

type Controller

type Controller struct {
	// contains filtered or unexported fields
}

Controller is the control interface for the policy backend. The tests can use the interface to control the fake.

func NewController

func NewController(address string) (*Controller, error)

NewController creates and returns a new instance of a controller client for the backend.

func (*Controller) AllowCheck

func (c *Controller) AllowCheck(d time.Duration, count int32) error

AllowCheck causes the policy backend to allow all check requests with the supplied valid duration and valid count in check result.

func (*Controller) DenyCheck

func (c *Controller) DenyCheck(deny bool) error

DenyCheck causes the policy backend to deny all check requests when set to true.

func (*Controller) GetReports

func (c *Controller) GetReports() ([]proto.Message, error)

GetReports returns the currently accumulated report instances.

func (*Controller) Reset

func (c *Controller) Reset() error

Reset the state of the backend.

type ControllerServiceClient

type ControllerServiceClient interface {
	// Set changes settings of the fake policy backend.
	Set(ctx context.Context, in *SetRequest, opts ...grpc.CallOption) (*SetResponse, error)
	// Resets the internal state of the policy backend (i.e. all settings are reverted to the default values
	// and all accumulated state is cleared.
	Reset(ctx context.Context, in *ResetRequest, opts ...grpc.CallOption) (*ResetResponse, error)
	// GetReports returns the accumulated set of reports from the service. The server clears out its
	// accumulated cache once the call completes.
	GetReports(ctx context.Context, in *GetReportsRequest, opts ...grpc.CallOption) (*GetReportsResponse, error)
}

ControllerServiceClient is the client API for ControllerService service.

For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.

func NewControllerServiceClient

func NewControllerServiceClient(cc *grpc.ClientConn) ControllerServiceClient

type ControllerServiceServer

type ControllerServiceServer interface {
	// Set changes settings of the fake policy backend.
	Set(context.Context, *SetRequest) (*SetResponse, error)
	// Resets the internal state of the policy backend (i.e. all settings are reverted to the default values
	// and all accumulated state is cleared.
	Reset(context.Context, *ResetRequest) (*ResetResponse, error)
	// GetReports returns the accumulated set of reports from the service. The server clears out its
	// accumulated cache once the call completes.
	GetReports(context.Context, *GetReportsRequest) (*GetReportsResponse, error)
}

ControllerServiceServer is the server API for ControllerService service.

type GetReportsRequest

type GetReportsRequest struct {
}

func (*GetReportsRequest) Descriptor

func (*GetReportsRequest) Descriptor() ([]byte, []int)

func (*GetReportsRequest) Equal

func (this *GetReportsRequest) Equal(that interface{}) bool

func (*GetReportsRequest) GoString

func (this *GetReportsRequest) GoString() string

func (*GetReportsRequest) Marshal

func (m *GetReportsRequest) Marshal() (dAtA []byte, err error)

func (*GetReportsRequest) MarshalTo

func (m *GetReportsRequest) MarshalTo(dAtA []byte) (int, error)

func (*GetReportsRequest) MarshalToSizedBuffer

func (m *GetReportsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*GetReportsRequest) ProtoMessage

func (*GetReportsRequest) ProtoMessage()

func (*GetReportsRequest) Reset

func (m *GetReportsRequest) Reset()

func (*GetReportsRequest) Size

func (m *GetReportsRequest) Size() (n int)

func (*GetReportsRequest) String

func (this *GetReportsRequest) String() string

func (*GetReportsRequest) Unmarshal

func (m *GetReportsRequest) Unmarshal(dAtA []byte) error

func (*GetReportsRequest) XXX_DiscardUnknown

func (m *GetReportsRequest) XXX_DiscardUnknown()

func (*GetReportsRequest) XXX_Marshal

func (m *GetReportsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*GetReportsRequest) XXX_Merge

func (m *GetReportsRequest) XXX_Merge(src proto.Message)

func (*GetReportsRequest) XXX_Size

func (m *GetReportsRequest) XXX_Size() int

func (*GetReportsRequest) XXX_Unmarshal

func (m *GetReportsRequest) XXX_Unmarshal(b []byte) error

type GetReportsResponse

type GetReportsResponse struct {
	Instances []*types.Any `protobuf:"bytes,1,rep,name=instances,proto3" json:"instances,omitempty"`
}

func (*GetReportsResponse) Descriptor

func (*GetReportsResponse) Descriptor() ([]byte, []int)

func (*GetReportsResponse) Equal

func (this *GetReportsResponse) Equal(that interface{}) bool

func (*GetReportsResponse) GetInstances

func (m *GetReportsResponse) GetInstances() []*types.Any

func (*GetReportsResponse) GoString

func (this *GetReportsResponse) GoString() string

func (*GetReportsResponse) Marshal

func (m *GetReportsResponse) Marshal() (dAtA []byte, err error)

func (*GetReportsResponse) MarshalTo

func (m *GetReportsResponse) MarshalTo(dAtA []byte) (int, error)

func (*GetReportsResponse) MarshalToSizedBuffer

func (m *GetReportsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*GetReportsResponse) ProtoMessage

func (*GetReportsResponse) ProtoMessage()

func (*GetReportsResponse) Reset

func (m *GetReportsResponse) Reset()

func (*GetReportsResponse) Size

func (m *GetReportsResponse) Size() (n int)

func (*GetReportsResponse) String

func (this *GetReportsResponse) String() string

func (*GetReportsResponse) Unmarshal

func (m *GetReportsResponse) Unmarshal(dAtA []byte) error

func (*GetReportsResponse) XXX_DiscardUnknown

func (m *GetReportsResponse) XXX_DiscardUnknown()

func (*GetReportsResponse) XXX_Marshal

func (m *GetReportsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*GetReportsResponse) XXX_Merge

func (m *GetReportsResponse) XXX_Merge(src proto.Message)

func (*GetReportsResponse) XXX_Size

func (m *GetReportsResponse) XXX_Size() int

func (*GetReportsResponse) XXX_Unmarshal

func (m *GetReportsResponse) XXX_Unmarshal(b []byte) error

type Params

type Params struct {
	// Specify check related params.
	CheckParams *Params_CheckParams `protobuf:"bytes,1,opt,name=check_params,json=checkParams,proto3" json:"check_params,omitempty"`
	// Specify route directive related params.
	Table map[string]string `` /* 151-byte string literal not displayed */
}

Config for policy backend, which could be used as a fake adpater for integration test, supports checknothing and keyval template.

func (*Params) Descriptor

func (*Params) Descriptor() ([]byte, []int)

func (*Params) Equal

func (this *Params) Equal(that interface{}) bool

func (*Params) GetCheckParams

func (m *Params) GetCheckParams() *Params_CheckParams

func (*Params) GetTable

func (m *Params) GetTable() map[string]string

func (*Params) GoString

func (this *Params) GoString() string

func (*Params) Marshal

func (m *Params) Marshal() (dAtA []byte, err error)

func (*Params) MarshalTo

func (m *Params) MarshalTo(dAtA []byte) (int, error)

func (*Params) MarshalToSizedBuffer

func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*Params) ProtoMessage

func (*Params) ProtoMessage()

func (*Params) Reset

func (m *Params) Reset()

func (*Params) Size

func (m *Params) Size() (n int)

func (*Params) String

func (this *Params) String() string

func (*Params) Unmarshal

func (m *Params) Unmarshal(dAtA []byte) error

func (*Params) XXX_DiscardUnknown

func (m *Params) XXX_DiscardUnknown()

func (*Params) XXX_Marshal

func (m *Params) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Params) XXX_Merge

func (m *Params) XXX_Merge(src proto.Message)

func (*Params) XXX_Size

func (m *Params) XXX_Size() int

func (*Params) XXX_Unmarshal

func (m *Params) XXX_Unmarshal(b []byte) error

type Params_CheckParams

type Params_CheckParams struct {
	// Controls that request should be allowed or not.
	CheckAllow bool `protobuf:"varint,1,opt,name=check_allow,json=checkAllow,proto3" json:"check_allow,omitempty"`
	// Valid duration of the check result.
	ValidDuration *types.Duration `protobuf:"bytes,2,opt,name=valid_duration,json=validDuration,proto3" json:"valid_duration,omitempty"`
	// Valid request count of the check result.
	ValidCount int64 `protobuf:"varint,3,opt,name=valid_count,json=validCount,proto3" json:"valid_count,omitempty"`
}

Check params which controls check result returned by policy backend.

func (*Params_CheckParams) Descriptor

func (*Params_CheckParams) Descriptor() ([]byte, []int)

func (*Params_CheckParams) Equal

func (this *Params_CheckParams) Equal(that interface{}) bool

func (*Params_CheckParams) GetCheckAllow

func (m *Params_CheckParams) GetCheckAllow() bool

func (*Params_CheckParams) GetValidCount

func (m *Params_CheckParams) GetValidCount() int64

func (*Params_CheckParams) GetValidDuration

func (m *Params_CheckParams) GetValidDuration() *types.Duration

func (*Params_CheckParams) GoString

func (this *Params_CheckParams) GoString() string

func (*Params_CheckParams) Marshal

func (m *Params_CheckParams) Marshal() (dAtA []byte, err error)

func (*Params_CheckParams) MarshalTo

func (m *Params_CheckParams) MarshalTo(dAtA []byte) (int, error)

func (*Params_CheckParams) MarshalToSizedBuffer

func (m *Params_CheckParams) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*Params_CheckParams) ProtoMessage

func (*Params_CheckParams) ProtoMessage()

func (*Params_CheckParams) Reset

func (m *Params_CheckParams) Reset()

func (*Params_CheckParams) Size

func (m *Params_CheckParams) Size() (n int)

func (*Params_CheckParams) String

func (this *Params_CheckParams) String() string

func (*Params_CheckParams) Unmarshal

func (m *Params_CheckParams) Unmarshal(dAtA []byte) error

func (*Params_CheckParams) XXX_DiscardUnknown

func (m *Params_CheckParams) XXX_DiscardUnknown()

func (*Params_CheckParams) XXX_Marshal

func (m *Params_CheckParams) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Params_CheckParams) XXX_Merge

func (m *Params_CheckParams) XXX_Merge(src proto.Message)

func (*Params_CheckParams) XXX_Size

func (m *Params_CheckParams) XXX_Size() int

func (*Params_CheckParams) XXX_Unmarshal

func (m *Params_CheckParams) XXX_Unmarshal(b []byte) error

type ResetRequest

type ResetRequest struct {
}

func (*ResetRequest) Descriptor

func (*ResetRequest) Descriptor() ([]byte, []int)

func (*ResetRequest) Equal

func (this *ResetRequest) Equal(that interface{}) bool

func (*ResetRequest) GoString

func (this *ResetRequest) GoString() string

func (*ResetRequest) Marshal

func (m *ResetRequest) Marshal() (dAtA []byte, err error)

func (*ResetRequest) MarshalTo

func (m *ResetRequest) MarshalTo(dAtA []byte) (int, error)

func (*ResetRequest) MarshalToSizedBuffer

func (m *ResetRequest) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*ResetRequest) ProtoMessage

func (*ResetRequest) ProtoMessage()

func (*ResetRequest) Reset

func (m *ResetRequest) Reset()

func (*ResetRequest) Size

func (m *ResetRequest) Size() (n int)

func (*ResetRequest) String

func (this *ResetRequest) String() string

func (*ResetRequest) Unmarshal

func (m *ResetRequest) Unmarshal(dAtA []byte) error

func (*ResetRequest) XXX_DiscardUnknown

func (m *ResetRequest) XXX_DiscardUnknown()

func (*ResetRequest) XXX_Marshal

func (m *ResetRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*ResetRequest) XXX_Merge

func (m *ResetRequest) XXX_Merge(src proto.Message)

func (*ResetRequest) XXX_Size

func (m *ResetRequest) XXX_Size() int

func (*ResetRequest) XXX_Unmarshal

func (m *ResetRequest) XXX_Unmarshal(b []byte) error

type ResetResponse

type ResetResponse struct {
}

func (*ResetResponse) Descriptor

func (*ResetResponse) Descriptor() ([]byte, []int)

func (*ResetResponse) Equal

func (this *ResetResponse) Equal(that interface{}) bool

func (*ResetResponse) GoString

func (this *ResetResponse) GoString() string

func (*ResetResponse) Marshal

func (m *ResetResponse) Marshal() (dAtA []byte, err error)

func (*ResetResponse) MarshalTo

func (m *ResetResponse) MarshalTo(dAtA []byte) (int, error)

func (*ResetResponse) MarshalToSizedBuffer

func (m *ResetResponse) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*ResetResponse) ProtoMessage

func (*ResetResponse) ProtoMessage()

func (*ResetResponse) Reset

func (m *ResetResponse) Reset()

func (*ResetResponse) Size

func (m *ResetResponse) Size() (n int)

func (*ResetResponse) String

func (this *ResetResponse) String() string

func (*ResetResponse) Unmarshal

func (m *ResetResponse) Unmarshal(dAtA []byte) error

func (*ResetResponse) XXX_DiscardUnknown

func (m *ResetResponse) XXX_DiscardUnknown()

func (*ResetResponse) XXX_Marshal

func (m *ResetResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*ResetResponse) XXX_Merge

func (m *ResetResponse) XXX_Merge(src proto.Message)

func (*ResetResponse) XXX_Size

func (m *ResetResponse) XXX_Size() int

func (*ResetResponse) XXX_Unmarshal

func (m *ResetResponse) XXX_Unmarshal(b []byte) error

type SetRequest

type SetRequest struct {
	// The settings to set on the service.
	Settings map[string]string `` /* 157-byte string literal not displayed */
}

func (*SetRequest) Descriptor

func (*SetRequest) Descriptor() ([]byte, []int)

func (*SetRequest) Equal

func (this *SetRequest) Equal(that interface{}) bool

func (*SetRequest) GetSettings

func (m *SetRequest) GetSettings() map[string]string

func (*SetRequest) GoString

func (this *SetRequest) GoString() string

func (*SetRequest) Marshal

func (m *SetRequest) Marshal() (dAtA []byte, err error)

func (*SetRequest) MarshalTo

func (m *SetRequest) MarshalTo(dAtA []byte) (int, error)

func (*SetRequest) MarshalToSizedBuffer

func (m *SetRequest) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*SetRequest) ProtoMessage

func (*SetRequest) ProtoMessage()

func (*SetRequest) Reset

func (m *SetRequest) Reset()

func (*SetRequest) Size

func (m *SetRequest) Size() (n int)

func (*SetRequest) String

func (this *SetRequest) String() string

func (*SetRequest) Unmarshal

func (m *SetRequest) Unmarshal(dAtA []byte) error

func (*SetRequest) XXX_DiscardUnknown

func (m *SetRequest) XXX_DiscardUnknown()

func (*SetRequest) XXX_Marshal

func (m *SetRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*SetRequest) XXX_Merge

func (m *SetRequest) XXX_Merge(src proto.Message)

func (*SetRequest) XXX_Size

func (m *SetRequest) XXX_Size() int

func (*SetRequest) XXX_Unmarshal

func (m *SetRequest) XXX_Unmarshal(b []byte) error

type SetResponse

type SetResponse struct {
}

func (*SetResponse) Descriptor

func (*SetResponse) Descriptor() ([]byte, []int)

func (*SetResponse) Equal

func (this *SetResponse) Equal(that interface{}) bool

func (*SetResponse) GoString

func (this *SetResponse) GoString() string

func (*SetResponse) Marshal

func (m *SetResponse) Marshal() (dAtA []byte, err error)

func (*SetResponse) MarshalTo

func (m *SetResponse) MarshalTo(dAtA []byte) (int, error)

func (*SetResponse) MarshalToSizedBuffer

func (m *SetResponse) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*SetResponse) ProtoMessage

func (*SetResponse) ProtoMessage()

func (*SetResponse) Reset

func (m *SetResponse) Reset()

func (*SetResponse) Size

func (m *SetResponse) Size() (n int)

func (*SetResponse) String

func (this *SetResponse) String() string

func (*SetResponse) Unmarshal

func (m *SetResponse) Unmarshal(dAtA []byte) error

func (*SetResponse) XXX_DiscardUnknown

func (m *SetResponse) XXX_DiscardUnknown()

func (*SetResponse) XXX_Marshal

func (m *SetResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*SetResponse) XXX_Merge

func (m *SetResponse) XXX_Merge(src proto.Message)

func (*SetResponse) XXX_Size

func (m *SetResponse) XXX_Size() int

func (*SetResponse) XXX_Unmarshal

func (m *SetResponse) XXX_Unmarshal(b []byte) error

type UnimplementedControllerServiceServer

type UnimplementedControllerServiceServer struct {
}

UnimplementedControllerServiceServer can be embedded to have forward compatible implementations.

func (*UnimplementedControllerServiceServer) GetReports

func (*UnimplementedControllerServiceServer) Reset

func (*UnimplementedControllerServiceServer) Set

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL