Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var Cmd = &cobra.Command{ Use: "set-default [optional file]", Short: "Sets the default storage config from stdin or a file", Long: `Sets the default storage config from stdin or a file`, Args: cobra.MaximumNArgs(1), PreRun: func(cmd *cobra.Command, args []string) { err := viper.BindPFlags(cmd.Flags()) c.CheckErr(err) }, Run: func(cmd *cobra.Command, args []string) { ctx, cancel := context.WithTimeout(context.Background(), time.Second*60) defer cancel() var reader io.Reader if len(args) > 0 { file, err := os.Open(args[0]) defer func() { if err := file.Close(); err != nil { log.Errorf("closing config file: %s", err) } }() reader = file c.CheckErr(err) } else { reader = cmd.InOrStdin() } buf := new(bytes.Buffer) _, err := buf.ReadFrom(reader) c.CheckErr(err) config := &userPb.StorageConfig{} err = protojson.UnmarshalOptions{}.Unmarshal(buf.Bytes(), config) c.CheckErr(err) _, err = c.PowClient.StorageConfig.SetDefault(c.MustAuthCtx(ctx), config) c.CheckErr(err) }, }
Cmd is the command.
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.