// GetBuild indicates an expected call of GetBuild
349641
func (mr *MockBuildsClientMockRecorder) GetBuild(ctx, in interface{}, opts ...interface{}) *gomock.Call {
	mr.mock.ctrl.T.Helper()
	varargs := append([]interface{}{ctx, in}, opts...)
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetBuild", reflect.TypeOf((*MockBuildsClient)(nil).GetBuild), varargs...)
}
159811
func GetBuildSummary(c context.Context, id int64) (*model.BuildSummary, error) {
	// The host is set to prod because buildbot is hardcoded to talk to prod.
	uri := fmt.Sprintf("buildbucket://cr-buildbucket.appspot.com/build/%d", id)
	bs := make([]*model.BuildSummary, 0, 1)
	q := datastore.NewQuery("BuildSummary").Eq("ContextURI", uri).Limit(1)
	switch err := datastore.GetAll(c, q, &bs); {
	case err != nil:
		return nil, common.ReplaceNSEWith(err.(errors.MultiError), ErrNotFound)
	case len(bs) == 0:
		return nil, ErrNotFound
	default:
		return bs[0], nil
	}
}
61183
func GetBuilderID(c context.Context, id int64) (builder *buildbucketpb.BuilderID, number int32, err error) {
	host, err := getHost(c)
	if err != nil {
		return
	}
	client, err := buildbucketClient(c, host, auth.AsUser)
	if err != nil {
		return
	}
	br, err := client.GetBuild(c, &buildbucketpb.GetBuildRequest{
		Id:     id,
		Fields: builderIDMask,
	})
	switch grpcutil.Code(err) {
	case codes.OK:
		builder = br.Builder
		number = br.Number
	case codes.NotFound:
		if auth.CurrentIdentity(c) == identity.AnonymousIdentity {
			err = ErrNotLoggedIn
			return
		}
		fallthrough
	case codes.PermissionDenied:
		err = ErrNotFound
	}
	return
}
1001934
func (c *ApiController) GetActiveBuilds() {
	// TODO(tobe): this is not implemented because nobody uses it yet.
	log.Info("Get active builds")

	result := "Not implemented"
	c.Ctx.WriteString(result)
}
1145032
func GetBuildLegacy(c context.Context, address string, fetchFull bool) (*ui.MiloBuildLegacy, error) {
	bbBuildMessage, err := GetRawBuild(c, address)
	if err != nil {
		return nil, err
	}
	return ToMiloBuild(c, bbBuildMessage, fetchFull)
}
962029
func (c *ApiController) GetBuildsWithProjectName() {
	log.Info("Get builds with project name")

	projectName := c.GetString(":projectName")

	builds := models.GetBuildsWithProjectName(projectName)

	c.Data["json"] = builds
	c.ServeJson()
}
821506
func (jenkins *Jenkins) GetBuild(job Job, number int) (build Build, err error) {
	err = jenkins.get(fmt.Sprintf("/job/%s/%d", job.Name, number), nil, &build)
	return
}
1131276
func (s *BuildStore) Get(ctx context.Context) (chronograf.BuildInfo, error) {
	var build chronograf.BuildInfo
	if err := s.client.db.View(func(tx *bolt.Tx) error {
		var err error
		build, err = s.get(ctx, tx)
		if err != nil {
			return err
		}
		return nil
	}); err != nil {
		return chronograf.BuildInfo{}, err
	}

	return build, nil
}
50088
func (c ClientBuildClient) DeleteBuild(build *buildv1.Build) error {
	return c.Client.BuildV1().Builds(build.Namespace).Delete(build.Name, &metav1.DeleteOptions{})
}
896669
func (b BuilderID) Get(c context.Context, limit int, cursor string) (*ui.Builder, error) {
	// TODO(iannucci): replace these implementations with a BuildSummary query.
	source, group, builderName, err := b.Split()
	if err != nil {
		return nil, err
	}

	var builder *ui.Builder
	var consoles []*common.Console
	err = parallel.FanOutIn(func(work chan<- func() error) {
		work <- func() (err error) {
			switch source {
			case "buildbot":
				builder, err = buildbot.GetBuilder(c, group, builderName, limit, cursor)
			case "buildbucket":
				bid := buildbucket.NewBuilderID(group, builderName)
				builder, err = buildbucket.GetBuilder(c, bid, limit, cursor)
			default:
				panic(fmt.Errorf("unexpected build source %q", source))
			}
			return
		}
		work <- func() (err error) {
			consoles, err = common.GetAllConsoles(c, string(b))
			return
		}
	})
	if err != nil {
		return nil, err
	}

	builder.Groups = make([]*ui.Link, len(consoles))
	for i, c := range consoles {
		builder.Groups[i] = ui.NewLink(
			fmt.Sprintf("%s / %s", c.ProjectID(), c.ID),
			fmt.Sprintf("/p/%s/g/%s", c.ProjectID(), c.ID),
			fmt.Sprintf("builder group %s in project %s", c.ID, c.ProjectID()))
	}
	sort.Slice(builder.Groups, func(i, j int) bool {
		return builder.Groups[i].Label < builder.Groups[j].Label
	})

	for _, b := range builder.FinishedBuilds {
		if len(b.Blame) > 0 {
			builder.HasBlamelist = true
			break
		}
	}

	return builder, nil
}
398173
func (e *Invocation) GetProjectID() string {
	parts := strings.Split(e.JobID, "/")
	return parts[0]
}
1229547
func (bc *BuildController) handleBuild(build *buildv1.Build) error {

	// If pipeline build, handle pruning.
	if build.Spec.Strategy.JenkinsPipelineStrategy != nil {
		if buildutil.IsBuildComplete(build) {
			if err := common.HandleBuildPruning(buildutil.ConfigNameForBuild(build), build.Namespace, bc.buildLister, bc.buildConfigGetter, bc.buildDeleter); err != nil {
				utilruntime.HandleError(fmt.Errorf("failed to prune builds for %s/%s: %v", build.Namespace, build.Name, err))
			}
		}
	}

	if shouldIgnore(build) {
		return nil
	}

	klog.V(4).Infof("Handling build %s", buildDesc(build))

	pod, podErr := bc.podStore.Pods(build.Namespace).Get(buildapihelpers.GetBuildPodName(build))

	// Technically the only error that is returned from retrieving the pod is the
	// NotFound error so this check should not be needed, but leaving here in case
	// that changes in the future.
	if podErr != nil && !errors.IsNotFound(podErr) {
		return podErr
	}

	var update *buildUpdate
	var err, updateErr error

	switch {
	case shouldCancel(build):
		update, err = bc.cancelBuild(build)
	case build.Status.Phase == buildv1.BuildPhaseNew:
		update, err = bc.handleNewBuild(build, pod)
	case build.Status.Phase == buildv1.BuildPhasePending,
		build.Status.Phase == buildv1.BuildPhaseRunning:
		update, err = bc.handleActiveBuild(build, pod)
	case buildutil.IsBuildComplete(build):
		update, err = bc.handleCompletedBuild(build, pod)
	}
	if update != nil && !update.isEmpty() {
		updateErr = bc.updateBuild(build, update, pod)
	}
	if err != nil {
		return err
	}
	if updateErr != nil {
		return updateErr
	}
	return nil
}
528361
func getRelatedBuilds(c context.Context, client buildbucketpb.BuildsClient, b *buildbucketpb.Build) ([]*ui.Build, error) {
	var bs []string
	for _, buildset := range protoutil.BuildSets(b) {
		// HACK(hinoka): Remove the commit/git/ buildsets because we know they're redundant
		// with the commit/gitiles/ buildsets, and we don't need to ask Buildbucket twice.
		if strings.HasPrefix(buildset, "commit/git/") {
			continue
		}
		bs = append(bs, buildset)
	}
	if len(bs) == 0 {
		// No buildset? No builds.
		return nil, nil
	}

	// Do the search request.
	// Use multiple requests instead of a single batch request.
	// A single large request is CPU bound to a single GAE instance on the buildbucket side.
	// Multiple requests allows the use of multiple GAE instances, therefore more parallelism.
	resps := make([]*buildbucketpb.SearchBuildsResponse, len(bs))
	if err := parallel.FanOutIn(func(ch chan<- func() error) {
		for i, buildset := range bs {
			i := i
			buildset := buildset
			ch <- func() (err error) {
				logging.Debugf(c, "Searching for %s (%d)", buildset, i)
				resps[i], err = client.SearchBuilds(c, searchBuildset(buildset, summaryBuildsMask))
				return
			}
		}
	}); err != nil {
		return nil, err
	}

	// Dedupe builds.
	// It's possible since we've made multiple requests that we got back the same builds
	// multiple times.
	seen := map[int64]bool{} // set of build IDs.
	result := []*ui.Build{}
	for _, resp := range resps {
		for _, rb := range resp.GetBuilds() {
			if seen[rb.Id] {
				continue
			}
			seen[rb.Id] = true
			result = append(result, &ui.Build{rb})
		}
	}

	// Sort builds by ID.
	sort.Slice(result, func(i, j int) bool { return result[i].Id < result[j].Id })

	return result, nil
}
577490
func (j *Jenkins) GetAllBuildIds(job string) ([]JobBuild, error) {
	jobObj, err := j.GetJob(job)
	if err != nil {
		return nil, err
	}
	return jobObj.GetAllBuildIds()
}
652770
func (s *Server) getBuilder(path string) (*ring.Builder, error) {
	_, b, err := ring.RingOrBuilder(path)
	return b, err
}
1140226
func getEmulatedBuild(c context.Context, id buildbot.BuildID, fetchAnnotations, fetchChanges bool) (*buildbot.Build, error) {
	if err := id.Validate(); err != nil {
		return nil, err
	}

	buildbucketBuild, err := EmulationOf(c, id)
	switch {
	case err != nil:
		return nil, err
	case buildbucketBuild == nil:
		return nil, nil
	}

	buildbotBuild, err := buildFromBuildbucket(c, id.Master, buildbucketBuild, fetchAnnotations)
	switch {
	case ErrNoBuildNumber.In(err):
		// This is an old buildbucket build without a build number.  Just drop it.
		// All emulated builds should have a build number.
		return nil, nil
	case err != nil:
		return nil, err
	}

	if fetchChanges {
		if err := blame(c, buildbotBuild); err != nil {
			return nil, err
		}
	}

	return buildbotBuild, nil
}
711906
func getBuiltinDriver(name, home string, options []string, uidMaps, gidMaps []idtools.IDMap) (Driver, error) {
	if initFunc, exists := drivers[name]; exists {
		return initFunc(filepath.Join(home, name), options, uidMaps, gidMaps)
	}
	logrus.Errorf("Failed to built-in GetDriver graph %s %s", name, home)
	return nil, ErrNotSupported
}