16
"github.com/spf13/cobra"
18
"github.com/siderolabs/talos/cmd/talosctl/pkg/talos/helpers"
19
"github.com/siderolabs/talos/pkg/machinery/client"
23
var readCmd = &cobra.Command{
25
Short: "Read a file on the machine",
27
Args: cobra.ExactArgs(1),
28
Aliases: []string{"cat"},
29
ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
31
return nil, cobra.ShellCompDirectiveError | cobra.ShellCompDirectiveNoFileComp
34
return completePathFromNode(toComplete), cobra.ShellCompDirectiveNoFileComp
36
RunE: func(cmd *cobra.Command, args []string) error {
37
return WithClient(func(ctx context.Context, c *client.Client) error {
38
if err := helpers.FailIfMultiNodes(ctx, "read"); err != nil {
42
r, err := c.Read(ctx, args[0])
44
return fmt.Errorf("error reading file: %w", err)
49
_, err = io.Copy(os.Stdout, r)
51
return fmt.Errorf("error reading: %w", err)
60
readCmd.Flags().StringSliceVarP(&readCmdFlags.configFiles, "file",
61
"f", nil, "specify config files or patches in a YAML file (can specify multiple)",
63
readCmd.PreRunE = func(cmd *cobra.Command,
65
args []string) error {
69
endpointsFromArgs := len(GlobalArgs.Endpoints) > 0
70
for _, configFile := range readCmdFlags.configFiles {
71
if err := processModelineAndUpdateGlobals(configFile, nodesFromArgs,
72
endpointsFromArgs, false,
83
var readCmdFlags struct {