Skip to content

Commit e07fe94

Browse files
committed
Add support for buildCommitTarget
1 parent fbb7ea6 commit e07fe94

File tree

5 files changed

+39
-67
lines changed

5 files changed

+39
-67
lines changed

activestate.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -467,3 +467,4 @@ events:
467467
- name: file-changed
468468
scope: ["internal/locale/locales"]
469469
value: build
470+
config_version: 1

internal/runners/eval/rationalize.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ func rationalizeError(rerr *error) {
2222
switch {
2323
case errors.Is(*rerr, rationalize.ErrNotAuthenticated):
2424
*rerr = errs.WrapUserFacing(*rerr,
25-
locale.T("err_init_authenticated"),
25+
locale.Tl("err_eval_not_authenticated", "You need to authenticate to evaluate a target"),
2626
errs.SetInput(),
2727
)
2828

pkg/platform/api/buildplanner/model/buildplan.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,7 @@ func processPlanningError(message string, subErrors []*BuildExprLocation) error
431431
}
432432
}
433433
}
434+
fmt.Println("Returning BuildPlannerError")
434435
return &BuildPlannerError{
435436
ValidationErrors: errs,
436437
IsTransient: isTransient,
@@ -559,7 +560,7 @@ type MergeCommitResult struct {
559560
}
560561

561562
type BuildTargetResult struct {
562-
Project *Project `json:"Project"`
563+
Build *Build `json:"buildCommitTarget"`
563564
*Error
564565
*NotFoundError
565566
}

pkg/platform/api/buildplanner/request/evaluate.go

Lines changed: 32 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -15,56 +15,42 @@ type evaluate struct {
1515

1616
func (b *evaluate) Query() string {
1717
return `
18-
query ($organization: String!, $project: String!, $commitId: String!, $target: String!) {
19-
project(organization: $organization, project: $project) {
20-
... on Project {
18+
mutation ($organization: String!, $project: String!, $commitId: String!, $target: String) {
19+
buildCommitTarget(
20+
input: {organization: $organization, project: $project, commitId: $commitId, target: $target}
21+
) {
22+
... on Build {
2123
__typename
22-
commit(vcsRef: $commitId) {
23-
... on Commit {
24-
__typename
25-
build(target: $target) {
26-
... on Build {
27-
__typename
28-
status
29-
}
30-
... on PlanningError {
31-
__typename
32-
message
33-
subErrors {
34-
__typename
35-
... on GenericSolveError {
36-
path
37-
message
38-
isTransient
39-
validationErrors {
40-
error
41-
jsonPath
42-
}
43-
}
44-
... on RemediableSolveError {
45-
path
46-
message
47-
isTransient
48-
errorType
49-
validationErrors {
50-
error
51-
jsonPath
52-
}
53-
suggestedRemediations {
54-
remediationType
55-
command
56-
parameters
57-
}
58-
}
59-
}
60-
}
24+
status
25+
}
26+
... on PlanningError {
27+
__typename
28+
message
29+
subErrors {
30+
__typename
31+
... on GenericSolveError {
32+
path
33+
message
34+
isTransient
35+
validationErrors {
36+
error
37+
jsonPath
6138
}
6239
}
63-
... on NotFound {
64-
type
40+
... on RemediableSolveError {
41+
path
6542
message
66-
resource
67-
mayNeedAuthentication
43+
isTransient
44+
errorType
45+
validationErrors {
46+
error
47+
jsonPath
48+
}
49+
suggestedRemediations {
50+
remediationType
51+
command
52+
parameters
53+
}
6854
}
6955
}
7056
}

pkg/platform/model/buildplanner.go

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -687,28 +687,12 @@ func (bp *BuildPlanner) BuildTarget(owner, project, commitID, target string) err
687687
return processBuildPlannerError(err, "Failed to evaluate target")
688688
}
689689

690-
if resp.Project == nil {
691-
return errs.New("Project is nil")
692-
}
693-
694-
if bpModel.IsErrorResponse(resp.Project.Type) {
695-
return bpModel.ProcessProjectError(resp.Project, "Could not evaluate target")
696-
}
697-
698-
if resp.Project.Commit == nil {
699-
return errs.New("Commit is nil")
700-
}
701-
702-
if bpModel.IsErrorResponse(resp.Project.Commit.Type) {
703-
return bpModel.ProcessCommitError(resp.Project.Commit, "Could not process error response from evaluate target")
704-
}
705-
706-
if resp.Project.Commit.Build == nil {
690+
if resp.Build == nil {
707691
return errs.New("Build is nil")
708692
}
709693

710-
if bpModel.IsErrorResponse(resp.Project.Commit.Build.Type) {
711-
return bpModel.ProcessBuildError(resp.Project.Commit.Build, "Could not process error response from evaluate target")
694+
if bpModel.IsErrorResponse(resp.Build.Type) {
695+
return bpModel.ProcessBuildError(resp.Build, "Could not process error response from evaluate target")
712696
}
713697

714698
return nil

0 commit comments

Comments
 (0)