@@ -1,9 +1,12 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"dagger.io/go/dagger"
|
||||
"github.com/rs/zerolog"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
@@ -31,3 +34,15 @@ func getRouteName(lg zerolog.Logger, cmd *cobra.Command) string {
|
||||
|
||||
return currentDir
|
||||
}
|
||||
|
||||
func routeUp(ctx context.Context, lg zerolog.Logger, route *dagger.Route) {
|
||||
c, err := dagger.NewClient(ctx, "")
|
||||
if err != nil {
|
||||
lg.Fatal().Err(err).Msg("unable to create client")
|
||||
}
|
||||
output, err := c.Up(ctx, route)
|
||||
if err != nil {
|
||||
lg.Fatal().Err(err).Msg("failed to compute")
|
||||
}
|
||||
fmt.Println(output.JSON())
|
||||
}
|
||||
|
@@ -3,7 +3,6 @@ package cmd
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
@@ -121,15 +120,7 @@ var computeCmd = &cobra.Command{
|
||||
lg.Fatal().Err(err).Msg("unable to initialize route")
|
||||
}
|
||||
|
||||
c, err := dagger.NewClient(ctx, "")
|
||||
if err != nil {
|
||||
lg.Fatal().Err(err).Msg("unable to create client")
|
||||
}
|
||||
output, err := c.Up(ctx, route)
|
||||
if err != nil {
|
||||
lg.Fatal().Err(err).Msg("failed to compute")
|
||||
}
|
||||
fmt.Println(output.JSON())
|
||||
routeUp(ctx, lg, route)
|
||||
},
|
||||
}
|
||||
|
||||
|
@@ -1,6 +1,10 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"dagger.io/go/cmd/dagger/logger"
|
||||
"dagger.io/go/dagger"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
)
|
||||
@@ -17,10 +21,17 @@ var listCmd = &cobra.Command{
|
||||
}
|
||||
},
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
// lg := logger.New()
|
||||
// ctx := lg.WithContext(cmd.Context())
|
||||
lg := logger.New()
|
||||
ctx := lg.WithContext(cmd.Context())
|
||||
|
||||
panic("not implemented")
|
||||
routes, err := dagger.ListRoutes(ctx)
|
||||
if err != nil {
|
||||
lg.Fatal().Err(err).Msg("cannot list routes")
|
||||
}
|
||||
|
||||
for _, name := range routes {
|
||||
fmt.Println(name)
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
|
@@ -24,7 +24,7 @@ var newCmd = &cobra.Command{
|
||||
ctx := lg.WithContext(cmd.Context())
|
||||
|
||||
// nolint:staticcheck
|
||||
upRoute, err := cmd.Flags().GetBool("up")
|
||||
upRouteFlag, err := cmd.Flags().GetBool("up")
|
||||
if err != nil {
|
||||
lg.Fatal().Err(err).Str("flag", "up").Msg("unable to resolve flag")
|
||||
}
|
||||
@@ -39,12 +39,8 @@ var newCmd = &cobra.Command{
|
||||
}
|
||||
lg.Info().Str("route-id", route.ID()).Str("route-name", routeName).Msg("created route")
|
||||
|
||||
if upRoute {
|
||||
lg.Info().Str("route-id", route.ID()).Msg("bringing route online")
|
||||
// FIXME
|
||||
if err := route.FIXME(ctx); err != nil {
|
||||
lg.Fatal().Err(err).Str("route-id", route.ID()).Msg("failed to create route")
|
||||
}
|
||||
if upRouteFlag {
|
||||
routeUp(ctx, lg, route)
|
||||
}
|
||||
},
|
||||
}
|
||||
|
@@ -32,10 +32,7 @@ var upCmd = &cobra.Command{
|
||||
}
|
||||
|
||||
// TODO: Implement options: --no-cache
|
||||
// FIXME
|
||||
if err := route.FIXME(ctx); err != nil {
|
||||
lg.Fatal().Err(err).Str("route-name", routeName).Str("route-id", route.ID()).Msg("failed to up the route")
|
||||
}
|
||||
routeUp(ctx, lg, route)
|
||||
},
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user