Help us shape the future of Go! Take the 2026 Go Developer Survey

datastore

package
v1.14.9 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AttestedNodeEvent added in v1.8.7

type AttestedNodeEvent struct {
	EventID  uint
	SpiffeID string
}

type BundleEndpointType added in v1.1.0

type BundleEndpointType string
const (
	BundleEndpointSPIFFE BundleEndpointType = "https_spiffe"
	BundleEndpointWeb    BundleEndpointType = "https_web"
)

type ByFederatesWith

type ByFederatesWith struct {
	TrustDomains []string
	Match        MatchBehavior
}

type BySelectors

type BySelectors struct {
	Selectors []*common.Selector
	Match     MatchBehavior
}

type CAJournal added in v1.9.0

type CAJournal struct {
	ID                    uint
	Data                  []byte
	ActiveX509AuthorityID string
}

type CountAttestedNodesRequest added in v1.9.6

type CountAttestedNodesRequest struct {
	ByAttestationType string
	ByBanned          *bool
	ByExpiresBefore   time.Time
	BySelectorMatch   *BySelectors
	FetchSelectors    bool
	ByCanReattest     *bool
}

type CountRegistrationEntriesRequest added in v1.9.6

type CountRegistrationEntriesRequest struct {
	DataConsistency DataConsistency
	ByParentID      string
	BySelectors     *BySelectors
	BySpiffeID      string
	ByFederatesWith *ByFederatesWith
	ByHint          string
	ByDownstream    *bool
}

type DataConsistency

type DataConsistency int32

DataConsistency indicates the required data consistency for a read operation.

const (
	// Require data from a primary database instance (default)
	RequireCurrent DataConsistency = iota

	// Allow access from available secondary database instances
	// Data staleness may be observed in the responses
	TolerateStale
)

type DataStore

type DataStore interface {
	// Bundles
	AppendBundle(context.Context, *common.Bundle) (*common.Bundle, error)
	CountBundles(context.Context) (int32, error)
	CreateBundle(context.Context, *common.Bundle) (*common.Bundle, error)
	DeleteBundle(ctx context.Context, trustDomainID string, mode DeleteMode) error
	FetchBundle(ctx context.Context, trustDomainID string) (*common.Bundle, error)
	ListBundles(context.Context, *ListBundlesRequest) (*ListBundlesResponse, error)
	PruneBundle(ctx context.Context, trustDomainID string, expiresBefore time.Time) (changed bool, err error)
	SetBundle(context.Context, *common.Bundle) (*common.Bundle, error)
	UpdateBundle(context.Context, *common.Bundle, *common.BundleMask) (*common.Bundle, error)

	// Keys
	TaintX509CA(ctx context.Context, trustDomainID string, subjectKeyIDToTaint string) error
	RevokeX509CA(ctx context.Context, trustDomainID string, subjectKeyIDToRevoke string) error
	TaintJWTKey(ctx context.Context, trustDomainID string, authorityID string) (*common.PublicKey, error)
	RevokeJWTKey(ctx context.Context, trustDomainID string, authorityID string) (*common.PublicKey, error)

	// Entries
	CountRegistrationEntries(context.Context, *CountRegistrationEntriesRequest) (int32, error)
	CreateRegistrationEntry(context.Context, *common.RegistrationEntry) (*common.RegistrationEntry, error)
	CreateOrReturnRegistrationEntry(context.Context, *common.RegistrationEntry) (*common.RegistrationEntry, bool, error)
	DeleteRegistrationEntry(ctx context.Context, entryID string) (*common.RegistrationEntry, error)
	FetchRegistrationEntry(ctx context.Context, entryID string) (*common.RegistrationEntry, error)
	FetchRegistrationEntries(ctx context.Context, entryIDs []string) (map[string]*common.RegistrationEntry, error)
	ListRegistrationEntries(context.Context, *ListRegistrationEntriesRequest) (*ListRegistrationEntriesResponse, error)
	PruneRegistrationEntries(ctx context.Context, expiresBefore time.Time) error
	UpdateRegistrationEntry(context.Context, *common.RegistrationEntry, *common.RegistrationEntryMask) (*common.RegistrationEntry, error)

	// Entries Events
	ListRegistrationEntryEvents(ctx context.Context, req *ListRegistrationEntryEventsRequest) (*ListRegistrationEntryEventsResponse, error)
	PruneRegistrationEntryEvents(ctx context.Context, olderThan time.Duration) error
	FetchRegistrationEntryEvent(ctx context.Context, eventID uint) (*RegistrationEntryEvent, error)
	CreateRegistrationEntryEventForTesting(ctx context.Context, event *RegistrationEntryEvent) error
	DeleteRegistrationEntryEventForTesting(ctx context.Context, eventID uint) error

	// Nodes
	CountAttestedNodes(context.Context, *CountAttestedNodesRequest) (int32, error)
	CreateAttestedNode(context.Context, *common.AttestedNode) (*common.AttestedNode, error)
	DeleteAttestedNode(ctx context.Context, spiffeID string) (*common.AttestedNode, error)
	FetchAttestedNode(ctx context.Context, spiffeID string) (*common.AttestedNode, error)
	ListAttestedNodes(context.Context, *ListAttestedNodesRequest) (*ListAttestedNodesResponse, error)
	UpdateAttestedNode(context.Context, *common.AttestedNode, *common.AttestedNodeMask) (*common.AttestedNode, error)
	PruneAttestedExpiredNodes(ctx context.Context, expiredBefore time.Time, includeNonReattestable bool) error

	// Nodes Events
	ListAttestedNodeEvents(ctx context.Context, req *ListAttestedNodeEventsRequest) (*ListAttestedNodeEventsResponse, error)
	PruneAttestedNodeEvents(ctx context.Context, olderThan time.Duration) error
	FetchAttestedNodeEvent(ctx context.Context, eventID uint) (*AttestedNodeEvent, error)
	CreateAttestedNodeEventForTesting(ctx context.Context, event *AttestedNodeEvent) error
	DeleteAttestedNodeEventForTesting(ctx context.Context, eventID uint) error

	// Node selectors
	GetNodeSelectors(ctx context.Context, spiffeID string, dataConsistency DataConsistency) ([]*common.Selector, error)
	ListNodeSelectors(context.Context, *ListNodeSelectorsRequest) (*ListNodeSelectorsResponse, error)
	SetNodeSelectors(ctx context.Context, spiffeID string, selectors []*common.Selector) error

	// Tokens
	CreateJoinToken(context.Context, *JoinToken) error
	DeleteJoinToken(ctx context.Context, token string) error
	FetchJoinToken(ctx context.Context, token string) (*JoinToken, error)
	PruneJoinTokens(context.Context, time.Time) error

	// Federation Relationships
	CreateFederationRelationship(context.Context, *FederationRelationship) (*FederationRelationship, error)
	FetchFederationRelationship(context.Context, spiffeid.TrustDomain) (*FederationRelationship, error)
	ListFederationRelationships(context.Context, *ListFederationRelationshipsRequest) (*ListFederationRelationshipsResponse, error)
	DeleteFederationRelationship(context.Context, spiffeid.TrustDomain) error
	UpdateFederationRelationship(context.Context, *FederationRelationship, *types.FederationRelationshipMask) (*FederationRelationship, error)

	// CA Journals
	SetCAJournal(ctx context.Context, caJournal *CAJournal) (*CAJournal, error)
	FetchCAJournal(ctx context.Context, activeX509AuthorityID string) (*CAJournal, error)
	PruneCAJournals(ctx context.Context, allCAsExpireBefore int64) error
	ListCAJournalsForTesting(ctx context.Context) ([]*CAJournal, error)
}

DataStore defines the data storage interface.

type DeleteMode

type DeleteMode int32

DeleteMode defines delete behavior if associated records exist.

const (
	// Restrict the bundle from being deleted in the presence of associated entries
	Restrict DeleteMode = iota

	// Delete the bundle and associated entries
	Delete

	// Dissociate deletes the bundle and dissociates associated entries
	Dissociate
)

func (DeleteMode) String

func (mode DeleteMode) String() string

type FederationRelationship added in v1.1.0

