-
Notifications
You must be signed in to change notification settings - Fork 96
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: adds
agent config
command that returns the agent configuration
- closes #4113
- Loading branch information
frrist
committed
Oct 28, 2024
1 parent
efddb20
commit 5b0f545
Showing
5 changed files
with
66 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package agent | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/spf13/cobra" | ||
|
||
"github.com/bacalhau-project/bacalhau/cmd/util" | ||
"github.com/bacalhau-project/bacalhau/pkg/publicapi/client/v2" | ||
) | ||
|
||
func NewConfigCmd() *cobra.Command { | ||
configCmd := &cobra.Command{ | ||
Use: "config", | ||
Short: "Get the agent's configuration.", | ||
Args: cobra.NoArgs, | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
cfg, err := util.SetupRepoConfig(cmd) | ||
if err != nil { | ||
return fmt.Errorf("failed to setup repo: %w", err) | ||
} | ||
api, err := util.GetAPIClientV2(cmd, cfg) | ||
if err != nil { | ||
return fmt.Errorf("failed to create api client: %w", err) | ||
} | ||
return run(cmd, api) | ||
}, | ||
} | ||
return configCmd | ||
} | ||
|
||
func run(cmd *cobra.Command, api client.API) error { | ||
ctx := cmd.Context() | ||
response, err := api.Agent().Config(ctx) | ||
if err != nil { | ||
return fmt.Errorf("cannot get agent config: %w", err) | ||
} | ||
cmd.Println(string(response.Config)) | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters