ledcmd

package
v0.0.0-...-a70aae3 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2024 License: Apache-2.0 Imports: 39 Imported by: 1

Documentation

Overview

Package ledcmd implements the subcommands for the `led` command line tool which interact with external services.

Index

Constants

View Source
const (
	// In PropertyOnly mode or if the "led_builder_is_bootstrapped" property
	// of the build is true, this property will be set with the CAS digest
	// of the executable of the recipe bundle.
	CASRecipeBundleProperty = "led_cas_recipe_bundle"
)
View Source
const UserAgentTag = "user_agent:led"

UserAgentTag is added by default to all Swarming tasks launched by LED.

Variables

This section is empty.

Functions

func ConsolidateRbeCasSources

func ConsolidateRbeCasSources(ctx context.Context, authOpts auth.Options, jd *job.Definition) error

ConsolidateRbeCasSources combines RBE-CAS inputs in slice.Properties.CasInputRoot and CasUserPayload for swarming tasks. For the same file, the one in CasUserPayload will replace the one in slice.Properties.CasInputRoot.

func EditIsolated

func EditIsolated(ctx context.Context, authOpts auth.Options, jd *job.Definition, xform IsolatedTransformer) error

EditIsolated allows you to edit the isolated (cas_input_root) contents of the job.Definition.

This implicitly collapses all isolated sources in the job.Definition into a single isolated source. The output job.Definition always has cas_user_payload.

func EditPayload

func EditPayload(ctx context.Context, jd *job.Definition, opts *EditPayloadOpts) error

EditPayload overrides the payload of the given job with given RBE-CAS or CIPD info.

func EditRecipeBundle

func EditRecipeBundle(ctx context.Context, authOpts auth.Options, jd *job.Definition, opts *EditRecipeBundleOpts) error

EditRecipeBundle overrides the recipe bundle in the given job with one located on disk.

It isolates the recipes from the repository in the given working directory into the UserPayload under the directory "kitchen-checkout/". If there's an existing directory in the UserPayload at that location, it will be removed.

func GetBuild

func GetBuild(ctx context.Context, authClient *http.Client, opts GetBuildOpts) (*job.Definition, error)

GetBuild retrieves a job Definition from a Buildbucket build.

func GetBuildFromJob

func GetBuildFromJob(jd *job.Definition, opts LaunchSwarmingOpts) (*bbpb.Build, error)

func GetBuilder

func GetBuilder(ctx context.Context, authClient *http.Client, opts GetBuildersOpts) (*job.Definition, error)

GetBuilder retrieves a new job Definition from a Buildbucket builder.

func GetFromSwarmingTask

func GetFromSwarmingTask(ctx context.Context, authClient *http.Client, bld *bbpb.Build, opts GetFromSwarmingTaskOpts) (*job.Definition, error)

GetFromSwarmingTask retrieves and renders a JobDefinition from the given swarming task, printing it to stdout and returning an error.

func GetUID

func GetUID(ctx context.Context, authenticator *auth.Authenticator) (string, error)

GetUID derives a user id string from the Authenticator for use with LaunchSwarming.

If the given authenticator has the userinfo.email scope, this will be the email associated with the Authenticator. Otherwise, this will be 'uid:<opaque user id>'.

func LaunchLocalBuild

func LaunchLocalBuild(ctx context.Context, build *bbpb.Build, opts LaunchSwarmingOpts) (*bbpb.Build, error)

func LaunchRemoteBuild

func LaunchRemoteBuild(ctx context.Context, authClient *http.Client, build *bbpb.Build, opts LaunchSwarmingOpts) (*bbpb.Build, error)

LaunchRemoteBuild creates a real Buildbucket build based on the given job Definition.

func LaunchSwarming

LaunchSwarming launches the given job Definition on swarming, returning the NewTaskRequest launched, as well as the launch metadata.

Types

type EditPayloadOpts

type EditPayloadOpts struct {
	// PropertyOnly determines whether to pass the recipe bundle's RBE-CAS reference
	// as a property and preserve the executable and payload of the input job
	// rather than overwriting it.
	PropertyOnly bool

	// CasDigest is the digest of the RBE-CAS reference.
	CasDigest *swarmingpb.Digest

	// CIPDPkg is the name of the CIPD package for the payload.
	CIPDPkg string
	// CIPDVer is the version of the CIPD package for the payload.
	CIPDVer string
}

type EditRecipeBundleOpts

type EditRecipeBundleOpts struct {
	// Path on disk to the repo to extract the recipes from. May be a subdirectory
	// of the repo, as long as `git rev-parse --show-toplevel` can find the root
	// of the repository.
	//
	// If empty, uses the current working directory.
	RepoDir string

	// Overrides is a mapping of recipe project id (e.g. "recipe_engine") to
	// a local path to a checkout of that repo (e.g. "/path/to/recipes-py.git").
	//
	// When the bundle is created, this local repo will be used instead of the
	// pinned version of this recipe project id. This is helpful for preparing
	// bundles which have code changes in multiple recipe repos.
	Overrides map[string]string

	// DebugSleep is the amount of time to wait after the recipe completes
	// execution (either success or failure). This is injected into the generated
	// recipe bundle as a 'sleep X' command after the invocation of the recipe
	// itself.
	DebugSleep time.Duration

	// PropertyOnly determines whether to pass the recipe bundle's CAS reference
	// as a property and preserve the executable and payload of the input job
	// rather than overwriting it.
	PropertyOnly bool
}

EditRecipeBundleOpts are user-provided options for the recipe bundling process.

type GetBuildOpts

type GetBuildOpts struct {
	BuildbucketHost string
	BuildID         int64
	PinBotID        bool
	PriorityDiff    int
	KitchenSupport  job.KitchenSupport
	RealBuild       bool
	Experiments     map[string]bool
}

GetBuildOpts are the options for GetBuild.

type GetBuildersOpts

type GetBuildersOpts struct {
	BuildbucketHost string
	Project         string
	Bucket          string
	Builder         string
	Canary          bool
	ExtraTags       []string
	PriorityDiff    int
	Experiments     map[string]bool

	KitchenSupport job.KitchenSupport

	BucketV1 string
}

GetBuildersOpts are the options for GetBuilder.

type GetFromSwarmingTaskOpts

type GetFromSwarmingTaskOpts struct {
	// The swarming host to retrieve the task from.
	SwarmingHost string

	// The ID of the task to retrieve.
	TaskID string

	// If the resulting Definition should be pinned to the same bot id that the
	// original task ran on (replaces job dimensions with just the 'id'
	// dimension).
	//
	// NOTE: This only "works" for bots which are managed statically. Dynamically
	// allocated bots (e.g. those from GCE Provider) have names which may recycle
	// from the time of the original swarming task to when GetFromSwarmingTask
	// runs, which means that 'pinning' will only get you a bot with the same
	// name, not necessarially the original bot.
	//
	// TODO: Remove this when we no longer mangage bots statically.
	PinBotID bool

	// The "name" of the resulting job Definition.
	Name string

	// The difference from the original priority.
	PriorityDiff int

	KitchenSupport job.KitchenSupport
}

GetFromSwarmingTaskOpts are the options for GetFromSwarmingTask.

type IsolatedTransformer

type IsolatedTransformer func(ctx context.Context, directory string) error

IsolatedTransformer is a function which receives a directory on the local disk with the contents of an isolate and is expected to manipulate the contents of that directory however it chooses.

EditIsolated takes these functions as a callback in order to manipulate the isolated content of a job.Definition.

func ProgramIsolatedTransformer

func ProgramIsolatedTransformer(args ...string) IsolatedTransformer

ProgramIsolatedTransformer returns an IsolatedTransformer which alters the contents of the isolated by running a program specified with `args` in the directory where the isolated content has been unpacked.

func PromptIsolatedTransformer

func PromptIsolatedTransformer() IsolatedTransformer

PromptIsolatedTransformer returns an IsolatedTransformer which prompts the user to navigate to the directory with the isolated content and manipulate it manually. When the user is done they should press "enter" to indicate that they're finished.

type LaunchSwarmingOpts

type LaunchSwarmingOpts struct {
	// If true, just generates the NewTaskRequest but does not send it to swarming
	// (SwarmingRpcsTaskRequestMetadata will be nil).
	DryRun bool

	// If true, lauch task with local luciexe host instead of sending to
	// swarming. This can be used for testing locally.
	Local bool

	// A path to be leaked when running task locally. Only be effective if Local
	// is true.
	LeakDir string

	// Must be a unique user identity string and must not be empty.
	//
	// Picking a bad value here means that generated logdog prefixes will
	// possibly collide, and the swarming task's User field will be misreported.
	//
	// See GetUID to obtain a standardized value here.
	UserID string

	// If launched from within a swarming task, this will be the current swarming
	// task's task id to be attached as the parent of the launched task.
	ParentTaskId string

	// A path, relative to ${ISOLATED_OUTDIR} of where to place the final
	// build.proto from this build. If omitted, the build.proto will not be
	// dumped.
	FinalBuildProto string

	KitchenSupport job.KitchenSupport

	// A flag for swarming/ResultDB integration on the launched task.
	ResultDB job.RDBEnablement

	// If true, `user_agent:led` tag will not be added to the launched task tags,
	// which is otherwise added by default.
	NoLEDTag bool

	// If the launched real Buildbucket build can outlive its parent or not.
	// Only works in the real build mode.
	CanOutliveParent bool
}

LaunchSwarmingOpts are the options for LaunchSwarming.

Jump to

Keyboard shortcuts

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