Skip to content

Commit

Permalink
Merge pull request #309 from depot/fix-default-path
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobwgillespie authored Jan 24, 2025
2 parents 013d9f6 + 91a43e2 commit cc68bbd
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 17 deletions.
39 changes: 23 additions & 16 deletions pkg/build/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,18 +99,15 @@ func NewBuild(ctx context.Context, req *cliv1.CreateBuildRequest, token string)
return Build{}, err
}

build, err := FromExistingBuild(ctx, res.Msg.BuildId, res.Msg.BuildToken)
build, err := FromExistingBuild(ctx, res.Msg.BuildId, res.Msg.BuildToken, res)
if err != nil {
return Build{}, err
}

build.Response = res
build.BuildURL = res.Msg.BuildUrl

return build, nil
}

func FromExistingBuild(ctx context.Context, buildID, token string) (Build, error) {
func FromExistingBuild(ctx context.Context, buildID, token string, buildRes *connect.Response[cliv1.CreateBuildResponse]) (Build, error) {
client := depotapi.NewBuildClient()

finish := func(buildErr error) {
Expand All @@ -135,19 +132,29 @@ func FromExistingBuild(ctx context.Context, buildID, token string) (Build, error
}
}

req := cliv1.GetBuildRequest{BuildId: buildID}
res, err := client.GetBuild(ctx, depotapi.WithAuthentication(connect.NewRequest(&req), token))
if err != nil {
return Build{}, err
if buildRes == nil {
req := cliv1.GetBuildRequest{BuildId: buildID}
res, err := client.GetBuild(ctx, depotapi.WithAuthentication(connect.NewRequest(&req), token))
if err != nil {
return Build{}, err
}
return Build{
ID: buildID,
Token: token,
Finish: finish,
BuildURL: res.Msg.BuildUrl,
projectID: res.Msg.ProjectId,
}, nil
} else {
return Build{
ID: buildID,
Token: token,
Finish: finish,
BuildURL: buildRes.Msg.BuildUrl,
Response: buildRes,
}, nil
}

return Build{
ID: buildID,
Token: token,
Finish: finish,
BuildURL: res.Msg.BuildUrl,
projectID: res.Msg.ProjectId,
}, nil
}

type authProvider struct {
Expand Down
2 changes: 1 addition & 1 deletion pkg/helpers/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ func BeginBuild(ctx context.Context, req *cliv1.CreateBuildRequest, token string
var build depotbuild.Build
var err error
if id := os.Getenv("DEPOT_BUILD_ID"); id != "" {
build, err = depotbuild.FromExistingBuild(ctx, id, token)
build, err = depotbuild.FromExistingBuild(ctx, id, token, nil)
} else {
build, err = depotbuild.NewBuild(ctx, req, token)
}
Expand Down

0 comments on commit cc68bbd

Please sign in to comment.