Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ require (
github.com/itchyny/gojq v0.12.19
github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db
github.com/nobl9/go-yaml v1.0.1
github.com/nobl9/nobl9-go v0.133.0-rc1
github.com/nobl9/nobl9-go v0.133.1
github.com/nobl9/nobl9-openslo v0.1.6
github.com/pkg/errors v0.9.1
github.com/schollz/progressbar/v3 v3.19.1
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,8 @@ github.com/nobl9/go-yaml v1.0.1 h1:Aj1kSaYdRQTKlvS6ihvXzQJhCpoHhtf9nfA95zqWH4Q=
github.com/nobl9/go-yaml v1.0.1/go.mod h1:t7vCO8ctYdBweZxU5lUgxzAw31+ZcqJYeqRtrv+5RHI=
github.com/nobl9/govy v0.26.0 h1:pjHXreO+3Rl+Uz6/rFX7L54zH4LW/SaTjb6YX3GQGs4=
github.com/nobl9/govy v0.26.0/go.mod h1:fExiIzXORe0ktwg2bWasOAmCZtEFMQkR4PpgzhHcZSA=
github.com/nobl9/nobl9-go v0.133.0-rc1 h1:sNLLfL7ag445KctymKzDP2MpHuyvMeGDeKZwXqJtvts=
github.com/nobl9/nobl9-go v0.133.0-rc1/go.mod h1:XUE+S6kcSkelfyXIuXxi6ep50LefQqVUUsn/Sqb5/2s=
github.com/nobl9/nobl9-go v0.133.1 h1:WpzfXSj+ckEGQ5DquMaR1AGxVO/yjg1TeJbaWvypUvY=
github.com/nobl9/nobl9-go v0.133.1/go.mod h1:XUE+S6kcSkelfyXIuXxi6ep50LefQqVUUsn/Sqb5/2s=
github.com/nobl9/nobl9-openslo v0.1.6 h1:0VJscyj0va+DMYKhzKskI1w5Q9ZvqnowlvaHqjtCJP0=
github.com/nobl9/nobl9-openslo v0.1.6/go.mod h1:A5GxukjS31tsIp0Raseh9eyEcxCZWsqi9drWW6aAEg0=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
Expand Down
9 changes: 7 additions & 2 deletions internal/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,18 @@ func registerSLOServiceFlag(cmd *cobra.Command, storeIn *[]string) {
// requireFlagsIfFlagIsSet validates that the provided deps are only set if the "parent" flag is set.
// This one way dependency is not supported natively by cobra and requires custom verification.
func requireFlagsIfFlagIsSet(cmd *cobra.Command, flag string, deps ...string) error {
if cmd.Flags().Changed(flag) {
if commandFlagChanged(cmd, flag) {
return nil
}
for _, d := range deps {
if cmd.Flags().Changed(d) {
if commandFlagChanged(cmd, d) {
return fmt.Errorf("--%s flag can only be set if --%s flag is also provided", d, flag)
}
}
return nil
}

func commandFlagChanged(cmd *cobra.Command, name string) bool {
flag := cmd.Flag(name)
return flag != nil && flag.Changed
}
4 changes: 4 additions & 0 deletions internal/printer/printer.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ type Printer struct {
jq *jq.ExpressionRunner
}

func (o *Printer) OutputFormat() Format {
return o.config.OutputFormat
}

// Validate should be called before [Printer.Print], after the flag values are assigned.
func (o *Printer) Validate() error {
if !slices.Contains(o.config.SupportedFromats, o.config.OutputFormat) {
Expand Down
1 change: 1 addition & 0 deletions internal/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ More detailed help is available for each command.`,
rootCmd.AddCommand(root.NewMoveCmd())
rootCmd.AddCommand(root.NewMCPCmd())
rootCmd.AddCommand(root.NewReviewCmd())
rootCmd.AddCommand(root.NewValidateCmd())

return rootCmd
}
Expand Down
1 change: 1 addition & 0 deletions internal/spinner.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ func NewSpinner(description string) *Spinner {
progressbar.OptionSetDescription(description),
progressbar.OptionSetWriter(os.Stderr),
progressbar.OptionOnCompletion(func() { _, _ = fmt.Fprint(os.Stderr, "\n") }),
progressbar.OptionClearOnFinish(),
progressbar.OptionSpinnerType(14))
return &Spinner{bar: bar, stop: make(chan struct{})}
}
Expand Down
24 changes: 24 additions & 0 deletions internal/validate.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package internal

import (
"github.com/spf13/cobra"

"github.com/nobl9/nobl9-go/sdk"
)

type ValidateCmd struct {
client *sdk.Client
}

func (r *RootCmd) NewValidateCmd() *cobra.Command {
validate := &ValidateCmd{}
cmd := &cobra.Command{
Use: "validate",
Short: "Validate Nobl9 resources.",
RunE: func(cmd *cobra.Command, args []string) error {
return cmd.Help()
},
}
cmd.AddCommand(validate.NewSLICmd(r.GetClient))
return cmd
}
Loading
Loading