Skip to content

Commit

Permalink
Logstream: add more target fields to delta manifest (#3430)
Browse files Browse the repository at this point in the history
This will allow for saving and exposing these fields in the API.
  • Loading branch information
mikejholly authored Oct 31, 2023
1 parent 4a48d13 commit 2f5483c
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 10 deletions.
8 changes: 6 additions & 2 deletions earthfile2llb/converter.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,12 @@ func NewConverter(ctx context.Context, target domain.Target, bc *buildcontext.Da
ovVars = append(ovVars, fmt.Sprintf("%s=%s", k, v))
}
logbusTarget, err := opt.Logbus.Run().NewTarget(
sts.ID, target.String(), target.StringCanonical(), ovVars,
opt.PlatformResolver.Current().String(), opt.Runner)
sts.ID,
target,
ovVars,
opt.PlatformResolver.Current().String(),
opt.Runner,
)
if err != nil {
return nil, errors.Wrap(err, "new logbus target")
}
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ require (
github.com/docker/distribution v2.8.2+incompatible
github.com/docker/go-connections v0.4.0
github.com/dustin/go-humanize v1.0.1
github.com/earthly/cloud-api v1.0.1-0.20230914190823-c58662fdabd8
github.com/earthly/cloud-api v1.0.1-0.20231027183434-d79534194d95
github.com/earthly/earthly/ast v0.0.0-00010101000000-000000000000
github.com/earthly/earthly/util/deltautil v0.0.0-00010101000000-000000000000
github.com/elastic/go-sysinfo v1.9.0
Expand Down
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,10 @@ github.com/earthly/buildkit v0.0.0-20231025204852-d5e9d257c398 h1:Zco4CmxV7h1lds
github.com/earthly/buildkit v0.0.0-20231025204852-d5e9d257c398/go.mod h1:AJ3nMleWpsh6L06n2sFkT70+zGjnD9+rtsdmyw5YHLU=
github.com/earthly/cloud-api v1.0.1-0.20230914190823-c58662fdabd8 h1:8EW/AMPNtzOcExSV7Dk1weQGK/XqbAuhvLs062xlBH4=
github.com/earthly/cloud-api v1.0.1-0.20230914190823-c58662fdabd8/go.mod h1:rU/tYJ7GFBjdKAITV2heDbez++glpGSbtJaZcp73rNI=
github.com/earthly/cloud-api v1.0.1-0.20231026202759-f8644c3705ad h1:F5gQOTQ1KtzkiSLRMpw5C05dJw//OUcBehMZpoAdLYc=
github.com/earthly/cloud-api v1.0.1-0.20231026202759-f8644c3705ad/go.mod h1:rU/tYJ7GFBjdKAITV2heDbez++glpGSbtJaZcp73rNI=
github.com/earthly/cloud-api v1.0.1-0.20231027183434-d79534194d95 h1:stFmLhGY7dbf4UhBtbMIN+oaIMEDZez/epwHt7g6MqM=
github.com/earthly/cloud-api v1.0.1-0.20231027183434-d79534194d95/go.mod h1:rU/tYJ7GFBjdKAITV2heDbez++glpGSbtJaZcp73rNI=
github.com/earthly/fsutil v0.0.0-20230530182746-82567e6e2a92 h1:dy3w3B4OiDyQS+iHi/beUgMDJ1+fAAgbtr7OZ0d9ks0=
github.com/earthly/fsutil v0.0.0-20230530182746-82567e6e2a92/go.mod h1:q1CxMSzcAbjUkVGHoZeQUcCaALnaE4XdWk+zJcgMYFw=
github.com/elastic/go-sysinfo v1.9.0 h1:usICqY/Nw4Mpn9f4LdtpFrKxXroJDe81GaxxUlCckIo=
Expand Down
17 changes: 11 additions & 6 deletions logbus/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (

"github.com/earthly/cloud-api/logstream"
"github.com/earthly/earthly/ast/spec"
"github.com/earthly/earthly/domain"
)

// Run is a run logstream delta generator for a run.
Expand Down Expand Up @@ -39,7 +40,7 @@ func (run *Run) Generic() *Generic {
}

// NewTarget creates a new target printer.
func (run *Run) NewTarget(targetID, shortTargetName, canonicalTargetName string, overrideArgs []string, initialPlatform string, runner string) (*Target, error) {
func (run *Run) NewTarget(targetID string, target domain.Target, overrideArgs []string, initialPlatform string, runner string) (*Target, error) {
run.mu.Lock()
defer run.mu.Unlock()
mainTargetID := ""
Expand All @@ -56,17 +57,21 @@ func (run *Run) NewTarget(targetID, shortTargetName, canonicalTargetName string,
MainTargetId: mainTargetID,
Targets: map[string]*logstream.DeltaTargetManifest{
targetID: {
Name: shortTargetName,
CanonicalName: canonicalTargetName,
Name: target.String(), // Includes "+" prefix (e.g., "+target-name").
CanonicalName: target.StringCanonical(),
GitUrl: target.GetGitURL(),
LocalPath: target.GetLocalPath(),
Tag: target.GetTag(),
ImportRef: target.GetImportRef(),
OverrideArgs: overrideArgs,
InitialPlatform: initialPlatform,
Runner: runner,
},
},
})
target := newTarget(run.b, targetID)
run.targets[targetID] = target
return target, nil
t := newTarget(run.b, targetID)
run.targets[targetID] = t
return t, nil
}

// Target returns the target printer for the given target ID.
Expand Down
12 changes: 12 additions & 0 deletions util/deltautil/apply.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,18 @@ func setManifestFields(dm *pb.DeltaManifest, ret *pb.RunManifest) {
if t2.GetEndedAtUnixNanos() != 0 {
t.EndedAtUnixNanos = t2.GetEndedAtUnixNanos()
}
if t2.GetGitUrl() != "" {
t.GitUrl = t2.GetGitUrl()
}
if t2.GetTag() != "" {
t.Tag = t2.GetTag()
}
if t2.GetImportRef() != "" {
t.ImportRef = t2.GetImportRef()
}
if t2.GetLocalPath() != "" {
t.LocalPath = t2.GetLocalPath()
}
}
for commandID, c2 := range f.GetCommands() {
c := ensureCommandExists(ret, commandID)
Expand Down
2 changes: 1 addition & 1 deletion util/deltautil/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/earthly/earthly/util/deltautil
go 1.21

require (
github.com/earthly/cloud-api v1.0.1-0.20221201210730-b407492c9901
github.com/earthly/cloud-api v1.0.1-0.20231027183434-d79534194d95
google.golang.org/protobuf v1.30.0
)

Expand Down
2 changes: 2 additions & 0 deletions util/deltautil/go.sum
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
github.com/earthly/cloud-api v1.0.1-0.20221201210730-b407492c9901 h1:HBmy3zsOcRrZzL6uCJKgENXvHFfcFIyXZyrLvYoYtR4=
github.com/earthly/cloud-api v1.0.1-0.20221201210730-b407492c9901/go.mod h1:38rj6sccWnuk+C981DeFFomBmAtwuuvchoPrXdKXi2I=
github.com/earthly/cloud-api v1.0.1-0.20231027183434-d79534194d95 h1:stFmLhGY7dbf4UhBtbMIN+oaIMEDZez/epwHt7g6MqM=
github.com/earthly/cloud-api v1.0.1-0.20231027183434-d79534194d95/go.mod h1:rU/tYJ7GFBjdKAITV2heDbez++glpGSbtJaZcp73rNI=
github.com/golang/glog v1.1.0 h1:/d3pCKDPWNnvIWe0vVUpNP32qc8U3PDVxySP/y360qE=
github.com/golang/glog v1.1.0/go.mod h1:pfYeQZ3JWZoXTV5sFc986z3HTpwQs9At6P4ImfuP3NQ=
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
Expand Down

0 comments on commit 2f5483c

Please sign in to comment.