implements dagger project update
Signed-off-by: Richard Jones <richard@dagger.io>
This commit is contained in:
@@ -88,9 +88,8 @@ func loadPlan() (*plan.Plan, error) {
|
||||
}
|
||||
|
||||
return plan.Load(context.Background(), plan.Config{
|
||||
Args: []string{planPath},
|
||||
With: viper.GetStringSlice("with"),
|
||||
Vendor: !viper.GetBool("no-vendor"),
|
||||
Args: []string{planPath},
|
||||
With: viper.GetStringSlice("with"),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -106,23 +105,32 @@ func doHelp(cmd *cobra.Command, _ []string) {
|
||||
w := tabwriter.NewWriter(os.Stdout, 0, 0, 1, ' ', tabwriter.StripEscape)
|
||||
defer w.Flush()
|
||||
|
||||
planPath := viper.GetString("plan")
|
||||
|
||||
var (
|
||||
errorMsg string
|
||||
loadedMsg string
|
||||
actionLookupPathMsg string
|
||||
actions []*plan.Action
|
||||
)
|
||||
|
||||
p, err := loadPlan()
|
||||
if err != nil {
|
||||
fmt.Printf("%s", err)
|
||||
fmt.Fprintln(w, "failed to load plan")
|
||||
return
|
||||
errorMsg = "Error: failed to load plan\n\n"
|
||||
} else {
|
||||
loadedMsg = "Plan loaded from " + planPath
|
||||
actionLookupPath := getTargetPath(cmd.Flags().Args())
|
||||
actions = p.Action().FindByPath(actionLookupPath).Children
|
||||
actionLookupPathMsg = fmt.Sprintf(`%s:`, actionLookupPath.String())
|
||||
}
|
||||
planPath := viper.GetString("plan")
|
||||
actionLookupPath := getTargetPath(cmd.Flags().Args())
|
||||
actions := p.Action().FindByPath(actionLookupPath).Children
|
||||
|
||||
fmt.Printf(`Execute a dagger action.
|
||||
fmt.Printf(`%s%s
|
||||
|
||||
%s
|
||||
|
||||
Plan loaded from %s:
|
||||
%s
|
||||
`, cmd.UsageString(), planPath, "\n"+actionLookupPath.String()+":")
|
||||
|
||||
%s
|
||||
`, errorMsg, cmd.Short, cmd.UsageString(), loadedMsg, actionLookupPathMsg)
|
||||
|
||||
// fmt.Fprintln(w, "Actions\tDescription\tPackage")
|
||||
// fmt.Fprintln(w, "\t\t")
|
||||
@@ -136,8 +144,7 @@ Plan loaded from %s:
|
||||
|
||||
func init() {
|
||||
doCmd.Flags().StringArrayP("with", "w", []string{}, "")
|
||||
doCmd.Flags().Bool("no-vendor", false, "Force up, disable inputs check")
|
||||
doCmd.PersistentFlags().StringP("plan", "p", ".", "Path to plan (defaults to current directory)")
|
||||
doCmd.Flags().StringP("plan", "p", ".", "Path to plan (defaults to current directory)")
|
||||
|
||||
doCmd.SetHelpFunc(doHelp)
|
||||
|
||||
|
@@ -1,15 +0,0 @@
|
||||
package mod
|
||||
|
||||
import "github.com/spf13/cobra"
|
||||
|
||||
// Cmd exposes the top-level command
|
||||
var Cmd = &cobra.Command{
|
||||
Use: "mod",
|
||||
Short: "Manage an environment's dependencies",
|
||||
}
|
||||
|
||||
func init() {
|
||||
Cmd.AddCommand(
|
||||
getCmd,
|
||||
)
|
||||
}
|
@@ -14,7 +14,7 @@ var sep = string(os.PathSeparator)
|
||||
|
||||
var initCmd = &cobra.Command{
|
||||
Use: fmt.Sprintf("init [path%sto%sproject]", sep, sep),
|
||||
Short: "Initialize a new empty project.",
|
||||
Short: "Initialize a new empty project",
|
||||
Args: cobra.MaximumNArgs(1),
|
||||
PreRun: func(cmd *cobra.Command, args []string) {
|
||||
// Fix Viper bug for duplicate flags:
|
||||
|
@@ -25,5 +25,6 @@ func init() {
|
||||
|
||||
Cmd.AddCommand(
|
||||
initCmd,
|
||||
updateCmd,
|
||||
)
|
||||
}
|
@@ -1,4 +1,4 @@
|
||||
package mod
|
||||
package project
|
||||
|
||||
import (
|
||||
"github.com/spf13/cobra"
|
||||
@@ -8,9 +8,9 @@ import (
|
||||
"go.dagger.io/dagger/pkg"
|
||||
)
|
||||
|
||||
var getCmd = &cobra.Command{
|
||||
Use: "get [packages]",
|
||||
Short: "download and install dependencies",
|
||||
var updateCmd = &cobra.Command{
|
||||
Use: "update [package]",
|
||||
Short: "Download and install dependencies",
|
||||
Args: cobra.MaximumNArgs(1),
|
||||
PreRun: func(cmd *cobra.Command, args []string) {
|
||||
// Fix Viper bug for duplicate flags:
|
||||
@@ -26,11 +26,15 @@ var getCmd = &cobra.Command{
|
||||
|
||||
var err error
|
||||
|
||||
cueModPath := pkg.GetCueModParent()
|
||||
err = pkg.CueModInit(ctx, cueModPath, "")
|
||||
if err != nil {
|
||||
lg.Fatal().Err(err).Msg("failed to initialize cue.mod")
|
||||
panic(err)
|
||||
cueModPath, cueModExists := pkg.GetCueModParent()
|
||||
if !cueModExists {
|
||||
lg.Fatal().Msg("dagger project not found. Run `dagger project init`")
|
||||
}
|
||||
|
||||
if len(args) == 0 {
|
||||
lg.Debug().Msg("No package specified, updating all packages")
|
||||
pkg.Vendor(ctx, cueModPath)
|
||||
return
|
||||
}
|
||||
|
||||
var update = viper.GetBool("update")
|
||||
@@ -64,11 +68,11 @@ var getCmd = &cobra.Command{
|
||||
}
|
||||
|
||||
func init() {
|
||||
getCmd.Flags().String("private-key-file", "", "Private ssh key")
|
||||
getCmd.Flags().String("private-key-password", "", "Private ssh key password")
|
||||
getCmd.Flags().BoolP("update", "u", false, "Update specified package")
|
||||
updateCmd.Flags().String("private-key-file", "", "Private ssh key")
|
||||
updateCmd.Flags().String("private-key-password", "", "Private ssh key password")
|
||||
updateCmd.Flags().BoolP("update", "u", false, "Update specified package")
|
||||
|
||||
if err := viper.BindPFlags(getCmd.Flags()); err != nil {
|
||||
if err := viper.BindPFlags(updateCmd.Flags()); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
@@ -7,7 +7,6 @@ import (
|
||||
"github.com/moby/buildkit/util/appcontext"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
"go.dagger.io/dagger/cmd/dagger/cmd/mod"
|
||||
"go.dagger.io/dagger/cmd/dagger/cmd/project"
|
||||
"go.dagger.io/dagger/cmd/dagger/logger"
|
||||
|
||||
@@ -42,7 +41,6 @@ func init() {
|
||||
upCmd,
|
||||
versionCmd,
|
||||
docCmd,
|
||||
mod.Cmd,
|
||||
doCmd,
|
||||
project.Cmd,
|
||||
)
|
||||
|
@@ -82,7 +82,6 @@ func europaUp(ctx context.Context, cl *client.Client, args ...string) error {
|
||||
Args: args,
|
||||
With: viper.GetStringSlice("with"),
|
||||
Target: viper.GetString("target"),
|
||||
Vendor: !viper.GetBool("no-vendor"),
|
||||
})
|
||||
if err != nil {
|
||||
lg.Fatal().Err(err).Msg("failed to load plan")
|
||||
@@ -97,7 +96,6 @@ func init() {
|
||||
upCmd.Flags().BoolP("force", "f", false, "Force up, disable inputs check")
|
||||
upCmd.Flags().StringArrayP("with", "w", []string{}, "")
|
||||
upCmd.Flags().StringP("target", "t", "", "Run a single target of the DAG (for debugging only)")
|
||||
upCmd.Flags().Bool("no-vendor", false, "Force up, disable inputs check")
|
||||
|
||||
if err := viper.BindPFlags(upCmd.Flags()); err != nil {
|
||||
panic(err)
|
||||
|
Reference in New Issue
Block a user