Documentation
¶
Overview ¶
Package policy implements management of snapshot policies.
Index ¶
- Constants
- Variables
- func ApplyRetentionPolicy(ctx context.Context, rep repo.RepositoryWriter, sourceInfo snapshot.SourceInfo, ...) ([]manifest.ID, error)
- func CompactPins(pins []string) []string
- func CompactRetentionReasons(reasons []string) []string
- func GetEffectivePolicy(ctx context.Context, rep repo.Repository, si snapshot.SourceInfo) (effective *Policy, definition *Definition, sources []*Policy, e error)
- func GetEffectivePolicyWithOverride(ctx context.Context, rep repo.Repository, si snapshot.SourceInfo, ...) (effective *Policy, definition *Definition, sources []*Policy, e error)
- func IsManualSnapshot(policyTree *Tree) bool
- func LabelsForSource(si snapshot.SourceInfo) map[string]string
- func MergePolicies(policies []*Policy, si snapshot.SourceInfo) (*Policy, *Definition)
- func RemovePolicy(ctx context.Context, rep repo.RepositoryWriter, si snapshot.SourceInfo) error
- func SetManual(ctx context.Context, rep repo.RepositoryWriter, sourceInfo snapshot.SourceInfo) error
- func SetPolicy(ctx context.Context, rep repo.RepositoryWriter, si snapshot.SourceInfo, ...) error
- func SortRetentionTags(tags []string)
- func ValidatePolicy(si snapshot.SourceInfo, pol *Policy) error
- func ValidateSchedulingPolicy(p SchedulingPolicy) error
- func ValidateUploadPolicy(si snapshot.SourceInfo, p UploadPolicy) error
- type ActionCommand
- type ActionsPolicy
- type ActionsPolicyDefinition
- type CompressionPolicy
- type CompressionPolicyDefinition
- type Definition
- type DirLoggingPolicy
- type DirLoggingPolicyDefinition
- type EntryLoggingPolicy
- type EntryLoggingPolicyDefinition
- type ErrorHandlingPolicy
- type ErrorHandlingPolicyDefinition
- type FilesPolicy
- type FilesPolicyDefinition
- type LogDetail
- type LoggingPolicy
- type LoggingPolicyDefinition
- type MetadataCompressionPolicy
- type MetadataCompressionPolicyDefinition
- type OSSnapshotMode
- type OSSnapshotPolicy
- type OSSnapshotPolicyDefinition
- type OptionalBool
- type OptionalInt
- type OptionalInt64
- type Policy
- func GetDefinedPolicy(ctx context.Context, rep repo.Repository, si snapshot.SourceInfo) (*Policy, error)
- func GetPolicyByID(ctx context.Context, rep repo.Repository, id manifest.ID) (*Policy, error)
- func GetPolicyHierarchy(ctx context.Context, rep repo.Repository, si snapshot.SourceInfo, ...) ([]*Policy, error)
- func ListPolicies(ctx context.Context, rep repo.Repository) ([]*Policy, error)
- type RetentionPolicy
- type RetentionPolicyDefinition
- type SchedulingPolicy
- func (p *SchedulingPolicy) Interval() time.Duration
- func (p *SchedulingPolicy) Merge(src SchedulingPolicy, def *SchedulingPolicyDefinition, si snapshot.SourceInfo)
- func (p *SchedulingPolicy) NextSnapshotTime(previousSnapshotTime, now time.Time) (time.Time, bool)
- func (p *SchedulingPolicy) SetInterval(d time.Duration)
- type SchedulingPolicyDefinition
- type SplitterPolicy
- type SplitterPolicyDefinition
- type SubdirectoryPolicyMap
- type TargetWithPolicy
- type TimeOfDay
- type Tree
- type UploadPolicy
- type UploadPolicyDefinition
- type VolumeShadowCopyPolicy
- type VolumeShadowCopyPolicyDefinition
Constants ¶
const ( OSSnapshotNeverString = "never" OSSnapshotAlwaysString = "always" OSSnapshotWhenAvailableString = "when-available" )
OS-level snapshot mode strings.
const ( PolicyTypeLabel = "policyType" PolicyTypePath = "path" PolicyTypeGlobal = "global" PolicyTypeHost = "host" PolicyTypeUser = "user" PathLabel = snapshot.PathLabel UsernameLabel = snapshot.UsernameLabel HostnameLabel = snapshot.HostnameLabel )
Manifest labels identifying snapshots.
const ManifestType = "policy"
ManifestType is the type of the manifest that represents policy.
Variables ¶
var ( // DefaultPolicy is a default policy returned by policy tree in absence of other policies. DefaultPolicy = &Policy{ FilesPolicy: defaultFilesPolicy, RetentionPolicy: defaultRetentionPolicy, CompressionPolicy: defaultCompressionPolicy, MetadataCompressionPolicy: defaultMetadataCompressionPolicy, ErrorHandlingPolicy: defaultErrorHandlingPolicy, SchedulingPolicy: defaultSchedulingPolicy, LoggingPolicy: defaultLoggingPolicy, Actions: defaultActionsPolicy, OSSnapshotPolicy: defaultOSSnapshotPolicy, UploadPolicy: defaultUploadPolicy, } // DefaultDefinition provides the Definition for the default policy. DefaultDefinition = &Definition{} )
var ErrPolicyNotFound = errors.New("policy not found")
ErrPolicyNotFound is returned when the policy is not found.
var GlobalPolicySourceInfo = snapshot.SourceInfo{}
GlobalPolicySourceInfo is a source where global policy is attached.
Functions ¶
func ApplyRetentionPolicy ¶
func ApplyRetentionPolicy(ctx context.Context, rep repo.RepositoryWriter, sourceInfo snapshot.SourceInfo, reallyDelete bool) ([]manifest.ID, error)
ApplyRetentionPolicy applies retention policy to a given source by deleting expired snapshots.
func CompactPins ¶ added in v0.9.7
CompactPins returns compressed pins reasons given a list of pins.
func CompactRetentionReasons ¶ added in v0.9.7
CompactRetentionReasons returns compressed retention reasons given a list of retention reasons.
func GetEffectivePolicy ¶
func GetEffectivePolicy(ctx context.Context, rep repo.Repository, si snapshot.SourceInfo) (effective *Policy, definition *Definition, sources []*Policy, e error)
GetEffectivePolicy calculates effective snapshot policy for a given source by combining the source-specific policy (if any) with parent policies. The source must contain a path. Returns the effective policies and all source policies that contributed to that (most specific first).
func GetEffectivePolicyWithOverride ¶ added in v0.9.7
func GetEffectivePolicyWithOverride(ctx context.Context, rep repo.Repository, si snapshot.SourceInfo, optionalPolicyOverride *Policy) (effective *Policy, definition *Definition, sources []*Policy, e error)
GetEffectivePolicyWithOverride calculates effective snapshot policy for a given source by combining the source-specific policy (if any) with parent policies. The source must contain a path. Returns the effective policies and all source policies that contributed to that (most specific first).
func IsManualSnapshot ¶ added in v0.8.0
IsManualSnapshot returns the SchedulingPolicy manual value from the given policy tree.
func LabelsForSource ¶ added in v0.9.7
func LabelsForSource(si snapshot.SourceInfo) map[string]string
LabelsForSource returns the set of labels that a given source will have on a policy.
func MergePolicies ¶
func MergePolicies(policies []*Policy, si snapshot.SourceInfo) (*Policy, *Definition)
MergePolicies computes the policy by applying the specified list of policies in order from most specific to most general.
func RemovePolicy ¶
func RemovePolicy(ctx context.Context, rep repo.RepositoryWriter, si snapshot.SourceInfo) error
RemovePolicy removes the policy for a given source.
func SetManual ¶ added in v0.8.0
func SetManual(ctx context.Context, rep repo.RepositoryWriter, sourceInfo snapshot.SourceInfo) error
SetManual sets the manual setting in the SchedulingPolicy on the given source.
func SetPolicy ¶
func SetPolicy(ctx context.Context, rep repo.RepositoryWriter, si snapshot.SourceInfo, pol *Policy) error
SetPolicy sets the policy on a given source.
func SortRetentionTags ¶ added in v0.9.7
func SortRetentionTags(tags []string)
SortRetentionTags sorts the provided retention tags in canonical order.
func ValidatePolicy ¶ added in v0.8.0
func ValidatePolicy(si snapshot.SourceInfo, pol *Policy) error
ValidatePolicy returns error if the given policy is invalid. Currently, only SchedulingPolicy is validated.
func ValidateSchedulingPolicy ¶ added in v0.8.0
func ValidateSchedulingPolicy(p SchedulingPolicy) error
ValidateSchedulingPolicy returns an error if manual field is set along with scheduling fields.
func ValidateUploadPolicy ¶ added in v0.10.7
func ValidateUploadPolicy(si snapshot.SourceInfo, p UploadPolicy) error
ValidateUploadPolicy returns an error if manual field is set along with Upload fields.
Types ¶
type ActionCommand ¶ added in v0.8.0
type ActionCommand struct {
// command + args to run
Command string `json:"path,omitempty"`
Arguments []string `json:"args,omitempty"`
// alternatively inline script to run using either Unix shell or cmd.exe on Windows.
Script string `json:"script,omitempty"`
TimeoutSeconds int `json:"timeout,omitempty"`
Mode string `json:"mode,omitempty"` // essential,optional,async
}
ActionCommand configures a action command.
type ActionsPolicy ¶ added in v0.8.0
type ActionsPolicy struct {
// command runs once before and after the folder it's attached to (not inherited).
BeforeFolder *ActionCommand `json:"beforeFolder,omitempty"`
AfterFolder *ActionCommand `json:"afterFolder,omitempty"`
// commands run once before and after each snapshot root (can be inherited).
BeforeSnapshotRoot *ActionCommand `json:"beforeSnapshotRoot,omitempty"`
AfterSnapshotRoot *ActionCommand `json:"afterSnapshotRoot,omitempty"`
}
ActionsPolicy describes actions to be invoked when taking snapshots.
func (*ActionsPolicy) Merge ¶ added in v0.8.0
func (p *ActionsPolicy) Merge(src ActionsPolicy, def *ActionsPolicyDefinition, si snapshot.SourceInfo)
Merge applies default values from the provided policy.
func (*ActionsPolicy) MergeNonInheritable ¶ added in v0.8.0
func (p *ActionsPolicy) MergeNonInheritable(src ActionsPolicy)
MergeNonInheritable copies non-inheritable properties from the provided actions policy.
type ActionsPolicyDefinition ¶ added in v0.9.7
type ActionsPolicyDefinition struct {
BeforeSnapshotRoot snapshot.SourceInfo `json:"beforeSnapshotRoot,omitempty"`
AfterSnapshotRoot snapshot.SourceInfo `json:"afterSnapshotRoot,omitempty"`
}
ActionsPolicyDefinition specifies which policy definition provided the value of a particular field.
type CompressionPolicy ¶ added in v0.4.0
type CompressionPolicy struct {
CompressorName compression.Name `json:"compressorName,omitempty"`
OnlyCompress []string `json:"onlyCompress,omitempty"`
NoParentOnlyCompress bool `json:"noParentOnlyCompress,omitempty"`
NeverCompress []string `json:"neverCompress,omitempty"`
NoParentNeverCompress bool `json:"noParentNeverCompress,omitempty"`
MinSize int64 `json:"minSize,omitempty"`
MaxSize int64 `json:"maxSize,omitempty"`
}
CompressionPolicy specifies compression policy.
func (*CompressionPolicy) CompressorForFile ¶ added in v0.4.0
func (p *CompressionPolicy) CompressorForFile(e fs.Entry) compression.Name
CompressorForFile returns compression name to be used for compressing a given file according to policy, using attributes such as name or size.
func (*CompressionPolicy) Merge ¶ added in v0.4.0
func (p *CompressionPolicy) Merge(src CompressionPolicy, def *CompressionPolicyDefinition, si snapshot.SourceInfo)
Merge applies default values from the provided policy.
type CompressionPolicyDefinition ¶ added in v0.9.7
type CompressionPolicyDefinition struct {
CompressorName snapshot.SourceInfo `json:"compressorName,omitempty"`
OnlyCompress snapshot.SourceInfo `json:"onlyCompress,omitempty"`
NeverCompress snapshot.SourceInfo `json:"neverCompress,omitempty"`
MinSize snapshot.SourceInfo `json:"minSize,omitempty"`
MaxSize snapshot.SourceInfo `json:"maxSize,omitempty"`
}
CompressionPolicyDefinition specifies which policy definition provided the value of a particular field.
type Definition ¶ added in v0.9.7
type Definition struct {
RetentionPolicy RetentionPolicyDefinition `json:"retention,omitempty"`
FilesPolicy FilesPolicyDefinition `json:"files,omitempty"`
ErrorHandlingPolicy ErrorHandlingPolicyDefinition `json:"errorHandling,omitempty"`
SchedulingPolicy SchedulingPolicyDefinition `json:"scheduling,omitempty"`
CompressionPolicy CompressionPolicyDefinition `json:"compression,omitempty"`
MetadataCompressionPolicy MetadataCompressionPolicyDefinition `json:"metadataCompression,omitempty"`
SplitterPolicy SplitterPolicyDefinition `json:"splitter,omitempty"`
Actions ActionsPolicyDefinition `json:"actions,omitempty"`
OSSnapshotPolicy OSSnapshotPolicyDefinition `json:"osSnapshots,omitempty"`
LoggingPolicy LoggingPolicyDefinition `json:"logging,omitempty"`
UploadPolicy UploadPolicyDefinition `json:"upload,omitempty"`
}
Definition corresponds 1:1 to Policy and each field specifies the snapshot.SourceInfo where a particular policy field was specified.
type DirLoggingPolicy ¶ added in v0.9.5
type DirLoggingPolicy struct {
Snapshotted *LogDetail `json:"snapshotted,omitempty"`
Ignored *LogDetail `json:"ignored,omitempty"`
}
DirLoggingPolicy represents the policy for logging directory information when snapshotting.
func (*DirLoggingPolicy) Merge ¶ added in v0.9.5
func (p *DirLoggingPolicy) Merge(src DirLoggingPolicy, def *DirLoggingPolicyDefinition, si snapshot.SourceInfo)
Merge merges the provided directory logging policy.
type DirLoggingPolicyDefinition ¶ added in v0.9.7
type DirLoggingPolicyDefinition struct {
Snapshotted snapshot.SourceInfo `json:"snapshotted,omitempty"`
Ignored snapshot.SourceInfo `json:"ignored,omitempty"`
}
DirLoggingPolicyDefinition specifies which policy definition provided the value of a particular field.
type EntryLoggingPolicy ¶ added in v0.9.5
type EntryLoggingPolicy struct {
Snapshotted *LogDetail `json:"snapshotted,omitempty"`
Ignored *LogDetail `json:"ignored,omitempty"`
CacheHit *LogDetail `json:"cacheHit,omitempty"`
CacheMiss *LogDetail `json:"cacheMiss,omitempty"`
}
EntryLoggingPolicy represents the policy for logging entry information when snapshotting.
func (*EntryLoggingPolicy) Merge ¶ added in v0.9.5
func (p *EntryLoggingPolicy) Merge(src EntryLoggingPolicy, def *EntryLoggingPolicyDefinition, si snapshot.SourceInfo)
Merge merges the provided entry logging policy.
type EntryLoggingPolicyDefinition ¶ added in v0.9.7
type EntryLoggingPolicyDefinition struct {
Snapshotted snapshot.SourceInfo `json:"snapshotted,omitempty"`
Ignored snapshot.SourceInfo `json:"ignored,omitempty"`
CacheHit snapshot.SourceInfo `json:"cacheHit,omitempty"`
CacheMiss snapshot.SourceInfo `json:"cacheMiss,omitempty"`
}
EntryLoggingPolicyDefinition specifies which policy definition provided the value of a particular field.
type ErrorHandlingPolicy ¶ added in v0.5.2
type ErrorHandlingPolicy struct {
// IgnoreFileErrors controls whether or not snapshot operation should fail when a file throws an error on being read
IgnoreFileErrors *OptionalBool `json:"ignoreFileErrors,omitempty"`
// IgnoreDirectoryErrors controls whether or not snapshot operation should fail when a directory throws an error on being read or opened
IgnoreDirectoryErrors *OptionalBool `json:"ignoreDirectoryErrors,omitempty"`
// IgnoreUnknownTypes controls whether or not snapshot operation should fail when it encounters a directory entry of an unknown type.
IgnoreUnknownTypes *OptionalBool `json:"ignoreUnknownTypes,omitempty"`
}
ErrorHandlingPolicy controls error handling behavior when taking snapshots.
func (*ErrorHandlingPolicy) Merge ¶ added in v0.5.2
func (p *ErrorHandlingPolicy) Merge(src ErrorHandlingPolicy, def *ErrorHandlingPolicyDefinition, si snapshot.SourceInfo)
Merge applies default values from the provided policy.
type ErrorHandlingPolicyDefinition ¶ added in v0.9.7
type ErrorHandlingPolicyDefinition struct {
IgnoreFileErrors snapshot.SourceInfo `json:"ignoreFileErrors,omitempty"`
IgnoreDirectoryErrors snapshot.SourceInfo `json:"ignoreDirectoryErrors,omitempty"`
IgnoreUnknownTypes snapshot.SourceInfo `json:"ignoreUnknownTypes,omitempty"`
}
ErrorHandlingPolicyDefinition specifies which policy definition provided the value of a particular field.
type FilesPolicy ¶ added in v0.4.0
type FilesPolicy struct {
IgnoreRules []string `json:"ignore,omitempty"`
NoParentIgnoreRules bool `json:"noParentIgnore,omitempty"`
DotIgnoreFiles []string `json:"ignoreDotFiles,omitempty"`
NoParentDotIgnoreFiles bool `json:"noParentDotFiles,omitempty"`
IgnoreCacheDirectories *OptionalBool `json:"ignoreCacheDirs,omitempty"`
MaxFileSize int64 `json:"maxFileSize,omitempty"`
OneFileSystem *OptionalBool `json:"oneFileSystem,omitempty"`
}
FilesPolicy describes files to be ignored when taking snapshots.
func (*FilesPolicy) Merge ¶ added in v0.4.0
func (p *FilesPolicy) Merge(src FilesPolicy, def *FilesPolicyDefinition, si snapshot.SourceInfo)
Merge applies default values from the provided policy.
type FilesPolicyDefinition ¶ added in v0.9.7
type FilesPolicyDefinition struct {
IgnoreRules snapshot.SourceInfo `json:"ignore,omitempty"`
NoParentIgnoreRules snapshot.SourceInfo `json:"noParentIgnore,omitempty"`
DotIgnoreFiles snapshot.SourceInfo `json:"ignoreDotFiles,omitempty"`
NoParentDotIgnoreFiles snapshot.SourceInfo `json:"noParentDotFiles,omitempty"`
IgnoreCacheDirectories snapshot.SourceInfo `json:"ignoreCacheDirs,omitempty"`
MaxFileSize snapshot.SourceInfo `json:"maxFileSize,omitempty"`
OneFileSystem snapshot.SourceInfo `json:"oneFileSystem,omitempty"`
}
FilesPolicyDefinition specifies which policy definition provided the value of a particular field.
type LogDetail ¶ added in v0.9.5
type LogDetail int
LogDetail represents the details of log output.
Supported log detail levels.
func NewLogDetail ¶ added in v0.9.5
NewLogDetail returns a pointer to the provided LogDetail.
type LoggingPolicy ¶ added in v0.9.5
type LoggingPolicy struct {
Directories DirLoggingPolicy `json:"directories,omitempty"`
Entries EntryLoggingPolicy `json:"entries,omitempty"`
}
LoggingPolicy describes policy for emitting logs during snapshots.
func (*LoggingPolicy) Merge ¶ added in v0.9.5
func (p *LoggingPolicy) Merge(src LoggingPolicy, def *LoggingPolicyDefinition, si snapshot.SourceInfo)
Merge applies default values from the provided policy.
type LoggingPolicyDefinition ¶ added in v0.9.7
type LoggingPolicyDefinition struct {
Directories DirLoggingPolicyDefinition `json:"directories,omitempty"`
Entries EntryLoggingPolicyDefinition `json:"entries,omitempty"`
}
LoggingPolicyDefinition specifies which policy definition provided the value of a particular field.
type MetadataCompressionPolicy ¶ added in v0.18.0
type MetadataCompressionPolicy struct {
CompressorName compression.Name `json:"compressorName,omitempty"`
}
MetadataCompressionPolicy specifies compression policy for metadata.
func (*MetadataCompressionPolicy) Merge ¶ added in v0.18.0
func (p *MetadataCompressionPolicy) Merge(src MetadataCompressionPolicy, def *MetadataCompressionPolicyDefinition, si snapshot.SourceInfo)
Merge applies default values from the provided policy.
func (*MetadataCompressionPolicy) MetadataCompressor ¶ added in v0.18.0
func (p *MetadataCompressionPolicy) MetadataCompressor() compression.Name
MetadataCompressor returns compression name to be used for according to policy.
type MetadataCompressionPolicyDefinition ¶ added in v0.18.0
type MetadataCompressionPolicyDefinition struct {
CompressorName snapshot.SourceInfo `json:"compressorName,omitempty"`
}
MetadataCompressionPolicyDefinition specifies which policy definition provided the value of a particular field.
type OSSnapshotMode ¶ added in v0.16.0
type OSSnapshotMode byte
OSSnapshotMode specifies whether OS-level snapshots are used for file systems that support them.
const ( OSSnapshotNever OSSnapshotMode = iota // Disable OS-level snapshots OSSnapshotAlways // Fail if an OS-level snapshot cannot be created OSSnapshotWhenAvailable // Fall back to regular file access on error )
OS-level snapshot modes.
func NewOSSnapshotMode ¶ added in v0.16.0
func NewOSSnapshotMode(m OSSnapshotMode) *OSSnapshotMode
NewOSSnapshotMode provides an OptionalBool pointer.
func (*OSSnapshotMode) OrDefault ¶ added in v0.16.0
func (m *OSSnapshotMode) OrDefault(def OSSnapshotMode) OSSnapshotMode
OrDefault returns the OS snapshot mode or the provided default.
func (OSSnapshotMode) String ¶ added in v0.16.0
func (m OSSnapshotMode) String() string
type OSSnapshotPolicy ¶ added in v0.16.0
type OSSnapshotPolicy struct {
VolumeShadowCopy VolumeShadowCopyPolicy `json:"volumeShadowCopy,omitempty"`
}
OSSnapshotPolicy describes settings for OS-level snapshots.
func (*OSSnapshotPolicy) Merge ¶ added in v0.16.0
func (p *OSSnapshotPolicy) Merge(src OSSnapshotPolicy, def *OSSnapshotPolicyDefinition, si snapshot.SourceInfo)
Merge applies default values from the provided policy.
type OSSnapshotPolicyDefinition ¶ added in v0.16.0
type OSSnapshotPolicyDefinition struct {
VolumeShadowCopy VolumeShadowCopyPolicyDefinition `json:"volumeShadowCopy,omitempty"`
}
OSSnapshotPolicyDefinition specifies which policy definition provided the value of a particular field.
type OptionalBool ¶ added in v0.9.5
type OptionalBool bool
OptionalBool provides convenience methods for manipulating optional booleans.
func NewOptionalBool ¶ added in v0.15.0
func NewOptionalBool(b OptionalBool) *OptionalBool
NewOptionalBool provides an OptionalBool pointer.
func (*OptionalBool) OrDefault ¶ added in v0.9.5
func (b *OptionalBool) OrDefault(def bool) bool
OrDefault returns the value of the boolean or provided default if it's nil.
type OptionalInt ¶ added in v0.10.5
type OptionalInt int
OptionalInt provides convenience methods for manipulating optional integers.
func (*OptionalInt) OrDefault ¶ added in v0.10.5
func (b *OptionalInt) OrDefault(def int) int
OrDefault returns the value of the integer or provided default if it's nil.
type OptionalInt64 ¶ added in v0.11.0
type OptionalInt64 int64
OptionalInt64 provides convenience methods for manipulating optional integers.
func (*OptionalInt64) OrDefault ¶ added in v0.11.0
func (b *OptionalInt64) OrDefault(def int64) int64
OrDefault returns the value of the integer or provided default if it's nil.
type Policy ¶
type Policy struct {
Labels map[string]string `json:"-"`
RetentionPolicy RetentionPolicy `json:"retention,omitempty"`
FilesPolicy FilesPolicy `json:"files,omitempty"`
ErrorHandlingPolicy ErrorHandlingPolicy `json:"errorHandling,omitempty"`
SchedulingPolicy SchedulingPolicy `json:"scheduling,omitempty"`
CompressionPolicy CompressionPolicy `json:"compression,omitempty"`
MetadataCompressionPolicy MetadataCompressionPolicy `json:"metadataCompression,omitempty"`
SplitterPolicy SplitterPolicy `json:"splitter,omitempty"`
Actions ActionsPolicy `json:"actions,omitempty"`
OSSnapshotPolicy OSSnapshotPolicy `json:"osSnapshots,omitempty"`
LoggingPolicy LoggingPolicy `json:"logging,omitempty"`
UploadPolicy UploadPolicy `json:"upload,omitempty"`
NoParent bool `json:"noParent,omitempty"`
}
Policy describes snapshot policy for a single source.
func GetDefinedPolicy ¶
func GetDefinedPolicy(ctx context.Context, rep repo.Repository, si snapshot.SourceInfo) (*Policy, error)
GetDefinedPolicy returns the policy defined on the provided snapshot.SourceInfo or ErrPolicyNotFound if not present.
func GetPolicyByID ¶
GetPolicyByID gets the policy for a given unique ID or ErrPolicyNotFound if not found.
func GetPolicyHierarchy ¶ added in v0.9.7
func GetPolicyHierarchy(ctx context.Context, rep repo.Repository, si snapshot.SourceInfo, optionalPolicyOverride *Policy) ([]*Policy, error)
GetPolicyHierarchy returns the set of parent policies that apply to the path in most-specific-to-most-general order.
func ListPolicies ¶
ListPolicies returns a list of all policies.
func (*Policy) Target ¶
func (p *Policy) Target() snapshot.SourceInfo
Target returns the snapshot.SourceInfo describing username, host and path targeted by the policy.
type RetentionPolicy ¶
type RetentionPolicy struct {
KeepLatest *OptionalInt `json:"keepLatest,omitempty"`
KeepHourly *OptionalInt `json:"keepHourly,omitempty"`
KeepDaily *OptionalInt `json:"keepDaily,omitempty"`
KeepWeekly *OptionalInt `json:"keepWeekly,omitempty"`
KeepMonthly *OptionalInt `json:"keepMonthly,omitempty"`
KeepAnnual *OptionalInt `json:"keepAnnual,omitempty"`
IgnoreIdenticalSnapshots *OptionalBool `json:"ignoreIdenticalSnapshots,omitempty"`
}
RetentionPolicy describes snapshot retention policy.
func (*RetentionPolicy) ComputeRetentionReasons ¶
func (r *RetentionPolicy) ComputeRetentionReasons(manifests []*snapshot.Manifest)
ComputeRetentionReasons computes the reasons why each snapshot is retained, based on the settings in retention policy and stores them in RetentionReason field.
func (*RetentionPolicy) EffectiveKeepLatest ¶ added in v0.12.0
func (r *RetentionPolicy) EffectiveKeepLatest() *OptionalInt
EffectiveKeepLatest returns the number of "latest" snapshots to keep. If all retention values are set to 0 then returns MaxInt.
func (*RetentionPolicy) Merge ¶
func (r *RetentionPolicy) Merge(src RetentionPolicy, def *RetentionPolicyDefinition, si snapshot.SourceInfo)
Merge applies default values from the provided policy.
type RetentionPolicyDefinition ¶ added in v0.9.7
type RetentionPolicyDefinition struct {
KeepLatest snapshot.SourceInfo `json:"keepLatest,omitempty"`
KeepHourly snapshot.SourceInfo `json:"keepHourly,omitempty"`
KeepDaily snapshot.SourceInfo `json:"keepDaily,omitempty"`
KeepWeekly snapshot.SourceInfo `json:"keepWeekly,omitempty"`
KeepMonthly snapshot.SourceInfo `json:"keepMonthly,omitempty"`
KeepAnnual snapshot.SourceInfo `json:"keepAnnual,omitempty"`
IgnoreIdenticalSnapshots snapshot.SourceInfo `json:"ignoreIdenticalSnapshots,omitempty"`
}
RetentionPolicyDefinition specifies which policy definition provided the value of a particular field.
type SchedulingPolicy ¶
type SchedulingPolicy struct {
IntervalSeconds int64 `json:"intervalSeconds,omitempty"`
TimesOfDay []TimeOfDay `json:"timeOfDay,omitempty"`
NoParentTimesOfDay bool `json:"noParentTimeOfDay,omitempty"`
Manual bool `json:"manual,omitempty"`
Cron []string `json:"cron,omitempty"`
RunMissed *OptionalBool `json:"runMissed,omitempty"`
}
SchedulingPolicy describes policy for scheduling snapshots.
func (*SchedulingPolicy) Interval ¶
func (p *SchedulingPolicy) Interval() time.Duration
Interval returns the snapshot interval or zero if not specified.
func (*SchedulingPolicy) Merge ¶
func (p *SchedulingPolicy) Merge(src SchedulingPolicy, def *SchedulingPolicyDefinition, si snapshot.SourceInfo)
Merge applies default values from the provided policy.
func (*SchedulingPolicy) NextSnapshotTime ¶ added in v0.9.4
NextSnapshotTime computes next snapshot time given previous snapshot time and current wall clock time.
func (*SchedulingPolicy) SetInterval ¶
func (p *SchedulingPolicy) SetInterval(d time.Duration)
SetInterval sets the snapshot interval (zero disables).
type SchedulingPolicyDefinition ¶ added in v0.9.7
type SchedulingPolicyDefinition struct {
IntervalSeconds snapshot.SourceInfo `json:"intervalSeconds,omitempty"`
TimesOfDay snapshot.SourceInfo `json:"timeOfDay,omitempty"`
Cron snapshot.SourceInfo `json:"cron,omitempty"`
Manual snapshot.SourceInfo `json:"manual,omitempty"`
RunMissed snapshot.SourceInfo `json:"runMissed,omitempty"`
}
SchedulingPolicyDefinition specifies which policy definition provided the value of a particular field.
type SplitterPolicy ¶ added in v0.18.0
type SplitterPolicy struct {
Algorithm string `json:"algorithm,omitempty"`
}
SplitterPolicy specifies compression policy.
func (*SplitterPolicy) Merge ¶ added in v0.18.0
func (p *SplitterPolicy) Merge(src SplitterPolicy, def *SplitterPolicyDefinition, si snapshot.SourceInfo)
Merge applies default values from the provided policy.
func (*SplitterPolicy) SplitterForFile ¶ added in v0.18.0
func (p *SplitterPolicy) SplitterForFile(_ fs.Entry) string
SplitterForFile returns splitter algorithm.
type SplitterPolicyDefinition ¶ added in v0.18.0
type SplitterPolicyDefinition struct {
Algorithm snapshot.SourceInfo `json:"algorithm,omitempty"`
}
SplitterPolicyDefinition specifies which policy definition provided the value of a particular field.
type SubdirectoryPolicyMap ¶ added in v0.4.0
SubdirectoryPolicyMap implements Getter for a static mapping of relative paths to Policy for subdirectories.
func (SubdirectoryPolicyMap) GetPolicyForPath ¶ added in v0.4.0
func (m SubdirectoryPolicyMap) GetPolicyForPath(relativePath string) (*Policy, error)
GetPolicyForPath returns Policy defined in the map or nil.
type TargetWithPolicy ¶ added in v0.8.0
type TargetWithPolicy struct {
ID string `json:"id"`
Target snapshot.SourceInfo `json:"target"`
*Policy
}
TargetWithPolicy wraps a policy with its target and ID.
type TimeOfDay ¶
TimeOfDay represents the time of day (hh:mm) using 24-hour time format.
func SortAndDedupeTimesOfDay ¶
SortAndDedupeTimesOfDay sorts the slice of times of day and removes duplicates.
type Tree ¶ added in v0.4.0
type Tree struct {
// contains filtered or unexported fields
}
Tree represents a node in the policy tree, where a policy can be defined. A nil tree is a valid tree with default policy.
func BuildTree ¶ added in v0.4.0
BuildTree builds a policy tree from the given map of paths to policies. Each path must be relative and start with "." and be separated by slashes.
func TreeForSource ¶ added in v0.4.0
func TreeForSource(ctx context.Context, rep repo.Repository, si snapshot.SourceInfo) (*Tree, error)
TreeForSource returns policy Tree for a given source.
func TreeForSourceWithOverride ¶ added in v0.9.7
func TreeForSourceWithOverride(ctx context.Context, rep repo.Repository, si snapshot.SourceInfo, optionalPolicyOverride *Policy) (*Tree, error)
TreeForSourceWithOverride returns policy Tree for a given source with the root policy overridden.
func (*Tree) DefinedPolicy ¶ added in v0.4.0
DefinedPolicy returns policy that's been explicitly defined for tree node or nil if no policy was defined.
func (*Tree) EffectivePolicy ¶ added in v0.4.0
EffectivePolicy returns policy that's been defined for this tree node or inherited from its parent.
func (*Tree) IsInherited ¶ added in v0.4.0
IsInherited returns true if the policy inherited to the given tree node has been inherited from its parent.
type UploadPolicy ¶ added in v0.10.7
type UploadPolicy struct {
MaxParallelSnapshots *OptionalInt `json:"maxParallelSnapshots,omitempty"`
MaxParallelFileReads *OptionalInt `json:"maxParallelFileReads,omitempty"`
ParallelUploadAboveSize *OptionalInt64 `json:"parallelUploadAboveSize,omitempty"`
}
UploadPolicy describes policy to apply when uploading snapshots.
func (*UploadPolicy) Merge ¶ added in v0.10.7
func (p *UploadPolicy) Merge(src UploadPolicy, def *UploadPolicyDefinition, si snapshot.SourceInfo)
Merge applies default values from the provided policy.
type UploadPolicyDefinition ¶ added in v0.10.7
type UploadPolicyDefinition struct {
MaxParallelSnapshots snapshot.SourceInfo `json:"maxParallelSnapshots,omitempty"`
MaxParallelFileReads snapshot.SourceInfo `json:"maxParallelFileReads,omitempty"`
ParallelUploadAboveSize snapshot.SourceInfo `json:"parallelUploadAboveSize,omitempty"`
}
UploadPolicyDefinition specifies which policy definition provided the value of a particular field.
type VolumeShadowCopyPolicy ¶ added in v0.16.0
type VolumeShadowCopyPolicy struct {
Enable *OSSnapshotMode `json:"enable,omitempty"`
}
VolumeShadowCopyPolicy describes settings for Windows Volume Shadow Copy snapshots.
func (*VolumeShadowCopyPolicy) Merge ¶ added in v0.16.0
func (p *VolumeShadowCopyPolicy) Merge(src VolumeShadowCopyPolicy, def *VolumeShadowCopyPolicyDefinition, si snapshot.SourceInfo)
Merge applies default values from the provided policy.
type VolumeShadowCopyPolicyDefinition ¶ added in v0.16.0
type VolumeShadowCopyPolicyDefinition struct {
Enable snapshot.SourceInfo `json:"enable,omitempty"`
}
VolumeShadowCopyPolicyDefinition specifies which policy definition provided the value of a particular field.