backupformat

package
v0.34.1 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2026 License: Apache-2.0 Imports: 32 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterRewriterFlags added in v0.34.0

func RegisterRewriterFlags(cmd *cobra.Command)

Types

type ChainRewriter added in v0.34.0

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

ChainRewriter is a rewriter that composes other rewriters and runs them in the order they were declared.

func (*ChainRewriter) MarshalZerologObject added in v0.34.0

func (cr *ChainRewriter) MarshalZerologObject(e *zerolog.Event)

func (*ChainRewriter) RewriteRelationship added in v0.34.0

func (cr *ChainRewriter) RewriteRelationship(r *v1.Relationship) (*v1.Relationship, error)

func (*ChainRewriter) RewriteSchema added in v0.34.0

func (cr *ChainRewriter) RewriteSchema(schema string) (string, error)

type Decoder

type Decoder interface {
	Schema() (string, error)
	ZedToken() (*v1.ZedToken, error)
	Next() (*v1.Relationship, error)
}

type Encoder

type Encoder interface {
	WriteSchema(schema, revision string) error

	// Append encodes an additional Relationship using the provided cursor to
	// keep track of progress.
	Append(r *v1.Relationship, cursor string) error

	// MarkComplete signals that the final relationship has been written and
	// that the process is complete.
	MarkComplete()
}

Encoder represents the operations required to iteratively encode a backup of SpiceDB relationship data.

type LegacyRewriter added in v0.34.0

type LegacyRewriter struct{}

func (*LegacyRewriter) RewriteRelationship added in v0.34.0

func (lr *LegacyRewriter) RewriteRelationship(r *v1.Relationship) (*v1.Relationship, error)

func (*LegacyRewriter) RewriteSchema added in v0.34.0

func (lr *LegacyRewriter) RewriteSchema(schema string) (string, error)

TODO: what are these changes and why are they necessary?

type MockEncoder added in v0.34.0

type MockEncoder struct {
	Relationships []*v1.Relationship
	Cursors       []string
	Complete      bool
}

func (*MockEncoder) Append added in v0.34.0

func (m *MockEncoder) Append(r *v1.Relationship, cursor string) error

func (*MockEncoder) MarkComplete added in v0.34.0

func (m *MockEncoder) MarkComplete()

func (*MockEncoder) WriteSchema added in v0.34.0

func (m *MockEncoder) WriteSchema(_, _ string) error

type NoopRewriter added in v0.34.0

type NoopRewriter struct{}

NoopRewriter is a rewriter that returns the schema and relationships unchanged.

func (*NoopRewriter) RewriteRelationship added in v0.34.0

func (n *NoopRewriter) RewriteRelationship(r *v1.Relationship) (*v1.Relationship, error)

func (*NoopRewriter) RewriteSchema added in v0.34.0

func (n *NoopRewriter) RewriteSchema(schema string) (string, error)

type OcfDecoder added in v0.34.0

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

func NewDecoder

func NewDecoder(r io.Reader) (*OcfDecoder, error)

func (*OcfDecoder) Close added in v0.34.0

func (d *OcfDecoder) Close() error

func (*OcfDecoder) Next added in v0.34.0

func (d *OcfDecoder) Next() (*v1.Relationship, error)

func (*OcfDecoder) Schema added in v0.34.0

func (d *OcfDecoder) Schema() (string, error)

func (*OcfDecoder) ZedToken added in v0.34.0

func (d *OcfDecoder) ZedToken() (*v1.ZedToken, error)

type OcfEncoder added in v0.34.0

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

OcfEncoder implements `Encoder` by formatting data in the AVRO OCF format.

func NewOcfEncoder added in v0.34.0

func NewOcfEncoder(w io.Writer) *OcfEncoder

func (*OcfEncoder) Append added in v0.34.0

func (e *OcfEncoder) Append(r *v1.Relationship, _ string) error

func (*OcfEncoder) Close added in v0.34.0

func (e *OcfEncoder) Close() error

func (*OcfEncoder) MarkComplete added in v0.34.0

func (e *OcfEncoder) MarkComplete()

func (*OcfEncoder) MarshalZerologObject added in v0.34.0

func (e *OcfEncoder) MarshalZerologObject(event *zerolog.Event)

func (*OcfEncoder) WriteSchema added in v0.34.0

func (e *OcfEncoder) WriteSchema(schema, revision string) error

type OcfFileEncoder added in v0.34.0

type OcfFileEncoder struct {
	*OcfEncoder
	// contains filtered or unexported fields
}

OcfFileEncoder implements `Encoder` by formatting data in the AVRO OCF format, while also persisting it to a file and maintaining a lockfile that tracks the progress so that it can be resumed if stopped.

func NewFileEncoder added in v0.34.0

func NewFileEncoder(filename string) (e *OcfFileEncoder, existed bool, err error)

func (*OcfFileEncoder) Append added in v0.34.0

func (fe *OcfFileEncoder) Append(r *v1.Relationship, cursor string) error

func (*OcfFileEncoder) Close added in v0.34.0

func (fe *OcfFileEncoder) Close() error

func (*OcfFileEncoder) Cursor added in v0.34.0

func (fe *OcfFileEncoder) Cursor() (string, error)

func (*OcfFileEncoder) MarkComplete added in v0.34.0

func (fe *OcfFileEncoder) MarkComplete()

func (*OcfFileEncoder) MarshalZerologObject added in v0.34.0

func (fe *OcfFileEncoder) MarshalZerologObject(e *zerolog.Event)

type PrefixFilterer added in v0.34.0

type PrefixFilterer struct {
	Prefix string
	// contains filtered or unexported fields
}

PrefixFilterer implements Rewriter by filtering any definitions and relationships that do not have the included prefix.

func (*PrefixFilterer) MarshalZerologObject added in v0.34.0

