store

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RoleUser  = "user"
	RoleAdmin = "admin"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type APIToken

type APIToken struct {
	ID             uuid.UUID
	UserID         uuid.UUID
	Name           string
	KeyHash        string
	CreatedAt      time.Time
	ExpiresAt      *time.Time
	OrganizationID uuid.UUID // optional; when set, token is scoped to this org (global admin only)
}

APIToken represents an API key for a user. The secret is hashed; the raw token is only returned once at creation. ExpiresAt is optional; nil means never expires. OrganizationID, when set, scopes the token to that org (global admin only); uuid.Nil means full access.

type APITokenStore

type APITokenStore interface {
	CreateAPIToken(userID uuid.UUID, name string, expiresAt *time.Time, organizationID *uuid.UUID) (token *APIToken, rawToken string, err error)
	GetUserByTokenHash(keyHash string) (*User, error)
	GetAPITokenByKeyHash(keyHash string) (*APIToken, error)
	ListAPITokens(userID uuid.UUID) ([]*APIToken, error)
	DeleteAPIToken(tokenID, userID uuid.UUID) error
	GetAPIToken(tokenID uuid.UUID) (*APIToken, error)
}

type AllocationStore

type AllocationStore interface {
	CreateAllocation(id uuid.UUID, alloc *network.Allocation) error
	GetAllocation(id uuid.UUID) (*network.Allocation, error)
	ListAllocations() ([]*network.Allocation, error)
	ListAllocationsFiltered(name string, blockName string, environmentID uuid.UUID, organizationID *uuid.UUID, limit, offset int) ([]*network.Allocation, int, error)
	UpdateAllocation(id uuid.UUID, alloc *network.Allocation) error
	DeleteAllocation(id uuid.UUID) error
}

type BlockStore

type BlockStore interface {
	CreateBlock(block *network.Block) error
	GetBlock(id uuid.UUID) (*network.Block, error)
	ListBlocks() ([]*network.Block, error)
	ListBlocksFiltered(name string, environmentID *uuid.UUID, poolID *uuid.UUID, organizationID *uuid.UUID, orphanedOnly bool, limit, offset int) ([]*network.Block, int, error)
	ListBlocksByEnvironment(envID uuid.UUID) ([]*network.Block, error)
	ListBlocksByPool(poolID uuid.UUID) ([]*network.Block, error)
	UpdateBlock(id uuid.UUID, block *network.Block) error
	DeleteBlock(id uuid.UUID) error
}

type EnvironmentStore

type EnvironmentStore interface {
	CreateEnvironment(env *network.Environment) error
	GetEnvironment(id uuid.UUID) (*network.Environment, error)
	ListEnvironments() ([]*network.Environment, error)
	ListEnvironmentsFiltered(name string, organizationID *uuid.UUID, limit, offset int) ([]*network.Environment, int, error)
	UpdateEnvironment(id uuid.UUID, env *network.Environment) error
	DeleteEnvironment(id uuid.UUID) error
}

type IDGenerator

type IDGenerator interface {
	GenerateID() uuid.UUID
}

type Organization

type Organization struct {
	ID        uuid.UUID
	Name      string
	CreatedAt time.Time
}

Organization represents a tenant. Users and environments belong to an organization.

type OrganizationStore

type OrganizationStore interface {
	CreateOrganization(org *Organization) error
	GetOrganization(id uuid.UUID) (*Organization, error)
	ListOrganizations() ([]*Organization, error)
	UpdateOrganization(org *Organization) error
	DeleteOrganization(id uuid.UUID) error
}

type PoolStore

type PoolStore interface {
	CreatePool(pool *network.Pool) error
	GetPool(id uuid.UUID) (*network.Pool, error)
	ListPoolsByEnvironment(envID uuid.UUID) ([]*network.Pool, error)
	ListPoolsByOrganization(orgID uuid.UUID) ([]*network.Pool, error)
	UpdatePool(id uuid.UUID, pool *network.Pool) error
	DeletePool(id uuid.UUID) error
}

type PostgresStore

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

PostgresStore implements Storer using PostgreSQL.

func (*PostgresStore) Close

func (s *PostgresStore) Close() error

Close closes the database connection. Call this when shutting down.

func (*PostgresStore) CreateAPIToken

func (s *PostgresStore) CreateAPIToken(userID uuid.UUID, name string, expiresAt *time.Time, organizationID *uuid.UUID) (token *APIToken, rawToken string, err error)

func (*PostgresStore) CreateAllocation

func (s *PostgresStore) CreateAllocation(id uuid.UUID, alloc *network.Allocation) error

func (*PostgresStore) CreateBlock

func (s *PostgresStore) CreateBlock(block *network.Block) error

func (*PostgresStore) CreateEnvironment

func (s *PostgresStore) CreateEnvironment(env *network.Environment) error

func (*PostgresStore) CreateOrganization

func (s *PostgresStore) CreateOrganization(org *Organization) error

func (*PostgresStore) CreatePool

func (s *PostgresStore) CreatePool(pool *network.Pool) error

func (*PostgresStore) CreateReservedBlock

func (s *PostgresStore) CreateReservedBlock(r *ReservedBlock) error

func (*PostgresStore) CreateSession

func (s *PostgresStore) CreateSession(sessionID string, userID uuid.UUID, expiry time.Time)

func (*PostgresStore) CreateSignupInvite

func (s *PostgresStore) CreateSignupInvite(createdBy uuid.UUID, expiresAt time.Time, organizationID uuid.UUID, role string) (*SignupInvite, string, error)

func (*PostgresStore) CreateUser

func (s *PostgresStore) CreateUser(u *User) error

func (*PostgresStore) DeleteAPIToken

func (s *PostgresStore) DeleteAPIToken(tokenID, userID uuid.UUID) error

func (*PostgresStore) DeleteAllocation

func (s *PostgresStore) DeleteAllocation(id uuid.UUID) error

func (*PostgresStore) DeleteBlock

func (s *PostgresStore) DeleteBlock(id uuid.UUID) error

func (*PostgresStore) DeleteEnvironment

func (s *PostgresStore) DeleteEnvironment(id uuid.UUID) error

func (*PostgresStore) DeleteOrganization

func (s *PostgresStore) DeleteOrganization(id uuid.UUID) error

func (*PostgresStore) DeletePool

func (s *PostgresStore) DeletePool(id uuid.UUID) error

func (*PostgresStore) DeleteReservedBlock

func (s *PostgresStore) DeleteReservedBlock(id uuid.UUID) error

func (*PostgresStore) DeleteSession

func (s *PostgresStore) DeleteSession(sessionID string)

func (*PostgresStore) DeleteSignupInvite

func (s *PostgresStore) DeleteSignupInvite(id uuid.UUID) error

func (*PostgresStore) DeleteUser

func (s *PostgresStore) DeleteUser(userID uuid.UUID) error

func (*PostgresStore) GenerateID

func (s *PostgresStore) GenerateID() uuid.UUID

func (*PostgresStore) GetAPIToken

func (s *PostgresStore) GetAPIToken(tokenID uuid.UUID) (*APIToken, error)

func (*PostgresStore) GetAPITokenByKeyHash

func (s *PostgresStore) GetAPITokenByKeyHash(keyHash string) (*APIToken, error)

func (*PostgresStore) GetAllocation

func (s *PostgresStore) GetAllocation(id uuid.UUID) (*network.Allocation, error)

func (*PostgresStore) GetBlock

func (s *PostgresStore) GetBlock(id uuid.UUID) (*network.Block, error)

func (*PostgresStore) GetEnvironment

func (s *PostgresStore) GetEnvironment(id uuid.UUID) (*network.Environment, error)

func (*PostgresStore) GetOrganization

func (s *PostgresStore) GetOrganization(id uuid.UUID) (*Organization, error)

func (*PostgresStore) GetPool

func (s *PostgresStore) GetPool(id uuid.UUID) (*network.Pool, error)

func (*PostgresStore) GetReservedBlock

func (s *PostgresStore) GetReservedBlock(id uuid.UUID) (*ReservedBlock, error)

func (*PostgresStore) GetSession

func (s *PostgresStore) GetSession(sessionID string) (*Session, error)

func (*PostgresStore) GetSignupInviteByToken

func (s *PostgresStore) GetSignupInviteByToken(rawToken string) (*SignupInvite, error)

func (*PostgresStore) GetUser

func (s *PostgresStore) GetUser(id uuid.UUID) (*User, error)

func (*PostgresStore) GetUserByEmail

func (s *PostgresStore) GetUserByEmail(email string) (*User, error)

func (*PostgresStore) GetUserByOAuth

func (s *PostgresStore) GetUserByOAuth(provider, providerUserID string) (*User, error)

func (*PostgresStore) GetUserByTokenHash

func (s *PostgresStore) GetUserByTokenHash(keyHash string) (*User, error)

func (*PostgresStore) ListAPITokens

func (s *PostgresStore) ListAPITokens(userID uuid.UUID) ([]*APIToken, error)

func (*PostgresStore) ListAllocations

func (s *PostgresStore) ListAllocations() ([]*network.Allocation, error)

func (*PostgresStore) ListAllocationsFiltered

func (s *PostgresStore) ListAllocationsFiltered(name string, blockName string, environmentID uuid.UUID, organizationID *uuid.UUID, limit, offset int) ([]*network.Allocation, int, error)

func (*PostgresStore) ListBlocks

func (s *PostgresStore) ListBlocks() ([]*network.Block, error)

func (*PostgresStore) ListBlocksByEnvironment

func (s *PostgresStore) ListBlocksByEnvironment(envID uuid.UUID) ([]*network.Block, error)

func (*PostgresStore) ListBlocksByPool

func (s *PostgresStore) ListBlocksByPool(poolID uuid.UUID) ([]*network.Block, error)

func (*PostgresStore) ListBlocksFiltered

func (s *PostgresStore) ListBlocksFiltered(name string, environmentID *uuid.UUID, poolID *uuid.UUID, organizationID *uuid.UUID, orphanedOnly bool, limit, offset int) ([]*network.Block, int, error)

func (*PostgresStore) ListEnvironments

func (s *PostgresStore) ListEnvironments() ([]*network.Environment, error)

func (*PostgresStore) ListEnvironmentsFiltered

func (s *PostgresStore) ListEnvironmentsFiltered(name string, organizationID *uuid.UUID, limit, offset int) ([]*network.Environment, int, error)

func (*PostgresStore) ListOrganizations

func (s *PostgresStore) ListOrganizations() ([]*Organization, error)

func (*PostgresStore) ListPoolsByEnvironment

func (s *PostgresStore) ListPoolsByEnvironment(envID uuid.UUID) ([]*network.Pool, error)

func (*PostgresStore) ListPoolsByOrganization

func (s *PostgresStore) ListPoolsByOrganization(orgID uuid.UUID) ([]*network.Pool, error)

func (*PostgresStore) ListReservedBlocks

func (s *PostgresStore) ListReservedBlocks(organizationID *uuid.UUID) ([]*ReservedBlock, error)

func (*PostgresStore) ListSignupInvites

func (s *PostgresStore) ListSignupInvites(createdBy uuid.UUID) ([]*SignupInvite, error)

func (*PostgresStore) ListUsers

func (s *PostgresStore) ListUsers(organizationID *uuid.UUID) ([]*User, error)

func (*PostgresStore) MarkSignupInviteUsed

func (s *PostgresStore) MarkSignupInviteUsed(inviteID, userID uuid.UUID) error

func (*PostgresStore) OverlapsReservedBlock

func (s *PostgresStore) OverlapsReservedBlock(cidr string, organizationID *uuid.UUID) (*ReservedBlock, error)

func (*PostgresStore) SetUserOAuth

func (s *PostgresStore) SetUserOAuth(userID uuid.UUID, provider, providerUserID string) error

func (*PostgresStore) SetUserOrganization

func (s *PostgresStore) SetUserOrganization(userID uuid.UUID, organizationID uuid.UUID) error

func (*PostgresStore) SetUserRole

func (s *PostgresStore) SetUserRole(userID uuid.UUID, role string) error

func (*PostgresStore) SetUserTourCompleted

func (s *PostgresStore) SetUserTourCompleted(userID uuid.UUID, completed bool) error

func (*PostgresStore) UpdateAllocation

func (s *PostgresStore) UpdateAllocation(id uuid.UUID, alloc *network.Allocation) error

func (*PostgresStore) UpdateBlock

func (s *PostgresStore) UpdateBlock(id uuid.UUID, block *network.Block) error

func (*PostgresStore) UpdateEnvironment

func (s *PostgresStore) UpdateEnvironment(id uuid.UUID, env *network.Environment) error

func (*PostgresStore) UpdateOrganization

func (s *PostgresStore) UpdateOrganization(org *Organization) error

func (*PostgresStore) UpdatePool

func (s *PostgresStore) UpdatePool(id uuid.UUID, pool *network.Pool) error

func (*PostgresStore) UpdateReservedBlock

func (s *PostgresStore) UpdateReservedBlock(id uuid.UUID, r *ReservedBlock) error

type ReservedBlock

type ReservedBlock struct {
	ID             uuid.UUID
	Name           string
	CIDR           string
	Reason         string
	CreatedAt      time.Time
	OrganizationID uuid.UUID
}

ReservedBlock is a CIDR range that cannot be used as a network block or allocation (blacklisted). Used to preserve ranges for future use or other systems. Scoped to an organization; overlap checks use the org's reserved list (or all orgs when nil).

type ReservedBlockStore

type ReservedBlockStore interface {
	ListReservedBlocks(organizationID *uuid.UUID) ([]*ReservedBlock, error)
	CreateReservedBlock(r *ReservedBlock) error
	GetReservedBlock(id uuid.UUID) (*ReservedBlock, error)
	UpdateReservedBlock(id uuid.UUID, r *ReservedBlock) error
	DeleteReservedBlock(id uuid.UUID) error
	OverlapsReservedBlock(cidr string, organizationID *uuid.UUID) (*ReservedBlock, error)
}

type Session

type Session struct {
	UserID uuid.UUID
	Expiry time.Time
}

Session represents an active session.

func (*Session) Expired

func (s *Session) Expired() bool

Expired returns true if the session has expired.

type SessionStore

type SessionStore interface {
	CreateSession(sessionID string, userID uuid.UUID, expiry time.Time)
	GetSession(sessionID string) (*Session, error)
	DeleteSession(sessionID string)
}

type SignupInvite

type SignupInvite struct {
	ID             uuid.UUID
	TokenHash      string
	CreatedBy      uuid.UUID
	ExpiresAt      time.Time
	CreatedAt      time.Time
	UsedAt         *time.Time
	UsedByUserID   *uuid.UUID
	OrganizationID uuid.UUID
	Role           string
}

SignupInvite represents a time-bound invite link for new user signup. The token is hashed in storage; the raw token is only returned at creation. UsedAt/UsedByUserID are set when someone signs up with the invite. OrganizationID and Role are set when creating the invite (global admin can set; org admin gets their org and user role). If OrganizationID is uuid.Nil at use time, the inviter's org is used (backward compat).

type SignupInviteStore

type SignupInviteStore interface {
	CreateSignupInvite(createdBy uuid.UUID, expiresAt time.Time, organizationID uuid.UUID, role string) (*SignupInvite, string, error)
	GetSignupInviteByToken(rawToken string) (*SignupInvite, error)
	MarkSignupInviteUsed(inviteID, userID uuid.UUID) error
	DeleteSignupInvite(id uuid.UUID) error
	ListSignupInvites(createdBy uuid.UUID) ([]*SignupInvite, error)
}

type Store

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

Store manages all IPAM data

func NewStore

func NewStore() *Store

NewStore creates a new store

func (*Store) CreateAPIToken

func (s *Store) CreateAPIToken(userID uuid.UUID, name string, expiresAt *time.Time, organizationID *uuid.UUID) (token *APIToken, rawToken string, err error)

CreateAPIToken creates a new API token for the user. Returns the raw token (only shown once). expiresAt is optional; nil means the token never expires. organizationID is optional; when set (global admin only), the token is scoped to that org.

func (*Store) CreateAllocation

func (s *Store) CreateAllocation(id uuid.UUID, alloc *network.Allocation) error

Allocation operations

func (*Store) CreateBlock

func (s *Store) CreateBlock(block *network.Block) error

Block operations

func (*Store) CreateEnvironment

func (s *Store) CreateEnvironment(env *network.Environment) error

Environment operations

func (*Store) CreateOrganization

func (s *Store) CreateOrganization(org *Organization) error

Organization operations

func (*Store) CreatePool

func (s *Store) CreatePool(pool *network.Pool) error

Pool operations

func (*Store) CreateReservedBlock

func (s *Store) CreateReservedBlock(r *ReservedBlock) error

func (*Store) CreateSession

func (s *Store) CreateSession(sessionID string, userID uuid.UUID, expiry time.Time)

Session operations

func (*Store) CreateSignupInvite

func (s *Store) CreateSignupInvite(createdBy uuid.UUID, expiresAt time.Time, organizationID uuid.UUID, role string) (*SignupInvite, string, error)

CreateSignupInvite creates a time-bound signup invite. Returns the invite and raw token (only shown once).

func (*Store) CreateUser

func (s *Store) CreateUser(u *User) error

User operations

func (*Store) DeleteAPIToken

func (s *Store) DeleteAPIToken(tokenID, userID uuid.UUID) error

DeleteAPIToken removes the token. Returns error if token not found or not owned by user.

func (*Store) DeleteAllocation

func (s *Store) DeleteAllocation(id uuid.UUID) error

func (*Store) DeleteBlock

func (s *Store) DeleteBlock(id uuid.UUID) error

func (*Store) DeleteEnvironment

func (s *Store) DeleteEnvironment(id uuid.UUID) error

DeleteEnvironment removes the environment, its pools, all blocks that belong to it, and all allocations in those blocks.

func (*Store) DeleteOrganization

func (s *Store) DeleteOrganization(id uuid.UUID) error

func (*Store) DeletePool

func (s *Store) DeletePool(id uuid.UUID) error

func (*Store) DeleteReservedBlock

func (s *Store) DeleteReservedBlock(id uuid.UUID) error

func (*Store) DeleteSession

func (s *Store) DeleteSession(sessionID string)

func (*Store) DeleteSignupInvite

func (s *Store) DeleteSignupInvite(id uuid.UUID) error

DeleteSignupInvite removes the invite (revoke).

func (*Store) DeleteUser

func (s *Store) DeleteUser(userID uuid.UUID) error

func (*Store) GenerateID

func (s *Store) GenerateID() uuid.UUID

GenerateID generates a unique ID

func (*Store) GetAPIToken

func (s *Store) GetAPIToken(tokenID uuid.UUID) (*APIToken, error)

GetAPIToken returns the token by ID (for ownership check).

func (*Store) GetAPITokenByKeyHash

func (s *Store) GetAPITokenByKeyHash(keyHash string) (*APIToken, error)

GetAPITokenByKeyHash returns the API token for the given key hash, or error if not found or expired.

func (*Store) GetAllocation

func (s *Store) GetAllocation(id uuid.UUID) (*network.Allocation, error)

func (*Store) GetBlock

func (s *Store) GetBlock(id uuid.UUID) (*network.Block, error)

func (*Store) GetEnvironment

func (s *Store) GetEnvironment(id uuid.UUID) (*network.Environment, error)

func (*Store) GetOrganization

func (s *Store) GetOrganization(id uuid.UUID) (*Organization, error)

func (*Store) GetPool

func (s *Store) GetPool(id uuid.UUID) (*network.Pool, error)

func (*Store) GetReservedBlock

func (s *Store) GetReservedBlock(id uuid.UUID) (*ReservedBlock, error)

func (*Store) GetSession

func (s *Store) GetSession(sessionID string) (*Session, error)

func (*Store) GetSignupInviteByToken

func (s *Store) GetSignupInviteByToken(rawToken string) (*SignupInvite, error)

GetSignupInviteByToken returns the invite for the given raw token if valid and not expired.

func (*Store) GetUser

func (s *Store) GetUser(id uuid.UUID) (*User, error)

func (*Store) GetUserByEmail

func (s *Store) GetUserByEmail(email string) (*User, error)

func (*Store) GetUserByOAuth

func (s *Store) GetUserByOAuth(provider, providerUserID string) (*User, error)

func (*Store) GetUserByTokenHash

func (s *Store) GetUserByTokenHash(keyHash string) (*User, error)

GetUserByTokenHash returns the user for the given token hash, or nil if not found or token expired.

func (*Store) ListAPITokens

func (s *Store) ListAPITokens(userID uuid.UUID) ([]*APIToken, error)

ListAPITokens returns all API tokens for the user (without secret).

func (*Store) ListAllocations

func (s *Store) ListAllocations() ([]*network.Allocation, error)

func (*Store) ListAllocationsFiltered

func (s *Store) ListAllocationsFiltered(name string, blockName string, environmentID uuid.UUID, organizationID *uuid.UUID, limit, offset int) ([]*network.Allocation, int, error)

ListAllocationsFiltered returns allocations matching name (substring), optionally blockName, environmentID, and organizationID. When organizationID != nil, only allocations in blocks belonging to that org are returned (blocks in envs in that org, or orphan blocks with that organization_id).

func (*Store) ListBlocks

func (s *Store) ListBlocks() ([]*network.Block, error)

func (*Store) ListBlocksByEnvironment

func (s *Store) ListBlocksByEnvironment(envID uuid.UUID) ([]*network.Block, error)

ListBlocksByEnvironment returns all blocks belonging to the given environment.

func (*Store) ListBlocksByPool

func (s *Store) ListBlocksByPool(poolID uuid.UUID) ([]*network.Block, error)

ListBlocksByPool returns all blocks assigned to the given pool.

func (*Store) ListBlocksFiltered

func (s *Store) ListBlocksFiltered(name string, environmentID *uuid.UUID, poolID *uuid.UUID, organizationID *uuid.UUID, orphanedOnly bool, limit, offset int) ([]*network.Block, int, error)

ListBlocksFiltered returns blocks matching name (substring), optionally environmentID, poolID, organizationID, and orphaned only. If organizationID != nil, only blocks in envs belonging to that org are returned. If limit <= 0, no limit is applied.

func (*Store) ListEnvironments

func (s *Store) ListEnvironments() ([]*network.Environment, error)

func (*Store) ListEnvironmentsFiltered

func (s *Store) ListEnvironmentsFiltered(name string, organizationID *uuid.UUID, limit, offset int) ([]*network.Environment, int, error)

ListEnvironmentsFiltered returns environments matching name (substring, case-insensitive), optionally scoped by organizationID. If organizationID is nil, all environments are returned (global admin). If limit <= 0, no limit is applied. offset is 0-based.

func (*Store) ListOrganizations

func (s *Store) ListOrganizations() ([]*Organization, error)

func (*Store) ListPoolsByEnvironment

func (s *Store) ListPoolsByEnvironment(envID uuid.UUID) ([]*network.Pool, error)

func (*Store) ListPoolsByOrganization

func (s *Store) ListPoolsByOrganization(orgID uuid.UUID) ([]*network.Pool, error)

func (*Store) ListReservedBlocks

func (s *Store) ListReservedBlocks(organizationID *uuid.UUID) ([]*ReservedBlock, error)

ReservedBlock operations (blacklisted CIDR ranges; cannot be used as blocks or allocations).

func (*Store) ListSignupInvites

func (s *Store) ListSignupInvites(createdBy uuid.UUID) ([]*SignupInvite, error)

ListSignupInvites returns all signup invites created by the given user (for admin UI).

func (*Store) ListUsers

func (s *Store) ListUsers(organizationID *uuid.UUID) ([]*User, error)

func (*Store) MarkSignupInviteUsed

func (s *Store) MarkSignupInviteUsed(inviteID, userID uuid.UUID) error

MarkSignupInviteUsed marks the invite as used by the given user (on signup).

func (*Store) OverlapsReservedBlock

func (s *Store) OverlapsReservedBlock(cidr string, organizationID *uuid.UUID) (*ReservedBlock, error)

OverlapsReservedBlock returns the first reserved block that overlaps the given CIDR, or nil.

func (*Store) SetUserOAuth

func (s *Store) SetUserOAuth(userID uuid.UUID, provider, providerUserID string) error

func (*Store) SetUserOrganization

func (s *Store) SetUserOrganization(userID uuid.UUID, organizationID uuid.UUID) error

func (*Store) SetUserRole

func (s *Store) SetUserRole(userID uuid.UUID, role string) error

func (*Store) SetUserTourCompleted

func (s *Store) SetUserTourCompleted(userID uuid.UUID, completed bool) error

SetUserTourCompleted marks the onboarding tour as completed for the user.

func (*Store) UpdateAllocation

func (s *Store) UpdateAllocation(id uuid.UUID, alloc *network.Allocation) error

func (*Store) UpdateBlock

func (s *Store) UpdateBlock(id uuid.UUID, block *network.Block) error

func (*Store) UpdateEnvironment

func (s *Store) UpdateEnvironment(id uuid.UUID, env *network.Environment) error

func (*Store) UpdateOrganization

func (s *Store) UpdateOrganization(org *Organization) error

func (*Store) UpdatePool

func (s *Store) UpdatePool(id uuid.UUID, pool *network.Pool) error

func (*Store) UpdateReservedBlock

func (s *Store) UpdateReservedBlock(id uuid.UUID, r *ReservedBlock) error

type Storer

Storer is the full IPAM persistence interface, composed from smaller store interfaces. Implemented by the in-memory Store and PostgresStore.

func NewPostgresStore

func NewPostgresStore(ctx context.Context, dsn string) (Storer, error)

NewPostgresStore connects to PostgreSQL, runs migrations, and returns a Storer.

type User

type User struct {
	ID                  uuid.UUID
	Email               string
	PasswordHash        string
	Role                string
	TourCompleted       bool
	OrganizationID      uuid.UUID
	OAuthProvider       string
	OAuthProviderUserID string
}

User represents a user account. OrganizationID is uuid.Nil for the global admin (created at setup); otherwise the user belongs to that organization. OAuthProvider and OAuthProviderUserID are set when the user signs in via OAuth (e.g. "github", "12345"). PasswordHash may be empty for OAuth-only users.

type UserStore

type UserStore interface {
	CreateUser(u *User) error
	GetUser(id uuid.UUID) (*User, error)
	GetUserByEmail(email string) (*User, error)
	GetUserByOAuth(provider, providerUserID string) (*User, error)
	ListUsers(organizationID *uuid.UUID) ([]*User, error)
	DeleteUser(userID uuid.UUID) error
	SetUserRole(userID uuid.UUID, role string) error
	SetUserOrganization(userID uuid.UUID, organizationID uuid.UUID) error
	SetUserTourCompleted(userID uuid.UUID, completed bool) error
	SetUserOAuth(userID uuid.UUID, provider, providerUserID string) error
}

Jump to

Keyboard shortcuts

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