Merge pull request #1192 from aluzzardi/fix-europa

europa: fix task matching
This commit is contained in:
Andrea Luzzardi 2021-12-09 15:06:55 -05:00 committed by GitHub
commit ce74bf0de2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 41 additions and 41 deletions

View File

@ -762,7 +762,7 @@ func (p *Pipeline) FetchContainer(ctx context.Context, op *compiler.Value, st ll
// Load image metadata and convert to to LLB.
platform := p.pctx.Platform.Get()
p.image, err = p.s.ResolveImageConfig(ctx, ref.String(), llb.ResolveImageConfigOpt{
p.image, _, err = p.s.ResolveImageConfig(ctx, ref.String(), llb.ResolveImageConfigOpt{
LogName: p.vertexNamef("load metadata for %s", ref.String()),
Platform: &platform,
})

View File

@ -24,8 +24,9 @@ type Plan struct {
}
func Load(ctx context.Context, args ...string) (*Plan, error) {
// FIXME: universe vendoring
log.Ctx(ctx).Debug().Interface("args", args).Msg("loading plan")
// FIXME: universe vendoring
if err := state.VendorUniverse(ctx, ""); err != nil {
return nil, err
}
@ -121,7 +122,7 @@ func newRunner(pctx *plancontext.Context, s solver.Solver, computed *compiler.Va
ctx := t.Context()
lg := log.Ctx(ctx).With().Str("task", t.Path().String()).Logger()
ctx = lg.WithContext(ctx)
ctx, span := otel.Tracer("dagger").Start(ctx, fmt.Sprintf("compute: %s", t.Path().String()))
ctx, span := otel.Tracer("dagger").Start(ctx, fmt.Sprintf("up: %s", t.Path().String()))
defer span.End()
lg.Info().Str("state", string(environment.StateComputing)).Msg(string(environment.StateComputing))
@ -145,7 +146,7 @@ func newRunner(pctx *plancontext.Context, s solver.Solver, computed *compiler.Va
lg.Info().Dur("duration", time.Since(start)).Str("state", string(environment.StateCompleted)).Msg(string(environment.StateCompleted))
// If the result is not concrete, there's nothing to merge.
// If the result is not concrete (e.g. empty value), there's nothing to merge.
if !result.IsConcrete() {
return nil
}

View File

@ -11,12 +11,13 @@ import (
"go.dagger.io/dagger/environment"
"go.dagger.io/dagger/plancontext"
"go.dagger.io/dagger/solver"
"go.dagger.io/dagger/stdlib"
)
var (
ErrNotTask = errors.New("not a task")
tasks sync.Map
typePath = cue.MakePath(cue.Hid("_type", "alpha.dagger.io/dagger"))
typePath = cue.MakePath(cue.Hid("_type", stdlib.EnginePackage))
)
type NewFunc func() Task

View File

@ -101,21 +101,21 @@ func (s Solver) SessionID() string {
return s.opts.Gateway.BuildOpts().SessionID
}
func (s Solver) ResolveImageConfig(ctx context.Context, ref string, opts llb.ResolveImageConfigOpt) (dockerfile2llb.Image, error) {
func (s Solver) ResolveImageConfig(ctx context.Context, ref string, opts llb.ResolveImageConfigOpt) (dockerfile2llb.Image, digest.Digest, error) {
var image dockerfile2llb.Image
// Load image metadata and convert to to LLB.
// Inspired by https://github.com/moby/buildkit/blob/master/frontend/dockerfile/dockerfile2llb/convert.go
// FIXME: this needs to handle platform
_, meta, err := s.opts.Gateway.ResolveImageConfig(ctx, ref, opts)
dg, meta, err := s.opts.Gateway.ResolveImageConfig(ctx, ref, opts)
if err != nil {
return image, err
return image, "", err
}
if err := json.Unmarshal(meta, &image); err != nil {
return image, err
return image, "", err
}
return image, nil
return image, dg, nil
}
// Solve will block until the state is solved and returns a Reference.

View File

@ -1,11 +0,0 @@
package engine
// A reference to a filesystem tree.
// For example:
// - The root filesystem of a container
// - A source code repository
// - A directory containing binary artifacts
// Rule of thumb: if it fits in a tar archive, it fits in a #FS.
#FS: {
_fs: id: string
}

View File

@ -1,11 +0,0 @@
package engine
// A reference to an external secret, for example:
// - A password
// - A SSH private key
// - An API token
// Secrets are never merged in the Cue tree. They can only be used
// by a special filesystem mount designed to minimize leak risk.
#Secret: {
_secret: id: string
}

View File

@ -1,9 +0,0 @@
package engine
// A reference to a network service endpoint, for example:
// - A TCP or UDP port
// - A unix or npipe socket
// - An HTTPS endpoint
#Service: {
_service: id: string
}

View File

@ -0,0 +1,29 @@
package engine
// A reference to a filesystem tree.
// For example:
// - The root filesystem of a container
// - A source code repository
// - A directory containing binary artifacts
// Rule of thumb: if it fits in a tar archive, it fits in a #FS.
#FS: {
_fs: id: string
}
// A reference to an external secret, for example:
// - A password
// - A SSH private key
// - An API token
// Secrets are never merged in the Cue tree. They can only be used
// by a special filesystem mount designed to minimize leak risk.
#Secret: {
_secret: id: string
}
// A reference to a network service endpoint, for example:
// - A TCP or UDP port
// - A unix or npipe socket
// - An HTTPS endpoint
#Service: {
_service: id: string
}