From 595a2c2ce64b276545d2dcbedb273ea6fb52ab9a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Tich=C3=A1k?= Date: Wed, 30 Oct 2024 14:19:39 +0100 Subject: [PATCH] format everything with gofmt -s -w . --- apricot/cacheproxy/service.go | 2 +- apricot/local/service.go | 4 +- apricot/local/servicehttp.go | 2 +- apricot/remote/client.go | 3 +- cmd/coconut/main.go | 14 +- cmd/walnut/main.go | 1 - coconut/app/constants.go | 2 +- coconut/cmd/about.go | 25 ++-- coconut/cmd/configuration.go | 4 +- coconut/cmd/configuration_dump.go | 8 +- coconut/cmd/configuration_list.go | 8 +- coconut/cmd/configuration_show.go | 12 +- coconut/cmd/environment_control.go | 8 +- coconut/cmd/environment_destroy.go | 8 +- coconut/cmd/environment_list.go | 6 +- coconut/cmd/environment_modify.go | 10 +- coconut/cmd/info.go | 8 +- coconut/cmd/repo_add.go | 11 +- coconut/cmd/repo_default.go | 7 +- coconut/cmd/repo_default_revision.go | 5 +- coconut/cmd/repo_list.go | 8 +- coconut/cmd/repo_refresh.go | 11 +- coconut/cmd/repo_remove.go | 9 +- coconut/cmd/role.go | 4 +- coconut/cmd/role_query.go | 12 +- coconut/cmd/task.go | 4 +- coconut/cmd/task_clean.go | 10 +- coconut/cmd/task_list.go | 8 +- coconut/cmd/template.go | 4 +- coconut/control/control.go | 2 +- coconut/doc/generate.go | 5 +- common/cmdinfo.go | 4 +- common/controlmode/controlmode.go | 2 +- common/event/environmentevents.go | 4 +- common/event/roleevent.go | 2 +- common/event/taskevents.go | 12 +- common/event/tasksreleasedevent.go | 6 +- common/event/taskstatechangedevent.go | 8 +- common/logger/infologger/fields.go | 28 ++-- common/logger/infologger/hook.go | 3 +- common/logger/infologger/protocols.go | 10 +- common/logger/infologger/utils.go | 8 +- common/logger/loggercopy.go | 6 +- common/product/constants.go | 17 ++- common/system/systemid.go | 7 +- common/taskcmdinfo.go | 2 +- configuration/cfgbackend/configurationmap.go | 8 +- configuration/template/fieldwrappers.go | 4 +- configuration/template/loader.go | 2 +- core/controlcommands/command.go | 6 +- core/controlcommands/multiresponse.go | 8 +- core/environment/environment.go | 8 +- core/environment/manager.go | 4 +- core/globalstate.go | 3 +- core/integration/odc/handlers.go | 4 +- core/integration/odc/odcutils/state.go | 12 +- core/integration/trg/client.go | 19 ++- core/integration/trg/trgutil.go | 2 +- core/repos/repomanager.go | 22 ++-- core/repos/reposervice.go | 23 ++-- core/repos/repoutils.go | 31 +++-- core/repos/varsource/varsource.go | 1 + core/server.go | 2 +- core/servertypes.go | 1 + core/signals.go | 15 +-- core/task/agentcache.go | 10 +- core/task/channel/channel.go | 29 +++-- core/task/channel/endpoint.go | 25 ++-- core/task/channel/transport.go | 2 + core/task/constraint/constraints.go | 16 ++- core/task/coreevent.go | 47 ++++--- core/task/manager.go | 6 +- core/task/roster.go | 2 +- core/task/safeacks.go | 17 ++- core/task/scheduler.go | 6 +- core/task/schedutil/credentials.go | 1 - core/task/schedutil/forever.go | 2 +- core/task/schedutil/mesosutil.go | 7 +- core/task/taskclass/port/range.go | 2 +- core/task/taskop/messagetype.go | 4 +- core/workflow/aggregatorrole.go | 2 +- core/workflow/aggregatortemplate.go | 9 +- core/workflow/callable/maps.go | 4 +- core/workflow/calltemplate.go | 4 +- core/workflow/graft.go | 122 +++++++++--------- core/workflow/includetemplate.go | 4 +- core/workflow/iteratorrole.go | 4 +- core/workflow/rolebase.go | 4 +- core/workflow/roleutils.go | 2 +- core/workflow/tasktemplate.go | 4 +- executor/executable/pid_util.go | 4 +- executor/executorcmd/nopb/jsoncodec.go | 2 +- executor/executorcmd/nopb/occclient.go | 9 +- executor/executorcmd/nopb/test/main.go | 16 +-- executor/executorcmd/transitioner/direct.go | 2 +- executor/executorcmd/transitioner/fairmq.go | 17 +-- .../executorcmd/transitioner/fairmq/states.go | 4 +- .../transitioner/fairmq/transitions.go | 4 +- .../executorcmd/transitioner/transitioner.go | 11 +- occ/peanut/flatten/flatten.go | 3 +- walnut/converter/converter_test.go | 4 +- walnut/converter/testvalues.go | 16 +-- walnut/includeschemata.go | 8 +- walnut/schemata/schemata.go | 6 +- 104 files changed, 488 insertions(+), 472 deletions(-) diff --git a/apricot/cacheproxy/service.go b/apricot/cacheproxy/service.go index b0c55a608..99cfd4bdc 100644 --- a/apricot/cacheproxy/service.go +++ b/apricot/cacheproxy/service.go @@ -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 diff --git a/apricot/local/service.go b/apricot/local/service.go index 537ea553b..11af8add2 100644 --- a/apricot/local/service.go +++ b/apricot/local/service.go @@ -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++ } @@ -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++ } diff --git a/apricot/local/servicehttp.go b/apricot/local/servicehttp.go index ffcd58081..50e66995b 100644 --- a/apricot/local/servicehttp.go +++ b/apricot/local/servicehttp.go @@ -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) } diff --git a/apricot/remote/client.go b/apricot/remote/client.go index 1bc56cf85..6ded1cfbb 100644 --- a/apricot/remote/client.go +++ b/apricot/remote/client.go @@ -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 } - diff --git a/cmd/coconut/main.go b/cmd/coconut/main.go index 5d37d112f..e3a66aa7b 100644 --- a/cmd/coconut/main.go +++ b/cmd/coconut/main.go @@ -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, @@ -45,4 +45,4 @@ func init() { func main() { cmd.Execute() -} \ No newline at end of file +} diff --git a/cmd/walnut/main.go b/cmd/walnut/main.go index f013878d9..5c41f873b 100644 --- a/cmd/walnut/main.go +++ b/cmd/walnut/main.go @@ -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() { diff --git a/coconut/app/constants.go b/coconut/app/constants.go index 89a56c547..e66f78d47 100644 --- a/coconut/app/constants.go +++ b/coconut/app/constants.go @@ -28,4 +28,4 @@ const ( NAME = "coconut" PRETTY_SHORTNAME = "coconut" PRETTY_FULLNAME = "O² Control and Configuration Utility" -) \ No newline at end of file +) diff --git a/coconut/cmd/about.go b/coconut/cmd/about.go index 6519b4fc5..02b9f1298 100644 --- a/coconut/cmd/about.go +++ b/coconut/cmd/about.go @@ -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 + " *** ") @@ -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() diff --git a/coconut/cmd/configuration.go b/coconut/cmd/configuration.go index 39bfde7a3..2f1455323 100644 --- a/coconut/cmd/configuration.go +++ b/coconut/cmd/configuration.go @@ -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.`, } diff --git a/coconut/cmd/configuration_dump.go b/coconut/cmd/configuration_dump.go index c2268ab09..86d93d5a1 100644 --- a/coconut/cmd/configuration_dump.go +++ b/coconut/cmd/configuration_dump.go @@ -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() { diff --git a/coconut/cmd/configuration_list.go b/coconut/cmd/configuration_list.go index 95de8dcb2..0a116da4f 100644 --- a/coconut/cmd/configuration_list.go +++ b/coconut/cmd/configuration_list.go @@ -30,7 +30,7 @@ import ( ) var configurationListCmd = &cobra.Command{ - Use: "list [component]", + Use: "list [component]", Aliases: []string{"l", "ls"}, Example: `coconut conf list coconut conf list @@ -38,12 +38,12 @@ coconut conf list -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") } diff --git a/coconut/cmd/configuration_show.go b/coconut/cmd/configuration_show.go index 465811868..712d55ba2 100644 --- a/coconut/cmd/configuration_show.go +++ b/coconut/cmd/configuration_show.go @@ -30,7 +30,7 @@ import ( ) var configurationShowCmd = &cobra.Command{ - Use: "show ", + Use: "show ", Aliases: []string{"s"}, Example: `coconut conf show coconut conf show -t @@ -43,15 +43,15 @@ coconut conf show -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\"}`") diff --git a/coconut/cmd/environment_control.go b/coconut/cmd/environment_control.go index 995209306..8b08c2a7f 100644 --- a/coconut/cmd/environment_control.go +++ b/coconut/cmd/environment_control.go @@ -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. @@ -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() { diff --git a/coconut/cmd/environment_destroy.go b/coconut/cmd/environment_destroy.go index 457595d4a..ff06c4f78 100644 --- a/coconut/cmd/environment_destroy.go +++ b/coconut/cmd/environment_destroy.go @@ -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() { diff --git a/coconut/cmd/environment_list.go b/coconut/cmd/environment_list.go index 67250635c..8f8c179e5 100644 --- a/coconut/cmd/environment_list.go +++ b/coconut/cmd/environment_list.go @@ -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() { diff --git a/coconut/cmd/environment_modify.go b/coconut/cmd/environment_modify.go index c05e64952..89dc2173e 100644 --- a/coconut/cmd/environment_modify.go +++ b/coconut/cmd/environment_modify.go @@ -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() { diff --git a/coconut/cmd/info.go b/coconut/cmd/info.go index 86d254c1a..3a06fddbb 100644 --- a/coconut/cmd/info.go +++ b/coconut/cmd/info.go @@ -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() { diff --git a/coconut/cmd/repo_add.go b/coconut/cmd/repo_add.go index daffbdfb9..3083bb3b9 100644 --- a/coconut/cmd/repo_add.go +++ b/coconut/cmd/repo_add.go @@ -31,9 +31,9 @@ import ( // repoAddCmd represents the repo add command var repoAddCmd = &cobra.Command{ - Use: "add ", + Use: "add ", 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: @@ -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`", @@ -63,4 +62,4 @@ func init() { repoCmd.AddCommand(repoAddCmd) repoAddCmd.Flags().StringP("default-revision", "d", "", "default revision for repository to add") -} \ No newline at end of file +} diff --git a/coconut/cmd/repo_default.go b/coconut/cmd/repo_default.go index 71361911b..f9eb40ecc 100644 --- a/coconut/cmd/repo_default.go +++ b/coconut/cmd/repo_default.go @@ -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() { diff --git a/coconut/cmd/repo_default_revision.go b/coconut/cmd/repo_default_revision.go index a9a580a74..0067ba46c 100644 --- a/coconut/cmd/repo_default_revision.go +++ b/coconut/cmd/repo_default_revision.go @@ -36,11 +36,10 @@ var repoDefaultRevisionCmd = &cobra.Command{ Long: `The repository default-revision command sets the global default repository revision.' To set a per repository default revision, the default revision specified needs to be preceded by the repository index (not its name), as is reported by ` + "`coconut repo list`.", - Example: -` * ` + "`coconut repo default-revision basic-tasks`" + ` Sets ` + "`basic-tasks`" + `as the global default-revision + Example: ` * ` + "`coconut repo default-revision basic-tasks`" + ` Sets ` + "`basic-tasks`" + `as the global default-revision * ` + "`coconut repo default-revision 0 master`" + ` Sets ` + "`master`" + `as the default-revision for repo with index 0 * ` + "`coconut repo default-revision 2 vs-sftb`" + ` Sets ` + "`vs-sftb`" + `as the default-revision for repo with index 2`, - Run: control.WrapCall(control.SetDefaultRevision), + Run: control.WrapCall(control.SetDefaultRevision), Args: cobra.RangeArgs(1, 2), } diff --git a/coconut/cmd/repo_list.go b/coconut/cmd/repo_list.go index 7bf9d5a3d..eecdea2b6 100644 --- a/coconut/cmd/repo_list.go +++ b/coconut/cmd/repo_list.go @@ -31,11 +31,11 @@ import ( // repoListCmd represents the repo list command var repoListCmd = &cobra.Command{ - Use: "list", + Use: "list", Aliases: []string{"l"}, - Short: "list git repositories", - Long: "The repostory list command lists available git repositories to be used for task and workflow configuration.", - Run: control.WrapCall(control.ListRepos), + Short: "list git repositories", + Long: "The repostory list command lists available git repositories to be used for task and workflow configuration.", + Run: control.WrapCall(control.ListRepos), } func init() { diff --git a/coconut/cmd/repo_refresh.go b/coconut/cmd/repo_refresh.go index 071f58e02..ee86cd0c6 100644 --- a/coconut/cmd/repo_refresh.go +++ b/coconut/cmd/repo_refresh.go @@ -31,18 +31,17 @@ import ( // repoListCmd represents the repo list command var repoRefreshCmd = &cobra.Command{ - Use: "refresh [repo id]", + Use: "refresh [repo id]", Aliases: []string{"update", "u"}, - Short: "refresh git repositories", + Short: "refresh git repositories", Long: `The repository refresh command makes sure all git repositories used for task and workflow configuration are up to date. It can optionally be supplied with a repo id, to only refresh a specific repo. Repo ids are reported by ` + "`coconut repo list`.", - Example: -` * ` + "`coconut repo refresh`" + ` + Example: ` * ` + "`coconut repo refresh`" + ` * ` + "`coconut repo refresh 1`", - Run: control.WrapCall(control.RefreshRepos), + Run: control.WrapCall(control.RefreshRepos), Args: cobra.MaximumNArgs(1), } func init() { repoCmd.AddCommand(repoRefreshCmd) -} \ No newline at end of file +} diff --git a/coconut/cmd/repo_remove.go b/coconut/cmd/repo_remove.go index ec8cb1bd5..b2cbdb90f 100644 --- a/coconut/cmd/repo_remove.go +++ b/coconut/cmd/repo_remove.go @@ -31,15 +31,14 @@ import ( // repoRemoveCmd represents the repo remove command var repoRemoveCmd = &cobra.Command{ - Use: "remove ", + Use: "remove ", Aliases: []string{"r", "delete", "del", "d"}, - Short: "remove a git repository", + Short: "remove a git repository", Long: `The repository remove command removes a git repository from the catalogue of workflow configuration sources. A repository is referenced by its repo id, as reported by` + "`coconut repo list`", - Example: -` * ` + "`coconut repo remove 1`" + ` + Example: ` * ` + "`coconut repo remove 1`" + ` * ` + "`coconut repo del 2`", - Run: control.WrapCall(control.RemoveRepo), + Run: control.WrapCall(control.RemoveRepo), Args: cobra.ExactArgs(1), } diff --git a/coconut/cmd/role.go b/coconut/cmd/role.go index 091232087..1455a1a40 100644 --- a/coconut/cmd/role.go +++ b/coconut/cmd/role.go @@ -33,9 +33,9 @@ import ( // roleCmd represents the role command var roleCmd = &cobra.Command{ - Use: "role", + Use: "role", Aliases: []string{"r"}, - Short: "query roles in an environment", + Short: "query roles in an environment", Long: fmt.Sprintf(`The role command queries the running instance of %s to display information on active roles.`, product.PRETTY_SHORTNAME), } diff --git a/coconut/cmd/role_query.go b/coconut/cmd/role_query.go index 6b0ea35a1..9270772f6 100644 --- a/coconut/cmd/role_query.go +++ b/coconut/cmd/role_query.go @@ -25,18 +25,18 @@ package cmd import ( - "github.com/spf13/cobra" "github.com/AliceO2Group/Control/coconut/control" + "github.com/spf13/cobra" ) // roleQueryCmd represents the role list command var roleQueryCmd = &cobra.Command{ - Use: "query [environment id] [query path]", + Use: "query [environment id] [query path]", Aliases: []string{"query", "q"}, - Short: "query O² roles", - Long: `The role query command returns one or more role trees.`, - Run: control.WrapCall(control.QueryRoles), - Args: cobra.ExactArgs(2), + Short: "query O² roles", + Long: `The role query command returns one or more role trees.`, + Run: control.WrapCall(control.QueryRoles), + Args: cobra.ExactArgs(2), } func init() { diff --git a/coconut/cmd/task.go b/coconut/cmd/task.go index a2695146e..d858ec39e 100644 --- a/coconut/cmd/task.go +++ b/coconut/cmd/task.go @@ -33,9 +33,9 @@ import ( // taskCmd represents the task command var taskCmd = &cobra.Command{ - Use: "task", + Use: "task", Aliases: []string{"t"}, - Short: "manage active tasks", + Short: "manage active tasks", Long: fmt.Sprintf(`The task command interacts with the running instance of %s to manage active tasks.`, product.PRETTY_SHORTNAME), } diff --git a/coconut/cmd/task_clean.go b/coconut/cmd/task_clean.go index 20fada4e7..d0fa8b21f 100644 --- a/coconut/cmd/task_clean.go +++ b/coconut/cmd/task_clean.go @@ -25,20 +25,20 @@ package cmd import ( - "github.com/spf13/cobra" "github.com/AliceO2Group/Control/coconut/control" + "github.com/spf13/cobra" ) // taskCleanCmd represents the task clean command var taskCleanCmd = &cobra.Command{ - Use: "clean", + Use: "clean", Aliases: []string{"clean", "cleanup", "cl"}, - Short: "clean up idle O² tasks", + Short: "clean up idle O² tasks", Long: `The task clean command removes all tasks that aren't currently associated with an environment. This includes AliECS tasks in any state. Alternatively, a list of task IDs to remove can be passed as a space-separated sequence of parameters.`, - Run: control.WrapCall(control.CleanTasks), - Args: cobra.ArbitraryArgs, + Run: control.WrapCall(control.CleanTasks), + Args: cobra.ArbitraryArgs, } func init() { diff --git a/coconut/cmd/task_list.go b/coconut/cmd/task_list.go index fdaeb0f65..7a5ad4a4d 100644 --- a/coconut/cmd/task_list.go +++ b/coconut/cmd/task_list.go @@ -25,18 +25,18 @@ package cmd import ( - "github.com/spf13/cobra" "github.com/AliceO2Group/Control/coconut/control" + "github.com/spf13/cobra" ) // taskListCmd represents the task list command var taskListCmd = &cobra.Command{ - Use: "list", + Use: "list", Aliases: []string{"list", "ls", "l"}, - Short: "list O² tasks", + Short: "list O² tasks", Long: `The task list command shows a list of currently active tasks. This includes AliECS tasks in any state.`, - Run: control.WrapCall(control.GetTasks), + Run: control.WrapCall(control.GetTasks), } func init() { diff --git a/coconut/cmd/template.go b/coconut/cmd/template.go index c81c1b11e..d4723a835 100644 --- a/coconut/cmd/template.go +++ b/coconut/cmd/template.go @@ -32,9 +32,9 @@ import ( // templateCmd represents the template command var templateCmd = &cobra.Command{ - Use: "template", + Use: "template", Aliases: []string{"templ"}, - Short: "query available workflow templates in configuration repositories", + Short: "query available workflow templates in configuration repositories", Long: fmt.Sprintf(`The template command interacts with the workflow configuration system to display information on available workflow templates.`), } diff --git a/coconut/control/control.go b/coconut/control/control.go index 01a18b49a..bc0983a8b 100644 --- a/coconut/control/control.go +++ b/coconut/control/control.go @@ -184,7 +184,7 @@ func GetInfo(cxt context.Context, rpc *coconut.RpcClient, cmd *cobra.Command, ar sortedSvcIds := make([]string, len(services)) i := 0 - for svcId, _ := range services { + for svcId := range services { sortedSvcIds[i] = svcId i++ } diff --git a/coconut/doc/generate.go b/coconut/doc/generate.go index 4c336cef9..48af65ff3 100644 --- a/coconut/doc/generate.go +++ b/coconut/doc/generate.go @@ -24,13 +24,12 @@ package main - import ( "github.com/AliceO2Group/Control/coconut/app" + "github.com/AliceO2Group/Control/coconut/cmd" "github.com/AliceO2Group/Control/common/logger" "github.com/sirupsen/logrus" "github.com/spf13/cobra/doc" - "github.com/AliceO2Group/Control/coconut/cmd" ) var log = logger.New(logrus.StandardLogger(), app.NAME) @@ -41,4 +40,4 @@ func main() { if err != nil { log.Fatal(err) } -} \ No newline at end of file +} diff --git a/common/cmdinfo.go b/common/cmdinfo.go index 0c19f9977..7fe890aa2 100644 --- a/common/cmdinfo.go +++ b/common/cmdinfo.go @@ -116,12 +116,12 @@ func (m *CommandInfo) Equals(other *CommandInfo) (response bool) { return false } - for i, _ := range m.Env { + for i := range m.Env { if m.Env[i] != other.Env[i] { return false } } - for i, _ := range m.Arguments { + for i := range m.Arguments { if m.Arguments[i] != other.Arguments[i] { return false } diff --git a/common/controlmode/controlmode.go b/common/controlmode/controlmode.go index 075db220e..6d6dc8fdb 100644 --- a/common/controlmode/controlmode.go +++ b/common/controlmode/controlmode.go @@ -34,7 +34,7 @@ import ( type ControlMode int -const( +const ( DIRECT ControlMode = iota FAIRMQ BASIC diff --git a/common/event/environmentevents.go b/common/event/environmentevents.go index eee78b554..e60ab4492 100644 --- a/common/event/environmentevents.go +++ b/common/event/environmentevents.go @@ -52,6 +52,6 @@ func (e *EnvironmentEvent) GetError() string { return e.Error.Error() } -func(e *EnvironmentEvent) GetMessage() string { +func (e *EnvironmentEvent) GetMessage() string { return e.Message -} \ No newline at end of file +} diff --git a/common/event/roleevent.go b/common/event/roleevent.go index cdd907b40..451086bc5 100644 --- a/common/event/roleevent.go +++ b/common/event/roleevent.go @@ -46,4 +46,4 @@ func (r *RoleEvent) GetState() string { func (r *RoleEvent) GetRolePath() string { return r.RolePath -} \ No newline at end of file +} diff --git a/common/event/taskevents.go b/common/event/taskevents.go index 94c533dc7..2ed1e7780 100644 --- a/common/event/taskevents.go +++ b/common/event/taskevents.go @@ -26,11 +26,11 @@ package event type TaskEvent struct { eventBase - Name string - TaskID string - Status string - State string - Hostname string + Name string + TaskID string + Status string + State string + Hostname string ClassName string } @@ -56,4 +56,4 @@ func (r *TaskEvent) GetHostname() string { func (r *TaskEvent) GetClassName() string { return r.ClassName -} \ No newline at end of file +} diff --git a/common/event/tasksreleasedevent.go b/common/event/tasksreleasedevent.go index 635fdc755..b35cd524a 100644 --- a/common/event/tasksreleasedevent.go +++ b/common/event/tasksreleasedevent.go @@ -31,9 +31,9 @@ import ( type TasksReleasedEvent struct { eventBase - EnvironmentId uid.ID `json:"environmentId"` - TaskIdsReleased []string `json:"taskIdsReleased"` - TaskReleaseErrors map[string]error `json:"taskReleaseErrors"` + EnvironmentId uid.ID `json:"environmentId"` + TaskIdsReleased []string `json:"taskIdsReleased"` + TaskReleaseErrors map[string]error `json:"taskReleaseErrors"` } func (tr *TasksReleasedEvent) GetName() string { diff --git a/common/event/taskstatechangedevent.go b/common/event/taskstatechangedevent.go index f316bb6b0..1f757d996 100644 --- a/common/event/taskstatechangedevent.go +++ b/common/event/taskstatechangedevent.go @@ -31,9 +31,9 @@ import ( type TasksStateChangedEvent struct { eventBase - EnvironmentId uid.ID `json:"environmentId"` - TaskIdsStateChanged []string `json:"taskIdsStatesChanged"` - TaskStateChangedErr error `json:"taskStateChangedErr"` + EnvironmentId uid.ID `json:"environmentId"` + TaskIdsStateChanged []string `json:"taskIdsStatesChanged"` + TaskStateChangedErr error `json:"taskStateChangedErr"` } func (tr *TasksStateChangedEvent) GetName() string { @@ -67,7 +67,7 @@ func NewTasksStateChangedEvent(envId uid.ID, taskIdsChangeState []string, taskSt Timestamp: utils.NewUnixTimestamp(), MessageType: "TasksStateEvent", }, - EnvironmentId: envId, + EnvironmentId: envId, TaskIdsStateChanged: taskIdsChangeState, TaskStateChangedErr: taskStateChangedErr, } diff --git a/common/logger/infologger/fields.go b/common/logger/infologger/fields.go index 23646851d..89a9be669 100644 --- a/common/logger/infologger/fields.go +++ b/common/logger/infologger/fields.go @@ -28,24 +28,24 @@ package infologger // (Severity), Level, ErrorCode, SourceFile, SourceLine, // Facility, Role, System, Detector, Partition, Run -const( - Level = "level" +const ( + Level = "level" ErrorCode = "errcode" - Facility = "facility" - Role = "rolename" - System = "system" - Detector = "detector" + Facility = "facility" + Role = "rolename" + System = "system" + Detector = "detector" Partition = "partition" - Run = "run" + Run = "run" ) var Fields = map[string]bool{ - Level: true, + Level: true, ErrorCode: true, - Facility: true, - Role: true, - System: true, - Detector: true, + Facility: true, + Role: true, + System: true, + Detector: true, Partition: true, - Run: true, -} \ No newline at end of file + Run: true, +} diff --git a/common/logger/infologger/hook.go b/common/logger/infologger/hook.go index 2d343e6ae..d4791e812 100644 --- a/common/logger/infologger/hook.go +++ b/common/logger/infologger/hook.go @@ -23,6 +23,7 @@ */ package infologger + /* import ( "fmt" @@ -130,4 +131,4 @@ func (h *Hook) Fire(e *logrus.Entry) error { } return nil } -*/ \ No newline at end of file +*/ diff --git a/common/logger/infologger/protocols.go b/common/logger/infologger/protocols.go index c66949ce5..cf640f4a6 100644 --- a/common/logger/infologger/protocols.go +++ b/common/logger/infologger/protocols.go @@ -25,19 +25,21 @@ package infologger type protoVersion string -const( + +const ( v14 = protoVersion("1.4") v13 = protoVersion("1.3") ) type fieldType string -const( + +const ( ft_String = fieldType("String") ft_Number = fieldType("Number") ) type fieldSpec struct { - name string + name string ftype fieldType } @@ -81,4 +83,4 @@ var protocols = map[protoVersion]*protoSpec{ {name: "errsource", ftype: ft_String}, {name: "message", ftype: ft_String}, }, -} \ No newline at end of file +} diff --git a/common/logger/infologger/utils.go b/common/logger/infologger/utils.go index 5257c74de..0f135bf32 100644 --- a/common/logger/infologger/utils.go +++ b/common/logger/infologger/utils.go @@ -27,10 +27,10 @@ package infologger import "github.com/sirupsen/logrus" const ( - IL_Ops = 1 + IL_Ops = 1 IL_Support = 6 - IL_Devel = 11 - IL_Trace = 21 + IL_Devel = 11 + IL_Trace = 21 ) // Severity/priority constants: @@ -94,4 +94,4 @@ func buildFineFacility(baseFacility string, data logrus.Fields) string { return baseFacility + "/" + prefix.(string) } return baseFacility -} \ No newline at end of file +} diff --git a/common/logger/loggercopy.go b/common/logger/loggercopy.go index 8f8263107..b1db78c8a 100644 --- a/common/logger/loggercopy.go +++ b/common/logger/loggercopy.go @@ -34,10 +34,10 @@ import ( // This file implements a workaround for https://github.com/sirupsen/logrus/issues/564 type SafeLogrusWriter struct { - Entry *logrus.Entry + Entry *logrus.Entry PrintFunc func(...interface{}) - buf bytes.Buffer - mu sync.Mutex + buf bytes.Buffer + mu sync.Mutex } func (w *SafeLogrusWriter) Write(b []byte) (int, error) { diff --git a/common/product/constants.go b/common/product/constants.go index 0bbd29f2b..6f3c1f345 100644 --- a/common/product/constants.go +++ b/common/product/constants.go @@ -85,7 +85,6 @@ func fillBuildFromGit(localRepoPath string) { BUILD = h.String()[:7] } - func init() { // If the core was built with go build directly instead of make. if VERSION_MAJOR == "0" && @@ -103,16 +102,16 @@ func init() { fillBuildFromGit(basePath) } - VERSION = strings.Join([]string{VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH}, ".") - VERSION_SHORT = VERSION - VERSION_BUILD = strings.Join([]string{VERSION, BUILD}, "-") + VERSION = strings.Join([]string{VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH}, ".") + VERSION_SHORT = VERSION + VERSION_BUILD = strings.Join([]string{VERSION, BUILD}, "-") } var ( // Acquired from -ldflags="-X=..." in Makefile - VERSION_MAJOR = "0" - VERSION_MINOR = "0" - VERSION_PATCH = "0" - BUILD = "" + VERSION_MAJOR = "0" + VERSION_MINOR = "0" + VERSION_PATCH = "0" + BUILD = "" ) var ( @@ -122,4 +121,4 @@ var ( VERSION string VERSION_SHORT string VERSION_BUILD string -) \ No newline at end of file +) diff --git a/common/system/systemid.go b/common/system/systemid.go index 810d980d6..c25c3b927 100644 --- a/common/system/systemid.go +++ b/common/system/systemid.go @@ -36,7 +36,7 @@ type IDMap map[ID]struct{} func (m IDMap) StringList() []string { list := make([]string, len(m)) i := 0 - for k, _ := range m { + for k := range m { list[i] = k.String() i++ } @@ -45,6 +45,7 @@ func (m IDMap) StringList() []string { } type ID int + const ( // 1 // 2 @@ -72,7 +73,7 @@ const ( DCS ID = 38 FOC ID = 39 - FIT ID = 254 // non-standard mapping: FT0 + FV0 = FIT + FIT ID = 254 // non-standard mapping: FT0 + FV0 = FIT NIL ID = 255 ) @@ -81,4 +82,4 @@ const ( FLP ID = -1 EPN ID = -2 PDP ID = -3 -) \ No newline at end of file +) diff --git a/common/taskcmdinfo.go b/common/taskcmdinfo.go index e31b3fb23..af2e269a1 100644 --- a/common/taskcmdinfo.go +++ b/common/taskcmdinfo.go @@ -36,5 +36,5 @@ type TaskCommandInfo struct { ControlMode controlmode.ControlMode `json:"controlMode"` // Only applies to hooks and basic tasks - Timeout time.Duration `json:"timeout,omitempty"` + Timeout time.Duration `json:"timeout,omitempty"` } diff --git a/configuration/cfgbackend/configurationmap.go b/configuration/cfgbackend/configurationmap.go index 186978e3d..304312a52 100644 --- a/configuration/cfgbackend/configurationmap.go +++ b/configuration/cfgbackend/configurationmap.go @@ -32,13 +32,13 @@ import ( ) type ItemType int + const ( IT_Value ItemType = iota IT_Map IT_Array ) - type Item interface { Type() ItemType Value() string @@ -46,9 +46,9 @@ type Item interface { Array() Array DeepCopy() Item } -type Map map[string]Item -type Array []Item -type String string +type Map map[string]Item +type Array []Item +type String string func (m Map) Type() ItemType { return IT_Map diff --git a/configuration/template/fieldwrappers.go b/configuration/template/fieldwrappers.go index d213b1973..8e8fff4af 100644 --- a/configuration/template/fieldwrappers.go +++ b/configuration/template/fieldwrappers.go @@ -69,7 +69,7 @@ func WrapGeneric(getterF GetterFunc, setterF SetterFunc) Field { func WrapMapItems(items map[string]string) Fields { fields := make(Fields, 0) - for k, _ := range items { + for k := range items { key := k // we need a local copy for the Getter/Setter closures fields = append(fields, &GenericWrapper{ Getter: func() string { @@ -85,7 +85,7 @@ func WrapMapItems(items map[string]string) Fields { func WrapSliceItems(items []string) Fields { fields := make(Fields, 0) - for i, _ := range items { + for i := range items { index := i // we need a local copy for the Getter/Setter closures fields = append(fields, &GenericWrapper{ Getter: func() string { diff --git a/configuration/template/loader.go b/configuration/template/loader.go index 8a82aeca5..e6c4ea75a 100644 --- a/configuration/template/loader.go +++ b/configuration/template/loader.go @@ -41,7 +41,7 @@ type ConsulTemplateLoader struct { func NewConsulTemplateLoader(confSvc ConfigurationService, basePath string) *ConsulTemplateLoader { return &ConsulTemplateLoader{ basePath: basePath, - confSvc: confSvc, + confSvc: confSvc, } } diff --git a/core/controlcommands/command.go b/core/controlcommands/command.go index 1698dc63b..4c782e25b 100644 --- a/core/controlcommands/command.go +++ b/core/controlcommands/command.go @@ -29,8 +29,8 @@ package controlcommands type Command interface { - Name() string - Args() map[string]interface{} + Name() string + Args() map[string]interface{} IsMultiCmd() bool - IsMutator() bool + IsMutator() bool } diff --git a/core/controlcommands/multiresponse.go b/core/controlcommands/multiresponse.go index c4db76ba3..c6615f043 100644 --- a/core/controlcommands/multiresponse.go +++ b/core/controlcommands/multiresponse.go @@ -33,7 +33,7 @@ import ( type MesosCommandMultiResponse struct { MesosCommandResponseBase - responses map[MesosCommandTarget]MesosCommandResponse + responses map[MesosCommandTarget]MesosCommandResponse } func (m *MesosCommandMultiResponse) GetResponses() map[MesosCommandTarget]MesosCommandResponse { @@ -51,7 +51,7 @@ func (m *MesosCommandMultiResponse) GetResponseSenders() []MesosCommandTarget { if m != nil { senders := make([]MesosCommandTarget, len(m.responses)) i := 0 - for k, _ := range m.responses { + for k := range m.responses { senders[i] = k i++ } @@ -108,6 +108,6 @@ func consolidateResponses(command MesosCommand, responses map[MesosCommandTarget } return &MesosCommandMultiResponse{ MesosCommandResponseBase: *NewMesosCommandResponse(command, nil), - responses: responses, + responses: responses, } -} \ No newline at end of file +} diff --git a/core/environment/environment.go b/core/environment/environment.go index f55b109b0..9a06d121b 100644 --- a/core/environment/environment.go +++ b/core/environment/environment.go @@ -652,10 +652,10 @@ func (env *Environment) handleHooks(workflow workflow.Role, trigger string, weig callsMapForAwait := env.callsPendingAwait[trigger] allWeightsSet := make(callable.HooksMap) - for k, _ := range hooksMapForTrigger { + for k := range hooksMapForTrigger { allWeightsSet[k] = callable.Hooks{} } - for k, _ := range callsMapForAwait { + for k := range callsMapForAwait { allWeightsSet[k] = callable.Hooks{} } allWeights := allWeightsSet.GetWeights() @@ -932,7 +932,7 @@ func (env *Environment) runTasksAsHooks(hooksToTrigger task.Tasks) (errorMap map break } else { keys := make([]string, 0) - for k, _ := range hookTimers { + for k := range hookTimers { keys = append(keys, k) } log.WithField("taskIds", strings.Join(keys, ",")). @@ -1351,7 +1351,7 @@ func (env *Environment) GetAllHosts() []string { out := make([]string, len(hostSet)) i := 0 - for hostname, _ := range hostSet { + for hostname := range hostSet { out[i] = hostname i++ } diff --git a/core/environment/manager.go b/core/environment/manager.go index a20b9b4e2..b5c1f8b5e 100644 --- a/core/environment/manager.go +++ b/core/environment/manager.go @@ -211,7 +211,7 @@ func (envs *Manager) GetActiveDetectors() system.IDMap { continue } envDetectors := env.GetActiveDetectors() - for det, _ := range envDetectors { + for det := range envDetectors { response[det] = struct{}{} } } @@ -389,7 +389,7 @@ func (envs *Manager) CreateEnvironment(workflowPath string, userVars map[string] // env.GetActiveDetectors() is valid starting now, so we can check for detector exclusion neededDetectors := env.GetActiveDetectors() - for det, _ := range neededDetectors { + for det := range neededDetectors { if _, contains := alreadyActiveDetectors[det]; contains { // required detector det is already active in some other environment return env.id, fmt.Errorf("detector %s is already in use", det.String()) diff --git a/core/globalstate.go b/core/globalstate.go index 61a6c0b61..d8fd256be 100644 --- a/core/globalstate.go +++ b/core/globalstate.go @@ -68,10 +68,9 @@ func newGlobalState(shutdown func()) (*globalState, error) { type globalState struct { sync.RWMutex - shutdown func() + shutdown func() // uses locks, so thread safe environments *environment.Manager taskman *task.Manager - } diff --git a/core/integration/odc/handlers.go b/core/integration/odc/handlers.go index 6b7260da1..85869c1d0 100644 --- a/core/integration/odc/handlers.go +++ b/core/integration/odc/handlers.go @@ -729,7 +729,7 @@ func handleCleanup(ctx context.Context, odcClient *RpcClient, arguments map[stri partitionsToCleanStr := make([]string, len(partitionsToClean)) i := 0 - for k, _ := range partitionsToClean { + for k := range partitionsToClean { partitionsToCleanStr[i] = k i++ } @@ -740,7 +740,7 @@ func handleCleanup(ctx context.Context, odcClient *RpcClient, arguments map[stri wg.Add(len(partitionsToClean)) // Then the actual cleanup calls begin, in parallel... - for odcPartitionId, _ := range partitionsToClean { + for odcPartitionId := range partitionsToClean { go func(odcPartitionId string) { defer wg.Done() err = doShutdown(ctx, odcClient, arguments, paddingTimeout, odcPartitionId, call) // FIXME make this parallel diff --git a/core/integration/odc/odcutils/state.go b/core/integration/odc/odcutils/state.go index a47c8e9c0..8d340a6e1 100644 --- a/core/integration/odc/odcutils/state.go +++ b/core/integration/odc/odcutils/state.go @@ -26,15 +26,15 @@ package odcutils import "github.com/AliceO2Group/Control/executor/executorcmd/transitioner/fairmq" -var( +var ( stateMap = map[string]string{ - "STANDBY": fairmq.IDLE, + "STANDBY": fairmq.IDLE, "CONFIGURED": fairmq.READY, - "RUNNING": fairmq.RUNNING, - "ERROR": fairmq.ERROR, - "DONE": fairmq.EXITING, + "RUNNING": fairmq.RUNNING, + "ERROR": fairmq.ERROR, + "DONE": fairmq.EXITING, } - invStateMap = func() (inv map[string]string) { // invert stateMap + invStateMap = func() (inv map[string]string) { // invert stateMap inv = make(map[string]string, len(stateMap)) for k, v := range stateMap { inv[v] = k diff --git a/core/integration/trg/client.go b/core/integration/trg/client.go index 4b9293dde..92652903f 100644 --- a/core/integration/trg/client.go +++ b/core/integration/trg/client.go @@ -38,8 +38,7 @@ import ( "google.golang.org/grpc/keepalive" ) -var log = logger.New(logrus.StandardLogger(),"trgclient") - +var log = logger.New(logrus.StandardLogger(), "trgclient") type RpcClient struct { trgecspb.CTPdClient @@ -51,10 +50,10 @@ func NewClient(cxt context.Context, cancel context.CancelFunc, endpoint string) "endpoint": endpoint, }).Debug("dialing TRG endpoint") - dialOptions := []grpc.DialOption { + dialOptions := []grpc.DialOption{ grpc.WithInsecure(), grpc.WithConnectParams(grpc.ConnectParams{ - Backoff: backoff.Config{ + Backoff: backoff.Config{ BaseDelay: backoff.DefaultConfig.BaseDelay, Multiplier: backoff.DefaultConfig.Multiplier, Jitter: backoff.DefaultConfig.Jitter, @@ -94,26 +93,26 @@ func NewClient(cxt context.Context, cancel context.CancelFunc, endpoint string) for { select { - case ok := <- stateChangedNotify: + case ok := <-stateChangedNotify: if !ok { return } connState = conn.GetState() log.Debugf("TRG client %s", connState.String()) go notifyFunc(connState) - case <- time.After(2 * time.Minute): + case <-time.After(2 * time.Minute): if conn.GetState() != connectivity.Ready { conn.ResetConnectBackoff() } - case <- cxt.Done(): + case <-cxt.Done(): return } } }() - client := &RpcClient { + client := &RpcClient{ CTPdClient: trgecspb.NewCTPdClient(conn), - conn: conn, + conn: conn, } return client @@ -128,4 +127,4 @@ func (m *RpcClient) GetConnState() connectivity.State { func (m *RpcClient) Close() error { return m.conn.Close() -} \ No newline at end of file +} diff --git a/core/integration/trg/trgutil.go b/core/integration/trg/trgutil.go index 5bc9785f2..dca8b9a3f 100644 --- a/core/integration/trg/trgutil.go +++ b/core/integration/trg/trgutil.go @@ -37,7 +37,7 @@ type Run struct { RunNumber uint32 State State Detectors []system.ID - Skip bool + Skip bool } type Runs []Run diff --git a/core/repos/repomanager.go b/core/repos/repomanager.go index cd36931d4..afed8ccb3 100644 --- a/core/repos/repomanager.go +++ b/core/repos/repomanager.go @@ -52,10 +52,10 @@ const ( refRemotePrefix = refPrefix + "remotes/origin/" ) -var log = logger.New(logrus.StandardLogger(),"repos") +var log = logger.New(logrus.StandardLogger(), "repos") var ( - once sync.Once + once sync.Once instance *RepoManager ) @@ -135,7 +135,7 @@ func initializeRepos(service configuration.Service) *RepoManager { return &rm } -func (manager *RepoManager) discoverRepos() (repos []string, err error){ +func (manager *RepoManager) discoverRepos() (repos []string, err error) { var hostingSites []string hostingSites, err = filepath.Glob(filepath.Join(manager.rService.GetReposPath(), "*")) @@ -154,7 +154,9 @@ func (manager *RepoManager) discoverRepos() (repos []string, err error){ for _, hostingSite := range hostingSites { // Get rid of invalid paths - if !isValidPath(hostingSite) { continue } + if !isValidPath(hostingSite) { + continue + } // find .git dir // everything above is "path", dir containing ".git" is repo @@ -164,7 +166,7 @@ func (manager *RepoManager) discoverRepos() (repos []string, err error){ // i.e. don't include repos path // don't include trailing "/.git" repos = append(repos, strings.TrimPrefix(strings.TrimSuffix(path, "/.git"), - manager.rService.GetReposPath() + "/")) + manager.rService.GetReposPath()+"/")) } return nil @@ -337,7 +339,7 @@ func (manager *RepoManager) AddRepo(repoPath string, defaultRevision string) (st return "", false, err } - return repo.GetDefaultRevision(), repo.GetDefaultRevision()== manager.defaultRevision, nil + return repo.GetDefaultRevision(), repo.GetDefaultRevision() == manager.defaultRevision, nil } func cleanCloneParentDirs(parentDirs []string) error { @@ -385,7 +387,7 @@ func (manager *RepoManager) getRepos(repoPattern string) (repoList map[string]iR func (manager *RepoManager) getRepoByIndex(index int) (iRepo, error) { keys := manager.GetOrderedRepolistKeys() - if len(keys) - 1 >= index { // Verify that index is not out of bounds + if len(keys)-1 >= index { // Verify that index is not out of bounds return manager.repoList[keys[index]], nil } else { return nil, errors.New("getRepoByIndex: repo not found for index :" + strconv.Itoa(index)) @@ -471,7 +473,7 @@ func (manager *RepoManager) RefreshRepoByIndex(index int) error { return repo.refresh() } -func (manager *RepoManager) GetWorkflow(workflowPath string) (resolvedWorkflowPath string, workflowRepo IRepo, err error) { +func (manager *RepoManager) GetWorkflow(workflowPath string) (resolvedWorkflowPath string, workflowRepo IRepo, err error) { manager.mutex.Lock() defer manager.mutex.Unlock() @@ -491,7 +493,7 @@ func (manager *RepoManager) GetWorkflow(workflowPath string) (resolvedWorkflowP wfRepo = manager.defaultRepo workflowFile = workflowInfo[0] } else if len(workflowInfo) == 2 { // Repo specified - try to find it - wfRepo= manager.repoList[workflowInfo[0]] + wfRepo = manager.repoList[workflowInfo[0]] if wfRepo == nil { err = errors.New("Workflow comes from an unknown repo") return @@ -617,7 +619,7 @@ func (manager *RepoManager) EnsureReposPresent(taskClassesRequired []string) (er } // Make sure that the relevant repos are present and checked out on the expected revision - for _, repo := range reposRequired { + for _, repo := range reposRequired { existingRepo, ok := manager.repoList[repo.GetIdentifier()] if !ok { _, _, err = manager.AddRepo(repo.GetIdentifier(), repo.GetDefaultRevision()) diff --git a/core/repos/reposervice.go b/core/repos/reposervice.go index 12e5701b7..91e3f7d2c 100644 --- a/core/repos/reposervice.go +++ b/core/repos/reposervice.go @@ -21,10 +21,10 @@ func (s *RepoService) GetReposPath() string { func (s *RepoService) NewDefaultRepo(defaultRepo string) error { if s.Svc != nil { - return s.Svc.SetRuntimeEntry("aliecs","default_repo", defaultRepo) + return s.Svc.SetRuntimeEntry("aliecs", "default_repo", defaultRepo) } else { data := []byte(defaultRepo) - return ioutil.WriteFile(filepath.Join(s.GetReposPath(),"default_repo"), data, 0644) + return ioutil.WriteFile(filepath.Join(s.GetReposPath(), "default_repo"), data, 0644) } } @@ -33,7 +33,7 @@ func (s *RepoService) GetDefaultRepo() (defaultRepo string, err error) { return s.Svc.GetRuntimeEntry("aliecs", "default_repo") } else { var defaultRepoData []byte - defaultRepoData, err = ioutil.ReadFile(filepath.Join(s.GetReposPath(),"default_repo")) + defaultRepoData, err = ioutil.ReadFile(filepath.Join(s.GetReposPath(), "default_repo")) if err != nil { return } @@ -44,19 +44,19 @@ func (s *RepoService) GetDefaultRepo() (defaultRepo string, err error) { func (s *RepoService) NewDefaultRevision(defaultRevision string) error { if s.Svc != nil { - return s.Svc.SetRuntimeEntry("aliecs","default_revision", defaultRevision) + return s.Svc.SetRuntimeEntry("aliecs", "default_revision", defaultRevision) } else { data := []byte(defaultRevision) - return ioutil.WriteFile(filepath.Join(s.GetReposPath(),"default_revision"), data, 0644) + return ioutil.WriteFile(filepath.Join(s.GetReposPath(), "default_revision"), data, 0644) } } func (s *RepoService) GetDefaultRevision() (defaultRevision string, err error) { if s.Svc != nil { - return s.Svc.GetRuntimeEntry("aliecs","default_revision") + return s.Svc.GetRuntimeEntry("aliecs", "default_revision") } else { var defaultRevisionData []byte - defaultRevisionData, err = ioutil.ReadFile(filepath.Join(s.GetReposPath(),"default_revision")) + defaultRevisionData, err = ioutil.ReadFile(filepath.Join(s.GetReposPath(), "default_revision")) if err != nil { return } @@ -68,7 +68,7 @@ func (s *RepoService) GetDefaultRevision() (defaultRevision string, err error) { func (s *RepoService) GetRepoDefaultRevisions() (map[string]string, error) { var defaultRevisions map[string]string if s.Svc != nil { - data, err := s.Svc.GetRuntimeEntry("aliecs","default_revisions") + data, err := s.Svc.GetRuntimeEntry("aliecs", "default_revisions") if err != nil { return nil, err } @@ -77,7 +77,7 @@ func (s *RepoService) GetRepoDefaultRevisions() (map[string]string, error) { return nil, err } } else { - defaultRevisionData, err := ioutil.ReadFile(filepath.Join(s.GetReposPath(),"default_revisions.json")) + defaultRevisionData, err := ioutil.ReadFile(filepath.Join(s.GetReposPath(), "default_revisions.json")) if err != nil { return nil, err } @@ -93,10 +93,9 @@ func (s *RepoService) SetRepoDefaultRevisions(defaultRevisions map[string]string } if s.Svc != nil { - err = s.Svc.SetRuntimeEntry("aliecs","default_revisions", string(data)) + err = s.Svc.SetRuntimeEntry("aliecs", "default_revisions", string(data)) } else { - err = ioutil.WriteFile(filepath.Join(s.GetReposPath(),"default_revisions.json"), data, 0644) + err = ioutil.WriteFile(filepath.Join(s.GetReposPath(), "default_revisions.json"), data, 0644) } return err } - diff --git a/core/repos/repoutils.go b/core/repos/repoutils.go index b23ddff49..948e69604 100644 --- a/core/repos/repoutils.go +++ b/core/repos/repoutils.go @@ -35,11 +35,15 @@ import ( func ParseWorkflowPublicVariableInfo(fileName string) (bool, string, VarSpecMap, error) { yamlFile, err := ioutil.ReadFile(fileName) - if err != nil { return false, "", nil, err } + if err != nil { + return false, "", nil, err + } nodes := make(map[string]yaml.Node) err = yaml.Unmarshal(yamlFile, &nodes) - if err != nil { return false, "", nil, err } + if err != nil { + return false, "", nil, err + } isPublic := nodes["name"].Tag == "!public" @@ -50,7 +54,7 @@ func ParseWorkflowPublicVariableInfo(fileName string) (bool, string, VarSpecMap, workflowVarInfo := make(VarSpecMap) for k, v := range nodes { - if err = parseYamlPublicVars(&AuxNode{k, &v }, &workflowVarInfo); err != nil { + if err = parseYamlPublicVars(&AuxNode{k, &v}, &workflowVarInfo); err != nil { return false, "", nil, err } } @@ -79,7 +83,7 @@ type VarSpec struct { // AuxNode Use an auxiliary node struct that also carries its parent Name type AuxNode struct { parentName string - node *yaml.Node + node *yaml.Node } func parseYamlPublicVars(auxNode *AuxNode, workflowVarInfo *VarSpecMap) error { @@ -94,7 +98,9 @@ func parseYamlPublicVars(auxNode *AuxNode, workflowVarInfo *VarSpecMap) error { if node.Kind == yaml.SequenceNode { // If it's a sequence node, continue searching for a map within it for _, v := range node.Content { err := parseYamlPublicVars(&AuxNode{"", v}, workflowVarInfo) - if err != nil { return err} + if err != nil { + return err + } } } else if node.Kind == yaml.MappingNode { // If it's a mapping node, iterate through it // We do this decoding to have a sane key -> node map @@ -102,7 +108,9 @@ func parseYamlPublicVars(auxNode *AuxNode, workflowVarInfo *VarSpecMap) error { // with the first one holding the Name and the second one holding the tag m := make(map[string]yaml.Node) err := node.Decode(&m) - if err != nil { return err } + if err != nil { + return err + } parentName := auxNode.parentName // Search within the node contents for a "!public" mapping node, @@ -112,7 +120,10 @@ func parseYamlPublicVars(auxNode *AuxNode, workflowVarInfo *VarSpecMap) error { if (parentName == "defaults" || parentName == "vars") && v.Kind == yaml.MappingNode && v.Tag == "!public" { err = v.Decode(&varSpec) - if err != nil { fmt.Println(err); continue } + if err != nil { + fmt.Println(err) + continue + } // If the key already exists we have come upon a duplicate! if _, exists := (*workflowVarInfo)[k]; exists { @@ -129,9 +140,11 @@ func parseYamlPublicVars(auxNode *AuxNode, workflowVarInfo *VarSpecMap) error { (*workflowVarInfo)[k] = varSpec } else { err = parseYamlPublicVars(&AuxNode{k, &v}, workflowVarInfo) - if err != nil { return err } + if err != nil { + return err + } } } } return nil -} \ No newline at end of file +} diff --git a/core/repos/varsource/varsource.go b/core/repos/varsource/varsource.go index f5740008a..a7e3b85c1 100644 --- a/core/repos/varsource/varsource.go +++ b/core/repos/varsource/varsource.go @@ -25,6 +25,7 @@ package varsource type Source int + const ( WorkflowDefaults Source = iota WorkflowVars diff --git a/core/server.go b/core/server.go index 6cfa3bce3..b2eeb072a 100644 --- a/core/server.go +++ b/core/server.go @@ -127,7 +127,7 @@ func (m *RpcServer) GetIntegratedServices(ctx context.Context, empty *pb.Empty) services := make(map[string]*pb.IntegratedServiceInfo) - for pluginName, _ := range integration.RegisteredPlugins() { + for pluginName := range integration.RegisteredPlugins() { s := &pb.IntegratedServiceInfo{} var plugin integration.Plugin for _, p := range integration.PluginsInstance() { diff --git a/core/servertypes.go b/core/servertypes.go index 203db70f1..675f93934 100644 --- a/core/servertypes.go +++ b/core/servertypes.go @@ -29,6 +29,7 @@ import ( ) type EnvironmentInfos []*pb.EnvironmentInfo + func (infos EnvironmentInfos) Len() int { return len(infos) } diff --git a/core/signals.go b/core/signals.go index 3775135e8..5a4f67c5c 100644 --- a/core/signals.go +++ b/core/signals.go @@ -33,18 +33,17 @@ import ( "github.com/AliceO2Group/Control/core/environment" ) - - + func signals(state *globalState) { - - // Create channel to receive unix signals + + // Create channel to receive unix signals signal_chan := make(chan os.Signal, 1) - + //Register channel to receive SIGINT and SIGTERM signals signal.Notify(signal_chan, syscall.SIGINT, syscall.SIGTERM) - + // Goroutine executes a blocking receive for signals go func() { s := <-signal_chan @@ -54,9 +53,9 @@ func signals(state *globalState) { time.Sleep(2 * time.Second) switch s { case syscall.SIGINT: - os.Exit(130) // 128+2 + os.Exit(130) // 128+2 case syscall.SIGTERM: - os.Exit(143) // 128+15 + os.Exit(143) // 128+15 } }() } diff --git a/core/task/agentcache.go b/core/task/agentcache.go index 3a7820e27..57af48b67 100644 --- a/core/task/agentcache.go +++ b/core/task/agentcache.go @@ -25,17 +25,17 @@ package task import ( + "github.com/AliceO2Group/Control/core/task/constraint" "github.com/mesos/mesos-go/api/v1/lib" "sync" - "github.com/AliceO2Group/Control/core/task/constraint" ) type AgentCache struct { - mu sync.RWMutex + mu sync.RWMutex store map[mesos.AgentID]AgentCacheInfo } -type AgentCacheInfo struct{ +type AgentCacheInfo struct { AgentId mesos.AgentID Attributes constraint.Attributes Hostname string @@ -75,7 +75,7 @@ func (ac *AgentCache) Count() (count int) { if ac == nil || ac.store == nil { return 0 } - ac.mu.RLock() - defer ac.mu.RUnlock() + ac.mu.RLock() + defer ac.mu.RUnlock() return len(ac.store) } diff --git a/core/task/channel/channel.go b/core/task/channel/channel.go index 167906d80..1e05e5123 100644 --- a/core/task/channel/channel.go +++ b/core/task/channel/channel.go @@ -36,13 +36,13 @@ import ( var log = logger.New(logrus.StandardLogger(), "channel") type Channel struct { - Name string `yaml:"name"` - Type ChannelType `yaml:"type"` - SndBufSize int `yaml:"sndBufSize"` - RcvBufSize int `yaml:"rcvBufSize"` - RateLogging string `yaml:"rateLogging"` //actually an int but we allow templating - Transport TransportType `yaml:"transport"` //default: default - Target string `yaml:"target"` //default: empty + Name string `yaml:"name"` + Type ChannelType `yaml:"type"` + SndBufSize int `yaml:"sndBufSize"` + RcvBufSize int `yaml:"rcvBufSize"` + RateLogging string `yaml:"rateLogging"` //actually an int but we allow templating + Transport TransportType `yaml:"transport"` //default: default + Target string `yaml:"target"` //default: empty // allowed values for `target` field: // outbound channel (mandatory!): ->outbound.go // tcp://host:port @@ -57,13 +57,13 @@ type Channel struct { func (c *Channel) UnmarshalYAML(unmarshal func(interface{}) error) (err error) { type _channel struct { - Name string `yaml:"name"` - Type ChannelType `yaml:"type"` - SndBufSize string `yaml:"sndBufSize"` - RcvBufSize string `yaml:"rcvBufSize"` - RateLogging string `yaml:"rateLogging"` - Transport TransportType `yaml:"transport"` - Target string `yaml:"target"` + Name string `yaml:"name"` + Type ChannelType `yaml:"type"` + SndBufSize string `yaml:"sndBufSize"` + RcvBufSize string `yaml:"rcvBufSize"` + RateLogging string `yaml:"rateLogging"` + Transport TransportType `yaml:"transport"` + Target string `yaml:"target"` } aux := _channel{} err = unmarshal(&aux) @@ -105,6 +105,7 @@ func (c *Channel) UnmarshalYAML(unmarshal func(interface{}) error) (err error) { // push/pull/pub/sub/spub/xsub/pair/req/rep/dealer/router // Do we need to support them all? type ChannelType string + const ( PUSH = ChannelType("push") PULL = ChannelType("pull") diff --git a/core/task/channel/endpoint.go b/core/task/channel/endpoint.go index cc90c05ff..75c27993f 100644 --- a/core/task/channel/endpoint.go +++ b/core/task/channel/endpoint.go @@ -36,7 +36,6 @@ const ipcPathFormat = "/tmp/o2ipc-%s" type BindMap map[string]Endpoint - type Endpoint interface { GetAddressFormat() AddressFormat GetAddress() string @@ -68,38 +67,37 @@ func EndpointEquals(e Endpoint, f Endpoint) bool { func NewTcpEndpoint(host string, port uint64, transport TransportType) Endpoint { return TcpEndpoint{ - Host: host, - Port: port, + Host: host, + Port: port, Transport: transport, } } func NewBoundTcpEndpoint(port uint64, transport TransportType) Endpoint { return TcpEndpoint{ - Host: "*", - Port: port, + Host: "*", + Port: port, Transport: transport, } } func NewIpcEndpoint(path string, transport TransportType) Endpoint { return IpcEndpoint{ - Path: strings.TrimPrefix(path, "ipc://"), + Path: strings.TrimPrefix(path, "ipc://"), Transport: transport, } } func NewBoundIpcEndpoint(transport TransportType) Endpoint { return IpcEndpoint{ - Path: fmt.Sprintf(ipcPathFormat, xid.New().String()), + Path: fmt.Sprintf(ipcPathFormat, xid.New().String()), Transport: transport, } } - type TcpEndpoint struct { - Host string - Port uint64 + Host string + Port uint64 Transport TransportType } @@ -134,9 +132,8 @@ func (t TcpEndpoint) ToBoundEndpoint() Endpoint { } } - type IpcEndpoint struct { - Path string + Path string Transport TransportType } @@ -154,14 +151,14 @@ func (t IpcEndpoint) GetTransport() TransportType { func (t IpcEndpoint) ToTargetEndpoint(_ string) Endpoint { return IpcEndpoint{ - Path: t.Path, + Path: t.Path, Transport: t.Transport, } } func (t IpcEndpoint) ToBoundEndpoint() Endpoint { return IpcEndpoint{ - Path: t.Path, + Path: t.Path, Transport: t.Transport, } } diff --git a/core/task/channel/transport.go b/core/task/channel/transport.go index 98d6eefe4..0ba83db22 100644 --- a/core/task/channel/transport.go +++ b/core/task/channel/transport.go @@ -30,6 +30,7 @@ import ( ) type TransportType string + const ( DEFAULT = TransportType("default") ZEROMQ = TransportType("zeromq") @@ -57,6 +58,7 @@ func (tr *TransportType) UnmarshalText(b []byte) error { } type AddressFormat string + const ( TCP = AddressFormat("tcp") IPC = AddressFormat("ipc") diff --git a/core/task/constraint/constraints.go b/core/task/constraint/constraints.go index 5b0cbc683..3cfac6ca6 100644 --- a/core/task/constraint/constraints.go +++ b/core/task/constraint/constraints.go @@ -36,22 +36,26 @@ import ( "github.com/sirupsen/logrus" ) -/* TODO: +/* + TODO: + type Operator func(attribute string, value string) bool func Equals(attribute string, value string) bool { -}*/ -var log = logger.New(logrus.StandardLogger(),"constraints") +} +*/ +var log = logger.New(logrus.StandardLogger(), "constraints") type Constraint struct { - Attribute string `yaml:"attribute"` - Value string `yaml:"value"` + Attribute string `yaml:"attribute"` + Value string `yaml:"value"` // TODO: unmarshal this ↓ - Operator Operator + Operator Operator } type Operator int8 + const ( Equals Operator = 0 ) diff --git a/core/task/coreevent.go b/core/task/coreevent.go index 71934468a..6eb2efc61 100644 --- a/core/task/coreevent.go +++ b/core/task/coreevent.go @@ -22,19 +22,18 @@ * Intergovernmental Organization or submit itself to any jurisdiction. */ -package task +package task import ( + "github.com/AliceO2Group/Control/common/utils/uid" "github.com/AliceO2Group/Control/core/controlcommands" "github.com/AliceO2Group/Control/core/task/taskop" "github.com/mesos/mesos-go/api/v1/lib" - "github.com/AliceO2Group/Control/common/utils/uid" - ) type TaskmanMessage struct { MessageType taskop.MessageType `json:"_messageType"` - + environmentMessage transitionTasksMessage updateTaskMessage @@ -62,7 +61,7 @@ type environmentMessage struct { func (em *environmentMessage) GetEnvironmentId() (envid uid.ID) { if em == nil { - return + return } return em.envId } @@ -98,18 +97,18 @@ func (em *environmentMessage) GetError() string { func NewEnvironmentMessage(mt taskop.MessageType, envId uid.ID, tasks Tasks, desc Descriptors) (t *TaskmanMessage) { t = newTaskmanMessage(mt) t.environmentMessage = environmentMessage{ - envId: envId, - tasks: tasks, - descriptors: desc, + envId: envId, + tasks: tasks, + descriptors: desc, } return t } type transitionTasksMessage struct { - src string - event string - dest string - commonArgs controlcommands.PropertyMap + src string + event string + dest string + commonArgs controlcommands.PropertyMap } func (trm *transitionTasksMessage) GetSource() string { @@ -140,26 +139,26 @@ func (trm *transitionTasksMessage) GetArguments() controlcommands.PropertyMap { return trm.commonArgs } -func NewTransitionTaskMessage(tasks Tasks, src,transitionEvent,dest string, cargs controlcommands.PropertyMap, envID uid.ID) (t *TaskmanMessage) { +func NewTransitionTaskMessage(tasks Tasks, src, transitionEvent, dest string, cargs controlcommands.PropertyMap, envID uid.ID) (t *TaskmanMessage) { t = newTaskmanMessage(taskop.TransitionTasks) t.transitionTasksMessage = transitionTasksMessage{ - src: src, - event: transitionEvent, - dest: dest, + src: src, + event: transitionEvent, + dest: dest, commonArgs: cargs, } t.environmentMessage = environmentMessage{ - tasks: tasks, - envId: envID, + tasks: tasks, + envId: envID, runNumber: cargs["runNumber"], } return t } type updateTaskMessage struct { - taskId string - state string - status mesos.TaskStatus + taskId string + state string + status mesos.TaskStatus } func NewTaskStatusMessage(mesosStatus mesos.TaskStatus) (t *TaskmanMessage) { @@ -170,11 +169,11 @@ func NewTaskStatusMessage(mesosStatus mesos.TaskStatus) (t *TaskmanMessage) { return t } -func NewTaskStateMessage(taskid,state string) (t *TaskmanMessage) { +func NewTaskStateMessage(taskid, state string) (t *TaskmanMessage) { t = newTaskmanMessage(taskop.TaskStateMessage) t.updateTaskMessage = updateTaskMessage{ taskId: taskid, - state: state, + state: state, } return t -} \ No newline at end of file +} diff --git a/core/task/manager.go b/core/task/manager.go index 07396c958..88597dc1f 100644 --- a/core/task/manager.go +++ b/core/task/manager.go @@ -621,7 +621,7 @@ func (m *Manager) acquireTasks(envId uid.ID, taskDescriptors Descriptors) (err e // can't lock some of them, so we must roll back and keep them // unlocked in the roster. var deployedTaskIds []string - for taskPtr, _ := range deployedTasks { + for taskPtr := range deployedTasks { taskPtr.SetParent(nil) deployedTaskIds = append(deployedTaskIds, taskPtr.taskId) } @@ -636,11 +636,11 @@ func (m *Manager) acquireTasks(envId uid.ID, taskDescriptors Descriptors) (err e } // Finally, we write to the roster. Point of no return! - for taskPtr, _ := range deployedTasks { + for taskPtr := range deployedTasks { m.roster.append(taskPtr) } if deploymentSuccess { - for taskPtr, _ := range deployedTasks { + for taskPtr := range deployedTasks { taskPtr.GetParent().SetTask(taskPtr) } for taskPtr, descriptor := range tasksAlreadyRunning { diff --git a/core/task/roster.go b/core/task/roster.go index 59d8c3b37..c342c9592 100644 --- a/core/task/roster.go +++ b/core/task/roster.go @@ -96,7 +96,7 @@ func (m *roster) getTasks() Tasks { m.mu.RLock() defer m.mu.RUnlock() - tasks:= make(Tasks, len(m.tasks)) + tasks := make(Tasks, len(m.tasks)) copy(tasks, m.tasks) return tasks diff --git a/core/task/safeacks.go b/core/task/safeacks.go index b6ca867c6..5ae6c6c12 100644 --- a/core/task/safeacks.go +++ b/core/task/safeacks.go @@ -31,12 +31,12 @@ import ( // safeAcks is a thread safe map where key is a string usually a taskID // and the value is a channel of empty struct. It is being used // when we want to acknowledge that an action happened to the task -// such as task KILLED. At the moment we utilize -// safeAcks to acknowledge that all the requested tasks +// such as task KILLED. At the moment we utilize +// safeAcks to acknowledge that all the requested tasks // where killed by mesos (task/manager.go). type safeAcks struct { - mu sync.RWMutex - acks map[string]chan struct{} + mu sync.RWMutex + acks map[string]chan struct{} } func (a *safeAcks) getMap() map[string]chan struct{} { @@ -58,15 +58,14 @@ func (a *safeAcks) contains(key string) bool { defer a.mu.RUnlock() _, ok := a.acks[key] - + return ok } - func (a *safeAcks) addAckChannel(key string) { a.mu.Lock() defer a.mu.Unlock() - + a.acks[key] = make(chan struct{}) } @@ -75,11 +74,11 @@ func (a *safeAcks) getValue(key string) (ch chan struct{}, ok bool) { defer a.mu.Unlock() ch, ok = a.acks[key] - return + return } func newAcks() *safeAcks { return &safeAcks{ acks: make(map[string]chan struct{}), } -} \ No newline at end of file +} diff --git a/core/task/scheduler.go b/core/task/scheduler.go index eeb2103f1..d834d42cd 100644 --- a/core/task/scheduler.go +++ b/core/task/scheduler.go @@ -613,7 +613,7 @@ func (state *schedulerState) resourceOffers(fidStore store.Singleton) events.Han var offerWaitGroup sync.WaitGroup offerWaitGroup.Add(len(offers)) - for offerIndex, _ := range offers { + for offerIndex := range offers { go func(offerIndex int) { defer offerWaitGroup.Done() @@ -1094,7 +1094,7 @@ func (state *schedulerState) resourceOffers(fidStore store.Singleton) events.Han machinesUsedSlice := func(machines map[string]struct{}) []string { // StringSet to StringSlice out := make([]string, len(machines)) i := 0 - for k, _ := range machines { + for k := range machines { out[i] = k i++ } @@ -1274,7 +1274,7 @@ func logAllEvents() eventrules.Rule { } } offerIds := make([]string, len(off)) - for i, _ := range off { + for i := range off { offerIds[i] = off[i].GetID().Value } fields["offerIds"] = strings.Join(offerIds, ",") diff --git a/core/task/schedutil/credentials.go b/core/task/schedutil/credentials.go index f2d034125..7b74b76f3 100644 --- a/core/task/schedutil/credentials.go +++ b/core/task/schedutil/credentials.go @@ -32,7 +32,6 @@ import ( "os" ) - func LoadCredentials(username string, password string) (result credentials, err error) { result = credentials{username, password} if result.password != "" { diff --git a/core/task/schedutil/forever.go b/core/task/schedutil/forever.go index 5fb0b8ddc..0e3169eb1 100644 --- a/core/task/schedutil/forever.go +++ b/core/task/schedutil/forever.go @@ -40,7 +40,7 @@ func Forever(name string, jobRestartDelay time.Duration, counter xmetrics.Counte err := f() if err != nil { log.WithFields(logrus.Fields{ - "name": name, + "name": name, "error": err.Error(), }).Error("job exited with error") } else { diff --git a/core/task/schedutil/mesosutil.go b/core/task/schedutil/mesosutil.go index 56913067e..a6bff6201 100644 --- a/core/task/schedutil/mesosutil.go +++ b/core/task/schedutil/mesosutil.go @@ -50,7 +50,7 @@ import ( const AuthModeBasic = "basic" -var log = logger.New(logrus.StandardLogger(),"scheduler") +var log = logger.New(logrus.StandardLogger(), "scheduler") func PrepareExecutorInfo( execBinary, execImage string, @@ -84,8 +84,8 @@ func PrepareExecutorInfo( _, executorCmd := filepath.Split(execBinary) var ( - executorUris = []mesos.CommandInfo_URI{} - executorCommand = fmt.Sprintf("./%s", executorCmd) + executorUris = []mesos.CommandInfo_URI{} + executorCommand = fmt.Sprintf("./%s", executorCmd) ) executorUris = append(executorUris, mesos.CommandInfo_URI{Value: execBinary, Executable: proto.Bool(true)}) @@ -113,7 +113,6 @@ func BuildWantsExecutorResources(executorCPU float64, executorMemory float64) (r return } - type credentials struct { username string password string diff --git a/core/task/taskclass/port/range.go b/core/task/taskclass/port/range.go index 9072b2b14..895ba97ae 100644 --- a/core/task/taskclass/port/range.go +++ b/core/task/taskclass/port/range.go @@ -68,7 +68,7 @@ func (this Ranges) Equals(other Ranges) (response bool) { } response = true - for i, _ := range this { + for i := range this { if this[i].Begin == other[i].Begin && this[i].End == other[i].End { continue } diff --git a/core/task/taskop/messagetype.go b/core/task/taskop/messagetype.go index cf8548e49..92e97da06 100644 --- a/core/task/taskop/messagetype.go +++ b/core/task/taskop/messagetype.go @@ -32,7 +32,7 @@ import ( type MessageType int -const( +const ( AcquireTasks MessageType = iota ConfigureTasks TransitionTasks @@ -44,7 +44,7 @@ const( ) func (mt MessageType) String() string { - return [...]string{"AcquireTasks", "ConfigureTasks", "TransitionTasks", "MesosEvent", "ReleaseTasks", "KillTasks","TaskStatusMessage","TaskStateMessage","Error"}[mt] + return [...]string{"AcquireTasks", "ConfigureTasks", "TransitionTasks", "MesosEvent", "ReleaseTasks", "KillTasks", "TaskStatusMessage", "TaskStateMessage", "Error"}[mt] } func (mt *MessageType) UnmarshalJSON(b []byte) error { diff --git a/core/workflow/aggregatorrole.go b/core/workflow/aggregatorrole.go index 9fa89d71a..df677432b 100644 --- a/core/workflow/aggregatorrole.go +++ b/core/workflow/aggregatorrole.go @@ -192,7 +192,7 @@ func (r *aggregatorRole) ProcessTemplates(workflowRepo repos.IRepo, loadSubworkf var roleErrors *multierror.Error // Process templates for child roles - for roleIdx, _ := range r.Roles { + for roleIdx := range r.Roles { go func(roleIdx int) { defer wg.Done() role := r.Roles[roleIdx] diff --git a/core/workflow/aggregatortemplate.go b/core/workflow/aggregatortemplate.go index 8c582a63a..29bb39dae 100644 --- a/core/workflow/aggregatortemplate.go +++ b/core/workflow/aggregatortemplate.go @@ -25,10 +25,10 @@ package workflow import ( - "github.com/jinzhu/copier" "errors" + "github.com/jinzhu/copier" "text/template" - ) +) type aggregatorTemplate struct { aggregatorRole @@ -44,7 +44,6 @@ func (at *aggregatorTemplate) copy() copyable { return &rCopy } - func (at *aggregatorTemplate) UnmarshalYAML(unmarshal func(interface{}) error) (err error) { type _aggregatorTemplate aggregatorTemplate aux := _aggregatorTemplate{} @@ -70,7 +69,7 @@ func (at *aggregatorTemplate) UnmarshalYAML(unmarshal func(interface{}) error) ( } aux.stringTemplates[str] = *tempTmpl } - */ + */ *at = aggregatorTemplate(aux) return @@ -97,4 +96,4 @@ func (at *aggregatorTemplate) generateRole(localVars map[string]string) (c Role, c = &ar return -} \ No newline at end of file +} diff --git a/core/workflow/callable/maps.go b/core/workflow/callable/maps.go index 694480086..48503f804 100644 --- a/core/workflow/callable/maps.go +++ b/core/workflow/callable/maps.go @@ -33,7 +33,7 @@ type HookWeight int func (m HooksMap) GetWeights() []HookWeight { weights := make([]int, len(m)) i := 0 - for k, _ := range m { + for k := range m { weights[i] = int(k) i++ } @@ -48,7 +48,7 @@ func (m HooksMap) GetWeights() []HookWeight { func (m CallsMap) GetWeights() []HookWeight { weights := make([]int, len(m)) i := 0 - for k, _ := range m { + for k := range m { weights[i] = int(k) i++ } diff --git a/core/workflow/calltemplate.go b/core/workflow/calltemplate.go index 24cb03fc7..fba4625c1 100644 --- a/core/workflow/calltemplate.go +++ b/core/workflow/calltemplate.go @@ -25,9 +25,9 @@ package workflow import ( - "text/template" "errors" "github.com/jinzhu/copier" + "text/template" ) type callTemplate struct { @@ -86,4 +86,4 @@ func (tt *callTemplate) generateRole(localVars map[string]string) (c Role, err e c = &tr return -} \ No newline at end of file +} diff --git a/core/workflow/graft.go b/core/workflow/graft.go index 4a1cd9b8c..d66b24fc6 100644 --- a/core/workflow/graft.go +++ b/core/workflow/graft.go @@ -25,84 +25,84 @@ package workflow import ( - "fmt" - "gopkg.in/yaml.v3" - "strings" + "fmt" + "gopkg.in/yaml.v3" + "strings" ) // Graft takes a root node, a path to a role in root, byte array with an existing role and appends this // role asa child of the role in root where the path specifies. -func Graft(root *yaml.Node, path string, toAdd []byte, graftedName string) (out []byte, err error) { - var parent *yaml.Node - for _, step := range strings.Split(path, PATH_SEPARATOR) { - _ = iterateNode(root, &parent, step) - } - if parent == nil { - return nil, fmt.Errorf("specified path not found") - } +func Graft(root *yaml.Node, path string, toAdd []byte, graftedName string) (out []byte, err error) { + var parent *yaml.Node + for _, step := range strings.Split(path, PATH_SEPARATOR) { + _ = iterateNode(root, &parent, step) + } + if parent == nil { + return nil, fmt.Errorf("specified path not found") + } - err = appendRole(parent, toAdd) - if err != nil { - return nil, err - } + err = appendRole(parent, toAdd) + if err != nil { + return nil, err + } - if graftedName != "" { - nameNode := iterateNode(root, &parent, "name") - for index, node := range parent.Content { - // Search for the name node and change the Value field for the subsequent node - if node == nameNode { - parent.Content[index+1].Value = graftedName - break - } - } - } + if graftedName != "" { + nameNode := iterateNode(root, &parent, "name") + for index, node := range parent.Content { + // Search for the name node and change the Value field for the subsequent node + if node == nameNode { + parent.Content[index+1].Value = graftedName + break + } + } + } - out, err = yaml.Marshal(root) - if err != nil{ - return nil, err - } + out, err = yaml.Marshal(root) + if err != nil { + return nil, err + } - return out, nil + return out, nil } // When passed a node, iterate through each node of its node.Content array. If found, return that node. // If not found, call iterateNode on the current node's node.Content array. The goal of this function is to get // the parent node of where the search string is found. -func iterateNode(node *yaml.Node, parent **yaml.Node,identifier string) (found *yaml.Node) { - for _, n := range node.Content { - if n.Value == identifier { - return n - } - if len(n.Content) > 0 { - if n.Tag == "!!map" { - *parent = n - } - acNode := iterateNode(n, parent, identifier) - if acNode != nil { - return acNode - } - } - } - return nil +func iterateNode(node *yaml.Node, parent **yaml.Node, identifier string) (found *yaml.Node) { + for _, n := range node.Content { + if n.Value == identifier { + return n + } + if len(n.Content) > 0 { + if n.Tag == "!!map" { + *parent = n + } + acNode := iterateNode(n, parent, identifier) + if acNode != nil { + return acNode + } + } + } + return nil } // appendRole checks if the yaml.Node passed has a "roles" field. If it exists, the toAdd yaml.Node will // be appended. If not, appendRole will error out. func appendRole(parent *yaml.Node, toAdd []byte) (err error) { - var childRole yaml.Node - err = yaml.Unmarshal(toAdd, &childRole) - var auxParent *yaml.Node // dummy value to run iterateNode successfully + var childRole yaml.Node + err = yaml.Unmarshal(toAdd, &childRole) + var auxParent *yaml.Node // dummy value to run iterateNode successfully - if iterateNode(parent, &auxParent, "roles") != nil { - for i, v := range parent.Content { - if v.Value == "roles" { - // If a !!str yaml.Node with value "roles" found, append toAdd to the next yaml.Node's Content - parent.Content[i + 1].Content = append(parent.Content[i + 1].Content, childRole.Content[0]) - } - } - } else { - // error out if current yaml.Node does not have a "roles" field - return fmt.Errorf("specified node does not have a 'roles' field") - } - return + if iterateNode(parent, &auxParent, "roles") != nil { + for i, v := range parent.Content { + if v.Value == "roles" { + // If a !!str yaml.Node with value "roles" found, append toAdd to the next yaml.Node's Content + parent.Content[i+1].Content = append(parent.Content[i+1].Content, childRole.Content[0]) + } + } + } else { + // error out if current yaml.Node does not have a "roles" field + return fmt.Errorf("specified node does not have a 'roles' field") + } + return } diff --git a/core/workflow/includetemplate.go b/core/workflow/includetemplate.go index 55e644c98..e9cd07a81 100644 --- a/core/workflow/includetemplate.go +++ b/core/workflow/includetemplate.go @@ -25,9 +25,9 @@ package workflow import ( - "text/template" "errors" "github.com/jinzhu/copier" + "text/template" ) type includeTemplate struct { @@ -86,4 +86,4 @@ func (tt *includeTemplate) generateRole(localVars map[string]string) (c Role, er c = &tr return -} \ No newline at end of file +} diff --git a/core/workflow/iteratorrole.go b/core/workflow/iteratorrole.go index 5a5384921..f1c9a6ac7 100644 --- a/core/workflow/iteratorrole.go +++ b/core/workflow/iteratorrole.go @@ -172,7 +172,7 @@ func (i *iteratorRole) ProcessTemplates(workflowRepo repos.IRepo, loadSubworkflo var roleErrors *multierror.Error // Process templates for child roles - for roleIdx, _ := range i.Roles { + for roleIdx := range i.Roles { go func(roleIdx int) { defer wg.Done() role := i.Roles[roleIdx] @@ -238,7 +238,7 @@ func (i *iteratorRole) expandTemplate() (err error) { var roleErrors *multierror.Error roles = make([]Role, len(ran)) - for rangeIdx, _ := range ran { + for rangeIdx := range ran { go func(rangeIdx int) { defer wg.Done() localValue := ran[rangeIdx] diff --git a/core/workflow/rolebase.go b/core/workflow/rolebase.go index 4b8308de1..84481408d 100644 --- a/core/workflow/rolebase.go +++ b/core/workflow/rolebase.go @@ -318,7 +318,7 @@ func (r *roleBase) wrapBindAndConnectFields() template.Fields { fields := make(template.Fields, len(r.Connect)) // first we populate the connect fields, because we know we'll have 1 fields entry // for each connect block - for i, _ := range r.Connect { + for i := range r.Connect { index := i // always keep a local copy for the getter/setter closures fields[index] = template.WrapGeneric( func() string { @@ -331,7 +331,7 @@ func (r *roleBase) wrapBindAndConnectFields() template.Fields { } // then we add any Global channel alias declarations for bind fields, we don't know // how many in advance because not all bind blocks have Global aliases - for i, _ := range r.Bind { + for i := range r.Bind { index := i // always keep a local copy for the getter/setter closures if len(r.Bind[index].Global) == 0 { continue diff --git a/core/workflow/roleutils.go b/core/workflow/roleutils.go index 6abb6f20e..3d1ef93f8 100644 --- a/core/workflow/roleutils.go +++ b/core/workflow/roleutils.go @@ -32,7 +32,7 @@ import ( func WrapConstraints(items constraint.Constraints) template.Fields { fields := make(template.Fields, 0) - for i, _ := range items { + for i := range items { index := i // we need a local copy for the getter/setter closures fields = append(fields, &template.GenericWrapper{ Getter: func() string { diff --git a/core/workflow/tasktemplate.go b/core/workflow/tasktemplate.go index 5fdeced84..ce100bbcb 100644 --- a/core/workflow/tasktemplate.go +++ b/core/workflow/tasktemplate.go @@ -25,9 +25,9 @@ package workflow import ( - "text/template" "errors" "github.com/jinzhu/copier" + "text/template" ) type taskTemplate struct { @@ -86,4 +86,4 @@ func (tt *taskTemplate) generateRole(localVars map[string]string) (c Role, err e c = &tr return -} \ No newline at end of file +} diff --git a/executor/executable/pid_util.go b/executor/executable/pid_util.go index bf0605881..611faa88a 100644 --- a/executor/executable/pid_util.go +++ b/executor/executable/pid_util.go @@ -30,7 +30,7 @@ import ( ) // pidExists will check if a pid process is running -func pidExists(pid int) (bool) { +func pidExists(pid int) bool { if pid == 0 { return false } else if pid < 0 { @@ -60,4 +60,4 @@ func pidExists(pid int) (bool) { return true } return false -} \ No newline at end of file +} diff --git a/executor/executorcmd/nopb/jsoncodec.go b/executor/executorcmd/nopb/jsoncodec.go index 62576b7eb..a6abbff16 100644 --- a/executor/executorcmd/nopb/jsoncodec.go +++ b/executor/executorcmd/nopb/jsoncodec.go @@ -35,7 +35,7 @@ func init() { } // Satisfies interface grpc.encoding.Codec -type JsonCodec struct {} +type JsonCodec struct{} func (*JsonCodec) Marshal(v interface{}) ([]byte, error) { return json.Marshal(v) diff --git a/executor/executorcmd/nopb/occclient.go b/executor/executorcmd/nopb/occclient.go index d85755210..5efe87502 100644 --- a/executor/executorcmd/nopb/occclient.go +++ b/executor/executorcmd/nopb/occclient.go @@ -26,6 +26,7 @@ func NewOccClient(cc *grpc.ClientConn) OccClient { type occEventStreamClient struct { grpc.ClientStream } + func (x *occEventStreamClient) Recv() (*pb.EventStreamReply, error) { m := new(pb.EventStreamReply) if err := x.ClientStream.RecvMsg(m); err != nil { @@ -38,11 +39,11 @@ func (c *occClient) EventStream(ctx context.Context, in *pb.EventStreamRequest, opts = append(opts, []grpc.CallOption{ grpc.CallContentSubtype("json"), - }... + }..., ) streamDesc := grpc.StreamDesc{ StreamName: "EventStream", - Handler: nil, + Handler: nil, ServerStreams: true, ClientStreams: false, } @@ -69,7 +70,7 @@ func (c *occClient) GetState(ctx context.Context, in *pb.GetStateRequest, opts . opts = append(opts, []grpc.CallOption{ grpc.CallContentSubtype("json"), - }... + }..., ) err := c.cc.Invoke(ctx, "GetState", in, &out, opts...) if err != nil { @@ -83,7 +84,7 @@ func (c *occClient) Transition(ctx context.Context, in *pb.TransitionRequest, op opts = append(opts, []grpc.CallOption{ grpc.CallContentSubtype("json"), - }... + }..., ) err := c.cc.Invoke(ctx, "Transition", in, &out, opts...) if err != nil { diff --git a/executor/executorcmd/nopb/test/main.go b/executor/executorcmd/nopb/test/main.go index 757417aa2..ae5e3171f 100644 --- a/executor/executorcmd/nopb/test/main.go +++ b/executor/executorcmd/nopb/test/main.go @@ -44,17 +44,17 @@ func main() { targetPort, _ := strconv.Atoi(targetPortS) fmt.Printf("target port: %d", targetPort) - c := executorcmd.NewClient( - uint64(targetPort), - controlmode.FAIRMQ, - executorcmd.JsonTransport, - log.WithField("id", "")) - if c == nil { - fmt.Println("client is nil") + c := executorcmd.NewClient( + uint64(targetPort), + controlmode.FAIRMQ, + executorcmd.JsonTransport, + log.WithField("id", "")) + if c == nil { + fmt.Println("client is nil") } for i := 0; i < 10; i++ { - time.Sleep(100*time.Millisecond) + time.Sleep(100 * time.Millisecond) gsr, err := c.GetState(context.TODO(), &pb.GetStateRequest{}, grpc.EmptyCallOption{}) if err != nil { diff --git a/executor/executorcmd/transitioner/direct.go b/executor/executorcmd/transitioner/direct.go index 72961f47a..5d1d7c9a1 100644 --- a/executor/executorcmd/transitioner/direct.go +++ b/executor/executorcmd/transitioner/direct.go @@ -38,4 +38,4 @@ func (cm *Direct) Commit(evt string, src string, dst string, args map[string]str func (cm *Direct) FromDeviceState(state string) string { return state -} \ No newline at end of file +} diff --git a/executor/executorcmd/transitioner/fairmq.go b/executor/executorcmd/transitioner/fairmq.go index bfaab5dc9..8b521f7a3 100644 --- a/executor/executorcmd/transitioner/fairmq.go +++ b/executor/executorcmd/transitioner/fairmq.go @@ -29,22 +29,22 @@ import "github.com/AliceO2Group/Control/executor/executorcmd/transitioner/fairmq type FairMQ struct { DoTransition DoTransitionFunc - stateMap map[string]string + stateMap map[string]string invStateMap map[string]string } func NewFairMQTransitioner(transitionFunc DoTransitionFunc) *FairMQ { stateMap := map[string]string{ - "STANDBY": fairmq.IDLE, + "STANDBY": fairmq.IDLE, "CONFIGURED": fairmq.READY, - "RUNNING": fairmq.RUNNING, - "ERROR": fairmq.ERROR, - "DONE": fairmq.EXITING, + "RUNNING": fairmq.RUNNING, + "ERROR": fairmq.ERROR, + "DONE": fairmq.EXITING, } return &FairMQ{ DoTransition: transitionFunc, - stateMap: stateMap, - invStateMap: func() (inv map[string]string) { // invert stateMap + stateMap: stateMap, + invStateMap: func() (inv map[string]string) { // invert stateMap inv = make(map[string]string, len(stateMap)) for k, v := range stateMap { inv[v] = k @@ -63,7 +63,8 @@ func (cm *FairMQ) Commit(evt string, src string, dst string, args map[string]str case "STOP": finalState, err = cm.DoTransition(EventInfo{fairmq.EvtSTOP, cm.fmqStateForState(src), cm.fmqStateForState(dst), args}) finalState = cm.stateForFmqState(finalState) - case "RECOVER": fallthrough + case "RECOVER": + fallthrough case "GO_ERROR": log.WithField("event", evt).Error("transition not implemented yet") finalState = src diff --git a/executor/executorcmd/transitioner/fairmq/states.go b/executor/executorcmd/transitioner/fairmq/states.go index b755e7492..402601662 100644 --- a/executor/executorcmd/transitioner/fairmq/states.go +++ b/executor/executorcmd/transitioner/fairmq/states.go @@ -24,7 +24,7 @@ package fairmq -const( +const ( OK = "OK" ERROR = "ERROR" IDLE = "IDLE" @@ -35,4 +35,4 @@ const( READY = "READY" RUNNING = "RUNNING" EXITING = "EXITING" -) \ No newline at end of file +) diff --git a/executor/executorcmd/transitioner/fairmq/transitions.go b/executor/executorcmd/transitioner/fairmq/transitions.go index 5c6982d18..d64c5ca11 100644 --- a/executor/executorcmd/transitioner/fairmq/transitions.go +++ b/executor/executorcmd/transitioner/fairmq/transitions.go @@ -24,7 +24,7 @@ package fairmq -const( +const ( EvtAUTO = "Auto" EvtINIT_DEVICE = "INIT DEVICE" EvtCOMPLETE_INIT = "COMPLETE INIT" @@ -36,4 +36,4 @@ const( EvtRESET_TASK = "RESET TASK" EvtRESET_DEVICE = "RESET DEVICE" EvtEND = "END" -) \ No newline at end of file +) diff --git a/executor/executorcmd/transitioner/transitioner.go b/executor/executorcmd/transitioner/transitioner.go index 458a8075d..a909eae41 100644 --- a/executor/executorcmd/transitioner/transitioner.go +++ b/executor/executorcmd/transitioner/transitioner.go @@ -29,9 +29,9 @@ package transitioner import ( + "github.com/AliceO2Group/Control/common/controlmode" "github.com/AliceO2Group/Control/common/logger" "github.com/sirupsen/logrus" - "github.com/AliceO2Group/Control/common/controlmode" ) var log = logger.New(logrus.StandardLogger(), "executorcontrol") @@ -52,9 +52,12 @@ func NewTransitioner(cm controlmode.ControlMode, transitionFunc DoTransitionFunc switch cm { case controlmode.FAIRMQ: return NewFairMQTransitioner(transitionFunc) - case controlmode.BASIC: fallthrough - case controlmode.HOOK: fallthrough - case controlmode.DIRECT: fallthrough + case controlmode.BASIC: + fallthrough + case controlmode.HOOK: + fallthrough + case controlmode.DIRECT: + fallthrough default: return NewDirectTransitioner(transitionFunc) } diff --git a/occ/peanut/flatten/flatten.go b/occ/peanut/flatten/flatten.go index 72b2bad1e..09db104a1 100644 --- a/occ/peanut/flatten/flatten.go +++ b/occ/peanut/flatten/flatten.go @@ -89,7 +89,6 @@ SOFTWARE. // // "c[f]": "g", // // "z": 1.4567, // // } -// package flatten import ( @@ -215,4 +214,4 @@ func enkey(top bool, prefix, subkey string, style SeparatorStyle) string { } return key -} \ No newline at end of file +} diff --git a/walnut/converter/converter_test.go b/walnut/converter/converter_test.go index c16f2ed94..c32ae0add 100644 --- a/walnut/converter/converter_test.go +++ b/walnut/converter/converter_test.go @@ -102,13 +102,13 @@ func TestGraft(t *testing.T) { f2, _ := ioutil.ReadFile("dump.yaml") result, err := workflow.Graft(&root, "readout.host-{{ it }}", f2, "small") - if err != nil{ + if err != nil { t.Error(err) } wd, _ := os.Getwd() err = ioutil.WriteFile(filepath.Join(wd, "test", "grafted.yaml"), result, 0644) - if err != nil{ + if err != nil { t.Error(err) } }) diff --git a/walnut/converter/testvalues.go b/walnut/converter/testvalues.go index 028bb1562..70b178609 100644 --- a/walnut/converter/testvalues.go +++ b/walnut/converter/testvalues.go @@ -24,12 +24,12 @@ package converter -var defaults = map[string]string { +var defaults = map[string]string{ "qc_config_uri": "json:///etc/flp.d/qc/readout.json", - "user": "test-user-1", + "user": "test-user-1", } -var extraVars = map[string]string { +var extraVars = map[string]string{ "readout_cfg_uri": "file:/home/flp/readout_stfb_emu.cfg", } @@ -39,7 +39,7 @@ var TestDump = Dump{ Name: "producer-0", Inputs: []io{}, Outputs: []io{ - io{ + { Binding: "out", Origin: "TST", Description: "RAWDATA", @@ -106,25 +106,25 @@ var TestDump = Dump{ "dpl-dump.json", }, WorkflowOptions: []options{ - options{ + { Name: "config-path", Type: "4", DefaultValue: "", Help: "Absolute path to the config file. Overwrite the default paths. Do not use with no-data-sampling.", }, - options{ + { Name: "no-data-sampling", Type: "5", DefaultValue: "0", Help: "Skips data sampling, connects directly the task to the producer.", }, - options{ + { Name: "readers", Type: "1", DefaultValue: "1", Help: "number of parallel readers to use", }, - options{ + { Name: "pipeline", Type: "4", DefaultValue: "", diff --git a/walnut/includeschemata.go b/walnut/includeschemata.go index 655f2f4c0..b5843ace0 100644 --- a/walnut/includeschemata.go +++ b/walnut/includeschemata.go @@ -24,14 +24,14 @@ package main -// Generate latest schemas from .json files +// Generate latest schemas from .json files //go:generate go run includeschemata.go import ( "io" "io/ioutil" - "path/filepath" "os" + "path/filepath" "strings" ) @@ -46,7 +46,7 @@ func main() { return } - out, err := os.Create(filepath.Join(schemasPath,"schemata.go")) + out, err := os.Create(filepath.Join(schemasPath, "schemata.go")) if err != nil { return } @@ -55,7 +55,7 @@ func main() { for _, f := range fs { if strings.HasSuffix(f.Name(), ".json") { out.Write([]byte(strings.TrimSuffix(f.Name(), ".json") + " = `\n")) - f, _ := os.Open(filepath.Join(schemasPath,f.Name())) + f, _ := os.Open(filepath.Join(schemasPath, f.Name())) io.Copy(out, f) out.Write([]byte("`\n")) } diff --git a/walnut/schemata/schemata.go b/walnut/schemata/schemata.go index 31334c440..1e6c96aea 100644 --- a/walnut/schemata/schemata.go +++ b/walnut/schemata/schemata.go @@ -1,7 +1,7 @@ -package schemata +package schemata const ( -Task = ` + Task = ` { "$schema": "http://json-schema.org/draft-07/schema#", "$id": "https://github.com/obviyus/Controlss/walnut/schemata/Task.json", @@ -189,7 +189,7 @@ Task = ` } } ` -Workflow = ` + Workflow = ` { "$schema": "http://json-schema.org/draft-07/schema#", "$id": "https://github.com/obviyus/Control/walnut/schemata/Workflow.json",