runtime: new execution engine

Signed-off-by: Andrea Luzzardi <aluzzardi@gmail.com>
This commit is contained in:
Andrea Luzzardi
2021-11-24 16:22:33 -08:00
parent cdcb09126b
commit 2a4db167e4
9 changed files with 356 additions and 3 deletions

View File

@@ -36,6 +36,8 @@ func init() {
rootCmd.PersistentFlags().StringP("environment", "e", "", "Select an environment")
rootCmd.PersistentFlags().String("project", "", "Specify a project directory (defaults to current)")
rootCmd.PersistentFlags().Bool("europa", false, "Enable experiemental Europa UX")
rootCmd.PersistentPreRun = func(cmd *cobra.Command, _ []string) {
lg := logger.New()
ctx := lg.WithContext(cmd.Context())

View File

@@ -6,11 +6,13 @@ import (
"os"
"cuelang.org/go/cue"
"go.dagger.io/dagger/client"
"go.dagger.io/dagger/cmd/dagger/cmd/common"
"go.dagger.io/dagger/cmd/dagger/cmd/output"
"go.dagger.io/dagger/cmd/dagger/logger"
"go.dagger.io/dagger/compiler"
"go.dagger.io/dagger/environment"
"go.dagger.io/dagger/plan"
"go.dagger.io/dagger/solver"
"golang.org/x/term"
@@ -61,6 +63,18 @@ var upCmd = &cobra.Command{
cl := common.NewClient(ctx)
if viper.GetBool("europa") {
err = europaUp(ctx, cl, project.Path)
<-doneCh
if err != nil {
lg.Fatal().Err(err).Msg("failed to up environment")
}
return
}
env, err := environment.New(st)
if err != nil {
lg.Fatal().Msg("unable to create environment")
@@ -97,6 +111,27 @@ var upCmd = &cobra.Command{
},
}
func europaUp(ctx context.Context, cl *client.Client, path string) error {
lg := log.Ctx(ctx)
p, err := plan.Load(ctx, path, "")
if err != nil {
lg.Fatal().Err(err).Msg("failed to load plan")
}
localdirs, err := p.LocalDirectories()
if err != nil {
return err
}
return cl.Do(ctx, p.Context(), localdirs, func(ctx context.Context, s solver.Solver) error {
if err := p.Up(ctx, s); err != nil {
return err
}
return nil
})
}
func checkInputs(ctx context.Context, env *environment.Environment) error {
lg := log.Ctx(ctx)
warnOnly := viper.GetBool("force")