// GetBuild mocks base method
7916
func (m *MockBuildsClient) GetBuild(ctx context.Context, in *GetBuildRequest, opts ...grpc.CallOption) (*Build, error) {
	m.ctrl.T.Helper()
	varargs := []interface{}{ctx, in}
	for _, a := range opts {
		varargs = append(varargs, a)
	}
	ret := m.ctrl.Call(m, "GetBuild", varargs...)
	ret0, _ := ret[0].(*Build)
	ret1, _ := ret[1].(error)
	return ret0, ret1
}
1206965
func (c ClientBuildConfigClient) Get(namespace, name string, options metav1.GetOptions) (*buildv1.BuildConfig, error) {
	return c.Client.BuildV1().BuildConfigs(namespace).Get(name, options)
}
457048
func (m *MockBuildsServer) SearchBuilds(arg0 context.Context, arg1 *SearchBuildsRequest) (*SearchBuildsResponse, error) {
	m.ctrl.T.Helper()
	ret := m.ctrl.Call(m, "SearchBuilds", arg0, arg1)
	ret0, _ := ret[0].(*SearchBuildsResponse)
	ret1, _ := ret[1].(error)
	return ret0, ret1
}
1344960
func GetBuilder(c context.Context, bid BuilderID, limit int, cursor string) (*ui.Builder, error) {
	host, err := getHost(c)
	if err != nil {
		return nil, err
	}

	if limit < 0 {
		limit = 20
	}

	result := &ui.Builder{
		Name: bid.Builder,
	}
	if host == "debug" {
		return result, getDebugBuilds(c, bid, limit, result)
	}
	client, err := newBuildbucketClient(c, host)
	if err != nil {
		return nil, err
	}

	fetch := func(statusFilter string, limit int, cursor string) (result []*ui.BuildSummary, nextCursor string, err error) {
		msgs, nextCursor, err := fetchBuilds(c, client, bid, statusFilter, limit, cursor)
		if err != nil {
			logging.WithError(err).Errorf(c, "Could not fetch %s builds", statusFilter)
			return
		}
		result = toMiloBuildsSummaries(c, msgs)
		return
	}
	return result, parallel.FanOutIn(func(work chan<- func() error) {
		work <- func() error {
			return ensureDefined(c, host, bid)
		}
		work <- func() (err error) {
			result.MachinePool, err = getPool(c, bid)
			return
		}
		work <- func() (err error) {
			result.PendingBuilds, _, err = fetch(bbv1.StatusScheduled, -1, "")
			return
		}
		work <- func() (err error) {
			result.CurrentBuilds, _, err = fetch(bbv1.StatusStarted, -1, "")
			return
		}
		work <- func() (err error) {
			result.FinishedBuilds, result.NextCursor, err = fetch(bbv1.StatusCompleted, limit, cursor)
			result.PrevCursor = backCursor(c, bid, limit, cursor, result.NextCursor) // Safe to do even with error.
			return
		}
	})
}
1041070
func (_m *APIClient) ImageBuild(ctx context.Context, _a1 io.Reader, options types.ImageBuildOptions) (types.ImageBuildResponse, error) {
	ret := _m.Called(ctx, _a1, options)

	var r0 types.ImageBuildResponse
	if rf, ok := ret.Get(0).(func(context.Context, io.Reader, types.ImageBuildOptions) types.ImageBuildResponse); ok {
		r0 = rf(ctx, _a1, options)
	} else {
		r0 = ret.Get(0).(types.ImageBuildResponse)
	}

	var r1 error
	if rf, ok := ret.Get(1).(func(context.Context, io.Reader, types.ImageBuildOptions) error); ok {
		r1 = rf(ctx, _a1, options)
	} else {
		r1 = ret.Error(1)
	}

	return r0, r1
}
307111
func (jenkins *Jenkins) GetBuildConsoleOutput(build Build) ([]byte, error) {
	requestUrl := fmt.Sprintf("%s/consoleText", build.Url)
	req, err := http.NewRequest("GET", requestUrl, nil)
	if err != nil {
		return nil, err
	}

	res, err := jenkins.sendRequest(req)
	if err != nil {
		return nil, err
	}

	defer res.Body.Close()
	return ioutil.ReadAll(res.Body)
}
1050723
func GetBuildsWithProjectName(projectName string) []*Build {
	o := orm.NewOrm()

	var builds []*Build
	num, err := o.QueryTable("build").Filter("project_name", projectName).All(&builds)
	fmt.Printf("Returned Rows Num: %s, %s", num, err)
	return builds
}
849150
func GetBuildpackDir() (string, error) {
	var err error

	bpDir := os.Getenv("BUILDPACK_DIR")

	if bpDir == "" {
		bpDir, err = filepath.Abs(filepath.Join(filepath.Dir(os.Args[0]), ".."))

		if err != nil {
			return "", err
		}
	}

	return bpDir, nil
}
965544
func GetRebuildImage(docker Docker, config *api.Config) (*PullResult, error) {
	return pullAndCheck(config.Tag, docker, config.BuilderPullPolicy, config)
}
950163
func GetBuildPodName(build *buildapi.Build) string {
	return apihelpers.GetPodName(build.Name, buildPodSuffix)
}
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
}
855267
func GetBuild(c context.Context, id buildbot.BuildID) (*ui.MiloBuildLegacy, error) {
	if err := id.Validate(); err != nil {
		return nil, err
	}
	if err := buildstore.CanAccessMaster(c, id.Master); err != nil {
		return nil, err
	}

	switch b, err := buildstore.GetBuild(c, id); {
	case err != nil:
		return nil, err
	case b == nil:
		return nil, errors.Reason("build %s not found", &id).Tag(grpcutil.NotFoundTag).Err()
	default:
		return renderBuild(c, b, true), nil
	}
}
661049
func getBuildDefaults(pluginConfig map[string]*legacyconfigv1.AdmissionPluginConfig) (*openshiftcontrolplanev1.BuildDefaultsConfig, error) {
	const buildDefaultsPlugin = "BuildDefaults"
	uncastConfig, err := getPluginConfigObj(pluginConfig, buildDefaultsPlugin, &openshiftcontrolplanev1.BuildDefaultsConfig{})
	if err != nil {
		return nil, err
	}
	if uncastConfig == nil {
		return nil, nil
	}
	config, ok := uncastConfig.(*openshiftcontrolplanev1.BuildDefaultsConfig)
	if !ok {
		return nil, fmt.Errorf("expected BuildDefaultsConfig, not %T", uncastConfig)
	}

	return config, nil
}
595356
func (m *MockCommonAPIClient) ImageBuild(ctx context.Context, context io.Reader, options types.ImageBuildOptions) (types.ImageBuildResponse, error) {
	ret := m.ctrl.Call(m, "ImageBuild", ctx, context, options)
	ret0, _ := ret[0].(types.ImageBuildResponse)
	ret1, _ := ret[1].(error)
	return ret0, ret1
}
102454
func (m *MockCustomResourceDefinitionInterface) Get(arg0 string, arg1 v1.GetOptions) (*v1beta1.CustomResourceDefinition, error) {
	ret := m.ctrl.Call(m, "Get", arg0, arg1)
	ret0, _ := ret[0].(*v1beta1.CustomResourceDefinition)
	ret1, _ := ret[1].(error)
	return ret0, ret1
}
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
}
410237
func GetBuildFromPod(pod *corev1.Pod) (*buildv1.Build, error) {
	if len(pod.Spec.Containers) == 0 {
		return nil, errors.New("unable to get build from pod: pod has no containers")
	}

	buildEnvVar := getEnvVar(&pod.Spec.Containers[0], "BUILD")
	if len(buildEnvVar) == 0 {
		return nil, errors.New("unable to get build from pod: BUILD environment variable is empty")
	}

	obj, err := runtime.Decode(buildscheme.Decoder, []byte(buildEnvVar))
	if err != nil {
		return nil, fmt.Errorf("unable to get build from pod: %v", err)
	}
	build, ok := obj.(*buildv1.Build)
	if !ok {
		return nil, fmt.Errorf("unable to get build from pod: %v", errors.New("decoded object is not of type Build"))
	}
	return build, nil
}