// GetRebuildImage obtains the metadata information for the image specified in
// a s2i rebuild operation. Assumptions are made that the build is available
// locally since it should have been previously built.
965544
func GetRebuildImage(docker Docker, config *api.Config) (*PullResult, error) {
	return pullAndCheck(config.Tag, docker, config.BuilderPullPolicy, config)
}
555543
func getBuild(c context.Context, id buildbot.BuildID, fetchAnnotations, fetchChanges bool) (*buildbot.Build, error) {
	if !EmulationEnabled(c) {
		return getDatastoreBuild(c, id)
	}

	// Is it a LUCI build?
	build, err := getEmulatedBuild(c, id, fetchAnnotations, fetchChanges)
	switch {
	case err != nil:
		return nil, err
	case build != nil:
		// does not exist or experimental.
		return build, nil
	}

	// Is it a Buildbot build?
	build, err = getDatastoreBuild(c, id)
	switch {
	case err != nil:
		return nil, err
	case build == nil:
		return nil, nil
	case build.Experimental():
		return nil, nil
	default:
		return build, nil
	}
}
541796
func (e *Engine) ImageBuildCachePrune(ctx context.Context, all bool) (uint64, error) {
	r, err := e.client.BuildCachePrune(ctx, dockertypes.BuildCachePruneOptions{All: all})
	if err != nil {
		return 0, err
	}
	return r.SpaceReclaimed, nil
}
1325334
func (c *ApiController) GetBuildsAll() {
	log.Info("Get all builds")

	builds := models.GetAllBuilds()

	c.Data["json"] = builds
	c.ServeJson()
}
1374893
func GetBuild(c context.Context, host, taskId string) (*ui.MiloBuildLegacy, error) {
	if taskId == "" {
		return nil, errors.New("no swarming task id", grpcutil.InvalidArgumentTag)
	}

	sf, err := NewProdService(c, host)
	if err != nil {
		return nil, err
	}

	return SwarmingBuildImpl(c, sf, taskId)
}
1337085
func (bs *BuildSummary) GetBuildName() string {
	if bs == nil {
		return ""
	}
	li := strings.LastIndex(bs.BuildID, "/")
	if li == -1 {
		return ""
	}
	// Don't include the "/", therefore li+1.
	return bs.BuildID[li+1:]
}
284803
func (s *Service) GetBuildbotBuildsJSON(c context.Context, req *milo.BuildbotBuildsRequest) (
	*milo.BuildbotBuildsJSON, error) {

	apiUsage.Add(c, 1, "GetBuildbotBuildsJSON", req.Master, req.Builder, req.ExcludeDeprecated, req.NoEmulation)

	if req.Master == "" {
		return nil, status.Errorf(codes.InvalidArgument, "No master specified")
	}
	if req.Builder == "" {
		return nil, status.Errorf(codes.InvalidArgument, "No builder specified")
	}

	limit := int(req.Limit)
	if limit == 0 {
		limit = 20
	}

	cu := auth.CurrentUser(c)
	logging.Debugf(c, "%s is requesting %s/%s (limit %d)",
		cu.Identity, req.Master, req.Builder, limit)

	if err := buildstore.CanAccessMaster(c, req.Master); err != nil {
		return nil, err
	}

	q := buildstore.Query{
		Master:  req.Master,
		Builder: req.Builder,
		Limit:   limit,
	}
	if !req.IncludeCurrent {
		q.Finished = buildstore.Yes
	}
	res, err := buildstore.GetBuilds(c, q)
	switch code := grpcutil.Code(err); {
	case code == codes.NotFound, code == codes.PermissionDenied:
		return nil, errNotFoundGRPC
	case err != nil:
		return nil, err
	}

	buildsJSON := &milo.BuildbotBuildsJSON{
		Builds: make([]*milo.BuildbotBuildJSON, len(res.Builds)),
	}
	for i, b := range res.Builds {
		if req.ExcludeDeprecated {
			excludeDeprecatedFromBuild(b)
		}
		bs, err := json.Marshal(b)
		if err != nil {
			return nil, err
		}
		buildsJSON.Builds[i] = &milo.BuildbotBuildJSON{Data: bs}
	}
	return buildsJSON, nil
}
673564
func getDatastoreBuild(c context.Context, id buildbot.BuildID) (*buildbot.Build, error) {
	if err := id.Validate(); err != nil {
		return nil, err
	}

	entity := &buildEntity{
		Master:      id.Master,
		Buildername: id.Builder,
		Number:      id.Number,
	}

	err := datastore.Get(c, entity)
	if err == datastore.ErrNoSuchEntity {
		return nil, nil
	}

	entity.addViewPath()

	return (*buildbot.Build)(entity), err
}
197944
func (r *ReleaseAsset) GetSize() int {
	if r == nil || r.Size == nil {
		return 0
	}
	return *r.Size
}
1323420
func (obj *GenericDimension) GetLayout(ctx context.Context) (*GenericDimensionLayout, error) {
	result := &struct {
		Layout *GenericDimensionLayout	`json:"qLayout"`
	} {}
	err := obj.rpc(ctx, "GetLayout", result)
	return result.Layout, err 
}
865092
func handleLUCIBuildLegacy(c *router.Context, bucket, builder, numberOrId string) error {
	var address string
	if strings.HasPrefix(numberOrId, "b") {
		address = numberOrId[1:]
	} else {
		address = fmt.Sprintf("%s/%s/%s", bucket, builder, numberOrId)
	}

	build, err := buildbucket.GetBuildLegacy(c.Context, address, true)
	return renderBuildLegacy(c, build, true, err)
}
198715
func (client Client) GetLastBuild(jobName string) (LastBuild, error) {
	retry := retry.New(3, retry.DefaultBackoffFunc)

	var data []byte
	work := func() error {
		req, err := http.NewRequest("GET", fmt.Sprintf("%s/job/%s/lastBuild/api/json?depth=1&tree=timestamp,result,url", client.baseURL.String(), jobName), nil)
		if err != nil {
			return err
		}
		req.Header.Set("Accept", "application/json")
		req.SetBasicAuth(client.userName, client.password)

		var responseCode int
		responseCode, data, err = consumeResponse(req)
		if err != nil {
			return err
		}

		if responseCode != http.StatusOK {
			return fmt.Errorf("Status code: %d, response %s", responseCode, string(data))
		}
		return nil
	}
	if err := retry.Try(work); err != nil {
		return LastBuild{}, err
	}

	var lastBuild LastBuild
	if err := json.Unmarshal(data, &lastBuild); err != nil {
		return LastBuild{}, err
	}
	return lastBuild, nil
}
300995
func (obj *GenericDimension) GetDimension(ctx context.Context) (*NxLibraryDimensionDef, error) {
	result := &struct {
		Dim *NxLibraryDimensionDef	`json:"qDim"`
	} {}
	err := obj.rpc(ctx, "GetDimension", result)
	return result.Dim, err 
}
861867
func (c *Client) GetVolume(appID, id string) (*ct.Volume, error) {
	if appID == "" {
		return nil, errors.New("controller: missing app ID")
	}
	if id == "" {
		return nil, errors.New("controller: missing id")
	}
	vol := &ct.Volume{}
	return vol, c.Get(fmt.Sprintf("/apps/%s/volumes/%s", appID, id), vol)
}
822328
func handleLUCIBuild(c *router.Context) error {
	bucket := c.Params.ByName("bucket")
	buildername := c.Params.ByName("builder")
	numberOrId := c.Params.ByName("numberOrId")
	forceBlamelist := c.Request.FormValue("blamelist") != ""

	if _, v2Bucket := deprecated.BucketNameToV2(bucket); v2Bucket != "" {
		// Params bucket is a v1 bucket, so call the legacy endpoint.
		return handleLUCIBuildLegacy(c, bucket, buildername, numberOrId)
	}

	// TODO(hinoka): Once v2 is default, redirect v1 bucketnames to v2 bucketname URLs.
	br := buildbucketpb.GetBuildRequest{}
	if strings.HasPrefix(numberOrId, "b") {
		id, err := strconv.ParseInt(numberOrId[1:], 10, 64)
		if err != nil {
			return errors.Annotate(err, "bad build id").Tag(grpcutil.InvalidArgumentTag).Err()
		}
		br.Id = int64(id)
	} else {
		number, err := strconv.Atoi(numberOrId)
		if err != nil {
			return errors.Annotate(err, "bad build number").Tag(grpcutil.InvalidArgumentTag).Err()
		}
		br.BuildNumber = int32(number)
		br.Builder = &buildbucketpb.BuilderID{
			Project: c.Params.ByName("project"),
			Bucket:  bucket,
			Builder: buildername,
		}
	}

	bp, err := buildbucket.GetBuildPage(c, br, forceBlamelist)
	return renderBuild(c, bp, err)
}
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)
}
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
}