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

yamlcodec

package
v0.1.0-alpha.3 Latest Latest
Warning

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

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

Documentation

Overview

Package yamlcodec reads and writes Flow-I files as YAML.

Decoding walks the parsed syntax tree instead of reflecting into structs, so that it can report every problem with its line and column, keep keys exactly as written, and preserve the order of user-ordered maps. Encoding produces the canonical form that `flowi fmt` writes.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HasComments

func HasComments(data []byte) bool

HasComments reports whether data contains YAML comments, which the canonical form does not keep.

Types

type Codec

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

Codec decodes and encodes Flow-I files.

func New

func New(schema []settings.Key) *Codec

New returns a codec validating settings blocks against schema.

func (*Codec) DecodeBlueprint

func (c *Codec) DecodeBlueprint(file, path string, data []byte) (model.Blueprint, diag.List)

DecodeBlueprint reads a *.blueprint.yaml file: a flow body plus declared parameters, where a request or subflow reference may be {param: name}. path is relative to blueprints/ without the suffix.

func (*Codec) DecodeEnvironment

func (c *Codec) DecodeEnvironment(file string, data []byte) (model.Environment, diag.List)

DecodeEnvironment reads an environments/*.yaml file. Each variable is a scalar value or {secret: true}; secret values never live in the file.

func (*Codec) DecodeFlow

func (c *Codec) DecodeFlow(file, path string, data []byte) (model.Flow, diag.List)

DecodeFlow reads a *.flow.yaml file. path is relative to flows/ without the suffix.

func (*Codec) DecodeFolder

func (c *Codec) DecodeFolder(file, dir string, data []byte) (model.Folder, diag.List)

DecodeFolder reads a _folder.yaml. dir is the folder's path relative to the collection root, e.g. "requests/auth".

func (*Codec) DecodeLayout

func (c *Codec) DecodeLayout(file string, data []byte) (model.Layout, diag.List)

DecodeLayout reads a *.layout.yaml file. Problems are diagnostics; what could be read is returned (a layout is only a convenience).

func (*Codec) DecodeManifest

func (c *Codec) DecodeManifest(file string, data []byte) (model.Manifest, diag.List)

DecodeManifest reads a collection's flowi.yaml.

func (*Codec) DecodeRequest

func (c *Codec) DecodeRequest(file, path string, data []byte) (model.Request, diag.List)

DecodeRequest reads a *.req.yaml file. path is the request's path relative to requests/ without the suffix, e.g. "auth/login".

func (*Codec) DecodeSettingsFile

func (c *Codec) DecodeSettingsFile(file string, data []byte) (map[string]any, diag.List)

DecodeSettingsFile reads the user settings file into flattened, not yet validated values.

func (*Codec) DecodeWorkspace

func (c *Codec) DecodeWorkspace(file string, data []byte) (model.Workspace, diag.List)

DecodeWorkspace reads workspace.yaml.

func (*Codec) EncodeBlueprint

func (c *Codec) EncodeBlueprint(bp model.Blueprint) ([]byte, error)

EncodeBlueprint writes a blueprint in canonical form.

func (*Codec) EncodeEnvironment

func (c *Codec) EncodeEnvironment(env model.Environment) ([]byte, error)

EncodeEnvironment writes an environment in canonical form.

func (*Codec) EncodeFlow

func (c *Codec) EncodeFlow(f model.Flow) ([]byte, error)

EncodeFlow writes a flow in canonical form.

func (*Codec) EncodeFolder

func (c *Codec) EncodeFolder(f model.Folder) ([]byte, error)

EncodeFolder writes a _folder.yaml in canonical form.

func (*Codec) EncodeLayout

func (c *Codec) EncodeLayout(l model.Layout) ([]byte, error)

EncodeLayout writes a layout in canonical form: positions sorted by node id.

func (*Codec) EncodeManifest

func (c *Codec) EncodeManifest(man model.Manifest) ([]byte, error)

EncodeManifest writes flowi.yaml in canonical form.

func (*Codec) EncodeRequest

func (c *Codec) EncodeRequest(r model.Request) ([]byte, error)

EncodeRequest writes a request in canonical form, versions sorted by version order (invalid labels last, in text order).

func (*Codec) EncodeSettingsFile

func (c *Codec) EncodeSettingsFile(s model.Settings) ([]byte, error)

EncodeSettingsFile writes validated user settings in schema order.

func (*Codec) EncodeWorkspace

func (c *Codec) EncodeWorkspace(ws model.Workspace) ([]byte, error)

EncodeWorkspace writes workspace.yaml in canonical form.

func (*Codec) HasComments

func (c *Codec) HasComments(data []byte) bool

HasComments is HasComments as a method, so the codec satisfies interfaces that need it.

func (*Codec) Locate

func (c *Codec) Locate(data []byte, yamlPath string) (diag.Position, bool)

Locate returns the position of the node at a YAML path such as "$.nodes[1].request.id", or false when the path does not exist.

Jump to

Keyboard shortcuts

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