type FederationRelationship struct {
	TrustDomain           spiffeid.TrustDomain
	BundleEndpointURL     *url.URL
	BundleEndpointProfile BundleEndpointType
	TrustDomainBundle     *common.Bundle

	// Fields only used for 'https_spiffe' bundle endpoint profile
	EndpointSPIFFEID spiffeid.ID
}

type Health

type Health struct {
	DataStore DataStore
}

func (*Health) CheckHealth

func (h *Health) CheckHealth() health.State

type HealthDetails

type HealthDetails struct {
	ListBundleErr string `json:"list_bundle_err,omitempty"`
}

type JoinToken

type JoinToken struct {
	Token  string
	Expiry time.Time
}

type ListAttestedNodeEventsRequest added in v1.11.0

type ListAttestedNodeEventsRequest struct {
	DataConsistency    DataConsistency
	GreaterThanEventID uint
	LessThanEventID    uint
}

type ListAttestedNodeEventsResponse added in v1.11.0

type ListAttestedNodeEventsResponse struct {
	Events []AttestedNodeEvent
}

type ListAttestedNodesRequest

type ListAttestedNodesRequest struct {
	ByAttestationType string
	ByBanned          *bool
	ByExpiresBefore   time.Time
	BySelectorMatch   *BySelectors
	FetchSelectors    bool
	Pagination        *Pagination
	ByCanReattest     *bool
	ValidAt           time.Time
}

type ListAttestedNodesResponse

type ListAttestedNodesResponse struct {
	Nodes      []*common.AttestedNode
	Pagination *Pagination
}

type ListBundlesRequest

type ListBundlesRequest struct {
	Pagination *Pagination
}

type ListBundlesResponse

type ListBundlesResponse struct {
	Bundles    []*common.Bundle
	Pagination *Pagination
}

type ListFederationRelationshipsRequest added in v1.1.0

type ListFederationRelationshipsRequest struct {
	Pagination *Pagination
}

type ListFederationRelationshipsResponse added in v1.1.0

type ListFederationRelationshipsResponse struct {
	FederationRelationships []*FederationRelationship
	Pagination              *Pagination
}

type ListNodeSelectorsRequest

type ListNodeSelectorsRequest struct {
	DataConsistency DataConsistency
	ValidAt         time.Time
}

type ListNodeSelectorsResponse

type ListNodeSelectorsResponse struct {
	Selectors map[string][]*common.Selector
}

type ListRegistrationEntriesRequest

type ListRegistrationEntriesRequest struct {
	DataConsistency DataConsistency
	ByParentID      string
	BySelectors     *BySelectors
	BySpiffeID      string
	Pagination      *Pagination
	ByFederatesWith *ByFederatesWith
	ByHint          string
	ByDownstream    *bool
}

type ListRegistrationEntriesResponse

type ListRegistrationEntriesResponse struct {
	Entries    []*common.RegistrationEntry
	Pagination *Pagination
}

type ListRegistrationEntryEventsRequest added in v1.11.0

type ListRegistrationEntryEventsRequest struct {
	DataConsistency    DataConsistency
	GreaterThanEventID uint
	LessThanEventID    uint
}

type ListRegistrationEntryEventsResponse added in v1.11.0

type ListRegistrationEntryEventsResponse struct {
	Events []RegistrationEntryEvent
}

type MatchBehavior

type MatchBehavior int32
const (
	Exact    MatchBehavior = 0
	Subset   MatchBehavior = 1
	Superset MatchBehavior = 2
	MatchAny MatchBehavior = 3
)

type Pagination

type Pagination struct {
	Token    string
	PageSize int32
}

type RegistrationEntryEvent added in v1.8.7

type RegistrationEntryEvent struct {
	EventID uint
	EntryID string
}

type Repository

type Repository struct {
	DataStore DataStore
}

func (*Repository) GetDataStore

func (repo *Repository) GetDataStore() DataStore

func (*Repository) SetDataStore

func (repo *Repository) SetDataStore(dataStore DataStore)

Directories

Path Synopsis
sqldriver

Jump to

Keyboard shortcuts

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