style(frontend): gofmt the apiserver and xcecli sources
Formatting only (gofmt -w on the 29 non-vendored, non-generated files gofmt -l reported); swag-generated apiserver/docs/docs.go left as is. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
b57ce6d6a9
commit
3615c7c0fb
29 changed files with 1280 additions and 1285 deletions
|
|
@ -1,50 +1,50 @@
|
|||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"text/tabwriter"
|
||||
"xcecli/common/request"
|
||||
"xcecli/config"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
// NewListCmd create the list command
|
||||
func NewListCmd(configManager *config.ConfigManager) *cobra.Command {
|
||||
return &cobra.Command{
|
||||
Use: "list",
|
||||
GroupID: "api",
|
||||
Short: "List the API Servers",
|
||||
Long: "List all the configured API Servers and the default API Server",
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
return runList(configManager)
|
||||
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func runList(cm *config.ConfigManager) error {
|
||||
cfg, err := cm.GetConfig()
|
||||
if err != nil {
|
||||
errMsg := request.ExtractErrorMessage(err)
|
||||
return fmt.Errorf("failed to get the config: [%s]", errMsg)
|
||||
}
|
||||
|
||||
// use tabwriter to format the output
|
||||
w := tabwriter.NewWriter(os.Stdout, 0, 0, 3, ' ', 0)
|
||||
fmt.Fprintln(w, "Default\tVersion\tURL")
|
||||
|
||||
for _, server := range cfg.APIServerInfo {
|
||||
isDefault := " "
|
||||
if server.Token == "" {
|
||||
continue
|
||||
}
|
||||
|
||||
fmt.Fprintf(w, "%s\t%s\n",
|
||||
isDefault,
|
||||
server.URL)
|
||||
}
|
||||
|
||||
return w.Flush()
|
||||
}
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"text/tabwriter"
|
||||
"xcecli/common/request"
|
||||
"xcecli/config"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
// NewListCmd create the list command
|
||||
func NewListCmd(configManager *config.ConfigManager) *cobra.Command {
|
||||
return &cobra.Command{
|
||||
Use: "list",
|
||||
GroupID: "api",
|
||||
Short: "List the API Servers",
|
||||
Long: "List all the configured API Servers and the default API Server",
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
return runList(configManager)
|
||||
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func runList(cm *config.ConfigManager) error {
|
||||
cfg, err := cm.GetConfig()
|
||||
if err != nil {
|
||||
errMsg := request.ExtractErrorMessage(err)
|
||||
return fmt.Errorf("failed to get the config: [%s]", errMsg)
|
||||
}
|
||||
|
||||
// use tabwriter to format the output
|
||||
w := tabwriter.NewWriter(os.Stdout, 0, 0, 3, ' ', 0)
|
||||
fmt.Fprintln(w, "Default\tVersion\tURL")
|
||||
|
||||
for _, server := range cfg.APIServerInfo {
|
||||
isDefault := " "
|
||||
if server.Token == "" {
|
||||
continue
|
||||
}
|
||||
|
||||
fmt.Fprintf(w, "%s\t%s\n",
|
||||
isDefault,
|
||||
server.URL)
|
||||
}
|
||||
|
||||
return w.Flush()
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue