Skip to content

Commit

Permalink
simplify buildsubtask id handling
Browse files Browse the repository at this point in the history
  • Loading branch information
MarlonGamez committed Jul 8, 2021
1 parent a4cf386 commit 3f58723
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 21 deletions.
2 changes: 1 addition & 1 deletion pkg/skaffold/build/scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ func (s *scheduler) build(ctx context.Context, tags tag.ImageTags, i int) error
}
defer closeFn()

w = output.WithEventContext(w, constants.Build, strconv.Itoa(eventV2.GetArtifactID(a)), "skaffold")
w = output.WithEventContext(w, constants.Build, a.ImageName, "skaffold")
finalTag, err := performBuild(ctx, w, tags, a, s.artifactBuilder)
if err != nil {
event.BuildFailed(a.ImageName, err)
Expand Down
20 changes: 1 addition & 19 deletions pkg/skaffold/event/v2/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,9 @@ package v2

import (
"fmt"
"strconv"

"github.com/GoogleContainerTools/skaffold/pkg/skaffold/constants"
sErrors "github.com/GoogleContainerTools/skaffold/pkg/skaffold/errors"
latestV1 "github.com/GoogleContainerTools/skaffold/pkg/skaffold/schema/latest/v1"
proto "github.com/GoogleContainerTools/skaffold/proto/v2"
)

Expand All @@ -31,22 +29,6 @@ const (
Build = "Build"
)

var artifactIDs = map[string]int{}

func AssignArtifactIDs(artifacts []*latestV1.Artifact) {
for i, a := range artifacts {
artifactIDs[a.ImageName] = i
}
}

func GetArtifactID(a *latestV1.Artifact) int {
if id, ok := artifactIDs[a.ImageName]; ok {
return id
}

return -1
}

func CacheCheckInProgress(artifact string) {
buildSubtaskEvent(artifact, Cache, InProgress, nil)
}
Expand Down Expand Up @@ -77,7 +59,7 @@ func buildSubtaskEvent(artifact, step, status string, err error) {
aErr = sErrors.ActionableErrV2(handler.cfg, constants.Build, err)
}
handler.handleBuildSubtaskEvent(&proto.BuildSubtaskEvent{
Id: strconv.Itoa(artifactIDs[artifact]),
Id: artifact,
TaskId: fmt.Sprintf("%s-%d", constants.Build, handler.iteration),
Artifact: artifact,
Step: step,
Expand Down
1 change: 0 additions & 1 deletion pkg/skaffold/runner/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ func (r *Builder) GetBuilds() []graph.Artifact {
// Build builds a list of artifacts.
func (r *Builder) Build(ctx context.Context, out io.Writer, artifacts []*latestV1.Artifact) ([]graph.Artifact, error) {
eventV2.TaskInProgress(constants.Build, "Build containers")
eventV2.AssignArtifactIDs(artifacts)
out = output.WithEventContext(out, constants.Build, eventV2.SubtaskIDNone, "skaffold")

// Use tags directly from the Kubernetes manifests.
Expand Down

0 comments on commit 3f58723

Please sign in to comment.