cleanup log messages
Signed-off-by: Andrea Luzzardi <aluzzardi@gmail.com>
This commit is contained in:
parent
bc3305610b
commit
1fcb36113f
@ -43,21 +43,18 @@ var computeCmd = &cobra.Command{
|
|||||||
if err := env.SetUpdater(updater.Value()); err != nil {
|
if err := env.SetUpdater(updater.Value()); err != nil {
|
||||||
lg.Fatal().Err(err).Msg("invalid updater script")
|
lg.Fatal().Err(err).Msg("invalid updater script")
|
||||||
}
|
}
|
||||||
lg.Debug().Str("input", input.Value().SourceUnsafe()).Msg("Setting input")
|
lg.Debug().Str("input", input.Value().SourceUnsafe()).Msg("setting input")
|
||||||
if err := env.SetInput(input.Value()); err != nil {
|
if err := env.SetInput(input.Value()); err != nil {
|
||||||
lg.Fatal().Err(err).Msg("invalid input")
|
lg.Fatal().Err(err).Msg("invalid input")
|
||||||
}
|
}
|
||||||
lg.Debug().Str("env state", env.State().SourceUnsafe()).Msg("creating client")
|
|
||||||
c, err := dagger.NewClient(ctx, "")
|
c, err := dagger.NewClient(ctx, "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
lg.Fatal().Err(err).Msg("unable to create client")
|
lg.Fatal().Err(err).Msg("unable to create client")
|
||||||
}
|
}
|
||||||
lg.Info().Msg("running")
|
|
||||||
output, err := c.Compute(ctx, env)
|
output, err := c.Compute(ctx, env)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
lg.Fatal().Err(err).Msg("failed to compute")
|
lg.Fatal().Err(err).Msg("failed to compute")
|
||||||
}
|
}
|
||||||
lg.Info().Msg("processing output")
|
|
||||||
fmt.Println(output.JSON())
|
fmt.Println(output.JSON())
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,7 @@ func CueBuild(ctx context.Context, fs FS, args ...string) (*compiler.Value, erro
|
|||||||
|
|
||||||
// Add the config files on top of the overlay
|
// Add the config files on top of the overlay
|
||||||
err = fs.Walk(ctx, func(p string, f Stat) error {
|
err = fs.Walk(ctx, func(p string, f Stat) error {
|
||||||
lg.Debug().Str("path", p).Msg("Compiler.Build: processing")
|
lg.Debug().Str("path", p).Msg("load")
|
||||||
if f.IsDir() {
|
if f.IsDir() {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -123,20 +123,24 @@ func (c *Client) buildfn(ctx context.Context, env *Env, ch chan *bk.SolveStatus,
|
|||||||
resp, err := c.c.Build(ctx, opts, "", func(ctx context.Context, c bkgw.Client) (*bkgw.Result, error) {
|
resp, err := c.c.Build(ctx, opts, "", func(ctx context.Context, c bkgw.Client) (*bkgw.Result, error) {
|
||||||
s := NewSolver(c)
|
s := NewSolver(c)
|
||||||
|
|
||||||
|
lg.Debug().Msg("loading configuration")
|
||||||
if err := env.Update(ctx, s); err != nil {
|
if err := env.Update(ctx, s); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
lg.Debug().Msg("computing env")
|
|
||||||
// Compute output overlay
|
// Compute output overlay
|
||||||
|
lg.Debug().Msg("computing env")
|
||||||
if err := env.Compute(ctx, s); err != nil {
|
if err := env.Compute(ctx, s); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
lg.Debug().Msg("exporting env")
|
|
||||||
// Export env to a cue directory
|
// Export env to a cue directory
|
||||||
|
lg.Debug().Msg("exporting env")
|
||||||
outdir, err := env.Export(s.Scratch())
|
outdir, err := env.Export(s.Scratch())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Wrap cue directory in buildkit result
|
// Wrap cue directory in buildkit result
|
||||||
return outdir.Result(ctx)
|
return outdir.Result(ctx)
|
||||||
}, ch)
|
}, ch)
|
||||||
|
@ -3,6 +3,7 @@ package dagger
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"time"
|
||||||
|
|
||||||
"cuelang.org/go/cue"
|
"cuelang.org/go/cue"
|
||||||
cueflow "cuelang.org/go/tools/flow"
|
cueflow "cuelang.org/go/tools/flow"
|
||||||
@ -212,10 +213,6 @@ func (env *Env) Compute(ctx context.Context, s Solver) error {
|
|||||||
|
|
||||||
// Cueflow cue instance
|
// Cueflow cue instance
|
||||||
flowInst := env.state.CueInst()
|
flowInst := env.state.CueInst()
|
||||||
lg.
|
|
||||||
Debug().
|
|
||||||
Str("value", compiler.Wrap(flowInst.Value(), flowInst).JSON().String()).
|
|
||||||
Msg("walking")
|
|
||||||
|
|
||||||
// Reset the output
|
// Reset the output
|
||||||
env.output = compiler.EmptyStruct()
|
env.output = compiler.EmptyStruct()
|
||||||
@ -233,11 +230,9 @@ func (env *Env) Compute(ctx context.Context, s Solver) error {
|
|||||||
Str("state", t.State().String()).
|
Str("state", t.State().String()).
|
||||||
Logger()
|
Logger()
|
||||||
|
|
||||||
lg.Debug().Msg("cueflow task")
|
|
||||||
if t.State() != cueflow.Terminated {
|
if t.State() != cueflow.Terminated {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
lg.Debug().Msg("cueflow task: filling result")
|
|
||||||
// Merge task value into output
|
// Merge task value into output
|
||||||
var err error
|
var err error
|
||||||
env.output, err = env.output.MergePath(t.Value(), t.Path())
|
env.output, err = env.output.MergePath(t.Value(), t.Path())
|
||||||
@ -245,7 +240,7 @@ func (env *Env) Compute(ctx context.Context, s Solver) error {
|
|||||||
lg.
|
lg.
|
||||||
Error().
|
Error().
|
||||||
Err(err).
|
Err(err).
|
||||||
Msg("failed to fill script result")
|
Msg("failed to fill task result")
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
@ -288,6 +283,10 @@ func newPipelineTaskFunc(ctx context.Context, inst *cue.Instance, s Solver) cuef
|
|||||||
Logger()
|
Logger()
|
||||||
ctx := lg.WithContext(ctx)
|
ctx := lg.WithContext(ctx)
|
||||||
|
|
||||||
|
start := time.Now()
|
||||||
|
lg.
|
||||||
|
Info().
|
||||||
|
Msg("computing")
|
||||||
for _, dep := range t.Dependencies() {
|
for _, dep := range t.Dependencies() {
|
||||||
lg.
|
lg.
|
||||||
Debug().
|
Debug().
|
||||||
@ -296,7 +295,20 @@ func newPipelineTaskFunc(ctx context.Context, inst *cue.Instance, s Solver) cuef
|
|||||||
}
|
}
|
||||||
v := compiler.Wrap(t.Value(), inst)
|
v := compiler.Wrap(t.Value(), inst)
|
||||||
p := NewPipeline(t.Path().String(), s, NewFillable(t))
|
p := NewPipeline(t.Path().String(), s, NewFillable(t))
|
||||||
return p.Do(ctx, v)
|
err := p.Do(ctx, v)
|
||||||
|
if err != nil {
|
||||||
|
lg.
|
||||||
|
Error().
|
||||||
|
Dur("duration", time.Since(start)).
|
||||||
|
Err(err).
|
||||||
|
Msg("failed")
|
||||||
|
} else {
|
||||||
|
lg.
|
||||||
|
Info().
|
||||||
|
Dur("duration", time.Since(start)).
|
||||||
|
Msg("completed")
|
||||||
|
}
|
||||||
|
return err
|
||||||
}), nil
|
}), nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -254,16 +254,13 @@ func (p *Pipeline) Local(ctx context.Context, op *compiler.Value) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
p.fs = p.fs.Change(func(st llb.State) llb.State {
|
p.fs = p.fs.Set(
|
||||||
return st.File(
|
llb.Local(
|
||||||
llb.Copy(
|
dir,
|
||||||
llb.Local(dir, llb.FollowPaths(include)),
|
llb.FollowPaths(include),
|
||||||
"/",
|
|
||||||
"/",
|
|
||||||
),
|
|
||||||
llb.WithCustomName(p.vertexNamef("Local %s", dir)),
|
llb.WithCustomName(p.vertexNamef("Local %s", dir)),
|
||||||
|
),
|
||||||
)
|
)
|
||||||
})
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -307,7 +304,11 @@ func (p *Pipeline) Exec(ctx context.Context, op *compiler.Value) error {
|
|||||||
|
|
||||||
// marker for status events
|
// marker for status events
|
||||||
// FIXME
|
// FIXME
|
||||||
opts = append(opts, llb.WithCustomName(p.vertexNamef("Exec %q", strings.Join(cmd.Args, " "))))
|
args := make([]string, 0, len(cmd.Args))
|
||||||
|
for _, a := range cmd.Args {
|
||||||
|
args = append(args, fmt.Sprintf("%q", a))
|
||||||
|
}
|
||||||
|
opts = append(opts, llb.WithCustomName(p.vertexNamef("Exec [%s]", strings.Join(args, ", "))))
|
||||||
|
|
||||||
// --> Execute
|
// --> Execute
|
||||||
p.fs = p.fs.Change(func(st llb.State) llb.State {
|
p.fs = p.fs.Change(func(st llb.State) llb.State {
|
||||||
|
Reference in New Issue
Block a user