models

package
v3.2.1 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2026 License: MIT Imports: 23 Imported by: 0

Documentation

Overview

Package models is a generated GoMock package.

Package models is a generated GoMock package.

Index

Constants

View Source
const (
	// Deprecated: use EncryptedDataTypeAESCFBSha512 instead
	EncryptedDataTypeAESCFB = "aes-cfb"

	EncryptedDataTypeAESCFBSha512 = "aes-cfb-sha512"
)
View Source
const (
	EtcdLinkDirectory = "/link"
)

Variables

View Source
var (
	ErrEndpointAlreadyPresent = errors.New("endpoint already present")
	ErrHostNotFound           = errors.New("host not found")
	ErrEncryptedDataNotFound  = errors.New("encrypted data not found")
)

Functions

This section is empty.

Types

type EncryptedData

type EncryptedData struct {
	ID         string `json:"id"`
	EndpointID string `json:"endpoint_id"`
	Type       string `json:"type"`
	Data       string `json:"data"`
	Hash       string `json:"hash"`
}
type EncryptedDataLink struct {
	ID         string `json:"id"`
	EndpointID string `json:"endpoint_id"`

	// Deprecated: This is here to keep compatibility with old storage method
	Type string `json:"type,omitempty"`
	Data string `json:"data,omitempty"`
	Hash string `json:"hash,omitempty"`
}

type EncryptedStorage

type EncryptedStorage interface {
	Encrypt(ctx context.Context, endpointID string, data any) (EncryptedDataLink, error)
	Decrypt(ctx context.Context, data EncryptedDataLink, v any) error
	Cleanup(ctx context.Context, endpointID string) error
	RotateEncryptionKey(ctx context.Context) error
}

func NewEncryptedStorage

func NewEncryptedStorage(ctx context.Context, config config.Config, storage Storage) (EncryptedStorage, error)

type Endpoint

type Endpoint struct {
	ID string `json:"id"` // ID of this endpoint (starting with vip-)

	// Full IP with mask (i.e. 10.0.0.1/32)
	// Deprecated: The IP is now stored in the ARP Plugin config. This field is kept for backward compatibility
	IP string `json:"ip"`

	Checks              HealthChecks `json:"checks,omitempty"`     // Health check configured with this Endpoint
	HealthCheckInterval int          `json:"healthcheck_interval"` // Health check Intervals for this Endpoint

	Plugin       string          `json:"plugin,omitempty"`        // Plugin to use for this Endpoint
	PluginConfig json.RawMessage `json:"plugin_config,omitempty"` // Plugin configuration
}

Endpoint stores the configuration of an endpoint for one host

func (Endpoint) LogFields

func (i Endpoint) LogFields() logrus.Fields

ToLogrusFields returns a Logrus representation of an IP

func (Endpoint) ToAPIType

func (i Endpoint) ToAPIType() api.Endpoint
type EndpointLink struct {
	UpdatedAt time.Time `json:"updated_at"`
}

EndpointLink is the structure stored when an IP is linked to an Host

type Endpoints

type Endpoints []Endpoint

func (Endpoints) ToAPIType

func (e Endpoints) ToAPIType() []api.Endpoint

type EtcdStorage

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

func NewEtcdStorage

func NewEtcdStorage(config config.Config) EtcdStorage

func (EtcdStorage) AddEndpoint

func (e EtcdStorage) AddEndpoint(ctx context.Context, endpoint Endpoint) (Endpoint, error)

func (EtcdStorage) GetCurrentHost

func (e EtcdStorage) GetCurrentHost(ctx context.Context) (Host, error)

func (EtcdStorage) GetEncryptedData added in v3.1.0

func (e EtcdStorage) GetEncryptedData(ctx context.Context, endpointID string, encryptedDataId string) (EncryptedData, error)

func (EtcdStorage) GetEndpointHosts

func (e EtcdStorage) GetEndpointHosts(ctx context.Context, lockKey string) ([]string, error)

func (EtcdStorage) GetEndpoints

func (e EtcdStorage) GetEndpoints(ctx context.Context) (Endpoints, error)

func (EtcdStorage) LinkEndpointWithCurrentHost

func (e EtcdStorage) LinkEndpointWithCurrentHost(ctx context.Context, lockKey string) error

func (EtcdStorage) ListEncryptedDataForHost added in v3.1.0

func (e EtcdStorage) ListEncryptedDataForHost(ctx context.Context) ([]EncryptedData, error)

func (EtcdStorage) RemoveEncryptedDataForEndpoint added in v3.1.0

func (e EtcdStorage) RemoveEncryptedDataForEndpoint(ctx context.Context, endpointID string) error

func (EtcdStorage) RemoveEndpoint

func (e EtcdStorage) RemoveEndpoint(ctx context.Context, id string) error

func (EtcdStorage) SaveHost

func (e EtcdStorage) SaveHost(ctx context.Context, host Host) error

func (EtcdStorage) UnlinkEndpointFromCurrentHost

func (e EtcdStorage) UnlinkEndpointFromCurrentHost(ctx context.Context, lockKey string) error

func (EtcdStorage) UpdateEndpoint

func (e EtcdStorage) UpdateEndpoint(ctx context.Context, endpoint Endpoint) error

func (EtcdStorage) UpsertEncryptedData added in v3.1.0

func (e EtcdStorage) UpsertEncryptedData(ctx context.Context, endpointID string, encryptedData EncryptedData) (EncryptedDataLink, error)

type HealthCheck

type HealthCheck struct {
	Type api.HealthCheckType `json:"type"`
	Host string              `json:"host"`
	Port int                 `json:"port"`
}

func HealthCheckFromAPIType

func HealthCheckFromAPIType(h api.HealthCheck) HealthCheck

func (HealthCheck) Addr

func (h HealthCheck) Addr() string

func (HealthCheck) ToAPIType

func (h HealthCheck) ToAPIType() api.HealthCheck

func (HealthCheck) Validate

func (h HealthCheck) Validate(_ context.Context) error

type HealthChecks

type HealthChecks []HealthCheck

func HealthChecksFromAPIType

func HealthChecksFromAPIType(hs []api.HealthCheck) HealthChecks

func (HealthChecks) ToAPIType

func (h HealthChecks) ToAPIType() []api.HealthCheck

func (HealthChecks) Validate

func (h HealthChecks) Validate(ctx context.Context) error

type Host

type Host struct {
	Hostname string `json:"hostname"` // Hostname of this host
	LeaseID  int64  `json:"lease_id"` // LeaseID current lease ID of this host
	// DataVersion is the version number of how the data is stored in etcd for this host. This field is introduced in 2.0.0. But the data format version v0 correspond to the format before v1.9.0.
	DataVersion int `json:"data_version,omitempty"`
}

Host stores the host configuration. This is used by an host to retrieve his configuration after a restart.

type MockEncryptedStorage added in v3.1.0

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

MockEncryptedStorage is a mock of EncryptedStorage interface.

func NewMockEncryptedStorage added in v3.1.0

func NewMockEncryptedStorage(ctrl *gomock.Controller) *MockEncryptedStorage

NewMockEncryptedStorage creates a new mock instance.

func (*MockEncryptedStorage) Cleanup added in v3.1.0

func (m *MockEncryptedStorage) Cleanup(arg0 context.Context, arg1 string) error

Cleanup mocks base method.

func (*MockEncryptedStorage) Decrypt added in v3.1.0

func (m *MockEncryptedStorage) Decrypt(arg0 context.Context, arg1 EncryptedDataLink, arg2 interface{}) error

Decrypt mocks base method.

func (*MockEncryptedStorage) EXPECT added in v3.1.0

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockEncryptedStorage) Encrypt added in v3.1.0

func (m *MockEncryptedStorage) Encrypt(arg0 context.Context, arg1 string, arg2 interface{}) (EncryptedDataLink, error)

Encrypt mocks base method.

func (*MockEncryptedStorage) RotateEncryptionKey added in v3.1.0

func (m *MockEncryptedStorage) RotateEncryptionKey(arg0 context.Context) error

RotateEncryptionKey mocks base method.

type MockEncryptedStorageMockRecorder added in v3.1.0

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

MockEncryptedStorageMockRecorder is the mock recorder for MockEncryptedStorage.

func (*MockEncryptedStorageMockRecorder) Cleanup added in v3.1.0

func (mr *MockEncryptedStorageMockRecorder) Cleanup(arg0, arg1 interface{}) *gomock.Call

Cleanup indicates an expected call of Cleanup.

func (*MockEncryptedStorageMockRecorder) Decrypt added in v3.1.0

func (mr *MockEncryptedStorageMockRecorder) Decrypt(arg0, arg1, arg2 interface{}) *gomock.Call

Decrypt indicates an expected call of Decrypt.

func (*MockEncryptedStorageMockRecorder) Encrypt added in v3.1.0

