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

importer

package
v1.4.14 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Overview

Package importer coordinates portable imports without exposing source credentials. Purpose: shared source contract. Inputs: env-name flags and a started target. Outputs: a verified report. Constraints: sources own extraction only.

Index

Constants

View Source
const PartitionedPrefix = "source table is partitioned (not supported yet): "

PartitionedPrefix starts the E520 message that names an unsupported partitioned source table.

Variables

This section is empty.

Functions

func Register

func Register(s Source)

func RegistryErrors

func RegistryErrors() []error

func SystemTables

func SystemTables(schema, name string, storage bool) bool

SystemTables excludes nSelf-owned data, with storage excluded only when enabled.

Types

type Detection

type Detection struct {
	Kind    string   `json:"kind"`
	Version string   `json:"version"`
	Notes   []string `json:"notes"`
	Schemas []string `json:"schemas"`
	// SourceUsers counts the source auth users seen at detection; --plan uses it to run the
	// same auth.users preflight as the real run.
	SourceUsers int `json:"source_users,omitempty"`
}

type Extracted

type Extracted struct{ Stage string }

type FlagSpec

type FlagSpec struct {
	Name, Usage string
	EnvVarName  bool
}

type HasuraReport

type HasuraReport struct {
	Equal bool              `json:"equal"`
	Diffs []verify.Mismatch `json:"diffs"`
}

type Input

type Input struct {
	Values map[string]string
	Env    func(string) string
	Target *config.Config
}

func (Input) Secret

func (in Input) Secret(flag string) (string, error)

type Policy

type Policy struct {
	Table  string `json:"table"`
	Policy string `json:"policy"`
	Reason string `json:"reason"`
}

type Report

type Report struct {
	Source               string               `json:"source"`
	RunID                string               `json:"run_id"`
	Result               string               `json:"result"`
	Tables               []TableReport        `json:"tables"`
	Users                UsersReport          `json:"users"`
	Storage              StorageReport        `json:"storage"`
	Hasura               HasuraReport         `json:"hasura"`
	UntranslatedPolicies []Policy             `json:"untranslated_policies"`
	Exemptions           []portable.Exemption `json:"exemptions"`
	Mismatches           []verify.Mismatch    `json:"mismatches"`
	Steps                []string             `json:"steps,omitempty"`
	// Wrote is true once the target may have changed; LastStep is the last finished load step.
	Wrote     bool       `json:"wrote"`
	LastStep  string     `json:"last_step,omitempty"`
	Detection *Detection `json:"detection,omitempty"`
}

func Run

func Run(ctx context.Context, cfg *config.Config, s Source, in Input, opts RunOptions) (Report, error)

type ResetUser

type ResetUser struct {
	ID    string `json:"id"`
	Email string `json:"email"`
}

type RunOptions

type RunOptions struct {
	ProjectDir                   string
	Plan, KeepStage, SkipStorage bool
}

type Source

type Source interface {
	Name() string
	Flags() []FlagSpec
	Detect(context.Context, Input) (Detection, error)
	Extract(context.Context, Input, string) (Extracted, error)
}

func Sources

func Sources() []Source

type StorageReport

type StorageReport struct {
	SourceObjects int  `json:"source_objects"`
	TargetObjects int  `json:"target_objects"`
	Equal         bool `json:"equal"`
}

type TableReport

type TableReport struct {
	Schema     string `json:"schema"`
	Name       string `json:"name"`
	SourceRows int64  `json:"source_rows"`
	TargetRows int64  `json:"target_rows"`
	Equal      bool   `json:"equal"`
}

type UsersReport

type UsersReport struct {
	Source        int         `json:"source"`
	Target        int         `json:"target"`
	Equal         bool        `json:"equal"`
	ResetRequired []ResetUser `json:"reset_required"`
}

Directories

Path Synopsis
Package load applies verified bundles to fresh, started targets.
Package load applies verified bundles to fresh, started targets.
Package postgres registers the base snapshot importer.
Package postgres registers the base snapshot importer.
Package scratch turns generated DDL and COPY files into a portable Postgres bundle.
Package scratch turns generated DDL and COPY files into a portable Postgres bundle.
Package testkit provides isolated source fixtures and target projects.
Package testkit provides isolated source fixtures and target projects.
Package verify defines the importer's zero-mismatch rule.
Package verify defines the importer's zero-mismatch rule.

Jump to

Keyboard shortcuts

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