Documentation
¶
Overview ¶
Package api defines the Go API shared by automation language adapters.
Index ¶
- Constants
- func ReadHTTPBody(body io.ReadCloser) ([]byte, error)
- type Browser
- type Callback
- type CallbackListener
- type CastLibrary
- type ExecutionPolicy
- type FileInfo
- type FileSystem
- type GroupScheduler
- type HTTP
- type HTTPService
- type LocalBrowser
- type LocalFileSystem
- func (fs LocalFileSystem) Exists(ctx context.Context, path string) (bool, error)
- func (LocalFileSystem) Glob(ctx context.Context, pattern string) ([]string, error)
- func (LocalFileSystem) Readlink(ctx context.Context, path string) (string, error)
- func (LocalFileSystem) Stat(ctx context.Context, path string, followSymlinks bool) (FileInfo, error)
- type ScheduledForker
- type StepCall
- type StepLibrary
- type StepResult
Examples ¶
Constants ¶
const MaxHTTPBody = 8 << 20
MaxHTTPBody bounds bodies below the plugin protocol's 16 MiB message limit.
Variables ¶
This section is empty.
Functions ¶
func ReadHTTPBody ¶
func ReadHTTPBody(body io.ReadCloser) ([]byte, error)
ReadHTTPBody reads a bounded body and always closes it.
Types ¶
type Browser ¶
type Browser interface {
Open(context.Context, string) error
Listen(context.Context, string, string) (CallbackListener, error)
}
Browser supplies browser interaction and loopback callback transport.
type Callback ¶
type Callback struct{ Code, State, Error string }
Callback contains authorization query parameters, never a rendered web response.
type CallbackListener ¶
type CallbackListener interface {
RedirectURI() string
Receive(context.Context) (Callback, error)
Close() error
}
CallbackListener is ready before it is returned. Closing it releases the socket.
type CastLibrary ¶
type CastLibrary interface {
ValidateCast(*castplan.Plan, *StepCall) error
GenerateCast(context.Context, *castplan.Plan, *StepCall, func(string) error) (string, error)
}
CastLibrary is the optional recording service supplied by a step-library host. ValidateCast performs structural checks only; GenerateCast checks the staged recording through validate before committing it to its destination.
type ExecutionPolicy ¶
ExecutionPolicy bounds an operation and its retry waits with one deadline. A nil Retry runs once. Clock is optional and controls retry backoff only.
type FileSystem ¶
type FileSystem interface {
Glob(context.Context, string) ([]string, error)
Stat(context.Context, string, bool) (FileInfo, error)
Exists(context.Context, string) (bool, error)
Readlink(context.Context, string) (string, error)
}
FileSystem supplies read-only filesystem operations to embedded interpreters. Paths are absolute when called by an interpreter. Implementations must be safe for concurrent use.
type GroupScheduler ¶
type GroupScheduler interface {
StepLibrary
// ScheduleGroup reserves the position of one parallel group that starts now.
ScheduleGroup() ScheduledForker
}
GroupScheduler is implemented by a StepLibrary that positions parallel groups. A scheduler that implements fan-out calls ScheduleGroup once per group, before it starts the first branch, and forks the branches from the returned library. Each group gets a position of its own, so the work of two consecutive groups is never interleaved.
type HTTPService ¶
type HTTPService struct{ Transport http.RoundTripper }
HTTPService reuses an injected transport, including its proxy and CA configuration. It does not inject authentication, follow redirects, or retry a failed exchange.
type LocalBrowser ¶
LocalBrowser uses an injected browser opener and loopback-only callback listener. Interactive must be set by the invocation, never by the plugin.
func (LocalBrowser) Listen ¶
func (b LocalBrowser) Listen(ctx context.Context, path, expectedState string) (CallbackListener, error)
Listen binds before returning. Wrong-state or unrelated requests leave the callback usable.
type LocalFileSystem ¶
type LocalFileSystem struct{}
LocalFileSystem implements read-only operations using the operating system.
func (LocalFileSystem) Exists ¶
Exists follows symlinks. Missing paths and dangling links return false; other failures are errors.
func (LocalFileSystem) Glob ¶
Glob returns sorted matches using filepath glob syntax. It does not support recursive ** matching.
type ScheduledForker ¶
type ScheduledForker interface {
StepLibrary
// ForkAt isolates a branch like Fork and records the branch's scheduled index.
ForkAt(index int) StepLibrary
}
ScheduledForker is implemented by a StepLibrary that can fork a branch of a parallel group at a known scheduled position. A scheduler that implements fan-out calls ForkAt instead of Fork, with the zero-based index of the branch in the group, so work recorded by the branches (such as artifact reports) is ordered by where each branch was scheduled rather than by when it finished. The library of a group comes from GroupScheduler.ScheduleGroup.
type StepCall ¶
type StepCall struct {
Type string
Configuration map[string]any
WorkingDirectory string
ProcessEnv []string
Stdout, Stderr io.Writer
Parallel bool
}
StepCall contains native Go step configuration. Writers and process settings belong to the calling script thread.
type StepLibrary ¶
type StepLibrary interface {
Names() []string
Fork() StepLibrary
Validate(*StepCall) error
Run(context.Context, *StepCall) (*StepResult, error)
}
StepLibrary dispatches registered Atmos steps. Each invocation and parallel branch owns a fork, so step outputs and environment changes remain local.
Example ¶
package main
import (
"context"
"fmt"
"github.com/cloudposse/atmos/pkg/api"
"github.com/cloudposse/atmos/pkg/runner/step"
)
func main() {
library := step.NewAutomationLibrary(nil, nil)
result, err := library.Run(context.Background(), &api.StepCall{
Type: "join",
Configuration: map[string]any{"options": []string{"api", "worker"}, "separator": ","},
})
if err != nil {
panic(err)
}
fmt.Println(result.Value)
}
Output: api,worker
type StepResult ¶
type StepResult struct {
Value string `json:"value"`
Values []string `json:"values"`
Metadata map[string]any `json:"metadata"`
Outputs map[string]string `json:"outputs"`
Skipped bool `json:"skipped"`
Error string `json:"error"`
}
StepResult exposes the same value, selections, metadata, and named outputs returned by the step registry. Engines convert these into immutable values.