func (mr *MockEncryptedStorageMockRecorder) Encrypt(arg0, arg1, arg2 interface{}) *gomock.Call

Encrypt indicates an expected call of Encrypt.

func (*MockEncryptedStorageMockRecorder) RotateEncryptionKey added in v3.1.0

func (mr *MockEncryptedStorageMockRecorder) RotateEncryptionKey(arg0 interface{}) *gomock.Call

RotateEncryptionKey indicates an expected call of RotateEncryptionKey.

type MockStorage added in v3.1.0

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

MockStorage is a mock of Storage interface.

func NewMockStorage added in v3.1.0

func NewMockStorage(ctrl *gomock.Controller) *MockStorage

NewMockStorage creates a new mock instance.

func (*MockStorage) AddEndpoint added in v3.1.0

func (m *MockStorage) AddEndpoint(arg0 context.Context, arg1 Endpoint) (Endpoint, error)

AddEndpoint mocks base method.

func (*MockStorage) EXPECT added in v3.1.0

func (m *MockStorage) EXPECT() *MockStorageMockRecorder

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockStorage) GetCurrentHost added in v3.1.0

func (m *MockStorage) GetCurrentHost(arg0 context.Context) (Host, error)

GetCurrentHost mocks base method.

func (*MockStorage) GetEncryptedData added in v3.1.0

func (m *MockStorage) GetEncryptedData(arg0 context.Context, arg1, arg2 string) (EncryptedData, error)

GetEncryptedData mocks base method.

func (*MockStorage) GetEndpointHosts added in v3.1.0

func (m *MockStorage) GetEndpointHosts(arg0 context.Context, arg1 string) ([]string, error)

GetEndpointHosts mocks base method.

func (*MockStorage) GetEndpoints added in v3.1.0

func (m *MockStorage) GetEndpoints(arg0 context.Context) (Endpoints, error)

GetEndpoints mocks base method.

func (*MockStorage) LinkEndpointWithCurrentHost added in v3.1.0

func (m *MockStorage) LinkEndpointWithCurrentHost(arg0 context.Context, arg1 string) error

LinkEndpointWithCurrentHost mocks base method.

func (*MockStorage) ListEncryptedDataForHost added in v3.1.0

func (m *MockStorage) ListEncryptedDataForHost(arg0 context.Context) ([]EncryptedData, error)

ListEncryptedDataForHost mocks base method.

func (*MockStorage) RemoveEncryptedDataForEndpoint added in v3.1.0

func (m *MockStorage) RemoveEncryptedDataForEndpoint(arg0 context.Context, arg1 string) error

RemoveEncryptedDataForEndpoint mocks base method.

func (*MockStorage) RemoveEndpoint added in v3.1.0

func (m *MockStorage) RemoveEndpoint(arg0 context.Context, arg1 string) error

RemoveEndpoint mocks base method.

func (*MockStorage) SaveHost added in v3.1.0

func (m *MockStorage) SaveHost(arg0 context.Context, arg1 Host) error

SaveHost mocks base method.

func (*MockStorage) UnlinkEndpointFromCurrentHost added in v3.1.0

func (m *MockStorage) UnlinkEndpointFromCurrentHost(arg0 context.Context, arg1 string) error

UnlinkEndpointFromCurrentHost mocks base method.

func (*MockStorage) UpdateEndpoint added in v3.1.0

func (m *MockStorage) UpdateEndpoint(arg0 context.Context, arg1 Endpoint) error

UpdateEndpoint mocks base method.

func (*MockStorage) UpsertEncryptedData added in v3.1.0

func (m *MockStorage) UpsertEncryptedData(arg0 context.Context, arg1 string, arg2 EncryptedData) (EncryptedDataLink, error)

UpsertEncryptedData mocks base method.

type MockStorageMockRecorder added in v3.1.0

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

MockStorageMockRecorder is the mock recorder for MockStorage.

func (*MockStorageMockRecorder) AddEndpoint added in v3.1.0

func (mr *MockStorageMockRecorder) AddEndpoint(arg0, arg1 interface{}) *gomock.Call

AddEndpoint indicates an expected call of AddEndpoint.

func (*MockStorageMockRecorder) GetCurrentHost added in v3.1.0

func (mr *MockStorageMockRecorder) GetCurrentHost(arg0 interface{}) *gomock.Call

GetCurrentHost indicates an expected call of GetCurrentHost.

func (*MockStorageMockRecorder) GetEncryptedData added in v3.1.0

