sync

package
v0.3.41 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2025 License: Apache-2.0 Imports: 35 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrSyncNotComplete = fmt.Errorf("sync exited without finishing")

Functions

func GetExpandableAnnotation added in v0.2.92

func GetExpandableAnnotation(annos annotations.Annotations) (*v2.GrantExpandable, error)

func GetExternalResourceMatchAllAnnotation added in v0.2.84

func GetExternalResourceMatchAllAnnotation(annos annotations.Annotations) (*v2.ExternalResourceMatchAll, error)

func GetExternalResourceMatchAnnotation added in v0.2.84

func GetExternalResourceMatchAnnotation(annos annotations.Annotations) (*v2.ExternalResourceMatch, error)

func GetExternalResourceMatchIDAnnotation added in v0.2.90

func GetExternalResourceMatchIDAnnotation(annos annotations.Annotations) (*v2.ExternalResourceMatchID, error)

Types

type Action

type Action struct {
	Op                   ActionOp `json:"operation,omitempty"`
	PageToken            string   `json:"page_token,omitempty"`
	ResourceTypeID       string   `json:"resource_type_id,omitempty"`
	ResourceID           string   `json:"resource_id,omitempty"`
	ParentResourceTypeID string   `json:"parent_resource_type_id,omitempty"`
	ParentResourceID     string   `json:"parent_resource_id,omitempty"`
}

Action stores the current operation, page token, and optional fields for which resource is being worked with.

type ActionOp

type ActionOp uint8

ActionOp represents a sync operation.

const (
	UnknownOp ActionOp = iota
	InitOp
	SyncResourceTypesOp
	SyncResourcesOp
	SyncEntitlementsOp
	ListResourcesForEntitlementsOp
	SyncGrantsOp
	SyncExternalResourcesOp
	SyncAssetsOp
	SyncGrantExpansionOp
	SyncTargetedResourceOp
)

func (*ActionOp) MarshalJSON

func (s *ActionOp) MarshalJSON() ([]byte, error)

MarshalJSON marshals the ActionOp into a json string.

func (ActionOp) String

func (s ActionOp) String() string

String() returns the string representation for an ActionOp. This is used for marshalling the op.

func (*ActionOp) UnmarshalJSON

func (s *ActionOp) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshals the input byte slice and updates this action op.

type Progress added in v0.0.25

type Progress struct {
	Action               string
	ResourceTypeID       string
	ResourceID           string
	ParentResourceTypeID string
	ParentResourceID     string
	Count                uint32
}

func NewProgress added in v0.0.25

func NewProgress(a *Action, c uint32) *Progress

type ProgressCounts added in v0.2.58

type ProgressCounts struct {
	ResourceTypes        int
	Resources            map[string]int
	EntitlementsProgress map[string]int
	LastEntitlementLog   map[string]time.Time
	GrantsProgress       map[string]int
	LastGrantLog         map[string]time.Time
	LastActionLog        time.Time
}

func NewProgressCounts added in v0.2.58

func NewProgressCounts() *ProgressCounts

TODO: use a mutex or a syncmap for when this code becomes parallel

func (*ProgressCounts) LogEntitlementsProgress added in v0.2.58

func (p *ProgressCounts) LogEntitlementsProgress(ctx context.Context, resourceType string)

func (*ProgressCounts) LogExpandProgress added in v0.2.58

func (p *ProgressCounts) LogExpandProgress(ctx context.Context, actions []*expand.EntitlementGraphAction)

func (*ProgressCounts) LogGrantsProgress added in v0.2.58

func (p *ProgressCounts) LogGrantsProgress(ctx context.Context, resourceType string)

func (*ProgressCounts) LogResourceTypesProgress added in v0.2.58

func (p *ProgressCounts) LogResourceTypesProgress(ctx context.Context)

func (*ProgressCounts) LogResourcesProgress added in v0.2.58

func (p *ProgressCounts) LogResourcesProgress(ctx context.Context, resourceType string)

type State

type State interface {
	PushAction(ctx context.Context, action Action)
	FinishAction(ctx context.Context)
	NextPage(ctx context.Context, pageToken string) error
	ResourceTypeID(ctx context.Context) string
	ResourceID(ctx context.Context) string
	EntitlementGraph(ctx context.Context) *expand.EntitlementGraph
	ParentResourceID(ctx context.Context) string
	ParentResourceTypeID(ctx context.Context) string
	PageToken(ctx context.Context) string
	Current() *Action
	Marshal() (string, error)
	Unmarshal(input string) error
	NeedsExpansion() bool
	SetNeedsExpansion()
	HasExternalResourcesGrants() bool
	SetHasExternalResourcesGrants()
	ShouldFetchRelatedResources() bool
	SetShouldFetchRelatedResources()
	ShouldSkipEntitlementsAndGrants() bool
	SetShouldSkipEntitlementsAndGrants()
}

type SyncOpt

type SyncOpt func(s *syncer)

func WithC1ZPath added in v0.1.0

func WithC1ZPath(path string) SyncOpt

func WithConnectorStore added in v0.1.0

func WithConnectorStore(store connectorstore.Writer) SyncOpt

func WithExternalResourceC1ZPath added in v0.2.84

func WithExternalResourceC1ZPath(path string) SyncOpt

func WithExternalResourceEntitlementIdFilter added in v0.2.84

func WithExternalResourceEntitlementIdFilter(entitlementId string) SyncOpt

func WithOnlyExpandGrants added in v0.3.8

func WithOnlyExpandGrants() SyncOpt

func WithProgressHandler added in v0.0.25

func WithProgressHandler(f func(s *Progress)) SyncOpt

WithProgress sets a `progressHandler` for `NewSyncer` Options.

func WithRunDuration

func WithRunDuration(d time.Duration) SyncOpt

WithRunDuration sets a `time.Duration` for `NewSyncer` Options. `d` represents a duration. The elapsed time between two instants as an int64 nanosecond count.

func WithSkipEntitlementsAndGrants added in v0.3.40

func WithSkipEntitlementsAndGrants(skip bool) SyncOpt

func WithSkipFullSync added in v0.2.15

func WithSkipFullSync() SyncOpt

func WithSyncID added in v0.3.8

func WithSyncID(syncID string) SyncOpt

func WithTargetedSyncResourceIDs added in v0.3.0

func WithTargetedSyncResourceIDs(resourceIDs []string) SyncOpt

func WithTmpDir added in v0.1.8

func WithTmpDir(path string) SyncOpt

func WithTransitionHandler

func WithTransitionHandler(f func(s Action)) SyncOpt

WithTransitionHandler sets a `transitionHandler` for `NewSyncer` Options.

type Syncer

type Syncer interface {
	Sync(context.Context) error
	Close(context.Context) error
}

func NewSyncer

func NewSyncer(ctx context.Context, c types.ConnectorClient, opts ...SyncOpt) (Syncer, error)

NewSyncer returns a new syncer object.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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