Add universe check version in europa up

Signed-off-by: Vasek - Tom C <tom.chauveau@epitech.eu>
This commit is contained in:
Tom Chauveau
2021-12-10 16:29:37 +01:00
committed by Vasek - Tom C
parent 034cb51781
commit b1188960df
2 changed files with 72 additions and 0 deletions

View File

@@ -3,6 +3,7 @@ package cmd
import (
"context"
"errors"
"fmt"
"os"
"cuelang.org/go/cue"
@@ -12,6 +13,7 @@ import (
"go.dagger.io/dagger/cmd/dagger/logger"
"go.dagger.io/dagger/compiler"
"go.dagger.io/dagger/environment"
"go.dagger.io/dagger/mod"
"go.dagger.io/dagger/plan"
"go.dagger.io/dagger/plancontext"
"go.dagger.io/dagger/solver"
@@ -74,6 +76,11 @@ var upCmd = &cobra.Command{
Str("environment", st.Name).
Logger()
universeUpdateCh := make(chan bool)
go func() {
universeUpdateCh <- checkUniverseVersion(ctx, project.Path)
}()
doneCh := common.TrackProjectCommand(ctx, cmd, project, st)
env, err := environment.New(st)
@@ -109,9 +116,29 @@ var upCmd = &cobra.Command{
if err != nil {
lg.Fatal().Err(err).Msg("failed to up environment")
}
// Warn universe version if out of date
if update := <-universeUpdateCh; update {
fmt.Println("A new version of universe is available, please run 'dagger mod get alpha.dagger.io'")
}
},
}
func checkUniverseVersion(ctx context.Context, projectPath string) bool {
lg := log.Ctx(ctx)
isLatest, err := mod.IsUniverseLatest(ctx, projectPath)
if err != nil {
lg.Debug().Err(err).Msg("failed to check universe version")
return false
}
if !isLatest {
return true
}
lg.Debug().Msg("universe is up to date")
return false
}
func europaUp(ctx context.Context, cl *client.Client, args ...string) error {
lg := log.Ctx(ctx)