Documentation ¶
Index ¶
- func MigrateFileStoreToSqlite(ctx context.Context, dataDir string) error
- type Engine
- type FileStore
- type LockingStrength
- type SqlStore
- func NewPostgresqlStore(ctx context.Context, dsn string, metrics telemetry.AppMetrics) (*SqlStore, error)
- func NewPostgresqlStoreFromSqlStore(ctx context.Context, sqliteStore *SqlStore, dsn string, ...) (*SqlStore, error)
- func NewSqlStore(ctx context.Context, db *gorm.DB, storeEngine Engine, ...) (*SqlStore, error)
- func NewSqliteStore(ctx context.Context, dataDir string, metrics telemetry.AppMetrics) (*SqlStore, error)
- func NewSqliteStoreFromFileStore(ctx context.Context, fileStore *FileStore, dataDir string, ...) (*SqlStore, error)
- func (s *SqlStore) AccountExists(ctx context.Context, lockStrength LockingStrength, id string) (bool, error)
- func (s *SqlStore) AcquireGlobalLock(ctx context.Context) (unlock func())
- func (s *SqlStore) AcquireReadLockByUID(ctx context.Context, uniqueID string) (unlock func())
- func (s *SqlStore) AcquireWriteLockByUID(ctx context.Context, uniqueID string) (unlock func())
- func (s *SqlStore) AddPeerToAccount(ctx context.Context, peer *nbpeer.Peer) error
- func (s *SqlStore) AddPeerToAllGroup(ctx context.Context, accountID string, peerID string) error
- func (s *SqlStore) AddPeerToGroup(ctx context.Context, accountId string, peerId string, groupID string) error
- func (s *SqlStore) AddResourceToGroup(ctx context.Context, accountId string, groupID string, ...) error
- func (s *SqlStore) Close(_ context.Context) error
- func (s *SqlStore) CreatePolicy(ctx context.Context, lockStrength LockingStrength, policy *types.Policy) error
- func (s *SqlStore) DeleteAccount(ctx context.Context, account *types.Account) error
- func (s *SqlStore) DeleteGroup(ctx context.Context, lockStrength LockingStrength, accountID, groupID string) error
- func (s *SqlStore) DeleteGroups(ctx context.Context, strength LockingStrength, accountID string, ...) error
- func (s *SqlStore) DeleteHashedPAT2TokenIDIndex(hashedToken string) error
- func (s *SqlStore) DeleteNameServerGroup(ctx context.Context, lockStrength LockingStrength, accountID, nsGroupID string) error
- func (s *SqlStore) DeleteNetwork(ctx context.Context, lockStrength LockingStrength, accountID, networkID string) error
- func (s *SqlStore) DeleteNetworkResource(ctx context.Context, lockStrength LockingStrength, ...) error
- func (s *SqlStore) DeleteNetworkRouter(ctx context.Context, lockStrength LockingStrength, accountID, routerID string) error
- func (s *SqlStore) DeletePolicy(ctx context.Context, lockStrength LockingStrength, accountID, policyID string) error
- func (s *SqlStore) DeletePostureChecks(ctx context.Context, lockStrength LockingStrength, ...) error
- func (s *SqlStore) DeleteSetupKey(ctx context.Context, lockStrength LockingStrength, accountID, keyID string) error
- func (s *SqlStore) DeleteTokenID2UserIDIndex(tokenID string) error
- func (s *SqlStore) ExecuteInTransaction(ctx context.Context, operation func(store Store) error) error
- func (s *SqlStore) GetAccount(ctx context.Context, accountID string) (*types.Account, error)
- func (s *SqlStore) GetAccountByPeerID(ctx context.Context, peerID string) (*types.Account, error)
- func (s *SqlStore) GetAccountByPeerPubKey(ctx context.Context, peerKey string) (*types.Account, error)
- func (s *SqlStore) GetAccountByPrivateDomain(ctx context.Context, domain string) (*types.Account, error)
- func (s *SqlStore) GetAccountBySetupKey(ctx context.Context, setupKey string) (*types.Account, error)
- func (s *SqlStore) GetAccountByUser(ctx context.Context, userID string) (*types.Account, error)
- func (s *SqlStore) GetAccountDNSSettings(ctx context.Context, lockStrength LockingStrength, accountID string) (*types.DNSSettings, error)
- func (s *SqlStore) GetAccountDomainAndCategory(ctx context.Context, lockStrength LockingStrength, accountID string) (string, string, error)
- func (s *SqlStore) GetAccountGroups(ctx context.Context, lockStrength LockingStrength, accountID string) ([]*types.Group, error)
- func (s *SqlStore) GetAccountIDByPeerPubKey(ctx context.Context, peerKey string) (string, error)
- func (s *SqlStore) GetAccountIDByPrivateDomain(ctx context.Context, lockStrength LockingStrength, domain string) (string, error)
- func (s *SqlStore) GetAccountIDBySetupKey(ctx context.Context, setupKey string) (string, error)
- func (s *SqlStore) GetAccountIDByUserID(userID string) (string, error)
- func (s *SqlStore) GetAccountNameServerGroups(ctx context.Context, lockStrength LockingStrength, accountID string) ([]*nbdns.NameServerGroup, error)
- func (s *SqlStore) GetAccountNetwork(ctx context.Context, lockStrength LockingStrength, accountID string) (*types.Network, error)
- func (s *SqlStore) GetAccountNetworks(ctx context.Context, lockStrength LockingStrength, accountID string) ([]*networkTypes.Network, error)
- func (s *SqlStore) GetAccountPolicies(ctx context.Context, lockStrength LockingStrength, accountID string) ([]*types.Policy, error)
- func (s *SqlStore) GetAccountPostureChecks(ctx context.Context, lockStrength LockingStrength, accountID string) ([]*posture.Checks, error)
- func (s *SqlStore) GetAccountRoutes(ctx context.Context, lockStrength LockingStrength, accountID string) ([]*route.Route, error)
- func (s *SqlStore) GetAccountSettings(ctx context.Context, lockStrength LockingStrength, accountID string) (*types.Settings, error)
- func (s *SqlStore) GetAccountSetupKeys(ctx context.Context, lockStrength LockingStrength, accountID string) ([]*types.SetupKey, error)
- func (s *SqlStore) GetAccountUsers(ctx context.Context, lockStrength LockingStrength, accountID string) ([]*types.User, error)
- func (s *SqlStore) GetAllAccounts(ctx context.Context) (all []*types.Account)
- func (s *SqlStore) GetDB() *gorm.DB
- func (s *SqlStore) GetGroupByID(ctx context.Context, lockStrength LockingStrength, accountID, groupID string) (*types.Group, error)
- func (s *SqlStore) GetGroupByName(ctx context.Context, lockStrength LockingStrength, accountID, groupName string) (*types.Group, error)
- func (s *SqlStore) GetGroupsByIDs(ctx context.Context, lockStrength LockingStrength, accountID string, ...) (map[string]*types.Group, error)
- func (s *SqlStore) GetInstallationID() string
- func (s *SqlStore) GetNameServerGroupByID(ctx context.Context, lockStrength LockingStrength, accountID, nsGroupID string) (*nbdns.NameServerGroup, error)
- func (s *SqlStore) GetNetworkByID(ctx context.Context, lockStrength LockingStrength, accountID, networkID string) (*networkTypes.Network, error)
- func (s *SqlStore) GetNetworkResourceByID(ctx context.Context, lockStrength LockingStrength, ...) (*resourceTypes.NetworkResource, error)
- func (s *SqlStore) GetNetworkResourceByName(ctx context.Context, lockStrength LockingStrength, ...) (*resourceTypes.NetworkResource, error)
- func (s *SqlStore) GetNetworkResourcesByAccountID(ctx context.Context, lockStrength LockingStrength, accountID string) ([]*resourceTypes.NetworkResource, error)
- func (s *SqlStore) GetNetworkResourcesByNetID(ctx context.Context, lockStrength LockingStrength, accountID, networkID string) ([]*resourceTypes.NetworkResource, error)
- func (s *SqlStore) GetNetworkRouterByID(ctx context.Context, lockStrength LockingStrength, accountID, routerID string) (*routerTypes.NetworkRouter, error)
- func (s *SqlStore) GetNetworkRoutersByAccountID(ctx context.Context, lockStrength LockingStrength, accountID string) ([]*routerTypes.NetworkRouter, error)
- func (s *SqlStore) GetNetworkRoutersByNetID(ctx context.Context, lockStrength LockingStrength, accountID, netID string) ([]*routerTypes.NetworkRouter, error)
- func (s *SqlStore) GetPeerByID(ctx context.Context, lockStrength LockingStrength, accountID, peerID string) (*nbpeer.Peer, error)
- func (s *SqlStore) GetPeerByPeerPubKey(ctx context.Context, lockStrength LockingStrength, peerKey string) (*nbpeer.Peer, error)
- func (s *SqlStore) GetPeerLabelsInAccount(ctx context.Context, lockStrength LockingStrength, accountID string) ([]string, error)
- func (s *SqlStore) GetPeersByIDs(ctx context.Context, lockStrength LockingStrength, accountID string, ...) (map[string]*nbpeer.Peer, error)
- func (s *SqlStore) GetPolicyByID(ctx context.Context, lockStrength LockingStrength, accountID, policyID string) (*types.Policy, error)
- func (s *SqlStore) GetPostureCheckByChecksDefinition(accountID string, checks *posture.ChecksDefinition) (*posture.Checks, error)
- func (s *SqlStore) GetPostureChecksByID(ctx context.Context, lockStrength LockingStrength, ...) (*posture.Checks, error)
- func (s *SqlStore) GetPostureChecksByIDs(ctx context.Context, lockStrength LockingStrength, accountID string, ...) (map[string]*posture.Checks, error)
- func (s *SqlStore) GetResourceGroups(ctx context.Context, lockStrength LockingStrength, ...) ([]*types.Group, error)
- func (s *SqlStore) GetRouteByID(ctx context.Context, lockStrength LockingStrength, routeID string, ...) (*route.Route, error)
- func (s *SqlStore) GetSetupKeyByID(ctx context.Context, lockStrength LockingStrength, ...) (*types.SetupKey, error)
- func (s *SqlStore) GetSetupKeyBySecret(ctx context.Context, lockStrength LockingStrength, key string) (*types.SetupKey, error)
- func (s *SqlStore) GetStoreEngine() Engine
- func (s *SqlStore) GetTakenIPs(ctx context.Context, lockStrength LockingStrength, accountID string) ([]net.IP, error)
- func (s *SqlStore) GetTokenIDByHashedToken(ctx context.Context, hashedToken string) (string, error)
- func (s *SqlStore) GetUserByTokenID(ctx context.Context, tokenID string) (*types.User, error)
- func (s *SqlStore) GetUserByUserID(ctx context.Context, lockStrength LockingStrength, userID string) (*types.User, error)
- func (s *SqlStore) GetUserPeers(ctx context.Context, lockStrength LockingStrength, accountID, userID string) ([]*nbpeer.Peer, error)
- func (s *SqlStore) IncrementNetworkSerial(ctx context.Context, lockStrength LockingStrength, accountId string) error
- func (s *SqlStore) IncrementSetupKeyUsage(ctx context.Context, setupKeyID string) error
- func (s *SqlStore) RemoveResourceFromGroup(ctx context.Context, accountId string, groupID string, resourceID string) error
- func (s *SqlStore) SaveAccount(ctx context.Context, account *types.Account) error
- func (s *SqlStore) SaveDNSSettings(ctx context.Context, lockStrength LockingStrength, accountID string, ...) error
- func (s *SqlStore) SaveGroup(ctx context.Context, lockStrength LockingStrength, group *types.Group) error
- func (s *SqlStore) SaveGroups(ctx context.Context, lockStrength LockingStrength, groups []*types.Group) error
- func (s *SqlStore) SaveInstallationID(_ context.Context, ID string) error
- func (s *SqlStore) SaveNameServerGroup(ctx context.Context, lockStrength LockingStrength, ...) error
- func (s *SqlStore) SaveNetwork(ctx context.Context, lockStrength LockingStrength, ...) error
- func (s *SqlStore) SaveNetworkResource(ctx context.Context, lockStrength LockingStrength, ...) error
- func (s *SqlStore) SaveNetworkRouter(ctx context.Context, lockStrength LockingStrength, ...) error
- func (s *SqlStore) SavePeer(ctx context.Context, accountID string, peer *nbpeer.Peer) error
- func (s *SqlStore) SavePeerLocation(accountID string, peerWithLocation *nbpeer.Peer) error
- func (s *SqlStore) SavePeerStatus(accountID, peerID string, peerStatus nbpeer.PeerStatus) error
- func (s *SqlStore) SavePolicy(ctx context.Context, lockStrength LockingStrength, policy *types.Policy) error
- func (s *SqlStore) SavePostureChecks(ctx context.Context, lockStrength LockingStrength, ...) error
- func (s *SqlStore) SaveSetupKey(ctx context.Context, lockStrength LockingStrength, setupKey *types.SetupKey) error
- func (s *SqlStore) SaveUser(ctx context.Context, lockStrength LockingStrength, user *types.User) error
- func (s *SqlStore) SaveUserLastLogin(ctx context.Context, accountID, userID string, lastLogin time.Time) error
- func (s *SqlStore) SaveUsers(accountID string, users map[string]*types.User) error
- func (s *SqlStore) UpdateAccountDomainAttributes(ctx context.Context, accountID string, domain string, category string, ...) error
- type Store
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type FileStore ¶
type FileStore struct { Accounts map[string]*types.Account SetupKeyID2AccountID map[string]string `json:"-"` PeerKeyID2AccountID map[string]string `json:"-"` PeerID2AccountID map[string]string `json:"-"` UserID2AccountID map[string]string `json:"-"` PrivateDomain2AccountID map[string]string `json:"-"` HashedPAT2TokenID map[string]string `json:"-"` TokenID2UserID map[string]string `json:"-"` InstallationID string // contains filtered or unexported fields }
FileStore represents an account storage backed by a file persisted to disk
func NewFileStore ¶
func NewFileStore(ctx context.Context, dataDir string, metrics telemetry.AppMetrics) (*FileStore, error)
NewFileStore restores a store from the file located in the datadir
func (*FileStore) GetAllAccounts ¶
GetAllAccounts returns all accounts
func (*FileStore) GetStoreEngine ¶
GetStoreEngine returns FileStoreEngine
type LockingStrength ¶
type LockingStrength string
const ( LockingStrengthUpdate LockingStrength = "UPDATE" // Strongest lock, preventing any changes by other transactions until your transaction completes. LockingStrengthNoKeyUpdate LockingStrength = "NO KEY UPDATE" // Similar to UPDATE but allows changes to related rows. )
type SqlStore ¶
type SqlStore struct {
// contains filtered or unexported fields
}
SqlStore represents an account storage backed by a Sql DB persisted to disk
func NewPostgresqlStore ¶
func NewPostgresqlStore(ctx context.Context, dsn string, metrics telemetry.AppMetrics) (*SqlStore, error)
NewPostgresqlStore creates a new Postgres store.
func NewPostgresqlStoreFromSqlStore ¶
func NewPostgresqlStoreFromSqlStore(ctx context.Context, sqliteStore *SqlStore, dsn string, metrics telemetry.AppMetrics) (*SqlStore, error)
NewPostgresqlStoreFromSqlStore restores a store from SqlStore and stores Postgres DB.
func NewSqlStore ¶
func NewSqlStore(ctx context.Context, db *gorm.DB, storeEngine Engine, metrics telemetry.AppMetrics) (*SqlStore, error)
NewSqlStore creates a new SqlStore instance.
func NewSqliteStore ¶
func NewSqliteStore(ctx context.Context, dataDir string, metrics telemetry.AppMetrics) (*SqlStore, error)
NewSqliteStore creates a new SQLite store.
func NewSqliteStoreFromFileStore ¶
func NewSqliteStoreFromFileStore(ctx context.Context, fileStore *FileStore, dataDir string, metrics telemetry.AppMetrics) (*SqlStore, error)
NewSqliteStoreFromFileStore restores a store from FileStore and stores SQLite DB in the file located in datadir.
func (*SqlStore) AccountExists ¶
func (s *SqlStore) AccountExists(ctx context.Context, lockStrength LockingStrength, id string) (bool, error)
AccountExists checks whether an account exists by the given ID.
func (*SqlStore) AcquireGlobalLock ¶
AcquireGlobalLock acquires global lock across all the accounts and returns a function that releases the lock
func (*SqlStore) AcquireReadLockByUID ¶
AcquireReadLockByUID acquires an ID lock for writing to a resource and returns a function that releases the lock
func (*SqlStore) AcquireWriteLockByUID ¶
AcquireWriteLockByUID acquires an ID lock for writing to a resource and returns a function that releases the lock
func (*SqlStore) AddPeerToAccount ¶
func (*SqlStore) AddPeerToAllGroup ¶
AddPeerToAllGroup adds a peer to the 'All' group. Method always needs to run in a transaction
func (*SqlStore) AddPeerToGroup ¶
func (s *SqlStore) AddPeerToGroup(ctx context.Context, accountId string, peerId string, groupID string) error
AddPeerToGroup adds a peer to a group. Method always needs to run in a transaction
func (*SqlStore) AddResourceToGroup ¶
func (s *SqlStore) AddResourceToGroup(ctx context.Context, accountId string, groupID string, resource *types.Resource) error
AddResourceToGroup adds a resource to a group. Method always needs to run n a transaction
func (*SqlStore) CreatePolicy ¶
func (*SqlStore) DeleteAccount ¶
func (*SqlStore) DeleteGroup ¶
func (s *SqlStore) DeleteGroup(ctx context.Context, lockStrength LockingStrength, accountID, groupID string) error
DeleteGroup deletes a group from the database.
func (*SqlStore) DeleteGroups ¶
func (s *SqlStore) DeleteGroups(ctx context.Context, strength LockingStrength, accountID string, groupIDs []string) error
DeleteGroups deletes groups from the database.
func (*SqlStore) DeleteHashedPAT2TokenIDIndex ¶
DeleteHashedPAT2TokenIDIndex is noop in SqlStore
func (*SqlStore) DeleteNameServerGroup ¶
func (s *SqlStore) DeleteNameServerGroup(ctx context.Context, lockStrength LockingStrength, accountID, nsGroupID string) error
DeleteNameServerGroup deletes a name server group from the database.
func (*SqlStore) DeleteNetwork ¶
func (*SqlStore) DeleteNetworkResource ¶
func (*SqlStore) DeleteNetworkRouter ¶
func (*SqlStore) DeletePolicy ¶
func (*SqlStore) DeletePostureChecks ¶
func (s *SqlStore) DeletePostureChecks(ctx context.Context, lockStrength LockingStrength, accountID, postureChecksID string) error
DeletePostureChecks deletes a posture checks from the database.
func (*SqlStore) DeleteSetupKey ¶
func (s *SqlStore) DeleteSetupKey(ctx context.Context, lockStrength LockingStrength, accountID, keyID string) error
DeleteSetupKey deletes a setup key from the database.
func (*SqlStore) DeleteTokenID2UserIDIndex ¶
DeleteTokenID2UserIDIndex is noop in SqlStore
func (*SqlStore) ExecuteInTransaction ¶
func (*SqlStore) GetAccount ¶
func (*SqlStore) GetAccountByPeerID ¶
func (*SqlStore) GetAccountByPeerPubKey ¶
func (*SqlStore) GetAccountByPrivateDomain ¶
func (*SqlStore) GetAccountBySetupKey ¶
func (*SqlStore) GetAccountByUser ¶
func (*SqlStore) GetAccountDNSSettings ¶
func (s *SqlStore) GetAccountDNSSettings(ctx context.Context, lockStrength LockingStrength, accountID string) (*types.DNSSettings, error)
func (*SqlStore) GetAccountDomainAndCategory ¶
func (s *SqlStore) GetAccountDomainAndCategory(ctx context.Context, lockStrength LockingStrength, accountID string) (string, string, error)
GetAccountDomainAndCategory retrieves the Domain and DomainCategory fields for an account based on the given accountID.
func (*SqlStore) GetAccountGroups ¶
func (*SqlStore) GetAccountIDByPeerPubKey ¶
func (*SqlStore) GetAccountIDByPrivateDomain ¶
func (*SqlStore) GetAccountIDBySetupKey ¶
func (*SqlStore) GetAccountIDByUserID ¶
func (*SqlStore) GetAccountNameServerGroups ¶
func (s *SqlStore) GetAccountNameServerGroups(ctx context.Context, lockStrength LockingStrength, accountID string) ([]*nbdns.NameServerGroup, error)
GetAccountNameServerGroups retrieves name server groups for an account.
func (*SqlStore) GetAccountNetwork ¶
func (*SqlStore) GetAccountNetworks ¶
func (s *SqlStore) GetAccountNetworks(ctx context.Context, lockStrength LockingStrength, accountID string) ([]*networkTypes.Network, error)
func (*SqlStore) GetAccountPolicies ¶
func (s *SqlStore) GetAccountPolicies(ctx context.Context, lockStrength LockingStrength, accountID string) ([]*types.Policy, error)
GetAccountPolicies retrieves policies for an account.
func (*SqlStore) GetAccountPostureChecks ¶
func (s *SqlStore) GetAccountPostureChecks(ctx context.Context, lockStrength LockingStrength, accountID string) ([]*posture.Checks, error)
GetAccountPostureChecks retrieves posture checks for an account.
func (*SqlStore) GetAccountRoutes ¶
func (s *SqlStore) GetAccountRoutes(ctx context.Context, lockStrength LockingStrength, accountID string) ([]*route.Route, error)
GetAccountRoutes retrieves network routes for an account.
func (*SqlStore) GetAccountSettings ¶
func (*SqlStore) GetAccountSetupKeys ¶
func (s *SqlStore) GetAccountSetupKeys(ctx context.Context, lockStrength LockingStrength, accountID string) ([]*types.SetupKey, error)
GetAccountSetupKeys retrieves setup keys for an account.
func (*SqlStore) GetAccountUsers ¶
func (*SqlStore) GetAllAccounts ¶
func (*SqlStore) GetGroupByID ¶
func (s *SqlStore) GetGroupByID(ctx context.Context, lockStrength LockingStrength, accountID, groupID string) (*types.Group, error)
GetGroupByID retrieves a group by ID and account ID.
func (*SqlStore) GetGroupByName ¶
func (s *SqlStore) GetGroupByName(ctx context.Context, lockStrength LockingStrength, accountID, groupName string) (*types.Group, error)
GetGroupByName retrieves a group by name and account ID.
func (*SqlStore) GetGroupsByIDs ¶
func (s *SqlStore) GetGroupsByIDs(ctx context.Context, lockStrength LockingStrength, accountID string, groupIDs []string) (map[string]*types.Group, error)
GetGroupsByIDs retrieves groups by their IDs and account ID.
func (*SqlStore) GetInstallationID ¶
func (*SqlStore) GetNameServerGroupByID ¶
func (s *SqlStore) GetNameServerGroupByID(ctx context.Context, lockStrength LockingStrength, accountID, nsGroupID string) (*nbdns.NameServerGroup, error)
GetNameServerGroupByID retrieves a name server group by its ID and account ID.
func (*SqlStore) GetNetworkByID ¶
func (s *SqlStore) GetNetworkByID(ctx context.Context, lockStrength LockingStrength, accountID, networkID string) (*networkTypes.Network, error)
func (*SqlStore) GetNetworkResourceByID ¶
func (s *SqlStore) GetNetworkResourceByID(ctx context.Context, lockStrength LockingStrength, accountID, resourceID string) (*resourceTypes.NetworkResource, error)
func (*SqlStore) GetNetworkResourceByName ¶
func (s *SqlStore) GetNetworkResourceByName(ctx context.Context, lockStrength LockingStrength, accountID, resourceName string) (*resourceTypes.NetworkResource, error)
func (*SqlStore) GetNetworkResourcesByAccountID ¶
func (s *SqlStore) GetNetworkResourcesByAccountID(ctx context.Context, lockStrength LockingStrength, accountID string) ([]*resourceTypes.NetworkResource, error)
func (*SqlStore) GetNetworkResourcesByNetID ¶
func (s *SqlStore) GetNetworkResourcesByNetID(ctx context.Context, lockStrength LockingStrength, accountID, networkID string) ([]*resourceTypes.NetworkResource, error)
func (*SqlStore) GetNetworkRouterByID ¶
func (s *SqlStore) GetNetworkRouterByID(ctx context.Context, lockStrength LockingStrength, accountID, routerID string) (*routerTypes.NetworkRouter, error)
func (*SqlStore) GetNetworkRoutersByAccountID ¶
func (s *SqlStore) GetNetworkRoutersByAccountID(ctx context.Context, lockStrength LockingStrength, accountID string) ([]*routerTypes.NetworkRouter, error)
func (*SqlStore) GetNetworkRoutersByNetID ¶
func (s *SqlStore) GetNetworkRoutersByNetID(ctx context.Context, lockStrength LockingStrength, accountID, netID string) ([]*routerTypes.NetworkRouter, error)
func (*SqlStore) GetPeerByID ¶
func (s *SqlStore) GetPeerByID(ctx context.Context, lockStrength LockingStrength, accountID, peerID string) (*nbpeer.Peer, error)
GetPeerByID retrieves a peer by its ID and account ID.
func (*SqlStore) GetPeerByPeerPubKey ¶
func (*SqlStore) GetPeerLabelsInAccount ¶
func (*SqlStore) GetPeersByIDs ¶
func (s *SqlStore) GetPeersByIDs(ctx context.Context, lockStrength LockingStrength, accountID string, peerIDs []string) (map[string]*nbpeer.Peer, error)
GetPeersByIDs retrieves peers by their IDs and account ID.
func (*SqlStore) GetPolicyByID ¶
func (s *SqlStore) GetPolicyByID(ctx context.Context, lockStrength LockingStrength, accountID, policyID string) (*types.Policy, error)
GetPolicyByID retrieves a policy by its ID and account ID.
func (*SqlStore) GetPostureCheckByChecksDefinition ¶
func (*SqlStore) GetPostureChecksByID ¶
func (s *SqlStore) GetPostureChecksByID(ctx context.Context, lockStrength LockingStrength, accountID, postureChecksID string) (*posture.Checks, error)
GetPostureChecksByID retrieves posture checks by their ID and account ID.
func (*SqlStore) GetPostureChecksByIDs ¶
func (s *SqlStore) GetPostureChecksByIDs(ctx context.Context, lockStrength LockingStrength, accountID string, postureChecksIDs []string) (map[string]*posture.Checks, error)
GetPostureChecksByIDs retrieves posture checks by their IDs and account ID.
func (*SqlStore) GetResourceGroups ¶
func (*SqlStore) GetRouteByID ¶
func (s *SqlStore) GetRouteByID(ctx context.Context, lockStrength LockingStrength, routeID string, accountID string) (*route.Route, error)
GetRouteByID retrieves a route by its ID and account ID.
func (*SqlStore) GetSetupKeyByID ¶
func (s *SqlStore) GetSetupKeyByID(ctx context.Context, lockStrength LockingStrength, accountID, setupKeyID string) (*types.SetupKey, error)
GetSetupKeyByID retrieves a setup key by its ID and account ID.
func (*SqlStore) GetSetupKeyBySecret ¶
func (*SqlStore) GetStoreEngine ¶
GetStoreEngine returns underlying store engine
func (*SqlStore) GetTakenIPs ¶
func (*SqlStore) GetTokenIDByHashedToken ¶
func (*SqlStore) GetUserByTokenID ¶
func (*SqlStore) GetUserByUserID ¶
func (*SqlStore) GetUserPeers ¶
func (s *SqlStore) GetUserPeers(ctx context.Context, lockStrength LockingStrength, accountID, userID string) ([]*nbpeer.Peer, error)
GetUserPeers retrieves peers for a user.
func (*SqlStore) IncrementNetworkSerial ¶
func (*SqlStore) IncrementSetupKeyUsage ¶
func (*SqlStore) RemoveResourceFromGroup ¶
func (s *SqlStore) RemoveResourceFromGroup(ctx context.Context, accountId string, groupID string, resourceID string) error
RemoveResourceFromGroup removes a resource from a group. Method always needs to run in a transaction
func (*SqlStore) SaveAccount ¶
func (*SqlStore) SaveDNSSettings ¶
func (s *SqlStore) SaveDNSSettings(ctx context.Context, lockStrength LockingStrength, accountID string, settings *types.DNSSettings) error
SaveDNSSettings saves the DNS settings to the store.
func (*SqlStore) SaveGroup ¶
func (s *SqlStore) SaveGroup(ctx context.Context, lockStrength LockingStrength, group *types.Group) error
SaveGroup saves a group to the store.
func (*SqlStore) SaveGroups ¶
func (s *SqlStore) SaveGroups(ctx context.Context, lockStrength LockingStrength, groups []*types.Group) error
SaveGroups saves the given list of groups to the database.
func (*SqlStore) SaveInstallationID ¶
func (*SqlStore) SaveNameServerGroup ¶
func (s *SqlStore) SaveNameServerGroup(ctx context.Context, lockStrength LockingStrength, nameServerGroup *nbdns.NameServerGroup) error
SaveNameServerGroup saves a name server group to the database.
func (*SqlStore) SaveNetwork ¶
func (s *SqlStore) SaveNetwork(ctx context.Context, lockStrength LockingStrength, network *networkTypes.Network) error
func (*SqlStore) SaveNetworkResource ¶
func (s *SqlStore) SaveNetworkResource(ctx context.Context, lockStrength LockingStrength, resource *resourceTypes.NetworkResource) error
func (*SqlStore) SaveNetworkRouter ¶
func (s *SqlStore) SaveNetworkRouter(ctx context.Context, lockStrength LockingStrength, router *routerTypes.NetworkRouter) error
func (*SqlStore) SavePeerLocation ¶
func (*SqlStore) SavePeerStatus ¶
func (s *SqlStore) SavePeerStatus(accountID, peerID string, peerStatus nbpeer.PeerStatus) error
func (*SqlStore) SavePolicy ¶
func (s *SqlStore) SavePolicy(ctx context.Context, lockStrength LockingStrength, policy *types.Policy) error
SavePolicy saves a policy to the database.
func (*SqlStore) SavePostureChecks ¶
func (s *SqlStore) SavePostureChecks(ctx context.Context, lockStrength LockingStrength, postureCheck *posture.Checks) error
SavePostureChecks saves a posture checks to the database.
func (*SqlStore) SaveSetupKey ¶
func (s *SqlStore) SaveSetupKey(ctx context.Context, lockStrength LockingStrength, setupKey *types.SetupKey) error
SaveSetupKey saves a setup key to the database.
func (*SqlStore) SaveUser ¶
func (s *SqlStore) SaveUser(ctx context.Context, lockStrength LockingStrength, user *types.User) error
SaveUser saves the given user to the database.
func (*SqlStore) SaveUserLastLogin ¶
func (s *SqlStore) SaveUserLastLogin(ctx context.Context, accountID, userID string, lastLogin time.Time) error
SaveUserLastLogin stores the last login time for a user in DB.
type Store ¶
type Store interface { GetAllAccounts(ctx context.Context) []*types.Account GetAccount(ctx context.Context, accountID string) (*types.Account, error) AccountExists(ctx context.Context, lockStrength LockingStrength, id string) (bool, error) GetAccountDomainAndCategory(ctx context.Context, lockStrength LockingStrength, accountID string) (string, string, error) GetAccountByUser(ctx context.Context, userID string) (*types.Account, error) GetAccountByPeerPubKey(ctx context.Context, peerKey string) (*types.Account, error) GetAccountIDByPeerPubKey(ctx context.Context, peerKey string) (string, error) GetAccountIDByUserID(userID string) (string, error) GetAccountIDBySetupKey(ctx context.Context, peerKey string) (string, error) GetAccountByPeerID(ctx context.Context, peerID string) (*types.Account, error) GetAccountBySetupKey(ctx context.Context, setupKey string) (*types.Account, error) // todo use key hash later GetAccountByPrivateDomain(ctx context.Context, domain string) (*types.Account, error) GetAccountIDByPrivateDomain(ctx context.Context, lockStrength LockingStrength, domain string) (string, error) GetAccountSettings(ctx context.Context, lockStrength LockingStrength, accountID string) (*types.Settings, error) GetAccountDNSSettings(ctx context.Context, lockStrength LockingStrength, accountID string) (*types.DNSSettings, error) SaveAccount(ctx context.Context, account *types.Account) error DeleteAccount(ctx context.Context, account *types.Account) error UpdateAccountDomainAttributes(ctx context.Context, accountID string, domain string, category string, isPrimaryDomain bool) error SaveDNSSettings(ctx context.Context, lockStrength LockingStrength, accountID string, settings *types.DNSSettings) error GetUserByTokenID(ctx context.Context, tokenID string) (*types.User, error) GetUserByUserID(ctx context.Context, lockStrength LockingStrength, userID string) (*types.User, error) GetAccountUsers(ctx context.Context, lockStrength LockingStrength, accountID string) ([]*types.User, error) SaveUsers(accountID string, users map[string]*types.User) error SaveUser(ctx context.Context, lockStrength LockingStrength, user *types.User) error SaveUserLastLogin(ctx context.Context, accountID, userID string, lastLogin time.Time) error GetTokenIDByHashedToken(ctx context.Context, secret string) (string, error) DeleteHashedPAT2TokenIDIndex(hashedToken string) error DeleteTokenID2UserIDIndex(tokenID string) error GetAccountGroups(ctx context.Context, lockStrength LockingStrength, accountID string) ([]*types.Group, error) GetResourceGroups(ctx context.Context, lockStrength LockingStrength, accountID, resourceID string) ([]*types.Group, error) GetGroupByID(ctx context.Context, lockStrength LockingStrength, accountID, groupID string) (*types.Group, error) GetGroupByName(ctx context.Context, lockStrength LockingStrength, groupName, accountID string) (*types.Group, error) GetGroupsByIDs(ctx context.Context, lockStrength LockingStrength, accountID string, groupIDs []string) (map[string]*types.Group, error) SaveGroups(ctx context.Context, lockStrength LockingStrength, groups []*types.Group) error SaveGroup(ctx context.Context, lockStrength LockingStrength, group *types.Group) error DeleteGroup(ctx context.Context, lockStrength LockingStrength, accountID, groupID string) error DeleteGroups(ctx context.Context, strength LockingStrength, accountID string, groupIDs []string) error GetAccountPolicies(ctx context.Context, lockStrength LockingStrength, accountID string) ([]*types.Policy, error) GetPolicyByID(ctx context.Context, lockStrength LockingStrength, accountID, policyID string) (*types.Policy, error) CreatePolicy(ctx context.Context, lockStrength LockingStrength, policy *types.Policy) error SavePolicy(ctx context.Context, lockStrength LockingStrength, policy *types.Policy) error DeletePolicy(ctx context.Context, lockStrength LockingStrength, accountID, policyID string) error GetPostureCheckByChecksDefinition(accountID string, checks *posture.ChecksDefinition) (*posture.Checks, error) GetAccountPostureChecks(ctx context.Context, lockStrength LockingStrength, accountID string) ([]*posture.Checks, error) GetPostureChecksByID(ctx context.Context, lockStrength LockingStrength, accountID, postureCheckID string) (*posture.Checks, error) GetPostureChecksByIDs(ctx context.Context, lockStrength LockingStrength, accountID string, postureChecksIDs []string) (map[string]*posture.Checks, error) SavePostureChecks(ctx context.Context, lockStrength LockingStrength, postureCheck *posture.Checks) error DeletePostureChecks(ctx context.Context, lockStrength LockingStrength, accountID, postureChecksID string) error GetPeerLabelsInAccount(ctx context.Context, lockStrength LockingStrength, accountId string) ([]string, error) AddPeerToAllGroup(ctx context.Context, accountID string, peerID string) error AddPeerToGroup(ctx context.Context, accountId string, peerId string, groupID string) error AddResourceToGroup(ctx context.Context, accountId string, groupID string, resource *types.Resource) error RemoveResourceFromGroup(ctx context.Context, accountId string, groupID string, resourceID string) error AddPeerToAccount(ctx context.Context, peer *nbpeer.Peer) error GetPeerByPeerPubKey(ctx context.Context, lockStrength LockingStrength, peerKey string) (*nbpeer.Peer, error) GetUserPeers(ctx context.Context, lockStrength LockingStrength, accountID, userID string) ([]*nbpeer.Peer, error) GetPeerByID(ctx context.Context, lockStrength LockingStrength, accountID string, peerID string) (*nbpeer.Peer, error) GetPeersByIDs(ctx context.Context, lockStrength LockingStrength, accountID string, peerIDs []string) (map[string]*nbpeer.Peer, error) SavePeer(ctx context.Context, accountID string, peer *nbpeer.Peer) error SavePeerStatus(accountID, peerID string, status nbpeer.PeerStatus) error SavePeerLocation(accountID string, peer *nbpeer.Peer) error GetSetupKeyBySecret(ctx context.Context, lockStrength LockingStrength, key string) (*types.SetupKey, error) IncrementSetupKeyUsage(ctx context.Context, setupKeyID string) error GetAccountSetupKeys(ctx context.Context, lockStrength LockingStrength, accountID string) ([]*types.SetupKey, error) GetSetupKeyByID(ctx context.Context, lockStrength LockingStrength, accountID, setupKeyID string) (*types.SetupKey, error) SaveSetupKey(ctx context.Context, lockStrength LockingStrength, setupKey *types.SetupKey) error DeleteSetupKey(ctx context.Context, lockStrength LockingStrength, accountID, keyID string) error GetAccountRoutes(ctx context.Context, lockStrength LockingStrength, accountID string) ([]*route.Route, error) GetRouteByID(ctx context.Context, lockStrength LockingStrength, routeID string, accountID string) (*route.Route, error) GetAccountNameServerGroups(ctx context.Context, lockStrength LockingStrength, accountID string) ([]*dns.NameServerGroup, error) GetNameServerGroupByID(ctx context.Context, lockStrength LockingStrength, nameServerGroupID string, accountID string) (*dns.NameServerGroup, error) SaveNameServerGroup(ctx context.Context, lockStrength LockingStrength, nameServerGroup *dns.NameServerGroup) error DeleteNameServerGroup(ctx context.Context, lockStrength LockingStrength, accountID, nameServerGroupID string) error GetTakenIPs(ctx context.Context, lockStrength LockingStrength, accountId string) ([]net.IP, error) IncrementNetworkSerial(ctx context.Context, lockStrength LockingStrength, accountId string) error GetAccountNetwork(ctx context.Context, lockStrength LockingStrength, accountId string) (*types.Network, error) GetInstallationID() string SaveInstallationID(ctx context.Context, ID string) error // AcquireWriteLockByUID should attempt to acquire a lock for write purposes and return a function that releases the lock AcquireWriteLockByUID(ctx context.Context, uniqueID string) func() // AcquireReadLockByUID should attempt to acquire lock for read purposes and return a function that releases the lock AcquireReadLockByUID(ctx context.Context, uniqueID string) func() // AcquireGlobalLock should attempt to acquire a global lock and return a function that releases the lock AcquireGlobalLock(ctx context.Context) func() // Close should close the store persisting all unsaved data. Close(ctx context.Context) error // GetStoreEngine should return Engine of the current store implementation. // This is also a method of metrics.DataSource interface. GetStoreEngine() Engine ExecuteInTransaction(ctx context.Context, f func(store Store) error) error GetAccountNetworks(ctx context.Context, lockStrength LockingStrength, accountID string) ([]*networkTypes.Network, error) GetNetworkByID(ctx context.Context, lockStrength LockingStrength, accountID, networkID string) (*networkTypes.Network, error) SaveNetwork(ctx context.Context, lockStrength LockingStrength, network *networkTypes.Network) error DeleteNetwork(ctx context.Context, lockStrength LockingStrength, accountID, networkID string) error GetNetworkRoutersByNetID(ctx context.Context, lockStrength LockingStrength, accountID, netID string) ([]*routerTypes.NetworkRouter, error) GetNetworkRoutersByAccountID(ctx context.Context, lockStrength LockingStrength, accountID string) ([]*routerTypes.NetworkRouter, error) GetNetworkRouterByID(ctx context.Context, lockStrength LockingStrength, accountID, routerID string) (*routerTypes.NetworkRouter, error) SaveNetworkRouter(ctx context.Context, lockStrength LockingStrength, router *routerTypes.NetworkRouter) error DeleteNetworkRouter(ctx context.Context, lockStrength LockingStrength, accountID, routerID string) error GetNetworkResourcesByNetID(ctx context.Context, lockStrength LockingStrength, accountID, netID string) ([]*resourceTypes.NetworkResource, error) GetNetworkResourcesByAccountID(ctx context.Context, lockStrength LockingStrength, accountID string) ([]*resourceTypes.NetworkResource, error) GetNetworkResourceByID(ctx context.Context, lockStrength LockingStrength, accountID, resourceID string) (*resourceTypes.NetworkResource, error) GetNetworkResourceByName(ctx context.Context, lockStrength LockingStrength, accountID, resourceName string) (*resourceTypes.NetworkResource, error) SaveNetworkResource(ctx context.Context, lockStrength LockingStrength, resource *resourceTypes.NetworkResource) error DeleteNetworkResource(ctx context.Context, lockStrength LockingStrength, accountID, resourceID string) error }
func NewStore ¶
func NewStore(ctx context.Context, kind Engine, dataDir string, metrics telemetry.AppMetrics) (Store, error)
NewStore creates a new store based on the provided engine type, data directory, and telemetry metrics
func NewTestStoreFromSQL ¶
func NewTestStoreFromSQL(ctx context.Context, filename string, dataDir string) (Store, func(), error)
NewTestStoreFromSQL is only used in tests. It will create a test database base of the store engine set in env. Optionally it can load a SQL file to the database. If the filename is empty it will return an empty database