input: support yaml and json inputs
Signed-off-by: Andrea Luzzardi <aluzzardi@gmail.com>
This commit is contained in:
33
cmd/dagger/cmd/input/json.go
Normal file
33
cmd/dagger/cmd/input/json.go
Normal file
@@ -0,0 +1,33 @@
|
||||
package input
|
||||
|
||||
import (
|
||||
"dagger.io/go/cmd/dagger/logger"
|
||||
"dagger.io/go/dagger"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
)
|
||||
|
||||
var jsonCmd = &cobra.Command{
|
||||
Use: "json TARGET VALUE",
|
||||
Short: "Add a JSON input",
|
||||
Args: cobra.ExactArgs(2),
|
||||
PreRun: func(cmd *cobra.Command, args []string) {
|
||||
// Fix Viper bug for duplicate flags:
|
||||
// https://github.com/spf13/viper/issues/233
|
||||
if err := viper.BindPFlags(cmd.Flags()); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
},
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
lg := logger.New()
|
||||
ctx := lg.WithContext(cmd.Context())
|
||||
|
||||
updateDeploymentInput(ctx, args[0], dagger.JSONInput(args[1]))
|
||||
},
|
||||
}
|
||||
|
||||
func init() {
|
||||
if err := viper.BindPFlags(jsonCmd.Flags()); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
@@ -22,6 +22,8 @@ func init() {
|
||||
containerCmd,
|
||||
secretCmd,
|
||||
textCmd,
|
||||
jsonCmd,
|
||||
yamlCmd,
|
||||
)
|
||||
}
|
||||
|
||||
|
@@ -9,7 +9,7 @@ import (
|
||||
|
||||
var textCmd = &cobra.Command{
|
||||
Use: "text TARGET VALUE",
|
||||
Short: "Add an input text",
|
||||
Short: "Add a text input",
|
||||
Args: cobra.ExactArgs(2),
|
||||
PreRun: func(cmd *cobra.Command, args []string) {
|
||||
// Fix Viper bug for duplicate flags:
|
||||
|
33
cmd/dagger/cmd/input/yaml.go
Normal file
33
cmd/dagger/cmd/input/yaml.go
Normal file
@@ -0,0 +1,33 @@
|
||||
package input
|
||||
|
||||
import (
|
||||
"dagger.io/go/cmd/dagger/logger"
|
||||
"dagger.io/go/dagger"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
)
|
||||
|
||||
var yamlCmd = &cobra.Command{
|
||||
Use: "yaml TARGET VALUE",
|
||||
Short: "Add a YAML input",
|
||||
Args: cobra.ExactArgs(2),
|
||||
PreRun: func(cmd *cobra.Command, args []string) {
|
||||
// Fix Viper bug for duplicate flags:
|
||||
// https://github.com/spf13/viper/issues/233
|
||||
if err := viper.BindPFlags(cmd.Flags()); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
},
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
lg := logger.New()
|
||||
ctx := lg.WithContext(cmd.Context())
|
||||
|
||||
updateDeploymentInput(ctx, args[0], dagger.YAMLInput(args[1]))
|
||||
},
|
||||
}
|
||||
|
||||
func init() {
|
||||
if err := viper.BindPFlags(yamlCmd.Flags()); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
@@ -4,7 +4,7 @@ import (
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
inputCmd "dagger.io/go/cmd/dagger/cmd/input"
|
||||
"dagger.io/go/cmd/dagger/cmd/input"
|
||||
"dagger.io/go/cmd/dagger/cmd/output"
|
||||
"dagger.io/go/cmd/dagger/cmd/plan"
|
||||
"dagger.io/go/cmd/dagger/logger"
|
||||
@@ -37,7 +37,7 @@ func init() {
|
||||
loginCmd,
|
||||
logoutCmd,
|
||||
plan.Cmd,
|
||||
inputCmd.Cmd,
|
||||
input.Cmd,
|
||||
output.Cmd,
|
||||
)
|
||||
|
||||
|
Reference in New Issue
Block a user