verify

package
v1.4.15 Latest Latest
Warning

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

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

Documentation

Overview

Package verify defines the importer's zero-mismatch rule. Purpose: compare independent observations. Inputs: manifest and target snapshot. Outputs: deterministic item-level mismatches. Constraints: never report content or secrets.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HasMember

func HasMember(r *portable.Reader, name string) bool

func Identity

func Identity(email, phone, display *string) string

Purpose: one canonical form of a user's nullable identity fields. Inputs: email, phone, display name (nil means SQL NULL). Outputs: a comparable string. Constraints: NULL and empty text stay distinct for email and phone, because hasura-auth keeps email unique; a NULL display name equals "" because the column may be NOT NULL.

Types

type Live

type Live struct {
	HasAuth  bool
	DB       *pgx.Conn
	Config   *config.Config
	Store    *objstore.Client
	Users    []User
	Metadata Metadata
	Observed State
}

func (*Live) Expected

func (l *Live) Expected() ([]User, Metadata)

func (*Live) Snapshot

func (l *Live) Snapshot(ctx context.Context, m portable.Manifest) (State, error)

type Metadata

type Metadata map[string]map[string]any

func ParseMetadata

func ParseMetadata(b []byte) (Metadata, error)

func ReadMetadata

func ReadMetadata(r *portable.Reader) (Metadata, error)

type Mismatch

type Mismatch struct {
	Kind   string `json:"kind"`
	ID     string `json:"id"`
	Detail string `json:"detail"`
}

func Compare

func Compare(ctx context.Context, target Target, m portable.Manifest) ([]Mismatch, error)

func CompareState

func CompareState(state State, m portable.Manifest, users []User, metadata Metadata) []Mismatch

type State

type State struct {
	Tables   map[string]portable.Table
	Users    map[string]string
	Objects  map[string]string
	Metadata Metadata
	Counts   map[string]int64
	// UserIdent holds Identity() of each target user; nil skips the identity check.
	UserIdent map[string]string
}

type Target

type Target interface {
	Snapshot(context.Context, portable.Manifest) (State, error)
	Expected() ([]User, Metadata)
}

type User

type User struct {
	ID            string         `json:"id"`
	Email         *string        `json:"email"`
	EmailVerified bool           `json:"email_verified"`
	Phone         *string        `json:"phone"`
	DisplayName   *string        `json:"display_name"`
	CreatedAt     string         `json:"created_at"`
	Disabled      bool           `json:"disabled"`
	PasswordHash  *string        `json:"password_hash"`
	HashAlgorithm string         `json:"hash_algorithm"`
	Metadata      map[string]any `json:"metadata"`
	Roles         []string       `json:"roles"`
}

func ReadUsers

func ReadUsers(r *portable.Reader) ([]User, error)

Jump to

Keyboard shortcuts

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