Skip to content

Commit d662a71

Browse files
authored
Merge branch 'main' into dependabot/go_modules/golang.org/x/time-0.6.0
2 parents 570d993 + ae552cf commit d662a71

31 files changed

+663
-269
lines changed

cmd/cli/config/list.go

+7-11
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import (
1010
"github.com/bacalhau-project/bacalhau/cmd/util/flags/cliflags"
1111
"github.com/bacalhau-project/bacalhau/cmd/util/hook"
1212
"github.com/bacalhau-project/bacalhau/cmd/util/output"
13-
"github.com/bacalhau-project/bacalhau/pkg/config"
1413
"github.com/bacalhau-project/bacalhau/pkg/config/types"
1514
)
1615

@@ -23,8 +22,13 @@ func newListCmd() *cobra.Command {
2322
Wide: false,
2423
}
2524
listCmd := &cobra.Command{
26-
Use: "list",
27-
Short: "List all config keys.",
25+
Use: "list",
26+
Short: "List all config keys and their descriptions",
27+
Long: `The config list command displays all available configuration keys along with their detailed descriptions.
28+
This comprehensive list helps you understand the settings you can adjust to customize the bacalhau's behavior.
29+
Each key shown can be used with:
30+
- bacalhau config set <key> <value> to directly set the value
31+
- bacalhau --config=<key>=<value> to temporarily modify the setting for a single command execution`,
2832
Args: cobra.MinimumNArgs(0),
2933
PreRunE: hook.ClientPreRunHooks,
3034
PostRunE: hook.ClientPostRunHooks,
@@ -38,7 +42,6 @@ func newListCmd() *cobra.Command {
3842

3943
type configListEntry struct {
4044
Key string
41-
EnvVar string
4245
Description string
4346
}
4447

@@ -51,7 +54,6 @@ func list(cmd *cobra.Command, o output.OutputOptions) error {
5154
for key, description := range types.ConfigDescriptions {
5255
cfgList = append(cfgList, configListEntry{
5356
Key: key,
54-
EnvVar: config.KeyAsEnvVar(key),
5557
Description: description,
5658
})
5759
}
@@ -70,12 +72,6 @@ var listColumns = []output.TableColumn[configListEntry]{
7072
return s.Key
7173
},
7274
},
73-
{
74-
ColumnConfig: table.ColumnConfig{Name: "Environment Variable", WidthMax: 80, WidthMaxEnforcer: text.WrapHard},
75-
Value: func(v configListEntry) string {
76-
return fmt.Sprintf("%v", v.EnvVar)
77-
},
78-
},
7975
{
8076
ColumnConfig: table.ColumnConfig{Name: "Description", WidthMax: 80, WidthMaxEnforcer: text.WrapText},
8177
Value: func(v configListEntry) string {

cmd/cli/job/describe.go

+10-6
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,13 @@ func NewDescribeOptions() *DescribeOptions {
5656
func NewDescribeCmd() *cobra.Command {
5757
o := NewDescribeOptions()
5858
jobCmd := &cobra.Command{
59-
Use: "describe [id]",
60-
Short: "Get the info of a job by id.",
61-
Long: describeLong,
62-
Example: describeExample,
63-
Args: cobra.ExactArgs(1),
59+
Use: "describe [id]",
60+
Short: "Get the info of a job by id.",
61+
Long: describeLong,
62+
Example: describeExample,
63+
SilenceUsage: true,
64+
SilenceErrors: true,
65+
Args: cobra.ExactArgs(1),
6466
RunE: func(cmd *cobra.Command, args []string) error {
6567
// initialize a new or open an existing repo merging any config file(s) it contains into cfg.
6668
cfg, err := util.SetupRepoConfig(cmd)
@@ -75,20 +77,22 @@ func NewDescribeCmd() *cobra.Command {
7577
return o.run(cmd, args, api)
7678
},
7779
}
80+
7881
jobCmd.Flags().AddFlagSet(cliflags.OutputNonTabularFormatFlags(&o.OutputOpts))
7982
return jobCmd
8083
}
8184

8285
func (o *DescribeOptions) run(cmd *cobra.Command, args []string, api client.API) error {
8386
ctx := cmd.Context()
8487
jobID := args[0]
88+
8589
response, err := api.Jobs().Get(ctx, &apimodels.GetJobRequest{
8690
JobID: jobID,
8791
Include: "executions,history",
8892
})
8993

9094
if err != nil {
91-
return fmt.Errorf("could not get job %s: %w", jobID, err)
95+
return err
9296
}
9397

9498
if o.OutputOpts.Format != "" {

cmd/cli/job/executions.go

+12-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package job
22

33
import (
4+
"errors"
45
"fmt"
56
"strconv"
67
"time"
@@ -56,11 +57,13 @@ func NewExecutionCmd() *cobra.Command {
5657
o := NewExecutionOptions()
5758

5859
nodeCmd := &cobra.Command{
59-
Use: "executions [id]",
60-
Short: executionShort,
61-
Long: executionLong,
62-
Example: executionExample,
63-
Args: cobra.ExactArgs(1),
60+
Use: "executions [id]",
61+
Short: executionShort,
62+
Long: executionLong,
63+
Example: executionExample,
64+
SilenceUsage: true,
65+
SilenceErrors: true,
66+
Args: cobra.ExactArgs(1),
6467
RunE: func(cmd *cobra.Command, args []string) error {
6568
// initialize a new or open an existing repo merging any config file(s) it contains into cfg.
6669
cfg, err := util.SetupRepoConfig(cmd)
@@ -76,6 +79,9 @@ func NewExecutionCmd() *cobra.Command {
7679
},
7780
}
7881

82+
nodeCmd.SilenceUsage = true
83+
nodeCmd.SilenceErrors = true
84+
7985
nodeCmd.Flags().AddFlagSet(cliflags.ListFlags(&o.ListOptions))
8086
nodeCmd.Flags().AddFlagSet(cliflags.OutputFormatFlags(&o.OutputOptions))
8187
return nodeCmd
@@ -147,7 +153,7 @@ func (o *ExecutionOptions) run(cmd *cobra.Command, args []string, api client.API
147153
},
148154
})
149155
if err != nil {
150-
return err
156+
return errors.New(err.Error())
151157
}
152158

153159
if err = output.Output(cmd, executionColumns, o.OutputOptions, response.Items); err != nil {

cmd/cli/job/get.go

+10-8
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,15 @@ func NewGetCmd() *cobra.Command {
5050
}
5151

5252
getCmd := &cobra.Command{
53-
Use: "get [id]",
54-
Short: "Get the results of a job",
55-
Long: getLong,
56-
Example: getExample,
57-
Args: cobra.ExactArgs(1),
58-
PreRunE: hook.Chain(hook.RemoteCmdPreRunHooks, configflags.PreRun(viper.GetViper(), getFlags)),
59-
PostRunE: hook.RemoteCmdPostRunHooks,
53+
Use: "get [id]",
54+
Short: "Get the results of a job",
55+
Long: getLong,
56+
Example: getExample,
57+
Args: cobra.ExactArgs(1),
58+
PreRunE: hook.Chain(hook.RemoteCmdPreRunHooks, configflags.PreRun(viper.GetViper(), getFlags)),
59+
PostRunE: hook.RemoteCmdPostRunHooks,
60+
SilenceUsage: true,
61+
SilenceErrors: true,
6062
RunE: func(cmd *cobra.Command, cmdArgs []string) error {
6163
// initialize a new or open an existing repo merging any config file(s) it contains into cfg.
6264
cfg, err := util.SetupRepoConfig(cmd)
@@ -108,7 +110,7 @@ func get(cmd *cobra.Command, cmdArgs []string, api client.API, cfg types.Bacalha
108110
jobID,
109111
OG.DownloadSettings,
110112
); err != nil {
111-
return fmt.Errorf("downloading job: %w", err)
113+
return err
112114
}
113115

114116
return nil

cmd/cli/job/get_test.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,12 @@ func (s *GetSuite) TestGetSingleFileFromOutputBadChoice() {
5353
require.NoError(s.T(), err, "Error submitting job")
5454
jobID := system.FindJobIDInTestOutput(out)
5555

56-
_, getoutput, err := s.ExecuteTestCobraCommand("job", "get",
56+
_, _, err = s.ExecuteTestCobraCommand("job", "get",
5757
"--config", fmt.Sprintf("%s=%s", types.ResultDownloadersTypesIPFSEndpointKey, s.Config.ResultDownloaders.Types.IPFS.Endpoint),
5858
fmt.Sprintf("%s/missing", jobID),
5959
)
6060

6161
require.Error(s.T(), err, "expected error but it wasn't returned")
62-
require.Contains(s.T(), getoutput, "Error: downloading job")
6362
}
6463

6564
func (s *GetSuite) TestGetSingleFileFromOutput() {

cmd/cli/job/history.go

+9-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package job
22

33
import (
4+
"errors"
45
"fmt"
56
"time"
67

@@ -58,11 +59,13 @@ func NewHistoryOptions() *HistoryOptions {
5859
func NewHistoryCmd() *cobra.Command {
5960
o := NewHistoryOptions()
6061
nodeCmd := &cobra.Command{
61-
Use: "history [id]",
62-
Short: historyShort,
63-
Long: historyLong,
64-
Example: historyExample,
65-
Args: cobra.ExactArgs(1),
62+
Use: "history [id]",
63+
Short: historyShort,
64+
Long: historyLong,
65+
Example: historyExample,
66+
SilenceUsage: true,
67+
SilenceErrors: true,
68+
Args: cobra.ExactArgs(1),
6669
RunE: func(cmd *cobra.Command, args []string) error {
6770
// initialize a new or open an existing repo merging any config file(s) it contains into cfg.
6871
cfg, err := util.SetupRepoConfig(cmd)
@@ -160,7 +163,7 @@ func (o *HistoryOptions) run(cmd *cobra.Command, args []string, api client.API)
160163
},
161164
})
162165
if err != nil {
163-
return err
166+
return errors.New(err.Error())
164167
}
165168

166169
if err = output.Output(cmd, historyColumns, o.OutputOptions, response.Items); err != nil {

cmd/cli/job/list.go

+7-5
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,13 @@ func NewListOptions() *ListOptions {
6464
func NewListCmd() *cobra.Command {
6565
o := NewListOptions()
6666
listCmd := &cobra.Command{
67-
Use: "list",
68-
Short: listShort,
69-
Long: listLong,
70-
Example: listExample,
71-
Args: cobra.NoArgs,
67+
Use: "list",
68+
Short: listShort,
69+
Long: listLong,
70+
Example: listExample,
71+
Args: cobra.NoArgs,
72+
SilenceUsage: true,
73+
SilenceErrors: true,
7274
RunE: func(cmd *cobra.Command, _ []string) error {
7375
// initialize a new or open an existing repo merging any config file(s) it contains into cfg.
7476
cfg, err := util.SetupRepoConfig(cmd)

cmd/cli/job/logs.go

+6-4
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,12 @@ func NewLogCmd() *cobra.Command {
3737
options := LogCommandOptions{}
3838

3939
logsCmd := &cobra.Command{
40-
Use: "logs [id]",
41-
Short: logsShortDesc,
42-
Example: logsExample,
43-
Args: cobra.ExactArgs(1),
40+
Use: "logs [id]",
41+
Short: logsShortDesc,
42+
Example: logsExample,
43+
Args: cobra.ExactArgs(1),
44+
SilenceUsage: true,
45+
SilenceErrors: true,
4446
RunE: func(cmd *cobra.Command, cmdArgs []string) error {
4547
opts := util.LogOptions{
4648
JobID: cmdArgs[0],

cmd/cli/job/run.go

+7-5
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,13 @@ func NewRunCmd() *cobra.Command {
5555
o := NewRunOptions()
5656

5757
runCmd := &cobra.Command{
58-
Use: "run",
59-
Short: "Run a job using a json or yaml file.",
60-
Long: runLong,
61-
Example: runExample,
62-
Args: cobra.MinimumNArgs(0),
58+
Use: "run",
59+
Short: "Run a job using a json or yaml file.",
60+
Long: runLong,
61+
Example: runExample,
62+
Args: cobra.MinimumNArgs(0),
63+
SilenceUsage: true,
64+
SilenceErrors: true,
6365
RunE: func(cmd *cobra.Command, args []string) error {
6466
// initialize a new or open an existing repo merging any config file(s) it contains into cfg.
6567
cfg, err := util.SetupRepoConfig(cmd)

cmd/cli/job/run_test.go

-3
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ import (
77
"fmt"
88
"testing"
99

10-
"github.com/bacalhau-project/bacalhau/pkg/userstrings"
11-
"github.com/stretchr/testify/assert"
1210
"github.com/stretchr/testify/require"
1311
"github.com/stretchr/testify/suite"
1412

@@ -46,7 +44,6 @@ func (s *RunSuite) TestRun() {
4644

4745
if tc.Invalid {
4846
require.Error(s.T(), err, "Should have seen error submitting job")
49-
assert.Contains(s.T(), out, userstrings.JobSpecBad)
5047
} else {
5148
require.NoError(s.T(), err, "Error submitting job")
5249
testutils.GetJobFromTestOutput(ctx, s.T(), s.ClientV2, out)

cmd/cli/job/stop.go

+10-5
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,13 @@ func NewStopCmd() *cobra.Command {
5656
o := NewStopOptions()
5757

5858
stopCmd := &cobra.Command{
59-
Use: "stop [id]",
60-
Short: "Stop a previously submitted job",
61-
Long: stopLong,
62-
Example: stopExample,
63-
Args: cobra.ExactArgs(1),
59+
Use: "stop [id]",
60+
Short: "Stop a previously submitted job",
61+
Long: stopLong,
62+
Example: stopExample,
63+
SilenceUsage: true,
64+
SilenceErrors: true,
65+
Args: cobra.ExactArgs(1),
6466
RunE: func(cmd *cobra.Command, args []string) error {
6567
// initialize a new or open an existing repo merging any config file(s) it contains into cfg.
6668
cfg, err := util.SetupRepoConfig(cmd)
@@ -76,6 +78,9 @@ func NewStopCmd() *cobra.Command {
7678
},
7779
}
7880

81+
stopCmd.SilenceUsage = true
82+
stopCmd.SilenceErrors = true
83+
7984
stopCmd.PersistentFlags().BoolVar(&o.Quiet, "quiet", o.Quiet,
8085
`Do not print anything to stdout or stderr`,
8186
)

cmd/cli/job/validate.go

+10-9
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,12 @@ const JobSpecLink = "https://docs.bacalhau.org/setting-up/jobs/job"
2828

2929
func NewValidateCmd() *cobra.Command {
3030
validateCmd := &cobra.Command{
31-
Use: "validate",
32-
Short: "validate a job using a json or yaml file.",
33-
Long: validateLong,
34-
Example: validateExample,
35-
Args: cobra.MinimumNArgs(1),
36-
// so we don't print the usage when a job is invalid, just print the validation errors
37-
// --help will still show usage
38-
SilenceUsage: true,
39-
// so we don't print the error twice
31+
Use: "validate",
32+
Short: "validate a job using a json or yaml file.",
33+
Long: validateLong,
34+
Example: validateExample,
35+
Args: cobra.MinimumNArgs(1),
36+
SilenceUsage: true,
4037
SilenceErrors: true,
4138
RunE: func(cmd *cobra.Command, cmdArgs []string) error {
4239
err := run(cmd, cmdArgs)
@@ -50,6 +47,10 @@ func NewValidateCmd() *cobra.Command {
5047
return nil
5148
},
5249
}
50+
51+
validateCmd.SilenceUsage = true
52+
validateCmd.SilenceErrors = true
53+
5354
return validateCmd
5455
}
5556

cmd/cli/node/action.go

+5-3
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,11 @@ func NewActionCmd(action apimodels.NodeAction) *cobra.Command {
2222
}
2323

2424
cmd := &cobra.Command{
25-
Use: fmt.Sprintf("%s [id]", action),
26-
Short: action.Description(),
27-
Args: cobra.ExactArgs(1),
25+
Use: fmt.Sprintf("%s [id]", action),
26+
Short: action.Description(),
27+
Args: cobra.ExactArgs(1),
28+
SilenceUsage: true,
29+
SilenceErrors: true,
2830
RunE: func(cmd *cobra.Command, args []string) error {
2931
// initialize a new or open an existing repo merging any config file(s) it contains into cfg.
3032
cfg, err := util.SetupRepoConfig(cmd)

cmd/cli/node/describe.go

+9-3
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,11 @@ func NewDescribeCmd() *cobra.Command {
2828
o := NewDescribeOptions()
2929

3030
nodeCmd := &cobra.Command{
31-
Use: "describe [id]",
32-
Short: "Get the info of a node by id.",
33-
Args: cobra.ExactArgs(1),
31+
Use: "describe [id]",
32+
Short: "Get the info of a node by id.",
33+
Args: cobra.ExactArgs(1),
34+
SilenceUsage: true,
35+
SilenceErrors: true,
3436
RunE: func(cmd *cobra.Command, args []string) error {
3537
// initialize a new or open an existing repo merging any config file(s) it contains into cfg.
3638
cfg, err := util.SetupRepoConfig(cmd)
@@ -45,6 +47,10 @@ func NewDescribeCmd() *cobra.Command {
4547
return o.runDescribe(cmd, args, api)
4648
},
4749
}
50+
51+
nodeCmd.SilenceUsage = true
52+
nodeCmd.SilenceErrors = true
53+
4854
nodeCmd.Flags().AddFlagSet(cliflags.OutputNonTabularFormatFlags(&o.OutputOpts))
4955
return nodeCmd
5056
}

0 commit comments

Comments
 (0)