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
- func CircleCIClient(logger *logrus.Logger, tokenEnv string) (*circleciclient.Client, error)
- func GitHubClient(logger *logrus.Logger, tokenEnv string, dryRun bool) (*githubclient.Client, error)
- func IsEnvVarNotFound(err error) bool
- func IsInvalidArg(err error) bool
- func IsInvalidFlag(err error) bool
- func IsStepFailed(err error) bool
- func LogWriter(logger *logrus.Logger) io.Writer
- func PipelineFiles(dir string) ([][]byte, error)
- func Report(w io.Writer, res *reconcile.Result, output string) error
- func Schema(ctx context.Context, logger *logrus.Logger, client *githubclient.Client, ...) (*reposetup.Schema, error)
- func Slug(arg, defaultOwner string) (owner, name string, err error)
- func Token(tokenEnv string) (string, error)
- func ValidateOutput(output string) error
Constants ¶
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 ¶
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 ¶
IsEnvVarNotFound asserts envVarNotFoundError.
func IsStepFailed ¶
IsStepFailed asserts stepFailedError: a step could not run to its end.
func LogWriter ¶
LogWriter adapts the logger to the io.Writer the Runner and the Renderer log through: one debug line per write.
func PipelineFiles ¶
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 ¶
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 ¶
Slug splits owner/name; a bare name takes defaultOwner, and without one the owner is required.
func ValidateOutput ¶
ValidateOutput checks an --output value.
Types ¶
This section is empty.