deploy

package
v0.1.36202 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package deploy implements the `circleci deploy` command group, including the `init` subcommand that wires deploy markers into an existing .circleci/config.yml with zero manual editing.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InferEnvironmentName

func InferEnvironmentName(jobName string) (string, bool)

InferEnvironmentName returns a best-effort environment name derived from the job name (e.g. `deploy-prod` → `production`). The boolean return reports whether the heuristic matched; callers should prompt the user when it did not.

func NewDeployCommand

func NewDeployCommand(config *settings.Config, opts ...Option) *cobra.Command

NewDeployCommand returns the top-level `circleci deploy` command group.

func ReadConfig

func ReadConfig(path string) ([]byte, *yaml.Node, error)

ReadConfig reads the config file at path and parses it into a YAML Document node that preserves formatting, comments and ordering for a subsequent round-trip.

func WriteConfig

func WriteConfig(path string, root *yaml.Node) error

WriteConfig marshals the document node back to YAML and writes it to path. It uses two-space indentation to match the style used across CircleCI config examples.

Types

type DetectedJob

type DetectedJob struct {
	// Name is the job name as it appears under the top-level `jobs:` key.
	Name string
	// AlreadyInstrumented is true when at least one of the job's existing
	// steps already invokes `circleci run release log` (or a compatible
	// marker command). Such jobs are skipped during patching to keep the
	// command idempotent.
	AlreadyInstrumented bool
}

DetectedJob describes a job in config.yml that matched the deploy heuristics.

func DetectDeployJobs

func DetectDeployJobs(root *yaml.Node) []DetectedJob

DetectDeployJobs scans the root YAML document of a CircleCI config and returns every job whose name matches the deploy heuristics. It never modifies the node tree.

type MarkerStep

type MarkerStep struct {
	JobName         string
	ComponentName   string
	EnvironmentName string
}

MarkerStep describes the deploy marker step we want to add to a single job.

type Option

type Option interface {
	// contains filtered or unexported methods
}

Option configures a command created by NewDeployCommand.

func CustomReader

func CustomReader(r UserInputReader) Option

CustomReader returns an Option that replaces the default interactive prompt reader with the supplied implementation. Useful for tests.

type PatchResult

type PatchResult struct {
	// Modified lists the names of jobs that had a new deploy marker step
	// appended to them in this invocation.
	Modified []string
	// Skipped lists jobs that were already instrumented and therefore
	// left untouched.
	Skipped []string
}

PatchResult summarises what PatchConfig did so the caller can report useful feedback to the user.

func PatchConfig

func PatchConfig(root *yaml.Node, steps []MarkerStep) (PatchResult, error)

PatchConfig mutates root so that each requested job gains a new step that records a deploy marker. Jobs that already contain such a step are left untouched so the command is safely re-runnable.

type UserInputReader

type UserInputReader interface {
	ReadStringFromUser(msg string, defaultValue string) string
}

UserInputReader displays a message and reads a user input value. It mirrors the pattern used by other command groups so tests can supply canned answers without a real TTY.

Jump to

Keyboard shortcuts

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