Skip to content

Commit

Permalink
format everything with gofmt -s -w .
Browse files Browse the repository at this point in the history
  • Loading branch information
Michal Tichák committed Oct 30, 2024
1 parent ddb067b commit 595a2c2
Show file tree
Hide file tree
Showing 104 changed files with 488 additions and 472 deletions.
2 changes: 1 addition & 1 deletion apricot/cacheproxy/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ func (s Service) GetDetectorsForHosts(hosts []string) ([]string, error) {
detectors[det] = struct{}{}
}
detList := make([]string, 0, len(detectors))
for det, _ := range detectors {
for det := range detectors {
detList = append(detList, det)
}
return detList, nil
Expand Down
4 changes: 2 additions & 2 deletions apricot/local/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ func (s *Service) GetDetectorsForHosts(hosts []string) ([]string, error) {

detectorSlice := make([]string, len(detectorMap))
i := 0
for k, _ := range detectorMap {
for k := range detectorMap {
detectorSlice[i] = k
i++
}
Expand Down Expand Up @@ -548,7 +548,7 @@ func (s *Service) ListComponents() (components []string, err error) {
}
components = make([]string, len(componentSet))
i := 0
for component, _ := range componentSet {
for component := range componentSet {
components[i] = component
i++
}
Expand Down
2 changes: 1 addition & 1 deletion apricot/local/servicehttp.go
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ func (httpsvc *HttpService) ApiListComponentEntries(w http.ResponseWriter, r *ht
filteredEntries := make([]string, 0)
if hasRuntype { // if there's any filtering to do
for _, entry := range entries {
for filterPrefix, _ := range filterPrefixes {
for filterPrefix := range filterPrefixes {
if strings.HasPrefix(entry, filterPrefix) {
filteredEntries = append(filteredEntries, entry)
}
Expand Down
3 changes: 1 addition & 2 deletions apricot/remote/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,8 @@ func newRpcClient(cxt context.Context, cancel context.CancelFunc, endpoint strin

client := &rpcClient{
ApricotClient: apricotpb.NewApricotClient(conn),
conn: conn,
conn: conn,
}

return client
}

14 changes: 7 additions & 7 deletions cmd/coconut/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,18 @@

package main

import(
import (
"github.com/AliceO2Group/Control/coconut/cmd"
"github.com/teo/logrus-prefixed-formatter"
log "github.com/sirupsen/logrus"
"github.com/teo/logrus-prefixed-formatter"
)

func init() {
log.SetFormatter(&prefixed.TextFormatter{
DisableTimestamp:true,
FullTimestamp: true,
SpacePadding: 20,
PrefixPadding: 12,
DisableTimestamp: true,
FullTimestamp: true,
SpacePadding: 20,
PrefixPadding: 12,

// Needed for colored stdout/stderr in GoLand, IntelliJ, etc.
ForceColors: true,
Expand All @@ -45,4 +45,4 @@ func init() {

func main() {
cmd.Execute()
}
}
1 change: 0 additions & 1 deletion cmd/walnut/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
// Package walnut implements the O² Workflow Administration and Linting Utility.
package main


import "github.com/AliceO2Group/Control/walnut/cmd"

func main() {
Expand Down
2 changes: 1 addition & 1 deletion coconut/app/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ const (
NAME = "coconut"
PRETTY_SHORTNAME = "coconut"
PRETTY_FULLNAME = "O² Control and Configuration Utility"
)
)
25 changes: 15 additions & 10 deletions coconut/cmd/about.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,20 @@
package cmd

import (
"fmt"
"github.com/AliceO2Group/Control/coconut/app"
"github.com/fatih/color"
"github.com/spf13/cobra"
"fmt"
"github.com/spf13/viper"
"github.com/fatih/color"
"time"
)

// aboutCmd represents the about command
var aboutCmd = &cobra.Command{
Use: "about",
Use: "about",
Aliases: []string{},
Short: fmt.Sprintf("about %s", app.NAME),
Long: `The about command shows some basic information on this utility.`,
Short: fmt.Sprintf("about %s", app.NAME),
Long: `The about command shows some basic information on this utility.`,
Run: func(*cobra.Command, []string) {
color.Set(color.FgHiWhite)
fmt.Print(app.PRETTY_SHORTNAME + " *** ")
Expand All @@ -52,15 +52,20 @@ endpoint: %s
config_endpoint: %s
`,
color.HiGreenString(viper.GetString("version")),
color.HiGreenString(func() string {if len(viper.ConfigFileUsed()) > 0 { return viper.ConfigFileUsed() }; return "builtin"}()),
color.HiGreenString(func() string {
if len(viper.ConfigFileUsed()) > 0 {
return viper.ConfigFileUsed()
}
return "builtin"
}()),
color.HiGreenString(viper.GetString("endpoint")),
color.HiGreenString(viper.GetString("config_endpoint")))

color.Set(color.FgHiBlue)
fmt.Printf("\nCopyright 2017-%d CERN and the copyright holders of ALICE O².\n" +
"This program is free software: you can redistribute it and/or modify \n" +
"it under the terms of the GNU General Public License as published by \n" +
"the Free Software Foundation, either version 3 of the License, or \n" +
fmt.Printf("\nCopyright 2017-%d CERN and the copyright holders of ALICE O².\n"+
"This program is free software: you can redistribute it and/or modify \n"+
"it under the terms of the GNU General Public License as published by \n"+
"the Free Software Foundation, either version 3 of the License, or \n"+
"(at your option) any later version.\n", time.Now().Year())
color.Unset()

Expand Down
4 changes: 2 additions & 2 deletions coconut/cmd/configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ import (

// configurationCmd represents the configuration command
var configurationCmd = &cobra.Command{
Use: "configuration",
Use: "configuration",
Aliases: []string{"config", "conf", "c"},
Short: "view or modify O² configuration",
Short: "view or modify O² configuration",
Long: `The configuration command allows you to perform operations on the O²
configuration store.`,
}
Expand Down
8 changes: 4 additions & 4 deletions coconut/cmd/configuration_dump.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,16 @@ import (

// configurationDumpCmd represents the configuration list command
var configurationDumpCmd = &cobra.Command{
Use: "dump [key]",
Use: "dump [key]",
Aliases: []string{"d"},
Short: "dump configuration subtree",
Short: "dump configuration subtree",
Long: `The configuration dump command requests from O² Configuration
a subtree of key-values, and dumps it to standard output in the specified
format. This command has full read access to the O² Configuration store
and performs a raw query with no additional processing or access control
semantics.`,
Run: configuration.WrapCall(configuration.Dump),
Args: cobra.ExactArgs(1),
Run: configuration.WrapCall(configuration.Dump),
Args: cobra.ExactArgs(1),
}

func init() {
Expand Down
8 changes: 4 additions & 4 deletions coconut/cmd/configuration_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,20 @@ import (
)

var configurationListCmd = &cobra.Command{
Use: "list [component]",
Use: "list [component]",
Aliases: []string{"l", "ls"},
Example: `coconut conf list
coconut conf list <component>
coconut conf list <component> -t`,
Short: "List all existing O² components in Consul",
Long: `The configuration list command requests all components
from O² Configuration as a list and displays it on the standard output`,
Run: configuration.WrapCall(configuration.List),
Args: cobra.MaximumNArgs(1),
Run: configuration.WrapCall(configuration.List),
Args: cobra.MaximumNArgs(1),
}

func init() {
configurationCmd.AddCommand(configurationListCmd)
configurationListCmd.Flags().StringP("output", "o", "yaml", "output format for the configuration list (yaml/json)")
configurationListCmd.Flags().BoolP("timestamp", "t", false, "display latest timestamp entries for the requested component")
configurationListCmd.Flags().BoolP("timestamp", "t", false, "display latest timestamp entries for the requested component")
}
12 changes: 6 additions & 6 deletions coconut/cmd/configuration_show.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import (
)

var configurationShowCmd = &cobra.Command{
Use: "show <component> <entry>",
Use: "show <component> <entry>",
Aliases: []string{"s"},
Example: `coconut conf show <component> <entry>
coconut conf show <component> <entry> -t <timestamp>
Expand All @@ -43,15 +43,15 @@ coconut conf show <component> <entry> -s -e '{"key1": "value1", "key2": "value2"
Long: `The configuration show command returns the most recent
configuration revision for the specified component and entry.
It can also return a specific revision, requested with the --timestamp/-t flag`,
Run: configuration.WrapCall(configuration.Show),
Args: cobra.RangeArgs(0, 3),
Run: configuration.WrapCall(configuration.Show),
Args: cobra.RangeArgs(0, 3),
}

func init() {
configurationCmd.AddCommand(configurationShowCmd)
configurationShowCmd.Flags().StringP("timestamp", "t", "", "request configuration for this timestamp")
configurationShowCmd.Flags().StringP("runtype", "r", "", "request configuration for this run type (e.g. PHYSICS, TECHNICAL, etc.)")
configurationShowCmd.Flags().StringP("role", "l", "", "request configuration for this O² machine role")
configurationShowCmd.Flags().StringP("timestamp", "t", "", "request configuration for this timestamp")
configurationShowCmd.Flags().StringP("runtype", "r", "", "request configuration for this run type (e.g. PHYSICS, TECHNICAL, etc.)")
configurationShowCmd.Flags().StringP("role", "l", "", "request configuration for this O² machine role")
configurationShowCmd.Flags().BoolP("simulate", "s", false, "simulate runtime template processing on the configuration payload")
// The following only applies if simulate is set:
configurationShowCmd.Flags().StringP("extra-vars", "e", "", "values passed using key=value CSV or JSON syntax, interpreted as strings `key1=val1,key2=val2` or `{\"key1\": \"value1\", \"key2\": \"value2\"}`")
Expand Down
8 changes: 4 additions & 4 deletions coconut/cmd/environment_control.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ import (

// environmentControlCmd represents the environment list command
var environmentControlCmd = &cobra.Command{
Use: "control [environment id]",
Use: "control [environment id]",
Aliases: []string{"ctl", "ct", "t"},
Short: "control the state machine of an environment",
Short: "control the state machine of an environment",
Long: `The environment control command triggers an event in the state
machine of an existing O² environment. The event, if valid, starts a transition.
The reached state is returned.
Expand All @@ -44,8 +44,8 @@ Valid events:
START_ACTIVITY STOP_ACTIVITY
Not all events are available in all states.`,
Run: control.WrapCall(control.ControlEnvironment),
Args: cobra.ExactArgs(1),
Run: control.WrapCall(control.ControlEnvironment),
Args: cobra.ExactArgs(1),
}

func init() {
Expand Down
8 changes: 4 additions & 4 deletions coconut/cmd/environment_destroy.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,16 @@ import (

// environmentDestroyCmd represents the environment list command
var environmentDestroyCmd = &cobra.Command{
Use: "destroy [environment id]",
Use: "destroy [environment id]",
Aliases: []string{"des", "d"},
Short: "destroy an environment",
Short: "destroy an environment",
Long: fmt.Sprintf(`The environment destroy command instructs %s to
teardown an existing O² environment. The environment must be in the
CONFIGURED or STANDBY state.
By default, all active tasks are killed unless the keep-tasks flag is passed, in which case all tasks are left idle.`, product.PRETTY_SHORTNAME),
Run: control.WrapCall(control.DestroyEnvironment),
Args: cobra.ExactArgs(1),
Run: control.WrapCall(control.DestroyEnvironment),
Args: cobra.ExactArgs(1),
}

func init() {
Expand Down
6 changes: 3 additions & 3 deletions coconut/cmd/environment_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ import (

// environmentListCmd represents the environment list command
var environmentListCmd = &cobra.Command{
Use: "list",
Use: "list",
Aliases: []string{"ls", "l"},
Short: "list environments",
Short: "list environments",
Long: `The environment list command shows a list of currently active environments.
This includes environments in any state.`,
Run: control.WrapCall(control.GetEnvironments),
Run: control.WrapCall(control.GetEnvironments),
}

func init() {
Expand Down
10 changes: 5 additions & 5 deletions coconut/cmd/environment_modify.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,19 @@
package cmd

import (
"github.com/spf13/cobra"
"github.com/AliceO2Group/Control/coconut/control"
"github.com/spf13/cobra"
)

// environmentModifyCmd represents the environment list command
var environmentModifyCmd = &cobra.Command{
Use: "modify [environment id]",
Use: "modify [environment id]",
Aliases: []string{"mod", "m"},
Short: "modify an environment",
Short: "modify an environment",
Long: `The environment modify command changes the roles workflow of an
existing O² environment.`,
Run: control.WrapCall(control.ModifyEnvironment),
Args: cobra.ExactArgs(1),
Run: control.WrapCall(control.ModifyEnvironment),
Args: cobra.ExactArgs(1),
}

func init() {
Expand Down
8 changes: 4 additions & 4 deletions coconut/cmd/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,19 @@ package cmd
import (
"fmt"

"github.com/AliceO2Group/Control/coconut/control"
"github.com/AliceO2Group/Control/common/product"
"github.com/spf13/cobra"
"github.com/AliceO2Group/Control/coconut/control"
)

// infoCmd represents the info command
var infoCmd = &cobra.Command{
Use: "info",
Use: "info",
Aliases: []string{},
Short: fmt.Sprintf("get information on the %s core instance", product.PRETTY_SHORTNAME),
Short: fmt.Sprintf("get information on the %s core instance", product.PRETTY_SHORTNAME),
Long: fmt.Sprintf(`The info command queries the running instance of %s core and
displays some general information.`, product.PRETTY_SHORTNAME),
Run: control.WrapCall(control.GetInfo),
Run: control.WrapCall(control.GetInfo),
}

func init() {
Expand Down
11 changes: 5 additions & 6 deletions coconut/cmd/repo_add.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ import (

// repoAddCmd represents the repo add command
var repoAddCmd = &cobra.Command{
Use: "add <repo url>",
Use: "add <repo url>",
Aliases: []string{"new", "a"},
Short: "add a new git repository",
Short: "add a new git repository",
Long: `The repository add command adds a git repository to the catalogue of repositories used for task and workflow configuration.
The default revision of the repository may be explicitly specified by passing the flag ` + "`--default-revision`" + ` . In any case,
the ensuing list is followed until a valid revision has been identified:
Expand All @@ -45,13 +45,12 @@ the ensuing list is followed until a valid revision has been identified:
Exhaustion of the aforementioned list results in a repo add failure.
` + "`coconut repo add`" + ` can be called with
` + "`coconut repo add`" + ` can be called with
1) a repository identifier
2) a repository identifier coupled with the ` + "`--default-revision`" + ` flag (see examples below)
The protocol prefix should always be omitted.`,
Example:
` * ` + "`coconut repo add github.com/AliceO2Group/ControlWorkflows`" + `
Example: ` * ` + "`coconut repo add github.com/AliceO2Group/ControlWorkflows`" + `
* ` + "`coconut repo add github.com/AliceO2Group/ControlWorkflows --default-revision custom-rev`" + `
* ` + "`coconut repo add alio2-cr1-hv-gw01.cern.ch:/opt/git/ControlWorkflows --default-revision custom-rev`" + `
* ` + "`coconut repo add /home/flp/git/ControlWorkflows`",
Expand All @@ -63,4 +62,4 @@ func init() {
repoCmd.AddCommand(repoAddCmd)

repoAddCmd.Flags().StringP("default-revision", "d", "", "default revision for repository to add")
}
}
7 changes: 3 additions & 4 deletions coconut/cmd/repo_default.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,9 @@ var repoDefaultCmd = &cobra.Command{
Short: "set a git repository as default",
Long: `The repository default command sets a git repository as the default repository for incoming workflow deployment requests.
A repository is referenced through its repo id, as reported by ` + "`coconut repo list`.",
Example:
` * ` + "`coconut repo default 2`",
Run: control.WrapCall(control.SetDefaultRepo),
Args: cobra.ExactArgs(1),
Example: ` * ` + "`coconut repo default 2`",
Run: control.WrapCall(control.SetDefaultRepo),
Args: cobra.ExactArgs(1),
}

func init() {
Expand Down
Loading

0 comments on commit 595a2c2

Please sign in to comment.