luci: go.chromium.org/luci/luciexe/host Index | Files

package host

import "go.chromium.org/luci/luciexe/host"

Package host implements the 'Host Application' portion of the luciexe protocol.

It manages a local Logdog Butler service, and also runs all LUCI Auth related daemons. It intercepts and interprets build.proto streams within the Butler context, merging them as necessary.

Index

Package Files

auth.go butler.go cleanup.go host.go options.go

Variables

var DefaultExeAuth = func(id string, knownGerritHosts []string) *authctx.Context {
    return &authctx.Context{
        ID: id,
        Options: chromeinfra.SetDefaultAuthOptions(auth.Options{
            Scopes: []string{
                "https://www.googleapis.com/auth/cloud-platform",
                "https://www.googleapis.com/auth/userinfo.email",
                "https://www.googleapis.com/auth/gerritcodereview",
                "https://www.googleapis.com/auth/firebase",
            },
        }),
        EnableGitAuth:      true,
        EnableGCEEmulation: true,
        EnableDockerAuth:   true,
        EnableFirebaseAuth: true,
        KnownGerritHosts:   knownGerritHosts,
    }
}

DefaultExeAuth returns a copy of the default value for Options.ExeAuth.

func Run Uses

func Run(ctx context.Context, options *Options, cb func(context.Context) error) (<-chan *bbpb.Build, error)

Run executes `cb` in a "luciexe" host environment.

The merged Build objects collected from the host environment (i.e. generated within `cb`) will be pushed to the returned channel as `cb` executes.

The context should be used for cancellation of the callback function; It's up to the `cb` implementation to respect the cancelled context.

When the callback function completes, Run closes the returned channel.

Blocking the returned channel may block the execution of `cb`.

NOTE: This modifies the environment (i.e. with os.Setenv) while `cb` is running. Be careful when using Run concurrently with other code.

type Options Uses

type Options struct {
    // Where the butler will sink its data to.
    //
    // This is typically one of the implementations in
    // go.chromium.org/luci/logdog/client/butler/output.
    //
    // If nil, will use the 'null' logdog Output.
    LogdogOutput ldOutput.Output

    // ExeAuth describes the LUCI Auth environment to run the user code within.
    //
    // `Run` will manage the lifecycle of ExeAuth entirely.
    //
    // If nil, defaults to `DefaultExeAuth("luciexe", nil)`.
    //
    // It's recommended to use DefaultExeAuth() explicitly with reasonable values
    // for `id` and `knownGerritHosts`.
    ExeAuth *authctx.Context

    // The BaseDir becomes the root of this hosted luciexe session; All
    // directories (workdirs, tempdirs, etc.) are derived relative to this.
    //
    // If not provided, Run will pick a random directory under os.TempDir as the
    // value for BaseDir.
    //
    // The BaseDir (provided or picked) will be managed by Run; Prior to
    // execution, Run will ensure that the directory is empty by removing its
    // contents.
    BaseDir string

    // If LeakBaseDir is true, Run will not try to remove BaseDir at the end if
    // it's execution.
    //
    // If BaseDir is not provided, this must be false.
    LeakBaseDir bool

    // The viewer URL for this hosted execution (if any). This will be used to
    // apply the "logdog.viewer_url" tag to all logdog streams (the tag which is
    // used to implement the "Back to build" link in Milo).
    ViewerURL string
    // contains filtered or unexported fields
}

Options is an optional struct which allows you to control how Run operates.

Package host imports 18 packages (graph). Updated 2019-09-20. Refresh now. Tools for package owners.