env -> route cleanup
Signed-off-by: Andrea Luzzardi <aluzzardi@gmail.com>
This commit is contained in:
@@ -60,8 +60,8 @@ func NewClient(ctx context.Context, host string) (*Client, error) {
|
||||
}, nil
|
||||
}
|
||||
|
||||
// FIXME: return completed *Env, instead of *compiler.Value
|
||||
func (c *Client) Up(ctx context.Context, env *Route) (*compiler.Value, error) {
|
||||
// FIXME: return completed *Route, instead of *compiler.Value
|
||||
func (c *Client) Up(ctx context.Context, route *Route) (*compiler.Value, error) {
|
||||
lg := log.Ctx(ctx)
|
||||
eg, gctx := errgroup.WithContext(ctx)
|
||||
|
||||
@@ -78,7 +78,7 @@ func (c *Client) Up(ctx context.Context, env *Route) (*compiler.Value, error) {
|
||||
outr, outw := io.Pipe()
|
||||
eg.Go(func() error {
|
||||
defer outw.Close()
|
||||
return c.buildfn(gctx, env, events, outw)
|
||||
return c.buildfn(gctx, route, events, outw)
|
||||
})
|
||||
|
||||
// Spawn output retriever
|
||||
@@ -95,11 +95,11 @@ func (c *Client) Up(ctx context.Context, env *Route) (*compiler.Value, error) {
|
||||
return out, compiler.Err(eg.Wait())
|
||||
}
|
||||
|
||||
func (c *Client) buildfn(ctx context.Context, env *Route, ch chan *bk.SolveStatus, w io.WriteCloser) error {
|
||||
func (c *Client) buildfn(ctx context.Context, route *Route, ch chan *bk.SolveStatus, w io.WriteCloser) error {
|
||||
lg := log.Ctx(ctx)
|
||||
|
||||
// Scan local dirs to grant access
|
||||
localdirs := env.LocalDirs()
|
||||
localdirs := route.LocalDirs()
|
||||
for label, dir := range localdirs {
|
||||
abs, err := filepath.Abs(dir)
|
||||
if err != nil {
|
||||
@@ -132,24 +132,24 @@ func (c *Client) buildfn(ctx context.Context, env *Route, ch chan *bk.SolveStatu
|
||||
s := NewSolver(c.c, gw, ch)
|
||||
|
||||
lg.Debug().Msg("loading configuration")
|
||||
if err := env.Update(ctx, s); err != nil {
|
||||
if err := route.LoadLayout(ctx, s); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Compute output overlay
|
||||
lg.Debug().Msg("computing env")
|
||||
if err := env.Up(ctx, s, nil); err != nil {
|
||||
lg.Debug().Msg("computing route")
|
||||
if err := route.Up(ctx, s, nil); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Export env to a cue directory
|
||||
// Export route to a cue directory
|
||||
// FIXME: this should be elsewhere
|
||||
lg.Debug().Msg("exporting env")
|
||||
span, _ := opentracing.StartSpanFromContext(ctx, "Env.Export")
|
||||
lg.Debug().Msg("exporting route")
|
||||
span, _ := opentracing.StartSpanFromContext(ctx, "Route.Export")
|
||||
defer span.Finish()
|
||||
|
||||
st := llb.Scratch().File(
|
||||
llb.Mkfile("state.cue", 0600, env.State().JSON()),
|
||||
llb.Mkfile("state.cue", 0600, route.State().JSON()),
|
||||
llb.WithCustomName("[internal] serializing state to JSON"),
|
||||
)
|
||||
ref, err := s.Solve(ctx, st)
|
||||
@@ -178,7 +178,7 @@ func (c *Client) buildfn(ctx context.Context, env *Route, ch chan *bk.SolveStatu
|
||||
func (c *Client) outputfn(ctx context.Context, r io.Reader) (*compiler.Value, error) {
|
||||
lg := log.Ctx(ctx)
|
||||
|
||||
// FIXME: merge this into env output.
|
||||
// FIXME: merge this into route output.
|
||||
out := compiler.EmptyStruct()
|
||||
|
||||
tr := tar.NewReader(r)
|
||||
|
Reference in New Issue
Block a user