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

flowioverlay

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package flowioverlay applies flowi overlays to request versions, works out the overlay that turns one version into an edited copy, and reads and writes overlay files.

A flowi overlay is not an OpenAPI Overlay (see package specoverlay): that patches an API description once, at import; this patches a request at send time and can set any field a request has.

Index

Constants

View Source
const FormatVersion = 1

FormatVersion is the value of the file's flowi_overlay key.

View Source
const StackSeparator = "+"

StackSeparator joins the names of overlays laid over one request, in order: "vip+slow". CheckName refuses it in a name, so a stack is never ambiguous and stays one string wherever an overlay is named (a flag, a flow step, a folder of saved responses).

View Source
const Suffix = ".flowi-overlay.yaml"

Suffix ends the file name of a flowi overlay, kept under overlays/.

Variables

This section is empty.

Functions

func CheckName

func CheckName(name string) error

CheckName reports why name cannot be a flowi overlay's name: it becomes a file name and appears in response folders and flags.

func CheckOp

func CheckOp(op model.OverlayOp) error

CheckOp reports why op can never apply to any version: an unknown field, a verb the field does not take, or a missing name after the dot. It does not look at any version, so it cannot tell a header that is absent.

func Decode

func Decode(file, fallbackName string, data []byte) (model.Overlay, diag.List)

Decode reads a *.flowi-overlay.yaml file. fallbackName names the overlay when the file does not (the file name without the suffix). Problems are FLW-OVL-001.

func Describe

func Describe(op model.OverlayOp) string

Describe says what op does in a short sentence a user reads in a save dialog or a warning: "Set header X-Tier to "vip"".

func Diff

func Diff(base, edited model.RequestVersion) (ops []model.OverlayOp, unsupported []string)

Diff works out the operations that turn base into edited, and the parts of the edit an overlay cannot hold (inline hooks, a changed form or file body), each as a short sentence. Applying the operations to base gives edited, except for those parts.

func Encode

func Encode(o model.Overlay) ([]byte, error)

Encode writes an overlay as a file. Requests are sorted by id so the file changes only where the overlay does.

func ForRequest

func ForRequest(o model.Overlay, id model.ID) []model.OverlayOp

ForRequest returns the operations that apply to request id: the shared part first, then the request's own.

func MergePatch

func MergePatch(base, patch any) any

MergePatch applies an RFC 7386 JSON merge patch: objects merge key by key, null removes a key, anything else replaces.

func Resolve

func Resolve(overlays []model.Overlay, stack string, id model.ID) (ops []model.OverlayOp, missing string)

Resolve returns the operations the overlays of stack make to request id, each overlay's shared part and then its own, in the order named, so a later overlay wins where two set the same field. missing is the first name that is not among overlays ("" when all are).

func Stack

func Stack(stack string) []string

Stack splits a stack of overlay names, dropping blanks.

Types

type Problem

type Problem struct {
	Op     model.OverlayOp
	Reason string
	// Drift marks an operation that was applied: the base no longer holds
	// what it held when the overlay was saved. Otherwise the operation was
	// left out.
	Drift bool
}

Problem is an operation that did not fit the version it was applied to, or that applied although the base changed since the overlay was saved.

func Apply

Apply returns v with ops applied in order. An operation that does not fit (it removes a header the version no longer has) is left out and reported; the rest still apply. v is not changed.

func (Problem) Describe

func (p Problem) Describe() string

Describe names the operation the way a user reads it (see Describe).

Jump to

Keyboard shortcuts

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