manifest

package
v0.0.0-...-2e8e066 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2019 License: MIT Imports: 14 Imported by: 2

Documentation

Index

Constants

View Source
const (
	// StandardDir is the directory that typically contains the conflict and
	// deleted manifest.
	StandardDir = "DfsrPrivate"
	// StandardFile is the name of the typical conflict and deleted manifest file.
	StandardFile = "ConflictAndDeletedManifest.xml"
	// StandardPath is the last part of a typical conflict and deleted manifest
	// file path.
	StandardPath = `\` + StandardDir + `\` + StandardFile
)
View Source
const TimeFormat = "MST 2006:1:2-15:4:5"

TimeFormat describes the DFSR manifest time format.

Variables

This section is empty.

Functions

func Find

func Find(path string) string

Find attempts to locate the DFSR manifest for the given path. It walks its way up the file tree looking for the DfsrPrivate directory. An empty string will be returned if it is unsuccessful.

Types

type Cursor

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

Cursor provides forward-only access to DFSR conflict and deleted manifests.

Cursors should be created with NewCursor. When finished with a cursor it should be closed.

func NewAdvancedCursor

func NewAdvancedCursor(reader io.ReadCloser, resolver Resolver, filter Filter) *Cursor

NewAdvancedCursor returns a new cursor for the DFSR conflict and deleted manifest file at path.

If filter is non-nil, the cursor will return resources that are matched by the filter. If filter is nil, all resources will be returned.

If resolver is non-nil, the cursor will attempt to populate the partner host and distinguished name fields of each resource by querying the resolver.

When finished with the cursor, it is the caller's responsibiliy to close it.

func NewCursor

func NewCursor(reader io.ReadCloser) *Cursor

NewCursor returns a new cursor for the DFSR conflict and deleted manifest file at path.

When finished with the cursor, it is the caller's responsibiliy to close it.

func (*Cursor) Close

func (c *Cursor) Close() (err error)

Close releases any resources consumed by the cursor.

func (*Cursor) End

func (c *Cursor) End() error

End will cause the cursor to read from its current position until the end of the manifest file. This is typically used to tally statistics about the manifest without processing individual records. Statistics can be retrieved by calling Stats().

If End encounters an error before reaching the end of the file, that error will be returned. End returns nil when io.EOF has been reached.

End will not close the cursor.

func (*Cursor) Read

func (c *Cursor) Read() (resource Resource, err error)

Read returns the next resource record from the cursor. If the cursor includes a filter, the next resource record that matches the filter will be returned.

Read returns io.EOF when it encounters the end of the manifest.

func (*Cursor) Stats

func (c *Cursor) Stats() (filtered, total Stats)

Stats return the current statistics for the cursor. Only the resources processed thus far will be reflected in the statistics.

type Decoder

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

Decoder reads and decodes DFSR conflict and deleted manifest entries from an input stream.

func NewDecoder

func NewDecoder(r io.Reader) *Decoder

NewDecoder returns a DFSR conflicted and deleted manifest decoder that reads from r.

func (*Decoder) Count

func (d *Decoder) Count() (total int, err error)

Count returns the number of resource records contained in the manifest.

func (*Decoder) Read

func (d *Decoder) Read() (resource Resource, err error)

Read returns the next resource record from the manifest data stream.

type Filter

type Filter func(r *Resource) bool

Filter returns true when a filter matches the given resource.

func (Filter) Match

func (f Filter) Match(r *Resource) bool

Match returns the result of f(r) if f is non-nil. When f is nil it returns true.

type Info

type Info struct {
	Modified time.Time // The last time the manifest was updated
	Size     int64     // The size of the manifest in bytes
}

Info provides information about a DFSR conflict and deleted manifest.

type Manifest

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

Manifest provides access to a DFSR conflict and deleted manifest file.

func BufferedFile

func BufferedFile(path string) (*Manifest, error)

BufferedFile returns a manifest for the conflict and deleted manifest file located at the given path. The contents of the file will be read immediately and buffered in memory.

func File

func File(path string) *Manifest

File returns a manifest for the conflict and deleted manifest file located at the given path.

func New

func New(s Source) *Manifest

New returns a manifest for the given source.

func (*Manifest) AdvancedCursor

func (m *Manifest) AdvancedCursor(resolver Resolver, filter Filter) (*Cursor, error)

AdvancedCursor creates a new cursor for the manifest with the given resolver and filter.

func (*Manifest) Cursor

func (m *Manifest) Cursor() (*Cursor, error)

Cursor creates a new cursor for the manifest.

func (*Manifest) Info

func (m *Manifest) Info() (Info, error)

Info returns information about the manifest.

func (*Manifest) Stats

func (m *Manifest) Stats(filter Filter) (filtered Stats, total Stats, err error)

Stats return statistics for the manifest. The returned total reflects all resources recorded in the manifest. If the provided cursor options describe filtering rules, filtered reflects only those resources that matched the filter.

type Resolver

type Resolver func(guid string) (info dfsr.MemberInfo, ok bool)

Resolver is capable of resolving DFSR member GUIDs.

func (Resolver) Resolve

func (r Resolver) Resolve(guid string) (info dfsr.MemberInfo, ok bool)

Resolve returns the result of r(guid) if r is non-nil. If r is nil it returns false.

type Resource

type Resource struct {
	PartnerGUID uuid.UUID `xml:"PartnerGuid"`
	PartnerHost string    `xml:"PartnerHost,omitempty"`
	PartnerDN   string    `xml:"PartnerDN,omitempty"`
	Type        string    `xml:"Type"`
	Time        time.Time `xml:"Time"`
	// contains filtered or unexported fields
}

Resource is a DFSR manifest resource entry.

func (*Resource) UnmarshalXML

func (r *Resource) UnmarshalXML(d *xml.Decoder, start xml.StartElement) (err error)

UnmarshalXML decodes DFSR manifest time values.

type Source

type Source interface {
	Reader() (io.ReadCloser, error)
	Info() (Info, error)
}

Source is a source of conflict and deleted manifest data.

type Stats

type Stats struct {
	Entries int       // Number of entries
	Size    int64     // Cumulative size of all entries
	First   time.Time // Timestamp of first entry
	Last    time.Time // Timestamp of last entry
}

Stats hold cumulative statistics for DFSR manifests.

func (*Stats) Add

func (s *Stats) Add(r *Resource)

Add updates s to reflect the inclusion of r.

func (*Stats) Summary

func (s *Stats) Summary() string

Summary returns a summary of the statistics.

type Time

type Time time.Time

Time is a time.Time that can be used by an XML decoder to deserialize manifest time values.

func (*Time) UnmarshalXML

func (t *Time) UnmarshalXML(d *xml.Decoder, start xml.StartElement) (err error)

UnmarshalXML decodes DFSR manifest time values.

func (*Time) UnmarshalXMLAttr

func (t *Time) UnmarshalXMLAttr(attr xml.Attr) (err error)

UnmarshalXMLAttr decodes DFSR manifest time value attributes.

type Type

type Type string

Type represents a manifest resource entry type.

func (*Type) UnmarshalXML

func (t *Type) UnmarshalXML(d *xml.Decoder, start xml.StartElement) (err error)

UnmarshalXML decodes DFSR manifest type values.

Directories

Path Synopsis
Package mfilter provides common manifest filtering functions.
Package mfilter provides common manifest filtering functions.

Jump to

Keyboard shortcuts

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