func (sf *PrefixFilterer) MarshalZerologObject(e *zerolog.Event)

func (*PrefixFilterer) RewriteRelationship added in v0.34.0

func (sf *PrefixFilterer) RewriteRelationship(r *v1.Relationship) (*v1.Relationship, error)

func (*PrefixFilterer) RewriteSchema added in v0.34.0

func (sf *PrefixFilterer) RewriteSchema(schema string) (string, error)

type PrefixReplacer added in v0.34.0

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

PrefixReplacer takes a given map of (oldPrefix, newPrefix) pairs and replaces those prefixes in definitions and relationships.

func (*PrefixReplacer) RewriteRelationship added in v0.34.0

func (pr *PrefixReplacer) RewriteRelationship(r *v1.Relationship) (*v1.Relationship, error)

func (*PrefixReplacer) RewriteSchema added in v0.34.0

func (pr *PrefixReplacer) RewriteSchema(schema string) (string, error)

type ProgressRenderingEncoder added in v0.34.0

type ProgressRenderingEncoder struct {
	Encoder
	// contains filtered or unexported fields
}

ProgressRenderingEncoder implements `Encoder` by wrapping an existing Encoder and displaying its progress to the current tty.

func WithProgress added in v0.34.0

func WithProgress(e Encoder) *ProgressRenderingEncoder

func (*ProgressRenderingEncoder) Append added in v0.34.0

func (pre *ProgressRenderingEncoder) Append(r *v1.Relationship, cursor string) error

func (*ProgressRenderingEncoder) Close added in v0.34.0

func (pre *ProgressRenderingEncoder) Close() error

func (*ProgressRenderingEncoder) MarshalZerologObject added in v0.34.0

func (pre *ProgressRenderingEncoder) MarshalZerologObject(e *zerolog.Event)

type RedactionMap added in v0.16.0

type RedactionMap struct {
	// Definitions is the map of original definition names to their redacted names.
	Definitions map[string]string

	// Caveats is the map of original caveat names to their redacted names.
	Caveats map[string]string

	// Relations is the map of original relation names to their redacted names.
	Relations map[string]string

	// ObjectIDs is the map of original object IDs to their redacted names.
	ObjectIDs map[string]string
}

RedactionMap is the map of original names to their redacted names.

func (RedactionMap) Invert added in v0.16.0

func (rm RedactionMap) Invert() RedactionMap

Invert returns the inverted redaction map, with the redacted names as the keys.

type RedactionOptions added in v0.16.0

type RedactionOptions struct {
	// RedactDefinitions will redact the definition names.
	RedactDefinitions bool

	// RedactRelations will redact the relation names.
	RedactRelations bool

	// RedactObjectIDs will redact the object IDs.
	RedactObjectIDs bool
}

RedactionOptions are the options to use when redacting data.

type Redactor added in v0.16.0

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

func NewRedactor added in v0.16.0

func NewRedactor(dec Decoder, w io.Writer, opts RedactionOptions) (*Redactor, error)

NewRedactor creates a new redactor that will redact the data as it is written.

func (*Redactor) Close added in v0.16.0

func (r *Redactor) Close() error

func (*Redactor) Next added in v0.16.0

func (r *Redactor) Next() error

Next redacts the next record and writes it to the writer.

func (*Redactor) RedactionMap added in v0.16.0

func (r *Redactor) RedactionMap() RedactionMap

RedactionMap returns the redaction map containing the original names and their redacted names.

type RelationshipV1

type RelationshipV1 struct {
	ObjectType        string    `avro:"object_type"`
	ObjectID          string    `avro:"object_id"`
	Relation          string    `avro:"relation"`
	SubjectObjectType string    `avro:"subject_object_type"`
	SubjectObjectID   string    `avro:"subject_object_id"`
	SubjectRelation   string    `avro:"subject_relation"`
	CaveatName        string    `avro:"caveat_name"`
	CaveatContext     []byte    `avro:"caveat_context"`
	Expiration        time.Time `avro:"expiration"`
}

type RewriteDecoder added in v0.34.0

type RewriteDecoder struct {
	Rewriter
	Decoder
}

func (*RewriteDecoder) Next added in v0.34.0

func (d *RewriteDecoder) Next() (*v1.Relationship, error)

func (*RewriteDecoder) Schema added in v0.34.0

func (d *RewriteDecoder) Schema() (string, error)

type RewriteEncoder added in v0.34.0

type RewriteEncoder struct {
	Rewriter
	Encoder
}

RewriteEncoder implements `Encoder` by rewriting any relationships before passing it on to the provided Encoder.

func WithRewriter added in v0.34.0

func WithRewriter(rw Rewriter, e Encoder) *RewriteEncoder

func (*RewriteEncoder) Append added in v0.34.0

func (e *RewriteEncoder) Append(r *v1.Relationship, cursor string) error

func (*RewriteEncoder) Close added in v0.34.0

func (e *RewriteEncoder) Close() error

func (*RewriteEncoder) MarshalZerologObject added in v0.34.0

func (e *RewriteEncoder) MarshalZerologObject(event *zerolog.Event)

type Rewriter added in v0.34.0

type Rewriter interface {
	// RewriteSchema transforms a schema.
	RewriteSchema(schema string) (string, error)

	// RewriteRelationship transforms a relationship or returns nil to signal
	// its removal.
	RewriteRelationship(r *v1.Relationship) (*v1.Relationship, error)
}

Rewriter is used to transform a backup while encoding or decoding.

func RewriterFromFlags added in v0.34.0

func RewriterFromFlags(cmd *cobra.Command) Rewriter

type SchemaV1

type SchemaV1 struct {
	SchemaText string `avro:"schema_text"`
}

Jump to

Keyboard shortcuts

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