func (mr *MockStorageMockRecorder) GetEncryptedData(arg0, arg1, arg2 interface{}) *gomock.Call

GetEncryptedData indicates an expected call of GetEncryptedData.

func (*MockStorageMockRecorder) GetEndpointHosts added in v3.1.0

func (mr *MockStorageMockRecorder) GetEndpointHosts(arg0, arg1 interface{}) *gomock.Call

GetEndpointHosts indicates an expected call of GetEndpointHosts.

func (*MockStorageMockRecorder) GetEndpoints added in v3.1.0

func (mr *MockStorageMockRecorder) GetEndpoints(arg0 interface{}) *gomock.Call

GetEndpoints indicates an expected call of GetEndpoints.

func (*MockStorageMockRecorder) LinkEndpointWithCurrentHost added in v3.1.0

func (mr *MockStorageMockRecorder) LinkEndpointWithCurrentHost(arg0, arg1 interface{}) *gomock.Call

LinkEndpointWithCurrentHost indicates an expected call of LinkEndpointWithCurrentHost.

func (*MockStorageMockRecorder) ListEncryptedDataForHost added in v3.1.0

func (mr *MockStorageMockRecorder) ListEncryptedDataForHost(arg0 interface{}) *gomock.Call

ListEncryptedDataForHost indicates an expected call of ListEncryptedDataForHost.

func (*MockStorageMockRecorder) RemoveEncryptedDataForEndpoint added in v3.1.0

func (mr *MockStorageMockRecorder) RemoveEncryptedDataForEndpoint(arg0, arg1 interface{}) *gomock.Call

RemoveEncryptedDataForEndpoint indicates an expected call of RemoveEncryptedDataForEndpoint.

func (*MockStorageMockRecorder) RemoveEndpoint added in v3.1.0

func (mr *MockStorageMockRecorder) RemoveEndpoint(arg0, arg1 interface{}) *gomock.Call

RemoveEndpoint indicates an expected call of RemoveEndpoint.

func (*MockStorageMockRecorder) SaveHost added in v3.1.0

func (mr *MockStorageMockRecorder) SaveHost(arg0, arg1 interface{}) *gomock.Call

SaveHost indicates an expected call of SaveHost.

func (*MockStorageMockRecorder) UnlinkEndpointFromCurrentHost added in v3.1.0

func (mr *MockStorageMockRecorder) UnlinkEndpointFromCurrentHost(arg0, arg1 interface{}) *gomock.Call

UnlinkEndpointFromCurrentHost indicates an expected call of UnlinkEndpointFromCurrentHost.

func (*MockStorageMockRecorder) UpdateEndpoint added in v3.1.0

func (mr *MockStorageMockRecorder) UpdateEndpoint(arg0, arg1 interface{}) *gomock.Call

UpdateEndpoint indicates an expected call of UpdateEndpoint.

func (*MockStorageMockRecorder) UpsertEncryptedData added in v3.1.0

func (mr *MockStorageMockRecorder) UpsertEncryptedData(arg0, arg1, arg2 interface{}) *gomock.Call

UpsertEncryptedData indicates an expected call of UpsertEncryptedData.

type Storage

type Storage interface {
	GetEndpoints(ctx context.Context) (Endpoints, error) // GetEndpoints configured for this host
	AddEndpoint(ctx context.Context, endpoint Endpoint) (Endpoint, error)
	UpdateEndpoint(ctx context.Context, endpoint Endpoint) error
	RemoveEndpoint(ctx context.Context, id string) error

	GetCurrentHost(ctx context.Context) (Host, error) // Get host configuration for the current host
	SaveHost(ctx context.Context, host Host) error    // Save host modifications

	LinkEndpointWithCurrentHost(ctx context.Context, key string) error   // Link an Endpoint to the current host
	UnlinkEndpointFromCurrentHost(ctx context.Context, key string) error // Unlink an Endpoint from the current host
	GetEndpointHosts(ctx context.Context, key string) ([]string, error)  // List all hosts linked to the Endpoint

	GetEncryptedData(ctx context.Context, endpointID string, encryptedDataId string) (EncryptedData, error)
	UpsertEncryptedData(ctx context.Context, endpointID string, data EncryptedData) (EncryptedDataLink, error)
	RemoveEncryptedDataForEndpoint(ctx context.Context, endpointID string) error
	ListEncryptedDataForHost(ctx context.Context) ([]EncryptedData, error)
}

Storage engine needed for the LinK persistent memory

Jump to

Keyboard shortcuts

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