engine

package
v8.64.4 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package engine is what the repo commands share to run the set-up steps of pkg/reposetup/reconcile as the person: the clients from the token environment variables, the repository slug, the log adapter and the result on stdout.

Index

Constants

View Source
const (
	// DefaultGitHubEnvVar names the environment variable the GitHub token is
	// read from unless a flag names another.
	DefaultGitHubEnvVar = "GITHUB_TOKEN"
	// DefaultCircleCIEnvVar names the environment variable the CircleCI token
	// is read from unless a flag names another.
	DefaultCircleCIEnvVar = "CIRCLECI_TOKEN"

	// OutputTable renders the result as a table, OutputJSON as the
	// structured value.
	OutputTable = "table"
	OutputJSON  = "json"
)

Variables

This section is empty.

Functions

func CircleCIClient

func CircleCIClient(logger *logrus.Logger, tokenEnv string) (*circleciclient.Client, error)

CircleCIClient returns the CircleCI client for the token in $tokenEnv, or nil when the variable is unset: the steps that need CircleCI are then skipped, which the log says.

func GitHubClient

func GitHubClient(logger *logrus.Logger, tokenEnv string, dryRun bool) (*githubclient.Client, error)

GitHubClient returns the GitHub client for the token in $tokenEnv.

func IsEnvVarNotFound

func IsEnvVarNotFound(err error) bool

IsEnvVarNotFound asserts envVarNotFoundError.

func IsInvalidArg

func IsInvalidArg(err error) bool

IsInvalidArg asserts invalidArgError.

func IsInvalidFlag

func IsInvalidFlag(err error) bool

IsInvalidFlag asserts invalidFlagError.

func IsStepFailed

func IsStepFailed(err error) bool

IsStepFailed asserts stepFailedError: a step could not run to its end.

func LogWriter

func LogWriter(logger *logrus.Logger) io.Writer

LogWriter adapts the logger to the io.Writer the Runner and the Renderer log through: one debug line per write.

func PipelineFiles

func PipelineFiles(dir string) ([][]byte, error)

PipelineFiles reads the pipeline documents (reconcile.PipelineFiles, whatever is missing is skipped) from a .circleci directory and checks that each parses; the result is empty when the directory holds none.

func Report

func Report(w io.Writer, res *reconcile.Result, output string) error

Report writes the result to w as a table or as JSON and returns an error when a step failed, so the command exits non-zero on a step that could not run to its end; drift and findings are the result's business.

func Schema

func Schema(ctx context.Context, logger *logrus.Logger, client *githubclient.Client, path string) (*reposetup.Schema, error)

Schema is the repositories schema: the file at path when given, else the schema on giantswarm/github main (with client), else the embedded copy.

func Slug

func Slug(arg, defaultOwner string) (owner, name string, err error)

Slug splits owner/name; a bare name takes defaultOwner, and without one the owner is required.

func Token

func Token(tokenEnv string) (string, error)

Token returns the token in $tokenEnv; an unset variable is an error.

func ValidateOutput

func ValidateOutput(output string) error

ValidateOutput checks an --output value.

Types

This section is empty.

Jump to

Keyboard shortcuts

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