repository

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2026 License: MIT Imports: 56 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ASNMin is the minimum asn defined according to
	// https://en.wikipedia.org/wiki/Autonomous_system_(Internet)
	ASNMin = uint32(4200000000)

	// ASNBase is the offset for all Machine ASN´s
	ASNBase = uint32(4210000000)

	// ASNMax defines the maximum allowed asn
	// https://en.wikipedia.org/wiki/Autonomous_system_(Internet)
	ASNMax = uint32(4294967294)
)
View Source
const (
	// This policy allows all users to access their own devices.
	// It is suitable for many use cases where you want to
	// allow users to access their own devices, but not other devices in the tailnet.
	HeadscaleDefaultPolicy = `{
		"acls": [
			{
				"action": "accept",
				"src": ["autogroup:member"],
				"dst": ["autogroup:self:*"]
			}
		]
	}`
)

Variables

This section is empty.

Functions

func GetNewNicState added in v0.1.0

func GetNewNicState(current *apiv2.NicState, status apiv2.SwitchPortStatus) (*apiv2.NicState, bool)

func NewTenantCreateOptWithCreator added in v0.0.7

func NewTenantCreateOptWithCreator(creator string) *tenantCreateOptWithCreator

func TenantRoleFromMap added in v0.0.6

func TenantRoleFromMap(annotations map[string]string) apiv2.TenantRole

Types

type Audit added in v0.1.8

type Audit interface {
	Repository[*auditRepository, *apiv2.AuditTrace, any, *auditEntity, *apiv2.AuditQuery]
}

type Component added in v0.1.6

type Config added in v0.1.2

type Config struct {
	Log              *slog.Logger
	Datastore        generic.Datastore
	MasterdataClient mdm.Client
	Ipam             ipamv1connect.IpamServiceClient
	Task             *task.Client
	Queue            *queue.Queue
	Component        valkey.Client
	Auditing         auditing.Auditing
	HeadscaleClient  *headscale.Client
}

type CreateMessage

type CreateMessage any

CreateMessage is an external request to create an entity for consumers. TODO: ideally all update messages should clearly expose the identifier in order to get the entity with it! UpdateMessage interface{ ID() string }

type Entity

type Entity interface {
	SetChanged(t time.Time)
}

Entity is the internal representation of an api resource, which is stored in the backend.

type IP

type InjectRethinkDbError added in v0.2.0

type InjectRethinkDbError string

type Machine added in v0.0.6

type Message

type Message any

Message is the external representation of an api resource for consumers.

type ProjectMember added in v0.0.6

type ProjectMember interface {
	Repository[*projectMemberRepository, *apiv2.ProjectMember, *api.ProjectMemberCreateRequest, *api.ProjectMemberUpdateRequest, *api.ProjectMemberQuery]
}

type ProjectScope

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

type Query

type Query any

Query is an external representation to filter an entity for consumers.

type Repo added in v0.0.4

type Repo any

Repo is the typed repository in order to expose public functions on the repository to the consumers.

type Repository

type Repository[R Repo, M Message, C CreateMessage, U UpdateMessage, Q Query] interface {
	// Get returns the API entity with the given id.
	Get(ctx context.Context, id string) (M, error)
	// Create creates the entity from the given create request and returns the API entity.
	Create(ctx context.Context, c C) (M, error)
	// Update updates the entity from the given update request and returns the API entity.
	Update(ctx context.Context, id string, u U) (M, error)
	// Delete deletes the API entity with the given id.
	Delete(ctx context.Context, id string) (M, error)
	// Find returns exactly the one API entity matched by the given query.
	// For multiple or no results an error is returned.
	Find(ctx context.Context, query Q) (M, error)
	// List returns the API entities matched by the given query.
	List(ctx context.Context, query Q) ([]M, error)
	// AdditionalMethods allows access to more specific, non-crud operations of a repository store.
	AdditionalMethods() R
}

Repository implements the basic CRUD operations (business logic) for the consuming API services. It shadows internal data representations from external API representations. It offers scopes during initialization so that resource operations can be scoped by projects and tenants. It ensures that all functions return a connect error, except those called from AdditionalMethods(). Therefore, consumers do not need to convert errors to connect errors.

type Size added in v0.0.5

type SizeReservation added in v0.1.3

type Store

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

func New

func New(c Config) *Store

func (*Store) Audit added in v0.1.8

func (s *Store) Audit(tenant string) Audit

func (*Store) Component added in v0.1.6

func (s *Store) Component() Component

func (*Store) FilesystemLayout

func (s *Store) FilesystemLayout() FilesystemLayout

func (*Store) IP

func (s *Store) IP(project string) IP

func (*Store) Image

func (s *Store) Image() Image

func (*Store) IpDeleteHandleFn

func (r *Store) IpDeleteHandleFn(ctx context.Context, t *asynq.Task) error

func (*Store) Machine added in v0.0.6

func (s *Store) Machine(project string) Machine

func (*Store) MachineBMCCommandHandleFn added in v0.1.2

func (r *Store) MachineBMCCommandHandleFn(ctx context.Context, t *asynq.Task) error

func (*Store) MachineDeleteHandleFn added in v0.0.6

func (r *Store) MachineDeleteHandleFn(ctx context.Context, t *asynq.Task) error

func (*Store) Network

func (s *Store) Network(project string) Network

func (*Store) NetworkDeleteHandleFn added in v0.0.3

func (r *Store) NetworkDeleteHandleFn(ctx context.Context, t *asynq.Task) error

NetworkDeleteHandleFn is called async to ensure all dependent entities are deleted Async deletion must be scheduled by async.NewNetworkDeleteTask

func (*Store) Partition

func (s *Store) Partition() Partition

func (*Store) Project

func (s *Store) Project(project string) Project

func (*Store) Size added in v0.0.5

func (s *Store) Size() Size

func (*Store) SizeImageConstraint added in v0.1.7

func (s *Store) SizeImageConstraint() SizeImageConstraint

func (*Store) SizeReservation added in v0.1.3

func (s *Store) SizeReservation(project string) SizeReservation

func (*Store) Switch added in v0.0.8

func (s *Store) Switch() Switch

func (*Store) Task added in v0.1.2

func (s *Store) Task() *task.Client

func (*Store) Tenant

func (s *Store) Tenant() Tenant

func (*Store) UnscopedAudit added in v0.1.8

func (s *Store) UnscopedAudit() Audit

func (*Store) UnscopedIP

func (s *Store) UnscopedIP() IP

func (*Store) UnscopedMachine added in v0.0.6

func (s *Store) UnscopedMachine() Machine

func (*Store) UnscopedNetwork

func (s *Store) UnscopedNetwork() Network

func (*Store) UnscopedProject

func (s *Store) UnscopedProject() Project

func (*Store) UnscopedSizeReservation added in v0.1.3

func (s *Store) UnscopedSizeReservation() SizeReservation

func (*Store) UnscopedVPN added in v0.1.9

func (s *Store) UnscopedVPN() *vpn

func (*Store) VPN added in v0.1.9

func (s *Store) VPN(project string) *vpn

type Switch added in v0.0.8

type TenantMember added in v0.0.6

type TenantMember interface {
	Repository[*tenantMemberRepository, *apiv2.TenantMember, *api.TenantMemberCreateRequest, *api.TenantMemberUpdateRequest, *api.TenantMemberQuery]
}

type TenantScope added in v0.0.6

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

type UpdateMessage

type UpdateMessage interface {
	GetUpdateMeta() *apiv2.UpdateMeta
}

UpdateMessage is an external request to update an entity for consumers.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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