session

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package session provides project context loading for CLI commands.

Index

Constants

View Source
const ConfigFileName = "daco.yaml"

ConfigFileName is the name of the daco configuration file.

Variables

View Source
var (
	// ErrNotInitialized indicates no daco.yaml was found in the current directory.
	ErrNotInitialized = errors.New("not in a daco project (daco.yaml not found)")

	// ErrInvalidConfig indicates the config file exists but is invalid.
	ErrInvalidConfig = errors.New("invalid configuration")

	// ErrSpecNotFound indicates the spec file referenced by config doesn't exist.
	ErrSpecNotFound = errors.New("spec file not found")

	// ErrInvalidSpec indicates the spec file exists but couldn't be parsed.
	ErrInvalidSpec = errors.New("invalid OpenDPI spec")
)

Functions

func Load

func Load(ctx context.Context) (context.Context, error)

Load loads the project context from the current working directory and returns a new context.Context with the daco Context stored in it.

func PreRunLoad

func PreRunLoad(cmd *cobra.Command, _ []string) error

PreRunLoad returns a PersistentPreRunE function that loads the project context and stores it in the command's context.

Types

type Context

type Context struct {
	// Config is the fully resolved configuration (with inheritance applied).
	Config *config.Config

	// Spec is the parsed OpenDPI specification.
	Spec *opendpi.Spec
}

Context holds the resolved project configuration and parsed OpenDPI spec.

func From

func From(ctx context.Context) *Context

From extracts the daco Context from a context.Context. Returns nil if no Context is stored.

func FromCommand

func FromCommand(cmd *cobra.Command) *Context

FromCommand extracts the daco Context from a cobra.Command's context. Returns nil if no Context is stored.

func RequireFromCommand

func RequireFromCommand(cmd *cobra.Command) (*Context, error)

RequireFromCommand extracts the daco Context from a cobra.Command's context, returning an error if not found.

Jump to

Keyboard shortcuts

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