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 ¶
- func InferEnvironmentName(jobName string) (string, bool)
- func NewDeployCommand(config *settings.Config, opts ...Option) *cobra.Command
- func ReadConfig(path string) ([]byte, *yaml.Node, error)
- func WriteConfig(path string, root *yaml.Node) error
- type DetectedJob
- type MarkerStep
- type Option
- type PatchResult
- type UserInputReader
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func InferEnvironmentName ¶
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 ¶
NewDeployCommand returns the top-level `circleci deploy` command group.
func ReadConfig ¶
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.
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 ¶
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 ¶
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.