// Builds routes build commands to their specific function.
763401
func Builds(argv []string) error {
	usage := `
Valid commands for builds:

builds:list        list build history for an application
builds:create      imports an image and deploys as a new release

Use 'deis help [command]' to learn more.
`

	switch argv[0] {
	case "builds:list":
		return buildsList(argv)
	case "builds:create":
		return buildsCreate(argv)
	default:
		if printHelp(argv, usage) {
			return nil
		}

		if argv[0] == "builds" {
			argv[0] = "builds:list"
			return buildsList(argv)
		}

		PrintUsage()
		return nil
	}
}
775395
func (op *UpdateUnitsOperation) Build(attempt int) ([]txn.Op, error) {
	var ops []txn.Op

	all := op.allOps()
	for _, op := range all {
		switch nextOps, err := op.Build(attempt); err {
		case jujutxn.ErrNoOperations:
			continue
		case nil:
			ops = append(ops, nextOps...)
		default:
			return nil, errors.Trace(err)
		}
	}
	return ops, nil
}
859488
func (builder *ListBucketsCommandBuilder) Build() (Command, error) {
	if builder.protobuf == nil {
		panic("builder.protobuf must not be nil")
	}
	if err := validateLocatable(builder.protobuf); err != nil {
		return nil, err
	}
	if builder.protobuf.GetStream() && builder.callback == nil {
		return nil, newClientError("ListBucketsCommand requires a callback when streaming.", nil)
	}
	if !builder.allowListing {
		return nil, ErrListingDisabled
	}
	return &ListBucketsCommand{
		listingImpl: listingImpl{
			allowListing: builder.allowListing,
		},
		protobuf: builder.protobuf,
		callback: builder.callback}, nil
}
431011
func (builder *StoreIndexCommandBuilder) Build() (Command, error) {
	if builder.protobuf == nil {
		panic("builder.protobuf must not be nil")
	}
	return &StoreIndexCommand{
		timeoutImpl: timeoutImpl{
			timeout: builder.timeout,
		},
		protobuf: builder.protobuf,
	}, nil
}
90966
func routes(reg *cookoo.Registry) {

	// The "boot" route starts up the builder as a daemon process. Along the
	// way, it starts and configures multiple services, including etcd, confd,
	// and sshd.
	reg.AddRoute(cookoo.Route{
		Name: "boot",
		Help: "Boot the builder",
		Does: []cookoo.Task{

			// ENV: Make sure the environment is correct.
			cookoo.Cmd{
				Name: "vars",
				Fn:   env.Get,
				Using: []cookoo.Param{
					{Name: "HOST", DefaultValue: "127.0.0.1"},
					{Name: "ETCD_PORT", DefaultValue: "4001"},
					{Name: "ETCD_PATH", DefaultValue: "/deis/builder"},
					{Name: "ETCD_TTL", DefaultValue: "20"},
				},
			},
			cookoo.Cmd{ // This depends on others being processed first.
				Name: "vars2",
				Fn:   env.Get,
				Using: []cookoo.Param{
					{Name: "ETCD", DefaultValue: "$HOST:$ETCD_PORT"},
				},
			},

			// DOCKER: start up Docker and make sure it's running.
			// Then let it download the images while we keep going.
			cookoo.Cmd{
				Name: "docker",
				Fn:   docker.CreateClient,
				Using: []cookoo.Param{
					{Name: "url", DefaultValue: "unix:///var/run/docker.sock"},
				},
			},
			cookoo.Cmd{
				Name: "dockerclean",
				Fn:   docker.Cleanup,
			},
			cookoo.Cmd{
				Name: "dockerstart",
				Fn:   docker.Start,
			},
			cookoo.Cmd{
				Name: "waitfordocker",
				Fn:   docker.WaitForStart,
				Using: []cookoo.Param{
					{Name: "client", From: "cxt:docker"},
				},
			},

			cookoo.Cmd{
				Name: "buildImages",
				Fn:   docker.ParallelBuild,
				Using: []cookoo.Param{
					{Name: "client", From: "cxt:docker"},
					{
						Name: "images",
						DefaultValue: []docker.BuildImg{
							{Path: "/usr/local/src/slugbuilder/", Tag: "deis/slugbuilder"},
							{Path: "/usr/local/src/slugrunner/", Tag: "deis/slugrunner"},
						},
					},
				},
			},

			// ETCD: Make sure Etcd is running, and do the initial population.
			cookoo.Cmd{
				Name:  "client",
				Fn:    etcd.CreateClient,
				Using: []cookoo.Param{{Name: "url", DefaultValue: "http://127.0.0.1:4001", From: "cxt:ETCD"}},
			},
			cookoo.Cmd{
				Name: "etcdup",
				Fn:   etcd.IsRunning,
				Using: []cookoo.Param{
					{Name: "client", From: "cxt:client"},
					{Name: "count", DefaultValue: 20},
				},
			},
			cookoo.Cmd{
				Name: "-",
				Fn:   Sleep,
				Using: []cookoo.Param{
					{Name: "duration", DefaultValue: 21 * time.Second},
					{Name: "message", DefaultValue: "Sleeping while etcd expires keys."},
				},
			},
			cookoo.Cmd{
				Name: "newdir",
				Fn:   fmt.Sprintf,
				Using: []cookoo.Param{
					{Name: "format", DefaultValue: "%s/users"},
					{Name: "0", From: "cxt:ETCD_PATH"},
				},
			},
			cookoo.Cmd{
				Name: "mkdir",
				Fn:   etcd.MakeDir,
				Using: []cookoo.Param{
					{Name: "path", From: "cxt:newdir"},
					{Name: "client", From: "cxt:client"},
				},
			},

			// SSHD: Create and configure host keys.
			cookoo.Cmd{
				Name: "installSshHostKeys",
				Fn:   etcd.StoreHostKeys,
				Using: []cookoo.Param{
					{Name: "client", From: "cxt:client"},
					{Name: "basepath", From: "cxt:ETCD_PATH"},
				},
			},
			cookoo.Cmd{
				Name: sshd.HostKeys,
				Fn:   sshd.ParseHostKeys,
			},
			cookoo.Cmd{
				Name: sshd.ServerConfig,
				Fn:   sshd.Configure,
			},

			// CONFD: Build out the templates, then start the Confd server.
			cookoo.Cmd{
				Name:  "once",
				Fn:    confd.RunOnce,
				Using: []cookoo.Param{{Name: "node", From: "cxt:ETCD"}},
			},
			cookoo.Cmd{
				Name:  "confd",
				Fn:    confd.Run,
				Using: []cookoo.Param{{Name: "node", From: "cxt:ETCD"}},
			},

			// Now we wait for Docker to finish downloading.
			cookoo.Cmd{
				Name: "dowloadImages",
				Fn:   docker.Wait,
				Using: []cookoo.Param{
					{Name: "wg", From: "cxt:buildImages"},
					{Name: "msg", DefaultValue: "Images downloaded"},
					{Name: "waiting", DefaultValue: "Downloading Docker images. This may take a long time. https://xkcd.com/303/"},
					{Name: "failures", From: "cxt:ParallelBuild.failN"},
				},
			},
			cookoo.Cmd{
				Name: "pushImages",
				Fn:   docker.Push,
				Using: []cookoo.Param{
					{Name: "tag", DefaultValue: "deis/slugrunner:latest"},
					{Name: "client", From: "cxt:client"},
				},
			},

			// ETDCD: Now watch for events on etcd, and trigger a git check-repos for
			// each. For the most part, this runs in the background.
			cookoo.Cmd{
				Name: "Cleanup",
				Fn:   etcd.Watch,
				Using: []cookoo.Param{
					{Name: "client", From: "cxt:client"},
				},
			},
			// If there's an EXTERNAL_PORT, we publish info to etcd.
			cookoo.Cmd{
				Name: "externalport",
				Fn:   env.Get,
				Using: []cookoo.Param{
					{Name: "EXTERNAL_PORT", DefaultValue: ""},
				},
			},
			cookoo.Cmd{
				Name: "etcdupdate",
				Fn:   etcd.UpdateHostPort,
				Using: []cookoo.Param{
					{Name: "base", From: "cxt:ETCD_PATH"},
					{Name: "host", From: "cxt:HOST"},
					{Name: "port", From: "cxt:EXTERNAL_PORT"},
					{Name: "client", From: "cxt:client"},
					{Name: "sshdPid", From: "cxt:sshd"},
				},
			},

			// DAEMON: Finally, we wait around for a signal, and then cleanup.
			cookoo.Cmd{
				Name: "listen",
				Fn:   KillOnExit,
				Using: []cookoo.Param{
					{Name: "docker", From: "cxt:dockerstart"},
					{Name: "sshd", From: "cxt:sshdstart"},
				},
			},
		},
	})

	// This route is called during a user authentication for SSH.
	// The rough pattern is that we parse the local authorized keys file, and
	// then validate that the supplied user key matches an authorized key.
	//
	// This grants access to running git-receive, but does not grant access
	// to writing to the repo. That's handled by the sshReceive.
	reg.AddRoute(cookoo.Route{
		Name: "pubkeyAuth",
		Does: []cookoo.Task{
			// Parse the authorized keys file.
			// We do this every time because confd is constantly regenerating
			// the auth keys file.
			cookoo.Cmd{
				Name: "authorizedKeys",
				Fn:   sshd.ParseAuthorizedKeys,
				Using: []cookoo.Param{
					{Name: "path", DefaultValue: "/home/git/.ssh/authorized_keys"},
				},
			},

			// Auth against the keys
			cookoo.Cmd{
				Name: "authN",
				Fn:   sshd.AuthKey,
				Using: []cookoo.Param{
					{Name: "metadata", From: "cxt:metadata"},
					{Name: "key", From: "cxt:key"},
					{Name: "authorizedKeys", From: "cxt:authorizedKeys"},
				},
			},
		},
	})

	// This provides a very basic SSH ping.
	// Called by the sshd.Server
	reg.AddRoute(cookoo.Route{
		Name: "sshPing",
		Help: "Handles an ssh exec ping.",
		Does: []cookoo.Task{
			cookoo.Cmd{
				Name: "ping",
				Fn:   sshd.Ping,
				Using: []cookoo.Param{
					{Name: "request", From: "cxt:request"},
					{Name: "channel", From: "cxt:channel"},
				},
			},
		},
	})

	// This proxies a client session into a git receive.
	//
	// Called by the sshd.Server
	reg.AddRoute(cookoo.Route{
		Name: "sshGitReceive",
		Help: "Handle a git receive over an SSH connection.",
		Does: []cookoo.Task{
			// The Git receive handler needs the username. So we provide
			// it by looking up the name based on the key. When the
			// controller no longer requires username for SSH auth, we can
			// ditch this.
			cookoo.Cmd{
				Name: "fingerprint",
				Fn:   sshd.FingerprintKey,
				Using: []cookoo.Param{
					{Name: "key", From: "cxt:key"},
				},
			},
			cookoo.Cmd{
				Name: "username",
				Fn:   etcd.FindSSHUser,
				Using: []cookoo.Param{
					{Name: "client", From: "cxt:client"},
					{Name: "fingerprint", From: "cxt:fingerprint"},
				},
			},
			cookoo.Cmd{
				Name: "receive",
				Fn:   git.Receive,
				Using: []cookoo.Param{
					{Name: "request", From: "cxt:request"},
					{Name: "channel", From: "cxt:channel"},
					{Name: "operation", From: "cxt:operation"},
					{Name: "repoName", From: "cxt:repository"},
					{Name: "fingerprint", From: "cxt:fingerprint"},
					{Name: "permissions", From: "cxt:authN"},
					{Name: "user", From: "cxt:username"},
				},
			},
		},
	})
}
1245312
func (builder *FetchSetCommandBuilder) Build() (Command, error) {
	if builder.protobuf == nil {
		panic("builder.protobuf must not be nil")
	}
	if err := validateLocatable(builder.protobuf); err != nil {
		return nil, err
	}
	return &FetchSetCommand{
		timeoutImpl: timeoutImpl{
			timeout: builder.timeout,
		},
		protobuf: builder.protobuf,
	}, nil
}
1021087
func (o *GetMapURL) Build() (*url.URL, error) {
	var _result url.URL

	var _path = "/map"

	_basePath := o._basePath
	if _basePath == "" {
		_basePath = "/v1"
	}
	_result.Path = golangswaggerpaths.Join(_basePath, _path)

	return &_result, nil
}
280963
func (c *messageCommand) build(sn shortNoncer, sk *precomputedKey, data []byte, sentByServer bool) error {

	total := uint64(8 + 8 + 16 + 1)
	total += uint64(len(data))

	_, err := c.realloc(total)
	if err != nil {
		return err
	}

	destHeader := c.buf[:8]
	destUnprefixedNonce := c.buf[8:16]
	destEncMessageBox := c.buf[16:total]

	var prefix [16]byte
	if sentByServer {
		prefix = serverMessageNoncePrefix
	} else {
		prefix = clientMessageNoncePrefix
	}
	prefixedNonce, unprefixedNonce, err := sn.prefixAndBump(prefix)
	if err != nil {
		return err
	}

	payload := append([]byte{0}, data...)
	encMessageBox := box.SealAfterPrecomputation(nil, payload, &prefixedNonce, (*[32]byte)(sk))

	copy(destHeader, []byte{7, 'M', 'E', 'S', 'S', 'A', 'G', 'E'})
	copy(destUnprefixedNonce, unprefixedNonce[:])
	copy(destEncMessageBox, encMessageBox)

	return nil
}
977758
func (b *OpenAPI3Builder) build(document *openapiv3.Document) (err error) {
	// Collect service type descriptions from Components/Schemas.
	if document.Components != nil && document.Components.Schemas != nil {
		for _, pair := range document.Components.Schemas.AdditionalProperties {
			t, err := b.buildTypeFromSchemaOrReference(pair.Name, pair.Value)
			if err != nil {
				return err
			}
			if t != nil {
				b.model.addType(t)
			}
		}
	}
	// Collect service method descriptions from each PathItem.
	if document.Paths != nil {
		for _, pair := range document.Paths.Path {
			b.buildMethodFromPathItem(pair.Name, pair.Value)
		}
	}
	return err
}
512634
func (b *Builder) Build() error {
	layerIDs := []string{}
	layers := []mml.Layer{}

	var mmlObj *mml.MML
	if b.mml != "" {
		r, err := os.Open(b.mml)
		if err != nil {
			return err
		}
		defer r.Close()
		mmlObj, err = mml.Parse(r)
		if err != nil {
			return err
		}
		if len(b.mss) == 0 {
			for _, s := range mmlObj.Stylesheets {
				b.mss = append(b.mss, filepath.Join(filepath.Dir(b.mml), s))
			}
		}

		for _, l := range mmlObj.Layers {
			layers = append(layers, l)
			layerIDs = append(layerIDs, l.ID)
		}
	}

	carto := mss.New()

	for _, mss := range b.mss {
		err := carto.ParseFile(mss)
		if err != nil {
			return err
		}
	}

	if err := carto.Evaluate(); err != nil {
		return err
	}

	if m, ok := b.dstMap.(MapZoomScaleSetter); ok {
		if mmlObj != nil && mmlObj.Map.ZoomScales != nil {
			m.SetZoomScales(mmlObj.Map.ZoomScales)
		}
	}

	if b.mml == "" {
		layerIDs = carto.MSS().Layers()
		for _, layerID := range layerIDs {
			layers = append(layers,
				// XXX assume we only have LineStrings for -mss only export
				mml.Layer{ID: layerID, Type: mml.LineString},
			)
		}
	}

	for _, l := range layers {
		rules := carto.MSS().LayerRules(l.ID, l.Classes...)

		if b.dumpRules != nil {
			for _, r := range rules {
				fmt.Fprintln(b.dumpRules, r.String())
			}
		}
		if len(rules) > 0 && (l.Active || b.includeInactive) {
			b.dstMap.AddLayer(l, rules)
		}
	}

	if m, ok := b.dstMap.(MapOptionsSetter); ok {
		if bgColor, ok := carto.MSS().Map().GetColor("background-color"); ok {
			m.SetBackgroundColor(bgColor)
		}
	}
	return nil
}
1054102
func (o *FindTodosURL) Build() (*url.URL, error) {
	var _result url.URL

	var _path = "/"

	_basePath := o._basePath
	_result.Path = golangswaggerpaths.Join(_basePath, _path)

	qs := make(url.Values)

	var limit string
	if o.Limit != nil {
		limit = swag.FormatInt32(*o.Limit)
	}
	if limit != "" {
		qs.Set("limit", limit)
	}

	var since string
	if o.Since != nil {
		since = swag.FormatInt64(*o.Since)
	}
	if since != "" {
		qs.Set("since", since)
	}

	_result.RawQuery = qs.Encode()

	return &_result, nil
}
162142
func (m *Manager) BuildHandlers(rootCtx context.Context, entryPoints []string) map[string]*tcp.Router {
	entryPointsRouters := m.filteredRouters(rootCtx, entryPoints)

	entryPointHandlers := make(map[string]*tcp.Router)
	for _, entryPointName := range entryPoints {
		entryPointName := entryPointName

		routers := entryPointsRouters[entryPointName]

		ctx := log.With(rootCtx, log.Str(log.EntryPointName, entryPointName))

		handler, err := m.buildEntryPointHandler(ctx, routers, m.httpHandlers[entryPointName], m.httpsHandlers[entryPointName])
		if err != nil {
			log.FromContext(ctx).Error(err)
			continue
		}
		entryPointHandlers[entryPointName] = handler
	}
	return entryPointHandlers
}
302421
func (builder *StoreBucketPropsCommandBuilder) Build() (Command, error) {
	if builder.protobuf == nil {
		panic("builder.protobuf must not be nil")
	}
	if err := validateLocatable(builder.protobuf); err != nil {
		return nil, err
	}
	return &StoreBucketPropsCommand{protobuf: builder.protobuf}, nil
}
187046
func (cl *CommandLine) BuildArgs() []string {
	targetArgs := cl.Target.buildArgsForTarget()
	args := make([]string, 0, len(cl.Flags)+1+len(targetArgs)+len(cl.Args))
	for _, flag := range cl.Flags {
		args = append(args, flag.String())
	}

	var flagSeparator []string
	if cl.FlagSeparator {
		flagSeparator = []string{"--"}
	}

	// If our target is specified as a flag, we need to emit it before the flag
	// separator. If our target is specified as a positional argument (e.g.,
	// CommandTarget), we can emit it on either side.
	if !cl.Target.followsFlagSeparator() {
		args = append(args, targetArgs...)
		args = append(args, flagSeparator...)
	} else {
		args = append(args, flagSeparator...)
		args = append(args, targetArgs...)
	}

	args = append(args, cl.Args...)
	return args
}
962248
func (builder *DeleteValueCommandBuilder) Build() (Command, error) {
	if builder.protobuf == nil {
		panic("builder.protobuf must not be nil")
	}
	if err := validateLocatable(builder.protobuf); err != nil {
		return nil, err
	}
	return &DeleteValueCommand{
		timeoutImpl: timeoutImpl{
			timeout: builder.timeout,
		},
		protobuf: builder.protobuf,
	}, nil
}
233399
func BuildDir(path string) option {
	return func(c *sass) error {
		c.ctx.BuildDir = path
		return nil
	}
}
1273719
func (o *GetMapNameURL) Build() (*url.URL, error) {
	var _result url.URL

	var _path = "/map/{name}"

	name := o.Name
	if name != "" {
		_path = strings.Replace(_path, "{name}", name, -1)
	} else {
		return nil, errors.New("name is required on GetMapNameURL")
	}

	_basePath := o._basePath
	if _basePath == "" {
		_basePath = "/v1"
	}
	_result.Path = golangswaggerpaths.Join(_basePath, _path)

	return &_result, nil
}