From 88a6f1805fc3800fe471c93bbe847086ea506d3f Mon Sep 17 00:00:00 2001 From: Vishwas Sharma <135056281+vishwas-sharma2480@users.noreply.github.com> Date: Mon, 12 Feb 2024 14:14:38 +0530 Subject: [PATCH] Enable revive (#2773) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * resolved conflict and made changes again * formated the changes * corrected the make format error ./agent/agents/mysql/slowlog/slowlog.go:723:30: missing ',' in argument list * corrected the make format error ./agent/agents/mysql/slowlog/slowlog.go:723:30: missing ',' in argument list * resolved the remaining linter warnings * made the requested changes * made changes to cleare main check * made changes to cleare main check * formatted the changes * made changes to cleare main check * formatted the changes * Remove unused lint. * Another changes. * make gen * Another lint. * Another lint. * Another lint. * Lint. * Lint godot. * Update managed/services/agents/versioner.go Co-authored-by: Alex Demidoff --------- Co-authored-by: Jiří Čtvrtka <62988319+JiriCtvrtka@users.noreply.github.com> Co-authored-by: Jiří Čtvrtka Co-authored-by: Alex Demidoff --- .golangci.yml | 2 +- admin/agentlocal/agentlocal.go | 10 +- admin/cli/cli.go | 2 + admin/cmd/pmm-admin/main.go | 2 +- admin/cmd/pmm/main.go | 2 +- admin/commands/base.go | 4 + .../inventory/add_agent_external_exporter.go | 1 + .../inventory/add_agent_mongodb_exporter.go | 1 + .../inventory/add_agent_mysqld_exporter.go | 1 + .../inventory/add_agent_node_exporter.go | 1 + .../commands/inventory/add_agent_pmm_agent.go | 1 + .../inventory/add_agent_postgres_exporter.go | 1 + .../inventory/add_agent_proxysql_exporter.go | 1 + .../add_agent_qan_mongodb_profiler_agent.go | 1 + .../add_agent_qan_mysql_perfschema_agent.go | 1 + .../add_agent_qan_mysql_slowlog_agent.go | 1 + ...d_agent_qan_postgres_pgstatements_agent.go | 1 + ..._agent_qan_postgres_pgstatmonitor_agent.go | 1 + .../inventory/add_agent_rds_exporter.go | 1 + .../commands/inventory/add_node_container.go | 1 + admin/commands/inventory/add_node_generic.go | 1 + admin/commands/inventory/add_node_remote.go | 1 + .../commands/inventory/add_node_remote_rds.go | 1 + .../inventory/add_service_external.go | 1 + .../commands/inventory/add_service_haproxy.go | 1 + .../commands/inventory/add_service_mongodb.go | 1 + admin/commands/inventory/add_service_mysql.go | 1 + .../inventory/add_service_postgresql.go | 1 + .../inventory/add_service_proxysql.go | 1 + admin/commands/inventory/inventory.go | 2 +- admin/commands/inventory/list_agents.go | 1 + admin/commands/inventory/list_nodes.go | 1 + admin/commands/inventory/list_services.go | 1 + admin/commands/inventory/remove_agent.go | 1 + admin/commands/inventory/remove_node.go | 1 + admin/commands/inventory/remove_service.go | 1 + admin/commands/list.go | 1 + admin/commands/management/add_external.go | 2 + .../management/add_external_serverless.go | 2 + admin/commands/management/add_haproxy.go | 2 + admin/commands/management/add_mongodb.go | 6 + admin/commands/management/add_mysql.go | 5 + admin/commands/management/add_postgresql.go | 6 + admin/commands/management/add_proxysql.go | 6 + admin/commands/management/register.go | 1 + admin/commands/management/remove.go | 1 + admin/commands/management/unregister.go | 1 + admin/commands/pmm/server/docker/upgrade.go | 2 +- admin/commands/status.go | 2 +- admin/pkg/docker/docker.go | 1 + agent/agentlocal/agent_local.go | 6 +- agent/agents/agents_test.go | 3 +- agent/agents/mongodb/mongodb.go | 6 +- agent/agents/mysql/perfschema/perfschema.go | 2 +- agent/agents/mysql/slowlog/parser/logger.go | 1 + .../mysql/slowlog/parser/parser_bench_test.go | 2 +- agent/agents/mysql/slowlog/slowlog.go | 4 +- agent/agents/mysql/slowlog/slowlog_test.go | 6 +- agent/agents/noop/noop.go | 4 +- agent/agents/noop/noop_test.go | 2 +- .../postgres/pgstatmonitor/pgstatmonitor.go | 6 +- .../pgstatstatements/pgstatstatements.go | 4 +- agent/agents/supervisor/supervisor.go | 6 +- agent/client/basic_auth.go | 2 +- agent/cmd/pmm-agent-entrypoint/main.go | 4 +- agent/commands/setup.go | 2 +- agent/config/config.go | 2 +- agent/config/logger.go | 2 +- agent/connectionchecker/connection_checker.go | 2 +- agent/main.go | 4 +- agent/runner/actions/mysql_explain_action.go | 2 +- agent/runner/jobs/mysql_restore_job.go | 2 +- agent/runner/jobs/pbm_helpers.go | 2 +- agent/runner/runner_test.go | 2 +- agent/utils/backoff/backoff_test.go | 2 +- agent/utils/mongo_fix/mongo_fix.go | 7 +- agent/utils/mongo_fix/mongo_fix_test.go | 2 +- agent/utils/version/postgresql.go | 1 + api-tests/helpers.go | 11 +- api-tests/management/helpers.go | 2 + api/agentpb/agent.go | 36 + api/inventorypb/agents.go | 2 +- managed/cmd/pmm-managed-init/main.go | 2 +- managed/cmd/pmm-managed-starlark/main.go | 2 +- managed/cmd/pmm-managed/main.go | 2 +- managed/data/gen.go | 2 + managed/models/agent_model.go | 1 + managed/models/agentversion.go | 2 + managed/models/artifact_helpers.go | 2 +- managed/models/artifact_model.go | 1 + managed/models/database.go | 6 +- managed/models/dump.go | 9 +- managed/models/dump_helpers.go | 4 + managed/models/models.go | 3 + managed/models/percona_sso_model_helpers.go | 3 +- managed/models/scheduled_tasks_helpers.go | 1 + managed/models/service_model.go | 18 +- managed/models/template_helpers.go | 3 +- managed/models/victoriametrics_params.go | 6 +- managed/services/agents/agents.go | 2 +- managed/services/agents/channel/channel.go | 2 +- managed/services/agents/jobs.go | 1 + managed/services/agents/registry.go | 1 + managed/services/agents/versioner.go | 36 +- managed/services/backup/deps.go | 1 + managed/services/backup/metrics.go | 4 + .../services/backup/pitr_timerange_service.go | 2 +- managed/services/checks/checks.go | 3 +- managed/services/dbaas/dbaas_client.go | 1 + .../dbaas/kubernetes/client/client.go | 15 +- .../kubernetes/client/database/database.go | 20 +- .../kubernetes/client/kubeclient_interface.go | 2 + .../dbaas/kubernetes/client/load_config.go | 2 +- .../services/dbaas/kubernetes/kubernetes.go | 10 +- managed/services/dbaas/kubernetes/types.go | 1 + managed/services/dump/dump.go | 8 + managed/services/grafana/client.go | 2 - managed/services/ha/highavailability.go | 10 + managed/services/ha/leaderservice.go | 11 + managed/services/inventory/agents.go | 6 +- .../services/inventory/grpc/agents_server.go | 2 +- .../inventory/grpc/services_server.go | 2 +- .../services/inventory/inventory_metrics.go | 16 +- managed/services/inventory/services.go | 16 +- .../management/backup/artifacts_service.go | 2 +- .../management/backup/backups_service.go | 4 +- .../management/backup/locations_service.go | 4 +- managed/services/management/checks.go | 3 +- managed/services/management/common/common.go | 1 + .../management/dbaas/components_service.go | 7 +- .../management/dbaas/db_cluster_service.go | 3 +- .../services/management/dbaas/kube_clients.go | 4 +- .../management/dbaas/psmdb_cluster_service.go | 2 +- .../management/dbaas/template_service.go | 6 +- .../dbaas/version_service_client.go | 1 + managed/services/management/dump/dump.go | 7 + managed/services/management/external.go | 1 + .../management/grpc/actions_server.go | 2 +- managed/services/management/haproxy.go | 1 + .../management/ia/channels_service.go | 8 +- .../services/management/ia/rules_service.go | 10 +- managed/services/platform/platform.go | 2 + managed/services/server/server.go | 10 +- managed/services/supervisord/supervisord.go | 4 +- managed/services/telemetry/config.go | 2 + .../telemetry/datasource_grafanadb_select.go | 4 +- .../telemetry/datasource_pmmdb_select.go | 4 +- .../telemetry/datasource_qandb_select.go | 4 +- .../telemetry/datasource_victoria_metrics.go | 4 +- managed/services/telemetry/telemetry.go | 1 + .../services/telemetry/uievents/uievents.go | 3 + managed/services/types.go | 1 + managed/services/versioncache/errors.go | 1 - managed/utils/envvars/parser.go | 4 +- managed/utils/interceptors/grpc_extension.go | 3 + managed/utils/interceptors/interceptors.go | 1 + managed/utils/platform/client.go | 7 + managed/utils/validators/validators.go | 6 +- my_changes.patch | 3734 +++++++++++++++++ qan-api2/db.go | 2 +- qan-api2/utils/logger/grpc.go | 13 +- update/main.go | 2 +- utils/logger/grpc.go | 11 +- utils/pdeathsig/pdeathsig.go | 2 +- utils/sqlmetrics/sqlmetrics.go | 2 + 165 files changed, 4190 insertions(+), 178 deletions(-) create mode 100644 my_changes.patch diff --git a/.golangci.yml b/.golangci.yml index f275ae1025..460696737c 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -116,7 +116,7 @@ linters: # TODO: carefully review all the rules below and either fix the code # or leave disabled and provide a reason why #- tagliatelle - - revive + #- revive - paralleltest - gocognit - tagalign diff --git a/admin/agentlocal/agentlocal.go b/admin/agentlocal/agentlocal.go index 26a7aa18cc..22adf8ed23 100644 --- a/admin/agentlocal/agentlocal.go +++ b/admin/agentlocal/agentlocal.go @@ -46,13 +46,14 @@ func SetTransport(ctx context.Context, debug bool, port uint32) { client.Default.SetTransport(transport) } +// NetworkInfo represents information about the network. type NetworkInfo bool const ( - RequestNetworkInfo NetworkInfo = true - DoNotRequestNetworkInfo NetworkInfo = false - Localhost = "127.0.0.1" - DefaultPMMAgentListenPort = 7777 + RequestNetworkInfo NetworkInfo = true //nolint:revive + DoNotRequestNetworkInfo NetworkInfo = false //nolint:revive + Localhost = "127.0.0.1" //nolint:revive + DefaultPMMAgentListenPort = 7777 //nolint:revive ) // ErrNotSetUp is returned by GetStatus when pmm-agent is running, but not set up. @@ -81,6 +82,7 @@ type Status struct { ConnectionUptime float32 `json:"connection_uptime"` } +// AgentStatus represents the status of the agent. type AgentStatus struct { AgentID string `json:"agent_id"` AgentType string `json:"agent_type"` diff --git a/admin/cli/cli.go b/admin/cli/cli.go index 9db76727dc..587896ac9c 100644 --- a/admin/cli/cli.go +++ b/admin/cli/cli.go @@ -68,6 +68,7 @@ func (c *PMMAdminCommands) Run(ctx *kong.Context, globals *flags.GlobalFlags) er return run(ctx, globals) } +// GetGlobalFlags returns the global flags for PMMAdminCommands. func (c *PMMAdminCommands) GetGlobalFlags() *flags.GlobalFlags { return &c.GlobalFlags } @@ -81,6 +82,7 @@ type PMMCommands struct { Completion commands.CompletionCommand `cmd:"" help:"Outputs shell code for initialising tab completions"` } +// GetGlobalFlags returns the global flags for PMMAdminCommands. func (c *PMMCommands) GetGlobalFlags() *flags.GlobalFlags { return &c.GlobalFlags } diff --git a/admin/cmd/pmm-admin/main.go b/admin/cmd/pmm-admin/main.go index c376184e68..73f7310282 100644 --- a/admin/cmd/pmm-admin/main.go +++ b/admin/cmd/pmm-admin/main.go @@ -11,7 +11,7 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. - +// Package main. package main import ( diff --git a/admin/cmd/pmm/main.go b/admin/cmd/pmm/main.go index 6800636f6d..649e2b403e 100644 --- a/admin/cmd/pmm/main.go +++ b/admin/cmd/pmm/main.go @@ -11,7 +11,7 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. - +// Package main. package main import ( diff --git a/admin/commands/base.go b/admin/commands/base.go index 9289789951..e7240664d1 100644 --- a/admin/commands/base.go +++ b/admin/commands/base.go @@ -111,16 +111,19 @@ func ReadFromSource(src string) (*Credentials, error) { return &creds, nil } +// ErrorResponse defines the interface for error responses. type ErrorResponse interface { error Code() int } +// Error represents an error with additional information. type Error struct { Code int `json:"code"` Error string `json:"error"` } +// GetError converts an ErrorResponse to an Error. func GetError(err ErrorResponse) Error { v := reflect.ValueOf(err) p := v.Elem().FieldByName("Payload") @@ -131,6 +134,7 @@ func GetError(err ErrorResponse) Error { } } +// ParseTemplate parses the input text into a template.Template. func ParseTemplate(text string) *template.Template { t := template.New("").Option("missingkey=error") return template.Must(t.Parse(strings.TrimSpace(text))) diff --git a/admin/commands/inventory/add_agent_external_exporter.go b/admin/commands/inventory/add_agent_external_exporter.go index 8d83d9240e..9aaf8f123c 100644 --- a/admin/commands/inventory/add_agent_external_exporter.go +++ b/admin/commands/inventory/add_agent_external_exporter.go @@ -60,6 +60,7 @@ type AddAgentExternalExporterCommand struct { PushMetrics bool `help:"Enables push metrics model flow, it will be sent to the server by an agent"` } +// RunCmd executes the AddAgentExternalExporterCommand and returns the result. func (cmd *AddAgentExternalExporterCommand) RunCmd() (commands.Result, error) { customLabels := commands.ParseCustomLabels(cmd.CustomLabels) diff --git a/admin/commands/inventory/add_agent_mongodb_exporter.go b/admin/commands/inventory/add_agent_mongodb_exporter.go index fb258a39c6..88f706d65e 100644 --- a/admin/commands/inventory/add_agent_mongodb_exporter.go +++ b/admin/commands/inventory/add_agent_mongodb_exporter.go @@ -69,6 +69,7 @@ type AddAgentMongodbExporterCommand struct { LogLevel string `enum:"debug,info,warn,error,fatal" default:"warn" help:"Service logging level. One of: [debug, info, warn, error, fatal]"` } +// RunCmd executes the AddAgentMongodbExporterCommand and returns the result. func (cmd *AddAgentMongodbExporterCommand) RunCmd() (commands.Result, error) { customLabels := commands.ParseCustomLabels(cmd.CustomLabels) diff --git a/admin/commands/inventory/add_agent_mysqld_exporter.go b/admin/commands/inventory/add_agent_mysqld_exporter.go index 0753670afa..1b4df9c4b3 100644 --- a/admin/commands/inventory/add_agent_mysqld_exporter.go +++ b/admin/commands/inventory/add_agent_mysqld_exporter.go @@ -101,6 +101,7 @@ type AddAgentMysqldExporterCommand struct { LogLevel string `enum:"debug,info,warn,error" default:"warn" help:"Service logging level. One of: [debug, info, warn, error]"` } +// RunCmd executes the AddAgentMysqldExporterCommand and returns the result. func (cmd *AddAgentMysqldExporterCommand) RunCmd() (commands.Result, error) { customLabels := commands.ParseCustomLabels(cmd.CustomLabels) diff --git a/admin/commands/inventory/add_agent_node_exporter.go b/admin/commands/inventory/add_agent_node_exporter.go index 0e8f4f3e0f..2dbdedfe09 100644 --- a/admin/commands/inventory/add_agent_node_exporter.go +++ b/admin/commands/inventory/add_agent_node_exporter.go @@ -51,6 +51,7 @@ type AddAgentNodeExporterCommand struct { LogLevel string `enum:"debug,info,warn,error" default:"warn" help:"Service logging level. One of: [debug, info, warn, error]"` } +// RunCmd runs the command for AddAgentNodeExporterCommand. func (cmd *AddAgentNodeExporterCommand) RunCmd() (commands.Result, error) { customLabels := commands.ParseCustomLabels(cmd.CustomLabels) params := &agents.AddNodeExporterParams{ diff --git a/admin/commands/inventory/add_agent_pmm_agent.go b/admin/commands/inventory/add_agent_pmm_agent.go index df8057e766..d257c8b16a 100644 --- a/admin/commands/inventory/add_agent_pmm_agent.go +++ b/admin/commands/inventory/add_agent_pmm_agent.go @@ -44,6 +44,7 @@ type AddPMMAgentCommand struct { CustomLabels map[string]string `mapsep:"," help:"Custom user-assigned labels"` } +// RunCmd executes the AddPMMAgentCommand and returns the result. func (cmd *AddPMMAgentCommand) RunCmd() (commands.Result, error) { customLabels := commands.ParseCustomLabels(cmd.CustomLabels) params := &agents.AddPMMAgentParams{ diff --git a/admin/commands/inventory/add_agent_postgres_exporter.go b/admin/commands/inventory/add_agent_postgres_exporter.go index 0ee39234d3..ce3bbdc615 100644 --- a/admin/commands/inventory/add_agent_postgres_exporter.go +++ b/admin/commands/inventory/add_agent_postgres_exporter.go @@ -68,6 +68,7 @@ type AddAgentPostgresExporterCommand struct { AutoDiscoveryLimit int32 `default:"0" placeholder:"NUMBER" help:"Auto-discovery will be disabled if there are more than that number of databases (default: server-defined, -1: always disabled)"` } +// RunCmd executes the AddAgentPostgresExporterCommand and returns the result. func (cmd *AddAgentPostgresExporterCommand) RunCmd() (commands.Result, error) { customLabels := commands.ParseCustomLabels(cmd.CustomLabels) diff --git a/admin/commands/inventory/add_agent_proxysql_exporter.go b/admin/commands/inventory/add_agent_proxysql_exporter.go index d0e53aa7d8..08ec8bda7f 100644 --- a/admin/commands/inventory/add_agent_proxysql_exporter.go +++ b/admin/commands/inventory/add_agent_proxysql_exporter.go @@ -62,6 +62,7 @@ type AddAgentProxysqlExporterCommand struct { LogLevel string `enum:"debug,info,warn,error,fatal" default:"warn" help:"Service logging level. One of: [debug, info, warn, error, fatal]"` } +// RunCmd executes the AddAgentProxysqlExporterCommand and returns the result. func (cmd *AddAgentProxysqlExporterCommand) RunCmd() (commands.Result, error) { customLabels := commands.ParseCustomLabels(cmd.CustomLabels) params := &agents.AddProxySQLExporterParams{ diff --git a/admin/commands/inventory/add_agent_qan_mongodb_profiler_agent.go b/admin/commands/inventory/add_agent_qan_mongodb_profiler_agent.go index 22fbd3dabf..065d885ec4 100644 --- a/admin/commands/inventory/add_agent_qan_mongodb_profiler_agent.go +++ b/admin/commands/inventory/add_agent_qan_mongodb_profiler_agent.go @@ -65,6 +65,7 @@ type AddAgentQANMongoDBProfilerAgentCommand struct { LogLevel string `enum:"debug,info,warn,error,fatal" default:"warn" help:"Service logging level. One of: [debug, info, warn, error, fatal]"` } +// RunCmd executes the AddAgentQANMongoDBProfilerAgentCommand and returns the result. func (cmd *AddAgentQANMongoDBProfilerAgentCommand) RunCmd() (commands.Result, error) { customLabels := commands.ParseCustomLabels(cmd.CustomLabels) diff --git a/admin/commands/inventory/add_agent_qan_mysql_perfschema_agent.go b/admin/commands/inventory/add_agent_qan_mysql_perfschema_agent.go index 82492ad33c..304ab2ae2f 100644 --- a/admin/commands/inventory/add_agent_qan_mysql_perfschema_agent.go +++ b/admin/commands/inventory/add_agent_qan_mysql_perfschema_agent.go @@ -71,6 +71,7 @@ type AddAgentQANMySQLPerfSchemaAgentCommand struct { LogLevel string `enum:"debug,info,warn,error,fatal" default:"warn" help:"Service logging level. One of: [debug, info, warn, error, fatal]"` } +// RunCmd runs the command for AddAgentQANMySQLPerfSchemaAgentCommand. func (cmd *AddAgentQANMySQLPerfSchemaAgentCommand) RunCmd() (commands.Result, error) { customLabels := commands.ParseCustomLabels(cmd.CustomLabels) diff --git a/admin/commands/inventory/add_agent_qan_mysql_slowlog_agent.go b/admin/commands/inventory/add_agent_qan_mysql_slowlog_agent.go index 1ca83e9bbc..af7462faf0 100644 --- a/admin/commands/inventory/add_agent_qan_mysql_slowlog_agent.go +++ b/admin/commands/inventory/add_agent_qan_mysql_slowlog_agent.go @@ -84,6 +84,7 @@ type AddAgentQANMySQLSlowlogAgentCommand struct { LogLevel string `enum:"debug,info,warn,error,fatal" default:"warn" help:"Service logging level. One of: [debug, info, warn, error, fatal]"` } +// RunCmd executes the AddAgentQANMySQLSlowlogAgentCommand and returns the result. func (cmd *AddAgentQANMySQLSlowlogAgentCommand) RunCmd() (commands.Result, error) { customLabels := commands.ParseCustomLabels(cmd.CustomLabels) diff --git a/admin/commands/inventory/add_agent_qan_postgres_pgstatements_agent.go b/admin/commands/inventory/add_agent_qan_postgres_pgstatements_agent.go index 8800accb96..4b10a4504a 100644 --- a/admin/commands/inventory/add_agent_qan_postgres_pgstatements_agent.go +++ b/admin/commands/inventory/add_agent_qan_postgres_pgstatements_agent.go @@ -62,6 +62,7 @@ type AddAgentQANPostgreSQLPgStatementsAgentCommand struct { LogLevel string `enum:"debug,info,warn,error,fatal" default:"warn" help:"Service logging level. One of: [debug, info, warn, error, fatal]"` } +// RunCmd executes the AddAgentQANPostgreSQLPgStatementsAgentCommand and returns the result. func (cmd *AddAgentQANPostgreSQLPgStatementsAgentCommand) RunCmd() (commands.Result, error) { customLabels := commands.ParseCustomLabels(cmd.CustomLabels) diff --git a/admin/commands/inventory/add_agent_qan_postgres_pgstatmonitor_agent.go b/admin/commands/inventory/add_agent_qan_postgres_pgstatmonitor_agent.go index 53df775c57..fb33087a3c 100644 --- a/admin/commands/inventory/add_agent_qan_postgres_pgstatmonitor_agent.go +++ b/admin/commands/inventory/add_agent_qan_postgres_pgstatmonitor_agent.go @@ -64,6 +64,7 @@ type AddAgentQANPostgreSQLPgStatMonitorAgentCommand struct { LogLevel string `enum:"debug,info,warn,error,fatal" default:"warn" help:"Service logging level. One of: [debug, info, warn, error, fatal]"` } +// RunCmd runs the command for AddAgentQANPostgreSQLPgStatMonitorAgentCommand. func (cmd *AddAgentQANPostgreSQLPgStatMonitorAgentCommand) RunCmd() (commands.Result, error) { customLabels := commands.ParseCustomLabels(cmd.CustomLabels) diff --git a/admin/commands/inventory/add_agent_rds_exporter.go b/admin/commands/inventory/add_agent_rds_exporter.go index 5d694ec7f2..ada60ee35e 100644 --- a/admin/commands/inventory/add_agent_rds_exporter.go +++ b/admin/commands/inventory/add_agent_rds_exporter.go @@ -58,6 +58,7 @@ type AddAgentRDSExporterCommand struct { LogLevel string `enum:"debug,info,warn,error,fatal" default:"warn" help:"Service logging level. One of: [debug, info, warn, error, fatal]"` } +// RunCmd executes the AddAgentRDSExporterCommand and returns the result. func (cmd *AddAgentRDSExporterCommand) RunCmd() (commands.Result, error) { customLabels := commands.ParseCustomLabels(cmd.CustomLabels) params := &agents.AddRDSExporterParams{ diff --git a/admin/commands/inventory/add_node_container.go b/admin/commands/inventory/add_node_container.go index 18fabfe19a..d106b3f7db 100644 --- a/admin/commands/inventory/add_node_container.go +++ b/admin/commands/inventory/add_node_container.go @@ -58,6 +58,7 @@ type AddNodeContainerCommand struct { NodeModel string `help:"Node model"` } +// RunCmd executes the AddNodeContainerCommand and returns the result. func (cmd *AddNodeContainerCommand) RunCmd() (commands.Result, error) { customLabels := commands.ParseCustomLabels(cmd.CustomLabels) params := &nodes.AddContainerNodeParams{ diff --git a/admin/commands/inventory/add_node_generic.go b/admin/commands/inventory/add_node_generic.go index 6bd51dc15a..e1a7c1f917 100644 --- a/admin/commands/inventory/add_node_generic.go +++ b/admin/commands/inventory/add_node_generic.go @@ -57,6 +57,7 @@ type AddNodeGenericCommand struct { NodeModel string `help:"Node mddel"` } +// RunCmd executes the AddNodeGenericCommand and returns the result. func (cmd *AddNodeGenericCommand) RunCmd() (commands.Result, error) { customLabels := commands.ParseCustomLabels(cmd.CustomLabels) params := &nodes.AddGenericNodeParams{ diff --git a/admin/commands/inventory/add_node_remote.go b/admin/commands/inventory/add_node_remote.go index 38fef75509..38ad2b025a 100644 --- a/admin/commands/inventory/add_node_remote.go +++ b/admin/commands/inventory/add_node_remote.go @@ -51,6 +51,7 @@ type AddNodeRemoteCommand struct { Az string `help:"Node availability zone"` } +// RunCmd executes the AddNodeRemoteCommand and returns the result. func (cmd *AddNodeRemoteCommand) RunCmd() (commands.Result, error) { customLabels := commands.ParseCustomLabels(cmd.CustomLabels) params := &nodes.AddRemoteNodeParams{ diff --git a/admin/commands/inventory/add_node_remote_rds.go b/admin/commands/inventory/add_node_remote_rds.go index fb045bfbce..6bed5e196e 100644 --- a/admin/commands/inventory/add_node_remote_rds.go +++ b/admin/commands/inventory/add_node_remote_rds.go @@ -53,6 +53,7 @@ type AddNodeRemoteRDSCommand struct { CustomLabels map[string]string `mapsep:"," help:"Custom user-assigned labels"` } +// RunCmd executes the AddNodeRemoteRDSCommand and returns the result. func (cmd *AddNodeRemoteRDSCommand) RunCmd() (commands.Result, error) { customLabels := commands.ParseCustomLabels(cmd.CustomLabels) params := &nodes.AddRemoteRDSNodeParams{ diff --git a/admin/commands/inventory/add_service_external.go b/admin/commands/inventory/add_service_external.go index 4b957148f6..8d6dc5e33d 100644 --- a/admin/commands/inventory/add_service_external.go +++ b/admin/commands/inventory/add_service_external.go @@ -53,6 +53,7 @@ type AddServiceExternalCommand struct { Group string `help:"Group name of external service"` } +// RunCmd executes the AddServiceExternalCommand and returns the result. func (cmd *AddServiceExternalCommand) RunCmd() (commands.Result, error) { customLabels := commands.ParseCustomLabels(cmd.CustomLabels) diff --git a/admin/commands/inventory/add_service_haproxy.go b/admin/commands/inventory/add_service_haproxy.go index a7fd48b922..664442e2ee 100644 --- a/admin/commands/inventory/add_service_haproxy.go +++ b/admin/commands/inventory/add_service_haproxy.go @@ -52,6 +52,7 @@ type AddServiceHAProxyCommand struct { CustomLabels map[string]string `mapsep:"," help:"Custom user-assigned labels"` } +// RunCmd executes the AddServiceHAProxyCommand and returns the result. func (cmd *AddServiceHAProxyCommand) RunCmd() (commands.Result, error) { isSupported, err := helpers.IsHAProxySupported() if !isSupported { diff --git a/admin/commands/inventory/add_service_mongodb.go b/admin/commands/inventory/add_service_mongodb.go index 3314324991..4cae65421f 100644 --- a/admin/commands/inventory/add_service_mongodb.go +++ b/admin/commands/inventory/add_service_mongodb.go @@ -60,6 +60,7 @@ type AddServiceMongoDBCommand struct { CustomLabels map[string]string `mapsep:"," help:"Custom user-assigned labels"` } +// RunCmd executes the AddServiceMongoDBCommand and returns the result. func (cmd *AddServiceMongoDBCommand) RunCmd() (commands.Result, error) { customLabels := commands.ParseCustomLabels(cmd.CustomLabels) params := &services.AddMongoDBServiceParams{ diff --git a/admin/commands/inventory/add_service_mysql.go b/admin/commands/inventory/add_service_mysql.go index ad05f1f057..c269db9238 100644 --- a/admin/commands/inventory/add_service_mysql.go +++ b/admin/commands/inventory/add_service_mysql.go @@ -60,6 +60,7 @@ type AddServiceMySQLCommand struct { CustomLabels map[string]string `mapsep:"," help:"Custom user-assigned labels"` } +// RunCmd runs the command for AddServiceMySQLCommand. func (cmd *AddServiceMySQLCommand) RunCmd() (commands.Result, error) { customLabels := commands.ParseCustomLabels(cmd.CustomLabels) params := &services.AddMySQLServiceParams{ diff --git a/admin/commands/inventory/add_service_postgresql.go b/admin/commands/inventory/add_service_postgresql.go index 992c3883af..6f9e3fabda 100644 --- a/admin/commands/inventory/add_service_postgresql.go +++ b/admin/commands/inventory/add_service_postgresql.go @@ -60,6 +60,7 @@ type AddServicePostgreSQLCommand struct { CustomLabels map[string]string `mapsep:"," help:"Custom user-assigned labels"` } +// RunCmd executes the AddServicePostgreSQLCommand and returns the result. func (cmd *AddServicePostgreSQLCommand) RunCmd() (commands.Result, error) { customLabels := commands.ParseCustomLabels(cmd.CustomLabels) diff --git a/admin/commands/inventory/add_service_proxysql.go b/admin/commands/inventory/add_service_proxysql.go index 60f50ea6cc..9e7d61b466 100644 --- a/admin/commands/inventory/add_service_proxysql.go +++ b/admin/commands/inventory/add_service_proxysql.go @@ -60,6 +60,7 @@ type AddServiceProxySQLCommand struct { CustomLabels map[string]string `mapsep:"," help:"Custom user-assigned labels"` } +// RunCmd executes the AddServiceProxySQLCommand and returns the result. func (cmd *AddServiceProxySQLCommand) RunCmd() (commands.Result, error) { customLabels := commands.ParseCustomLabels(cmd.CustomLabels) params := &services.AddProxySQLServiceParams{ diff --git a/admin/commands/inventory/inventory.go b/admin/commands/inventory/inventory.go index 8de367d9f1..0870bbb8ba 100644 --- a/admin/commands/inventory/inventory.go +++ b/admin/commands/inventory/inventory.go @@ -22,7 +22,7 @@ import ( ) // InventoryCommand is used by Kong for CLI flags and commands. -type InventoryCommand struct { +type InventoryCommand struct { //nolint:revive List ListCommand `cmd:"" help:"List inventory commands"` Add AddCommand `cmd:"" help:"Add to inventory commands"` Remove RemoveCommand `cmd:"" help:"Remove from inventory commands"` diff --git a/admin/commands/inventory/list_agents.go b/admin/commands/inventory/list_agents.go index 22ffc6da64..ed3cd6226f 100644 --- a/admin/commands/inventory/list_agents.go +++ b/admin/commands/inventory/list_agents.go @@ -101,6 +101,7 @@ type ListAgentsCommand struct { AgentType string `help:"Filter by Agent type"` } +// RunCmd executes the ListAgentsCommand and returns the result. func (cmd *ListAgentsCommand) RunCmd() (commands.Result, error) { agentType, err := formatTypeValue(acceptableAgentTypes, cmd.AgentType) if err != nil { diff --git a/admin/commands/inventory/list_nodes.go b/admin/commands/inventory/list_nodes.go index e9febcd072..5c608abea0 100644 --- a/admin/commands/inventory/list_nodes.go +++ b/admin/commands/inventory/list_nodes.go @@ -63,6 +63,7 @@ type ListNodesCommand struct { NodeType string `help:"Filter by Node type"` } +// RunCmd executes the ListNodesCommand and returns the result. func (cmd *ListNodesCommand) RunCmd() (commands.Result, error) { nodeType, err := formatTypeValue(acceptableNodeTypes, cmd.NodeType) if err != nil { diff --git a/admin/commands/inventory/list_services.go b/admin/commands/inventory/list_services.go index d3808fb8b8..e665f92da5 100644 --- a/admin/commands/inventory/list_services.go +++ b/admin/commands/inventory/list_services.go @@ -78,6 +78,7 @@ type ListServicesCommand struct { ExternalGroup string `help:"Filter by external group"` } +// RunCmd executes the ListServicesCommand and returns the result. func (cmd *ListServicesCommand) RunCmd() (commands.Result, error) { serviceType, err := formatTypeValue(acceptableServiceTypes, cmd.ServiceType) if err != nil { diff --git a/admin/commands/inventory/remove_agent.go b/admin/commands/inventory/remove_agent.go index ff04ba8c02..d13c4ca1f7 100644 --- a/admin/commands/inventory/remove_agent.go +++ b/admin/commands/inventory/remove_agent.go @@ -38,6 +38,7 @@ type RemoveAgentCommand struct { Force bool `help:"Remove agent with all dependencies"` } +// RunCmd executes the RemoveAgentCommand and returns the result. func (cmd *RemoveAgentCommand) RunCmd() (commands.Result, error) { params := &agents.RemoveAgentParams{ Body: agents.RemoveAgentBody{ diff --git a/admin/commands/inventory/remove_node.go b/admin/commands/inventory/remove_node.go index 6184a5974b..9e15059d1f 100644 --- a/admin/commands/inventory/remove_node.go +++ b/admin/commands/inventory/remove_node.go @@ -38,6 +38,7 @@ type RemoveNodeCommand struct { Force bool `help:"Remove node with all dependencies"` } +// RunCmd runs the command for RemoveNodeCommand. func (cmd *RemoveNodeCommand) RunCmd() (commands.Result, error) { params := &nodes.RemoveNodeParams{ Body: nodes.RemoveNodeBody{ diff --git a/admin/commands/inventory/remove_service.go b/admin/commands/inventory/remove_service.go index 551a28ca79..e28c953810 100644 --- a/admin/commands/inventory/remove_service.go +++ b/admin/commands/inventory/remove_service.go @@ -38,6 +38,7 @@ type RemoveServiceCommand struct { Force bool `help:"Remove service with all dependencies"` } +// RunCmd executes the RemoveServiceCommand and returns the result. func (cmd *RemoveServiceCommand) RunCmd() (commands.Result, error) { params := &services.RemoveServiceParams{ Body: services.RemoveServiceBody{ diff --git a/admin/commands/list.go b/admin/commands/list.go index 10e145c0e6..6f3609e0a8 100644 --- a/admin/commands/list.go +++ b/admin/commands/list.go @@ -123,6 +123,7 @@ type ListCommand struct { NodeID string `help:"Node ID (default is autodetected)"` } +// RunCmd executes the List command and returns the result. func (cmd *ListCommand) RunCmd() (Result, error) { if cmd.NodeID == "" { status, err := agentlocal.GetStatus(agentlocal.DoNotRequestNetworkInfo) diff --git a/admin/commands/management/add_external.go b/admin/commands/management/add_external.go index 0b9ee64ff4..8a80acc5df 100644 --- a/admin/commands/management/add_external.go +++ b/admin/commands/management/add_external.go @@ -73,6 +73,7 @@ type AddExternalCommand struct { SkipConnectionCheck bool `help:"Skip exporter connection checks"` } +// GetCredentials returns the credentials for AddExternalCommand. func (cmd *AddExternalCommand) GetCredentials() error { creds, err := commands.ReadFromSource(cmd.CredentialsSource) if err != nil { @@ -85,6 +86,7 @@ func (cmd *AddExternalCommand) GetCredentials() error { return nil } +// RunCmd runs the command for AddExternalCommand. func (cmd *AddExternalCommand) RunCmd() (commands.Result, error) { customLabels := commands.ParseCustomLabels(cmd.CustomLabels) diff --git a/admin/commands/management/add_external_serverless.go b/admin/commands/management/add_external_serverless.go index f7a7d08c0e..0b00a397d3 100644 --- a/admin/commands/management/add_external_serverless.go +++ b/admin/commands/management/add_external_serverless.go @@ -88,6 +88,7 @@ or even you can specify --address instead of host and port as individual paramet ` } +// GetCredentials returns the credentials for AddExternalServerlessCommand. func (cmd *AddExternalServerlessCommand) GetCredentials() error { creds, err := commands.ReadFromSource(cmd.CredentialsSource) if err != nil { @@ -100,6 +101,7 @@ func (cmd *AddExternalServerlessCommand) GetCredentials() error { return nil } +// RunCmd runs the command for AddExternalServerlessCommand. func (cmd *AddExternalServerlessCommand) RunCmd() (commands.Result, error) { customLabels := commands.ParseCustomLabels(cmd.CustomLabels) diff --git a/admin/commands/management/add_haproxy.go b/admin/commands/management/add_haproxy.go index b6e7c556a6..d8f0c775d3 100644 --- a/admin/commands/management/add_haproxy.go +++ b/admin/commands/management/add_haproxy.go @@ -63,6 +63,7 @@ type AddHAProxyCommand struct { SkipConnectionCheck bool `help:"Skip connection check"` } +// GetCredentials returns the credentials for AddHAProxyCommand. func (cmd *AddHAProxyCommand) GetCredentials() error { creds, err := commands.ReadFromSource(cmd.CredentialsSource) if err != nil { @@ -75,6 +76,7 @@ func (cmd *AddHAProxyCommand) GetCredentials() error { return nil } +// RunCmd runs the command for AddHAProxyCommand. func (cmd *AddHAProxyCommand) RunCmd() (commands.Result, error) { isSupported, err := helpers.IsHAProxySupported() if !isSupported { diff --git a/admin/commands/management/add_mongodb.go b/admin/commands/management/add_mongodb.go index 1d9fa14b3a..f69908f94a 100644 --- a/admin/commands/management/add_mongodb.go +++ b/admin/commands/management/add_mongodb.go @@ -88,22 +88,27 @@ type AddMongoDBCommand struct { AddLogLevelFatalFlags } +// GetServiceName returns the service name for AddMongoDBCommand. func (cmd *AddMongoDBCommand) GetServiceName() string { return cmd.ServiceName } +// GetAddress returns the address for AddMongoDBCommand. func (cmd *AddMongoDBCommand) GetAddress() string { return cmd.Address } +// GetDefaultAddress returns the default address for AddMongoDBCommand. func (cmd *AddMongoDBCommand) GetDefaultAddress() string { return "127.0.0.1:27017" } +// GetSocket returns the socket for AddMongoDBCommand. func (cmd *AddMongoDBCommand) GetSocket() string { return cmd.Socket } +// GetCredentials returns the credentials for AddMongoDBCommand. func (cmd *AddMongoDBCommand) GetCredentials() error { creds, err := commands.ReadFromSource(cmd.CredentialsSource) if err != nil { @@ -117,6 +122,7 @@ func (cmd *AddMongoDBCommand) GetCredentials() error { return nil } +// RunCmd runs the command for AddMongoDBCommand. func (cmd *AddMongoDBCommand) RunCmd() (commands.Result, error) { customLabels := commands.ParseCustomLabels(cmd.CustomLabels) diff --git a/admin/commands/management/add_mysql.go b/admin/commands/management/add_mysql.go index 79a5820def..af4a5e84d0 100644 --- a/admin/commands/management/add_mysql.go +++ b/admin/commands/management/add_mysql.go @@ -126,22 +126,27 @@ type AddMySQLCommand struct { AddLogLevelNoFatalFlags } +// GetServiceName returns the service name for AddMySQLCommand. func (cmd *AddMySQLCommand) GetServiceName() string { return cmd.ServiceName } +// GetAddress returns the address for AddMySQLCommand. func (cmd *AddMySQLCommand) GetAddress() string { return cmd.Address } +// GetDefaultAddress returns the default address for AddMySQLCommand. func (cmd *AddMySQLCommand) GetDefaultAddress() string { return "127.0.0.1:3306" } +// GetSocket returns the socket for AddMySQLCommand. func (cmd *AddMySQLCommand) GetSocket() string { return cmd.Socket } +// RunCmd runs the command for AddMySQLCommand. func (cmd *AddMySQLCommand) RunCmd() (commands.Result, error) { customLabels := commands.ParseCustomLabels(cmd.CustomLabels) diff --git a/admin/commands/management/add_postgresql.go b/admin/commands/management/add_postgresql.go index e2fc461ec8..8c6fe8e0b8 100644 --- a/admin/commands/management/add_postgresql.go +++ b/admin/commands/management/add_postgresql.go @@ -80,22 +80,27 @@ type AddPostgreSQLCommand struct { AddLogLevelNoFatalFlags } +// GetServiceName returns the service name for AddPostgreSQLCommand. func (cmd *AddPostgreSQLCommand) GetServiceName() string { return cmd.ServiceName } +// GetAddress returns the address for AddPostgreSQLCommand. func (cmd *AddPostgreSQLCommand) GetAddress() string { return cmd.Address } +// GetDefaultAddress returns the default address for AddPostgreSQLCommand. func (cmd *AddPostgreSQLCommand) GetDefaultAddress() string { return "127.0.0.1:5432" } +// GetSocket returns the socket for AddPostgreSQLCommand. func (cmd *AddPostgreSQLCommand) GetSocket() string { return cmd.Socket } +// GetCredentials returns the credentials for AddPostgreSQLCommand. func (cmd *AddPostgreSQLCommand) GetCredentials() error { creds, err := commands.ReadFromSource(cmd.CredentialsSource) if err != nil { @@ -109,6 +114,7 @@ func (cmd *AddPostgreSQLCommand) GetCredentials() error { return nil } +// RunCmd runs the command for AddPostgreSQLCommand. func (cmd *AddPostgreSQLCommand) RunCmd() (commands.Result, error) { customLabels := commands.ParseCustomLabels(cmd.CustomLabels) diff --git a/admin/commands/management/add_proxysql.go b/admin/commands/management/add_proxysql.go index 5f3da14159..3d1a6fe099 100644 --- a/admin/commands/management/add_proxysql.go +++ b/admin/commands/management/add_proxysql.go @@ -70,22 +70,27 @@ type AddProxySQLCommand struct { AddLogLevelFatalFlags } +// GetServiceName returns the service name for AddProxySQLCommand. func (cmd *AddProxySQLCommand) GetServiceName() string { return cmd.ServiceName } +// GetAddress returns the address for AddProxySQLCommand. func (cmd *AddProxySQLCommand) GetAddress() string { return cmd.Address } +// GetDefaultAddress returns the default address for AddProxySQLCommand. func (cmd *AddProxySQLCommand) GetDefaultAddress() string { return "127.0.0.1:6032" } +// GetSocket returns the socket for AddProxySQLCommand. func (cmd *AddProxySQLCommand) GetSocket() string { return cmd.Socket } +// GetCredentials returns the credentials for AddProxySQLCommand. func (cmd *AddProxySQLCommand) GetCredentials() error { creds, err := commands.ReadFromSource(cmd.CredentialsSource) if err != nil { @@ -99,6 +104,7 @@ func (cmd *AddProxySQLCommand) GetCredentials() error { return nil } +// RunCmd runs the command for AddProxySQLCommand. func (cmd *AddProxySQLCommand) RunCmd() (commands.Result, error) { customLabels := commands.ParseCustomLabels(cmd.CustomLabels) diff --git a/admin/commands/management/register.go b/admin/commands/management/register.go index b075eb537b..d6be9dc3b8 100644 --- a/admin/commands/management/register.go +++ b/admin/commands/management/register.go @@ -67,6 +67,7 @@ type RegisterCommand struct { DisableCollectors []string `help:"Comma-separated list of collector names to exclude from exporter"` } +// RunCmd runs the command for RegisterCommand. func (cmd *RegisterCommand) RunCmd() (commands.Result, error) { customLabels := commands.ParseCustomLabels(cmd.CustomLabels) diff --git a/admin/commands/management/remove.go b/admin/commands/management/remove.go index 94b1107e82..769abd91d9 100644 --- a/admin/commands/management/remove.go +++ b/admin/commands/management/remove.go @@ -44,6 +44,7 @@ type RemoveCommand struct { ServiceID string `help:"Service ID"` } +// RunCmd runs the command for RemoveCommand. func (cmd *RemoveCommand) RunCmd() (commands.Result, error) { if cmd.ServiceID == "" && cmd.ServiceName == "" { // Automatic service lookup during removal diff --git a/admin/commands/management/unregister.go b/admin/commands/management/unregister.go index 7632b34433..1bd1292057 100644 --- a/admin/commands/management/unregister.go +++ b/admin/commands/management/unregister.go @@ -45,6 +45,7 @@ type UnregisterCommand struct { NodeName string `help:"Node name (autodetected default: ${hostname})"` } +// RunCmd runs the command for UnregisterCommand. func (cmd *UnregisterCommand) RunCmd() (commands.Result, error) { var nodeName string var nodeID string diff --git a/admin/commands/pmm/server/docker/upgrade.go b/admin/commands/pmm/server/docker/upgrade.go index c8ce3a419b..b7e54ecf63 100644 --- a/admin/commands/pmm/server/docker/upgrade.go +++ b/admin/commands/pmm/server/docker/upgrade.go @@ -74,7 +74,7 @@ func (u *upgradeResult) String() string { } // RunCmdWithContext runs upgrade command. -func (c *UpgradeCommand) RunCmdWithContext(ctx context.Context, globals *flags.GlobalFlags) (commands.Result, error) { //nolint:unparam +func (c *UpgradeCommand) RunCmdWithContext(ctx context.Context, globals *flags.GlobalFlags) (commands.Result, error) { //nolint:unparam,revive logrus.Info("Starting PMM Server upgrade via Docker") d, err := prepareDocker(ctx, c.dockerFn, prepareOpts{install: false}) diff --git a/admin/commands/status.go b/admin/commands/status.go index b46281f068..9395cb1252 100644 --- a/admin/commands/status.go +++ b/admin/commands/status.go @@ -127,7 +127,7 @@ func (cmd *StatusCommand) RunCmd() (Result, error) { return newStatusResult(status), nil } - return nil, errors.Errorf("Failed to get PMM Agent status from local pmm-agent: %s.", err) //nolint:golint + return nil, errors.Errorf("Failed to get PMM Agent status from local pmm-agent: %s.", err) //nolint:golint,revive default: time.Sleep(1 * time.Second) } diff --git a/admin/pkg/docker/docker.go b/admin/pkg/docker/docker.go index 569bdb2fcc..2ba6c6d931 100644 --- a/admin/pkg/docker/docker.go +++ b/admin/pkg/docker/docker.go @@ -36,6 +36,7 @@ import ( "github.com/percona/pmm/admin/pkg/common" ) +// ErrPasswordChangeFailed represents an error indicating that password change failed. var ErrPasswordChangeFailed = errors.New("ErrPasswordChangeFailed") // Base contains methods to interact with Docker. diff --git a/agent/agentlocal/agent_local.go b/agent/agentlocal/agent_local.go index d23f2a8224..f392e2fbf5 100644 --- a/agent/agentlocal/agent_local.go +++ b/agent/agentlocal/agent_local.go @@ -136,7 +136,7 @@ func (s *Server) Run(ctx context.Context, reloadCh chan bool) { } // Status returns current pmm-agent status. -func (s *Server) Status(ctx context.Context, req *agentlocalpb.StatusRequest) (*agentlocalpb.StatusResponse, error) { +func (s *Server) Status(ctx context.Context, req *agentlocalpb.StatusRequest) (*agentlocalpb.StatusResponse, error) { //nolint:revive connected := true md := s.client.GetServerConnectMetadata() if md == nil { @@ -184,7 +184,7 @@ func roundFloat(upTime float32, numAfterDot int) float32 { } // Reload reloads pmm-agent and its configuration. -func (s *Server) Reload(ctx context.Context, req *agentlocalpb.ReloadRequest) (*agentlocalpb.ReloadResponse, error) { +func (s *Server) Reload(ctx context.Context, req *agentlocalpb.ReloadRequest) (*agentlocalpb.ReloadResponse, error) { //nolint:revive // sync errors with setup command if _, err := s.cfg.Reload(s.l); err != nil { @@ -365,7 +365,7 @@ func addData(zipW *zip.Writer, name string, data []byte) error { } // ZipLogs Handle function for generate zip file with logs. -func (s *Server) ZipLogs(w http.ResponseWriter, r *http.Request) { +func (s *Server) ZipLogs(w http.ResponseWriter, r *http.Request) { //nolint:revive zipBuffer := &bytes.Buffer{} zipWriter := zip.NewWriter(zipBuffer) diff --git a/agent/agents/agents_test.go b/agent/agents/agents_test.go index 49a11ecaf3..a222584dc6 100644 --- a/agent/agents/agents_test.go +++ b/agent/agents/agents_test.go @@ -16,6 +16,7 @@ package agents import "testing" -func TestAgents(t *testing.T) { +// TestAgents is a test function for the Agents module. +func TestAgents(t *testing.T) { //nolint:revive // we need at least one test per package to correctly calculate coverage } diff --git a/agent/agents/mongodb/mongodb.go b/agent/agents/mongodb/mongodb.go index f3a0dc8d40..38187c5a83 100644 --- a/agent/agents/mongodb/mongodb.go +++ b/agent/agents/mongodb/mongodb.go @@ -104,18 +104,18 @@ func (m *MongoDB) Write(r *report.Report) error { return nil } -type Profiler interface { +type Profiler interface { //nolint:revive Start() error Stop() error } // Describe implements prometheus.Collector. -func (m *MongoDB) Describe(ch chan<- *prometheus.Desc) { +func (m *MongoDB) Describe(ch chan<- *prometheus.Desc) { //nolint:revive // This method is needed to satisfy interface. } // Collect implement prometheus.Collector. -func (m *MongoDB) Collect(ch chan<- prometheus.Metric) { +func (m *MongoDB) Collect(ch chan<- prometheus.Metric) { //nolint:revive // This method is needed to satisfy interface. } diff --git a/agent/agents/mysql/perfschema/perfschema.go b/agent/agents/mysql/perfschema/perfschema.go index ae4af57dd3..9ef09a50e7 100644 --- a/agent/agents/mysql/perfschema/perfschema.go +++ b/agent/agents/mysql/perfschema/perfschema.go @@ -462,7 +462,7 @@ func (m *PerfSchema) Changes() <-chan agents.Change { } // Describe implements prometheus.Collector. -func (m *PerfSchema) Describe(ch chan<- *prometheus.Desc) { +func (m *PerfSchema) Describe(ch chan<- *prometheus.Desc) { //nolint:revive // This method is needed to satisfy interface. } diff --git a/agent/agents/mysql/slowlog/parser/logger.go b/agent/agents/mysql/slowlog/parser/logger.go index 2dd916f83c..5bad26ed6b 100644 --- a/agent/agents/mysql/slowlog/parser/logger.go +++ b/agent/agents/mysql/slowlog/parser/logger.go @@ -14,6 +14,7 @@ package parser +// Logger defines the interface for a MySQL slow log parser logger. type Logger interface { Warnf(format string, v ...interface{}) Infof(format string, v ...interface{}) diff --git a/agent/agents/mysql/slowlog/parser/parser_bench_test.go b/agent/agents/mysql/slowlog/parser/parser_bench_test.go index 26f466ddc0..947827f18c 100644 --- a/agent/agents/mysql/slowlog/parser/parser_bench_test.go +++ b/agent/agents/mysql/slowlog/parser/parser_bench_test.go @@ -54,7 +54,7 @@ func benchmarkFile(b *testing.B, name string) { b.StartTimer() go p.Run() - for p.Parse() != nil { + for p.Parse() != nil { //nolint:revive } b.StopTimer() diff --git a/agent/agents/mysql/slowlog/slowlog.go b/agent/agents/mysql/slowlog/slowlog.go index 398c117d3f..ab6b69acc1 100644 --- a/agent/agents/mysql/slowlog/slowlog.go +++ b/agent/agents/mysql/slowlog/slowlog.go @@ -715,12 +715,12 @@ func errListsToMap(k, v []uint64) map[uint64]uint64 { } // Describe implements prometheus.Collector. -func (s *SlowLog) Describe(ch chan<- *prometheus.Desc) { +func (s *SlowLog) Describe(ch chan<- *prometheus.Desc) { //nolint:revive // This method is needed to satisfy interface. } // Collect implement prometheus.Collector. -func (s *SlowLog) Collect(ch chan<- prometheus.Metric) { +func (s *SlowLog) Collect(ch chan<- prometheus.Metric) { //nolint:revive // This method is needed to satisfy interface. } diff --git a/agent/agents/mysql/slowlog/slowlog_test.go b/agent/agents/mysql/slowlog/slowlog_test.go index f049ef1a66..dfe0fb7017 100644 --- a/agent/agents/mysql/slowlog/slowlog_test.go +++ b/agent/agents/mysql/slowlog/slowlog_test.go @@ -171,7 +171,7 @@ func TestSlowLog(t *testing.T) { assert.Equal(t, expected, actual) cancel() - for range s.Changes() { + for range s.Changes() { //nolint:revive } }) @@ -222,7 +222,7 @@ func TestSlowLog(t *testing.T) { assert.Equal(t, expected, actual) cancel() - for range s.Changes() { + for range s.Changes() { //nolint:revive } }) @@ -271,7 +271,7 @@ func TestSlowLog(t *testing.T) { assert.Equal(t, expected, actual) cancel() - for range s.Changes() { + for range s.Changes() { //nolint:revive } }) } diff --git a/agent/agents/noop/noop.go b/agent/agents/noop/noop.go index d10817175b..d0c21ceee2 100644 --- a/agent/agents/noop/noop.go +++ b/agent/agents/noop/noop.go @@ -57,12 +57,12 @@ func (n *NoOp) Changes() <-chan agents.Change { } // Describe implements prometheus.Collector. -func (n *NoOp) Describe(ch chan<- *prometheus.Desc) { +func (n *NoOp) Describe(ch chan<- *prometheus.Desc) { //nolint:revive // This method is needed to satisfy interface. } // Collect implement prometheus.Collector. -func (n *NoOp) Collect(ch chan<- prometheus.Metric) { +func (n *NoOp) Collect(ch chan<- prometheus.Metric) { //nolint:revive // This method is needed to satisfy interface. } diff --git a/agent/agents/noop/noop_test.go b/agent/agents/noop/noop_test.go index ccce01930d..11b7662f4a 100644 --- a/agent/agents/noop/noop_test.go +++ b/agent/agents/noop/noop_test.go @@ -16,6 +16,6 @@ package noop import "testing" -func TestNoOp(t *testing.T) { +func TestNoOp(t *testing.T) { //nolint:revive // we need at least one test per package to correctly calculate coverage } diff --git a/agent/agents/postgres/pgstatmonitor/pgstatmonitor.go b/agent/agents/postgres/pgstatmonitor/pgstatmonitor.go index f489af40a8..5b26b531d8 100644 --- a/agent/agents/postgres/pgstatmonitor/pgstatmonitor.go +++ b/agent/agents/postgres/pgstatmonitor/pgstatmonitor.go @@ -43,7 +43,7 @@ import ( const defaultWaitTime = 60 * time.Second // PGStatMonitorQAN QAN services connects to PostgreSQL and extracts stats. -type PGStatMonitorQAN struct { +type PGStatMonitorQAN struct { //nolint:revive q *reform.Querier dbCloser io.Closer agentID string @@ -715,12 +715,12 @@ func (m *PGStatMonitorQAN) Changes() <-chan agents.Change { } // Describe implements prometheus.Collector. -func (m *PGStatMonitorQAN) Describe(ch chan<- *prometheus.Desc) { +func (m *PGStatMonitorQAN) Describe(ch chan<- *prometheus.Desc) { //nolint:revive // This method is needed to satisfy interface. } // Collect implement prometheus.Collector. -func (m *PGStatMonitorQAN) Collect(ch chan<- prometheus.Metric) { +func (m *PGStatMonitorQAN) Collect(ch chan<- prometheus.Metric) { //nolint:revive // This method is needed to satisfy interface. } diff --git a/agent/agents/postgres/pgstatstatements/pgstatstatements.go b/agent/agents/postgres/pgstatstatements/pgstatstatements.go index 2f9a270223..facecab62e 100644 --- a/agent/agents/postgres/pgstatstatements/pgstatstatements.go +++ b/agent/agents/postgres/pgstatstatements/pgstatstatements.go @@ -53,7 +53,7 @@ var pgStatVer18 = semver.MustParse("1.8.0") type statementsMap map[int64]*pgStatStatementsExtended // PGStatStatementsQAN QAN services connects to PostgreSQL and extracts stats. -type PGStatStatementsQAN struct { +type PGStatStatementsQAN struct { //nolint:revive q *reform.Querier dbCloser io.Closer agentID string @@ -409,7 +409,7 @@ func (m *PGStatStatementsQAN) Changes() <-chan agents.Change { } // Describe implements prometheus.Collector. -func (m *PGStatStatementsQAN) Describe(ch chan<- *prometheus.Desc) { +func (m *PGStatStatementsQAN) Describe(ch chan<- *prometheus.Desc) { //nolint:revive // This method is needed to satisfy interface. } diff --git a/agent/agents/supervisor/supervisor.go b/agent/agents/supervisor/supervisor.go index d426980942..e39a833126 100644 --- a/agent/agents/supervisor/supervisor.go +++ b/agent/agents/supervisor/supervisor.go @@ -425,7 +425,7 @@ func filter(existing, ap map[string]agentpb.AgentParams) ([]string, []string, [] return toStart, toRestart, toStop } -//nolint:golint,stylecheck +//nolint:golint,stylecheck,revive const ( type_TEST_SLEEP inventorypb.AgentType = 998 // process type_TEST_NOOP inventorypb.AgentType = 999 // built-in @@ -671,11 +671,11 @@ func (s *Supervisor) processParams(agentID string, agentProcess *agentpb.SetStat templateParams["tmp_dir"] = cfg.Paths.TempDir processParams.Path = cfg.Paths.VMAgent default: - return nil, errors.Errorf("unhandled agent type %[1]s (%[1]d).", agentProcess.Type) + return nil, errors.Errorf("unhandled agent type %[1]s (%[1]d).", agentProcess.Type) //nolint:revive } if processParams.Path == "" { - return nil, errors.Errorf("no path for agent type %[1]s (%[1]d).", agentProcess.Type) + return nil, errors.Errorf("no path for agent type %[1]s (%[1]d).", agentProcess.Type) //nolint:revive } tr := &templates.TemplateRenderer{ diff --git a/agent/client/basic_auth.go b/agent/client/basic_auth.go index 5055250fc9..2984533215 100644 --- a/agent/client/basic_auth.go +++ b/agent/client/basic_auth.go @@ -27,7 +27,7 @@ type basicAuth struct { } // GetRequestMetadata implements credentials.PerRPCCredentials interface. -func (b *basicAuth) GetRequestMetadata(ctx context.Context, uri ...string) (map[string]string, error) { +func (b *basicAuth) GetRequestMetadata(ctx context.Context, uri ...string) (map[string]string, error) { //nolint:revive auth := b.username + ":" + b.password enc := base64.StdEncoding.EncodeToString([]byte(auth)) return map[string]string{ diff --git a/agent/cmd/pmm-agent-entrypoint/main.go b/agent/cmd/pmm-agent-entrypoint/main.go index a8d222673b..bc3f392bc6 100644 --- a/agent/cmd/pmm-agent-entrypoint/main.go +++ b/agent/cmd/pmm-agent-entrypoint/main.go @@ -4,14 +4,14 @@ // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. - +// Package main provides the entry point for the PMM Agent. package main import ( diff --git a/agent/commands/setup.go b/agent/commands/setup.go index 16db5e6fa5..0cd218f944 100644 --- a/agent/commands/setup.go +++ b/agent/commands/setup.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -//nolint:forbidigo +//nolint:forbidigo,revive package commands import ( diff --git a/agent/config/config.go b/agent/config/config.go index 551ce4512a..9ba26d6911 100644 --- a/agent/config/config.go +++ b/agent/config/config.go @@ -169,7 +169,7 @@ type Config struct { //nolint:musttag // ConfigFileDoesNotExistError error is returned from Get method if configuration file is expected, // but does not exist. -type ConfigFileDoesNotExistError string +type ConfigFileDoesNotExistError string //nolint:revive func (e ConfigFileDoesNotExistError) Error() string { return fmt.Sprintf("configuration file %s does not exist", string(e)) diff --git a/agent/config/logger.go b/agent/config/logger.go index a2930f3711..018784fe72 100644 --- a/agent/config/logger.go +++ b/agent/config/logger.go @@ -27,7 +27,7 @@ type gRPCLogger struct { } // V reports whether verbosity level l is at least the requested verbose level. -func (v *gRPCLogger) V(l int) bool { +func (v *gRPCLogger) V(l int) bool { //nolint:revive // we don't need real implementation ATM return true } diff --git a/agent/connectionchecker/connection_checker.go b/agent/connectionchecker/connection_checker.go index a87ce7bd95..b7a9f9c08b 100644 --- a/agent/connectionchecker/connection_checker.go +++ b/agent/connectionchecker/connection_checker.go @@ -96,7 +96,7 @@ func (cc *ConnectionChecker) sqlPing(ctx context.Context, db *sql.DB) error { return err } -func (cc *ConnectionChecker) checkMySQLConnection(ctx context.Context, dsn string, files *agentpb.TextFiles, tlsSkipVerify bool, id uint32) *agentpb.CheckConnectionResponse { //nolint:lll,unparam +func (cc *ConnectionChecker) checkMySQLConnection(ctx context.Context, dsn string, files *agentpb.TextFiles, tlsSkipVerify bool, id uint32) *agentpb.CheckConnectionResponse { //nolint:lll,unparam,revive var res agentpb.CheckConnectionResponse var err error diff --git a/agent/main.go b/agent/main.go index 7bf443c56e..595d337fe7 100644 --- a/agent/main.go +++ b/agent/main.go @@ -4,14 +4,14 @@ // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. - +// Package main. package main import ( diff --git a/agent/runner/actions/mysql_explain_action.go b/agent/runner/actions/mysql_explain_action.go index 2ac3ff4ca5..6eb29cb795 100644 --- a/agent/runner/actions/mysql_explain_action.go +++ b/agent/runner/actions/mysql_explain_action.go @@ -85,7 +85,7 @@ func (a *mysqlExplainAction) Run(ctx context.Context) ([]byte, error) { // You cant run Explain on trimmed queries. if strings.HasSuffix(a.params.Query, "...") { - return nil, errors.New("EXPLAIN failed because the query was too long and trimmed. Set max-query-length to a larger value.") + return nil, errors.New("EXPLAIN failed because the query was too long and trimmed. Set max-query-length to a larger value.") //nolint:revive } // Explain is supported only for DML queries. diff --git a/agent/runner/jobs/mysql_restore_job.go b/agent/runner/jobs/mysql_restore_job.go index 0c8fb7abca..d34e20b802 100644 --- a/agent/runner/jobs/mysql_restore_job.go +++ b/agent/runner/jobs/mysql_restore_job.go @@ -228,7 +228,7 @@ func (j *MySQLRestoreJob) restoreMySQLFromS3(ctx context.Context, targetDirector } wrapError := func(err error) error { - return errors.Wrapf(err, "stderr: %s\n stdout: %s\n", stderr.String(), stdout.String()) + return errors.Wrapf(err, "stderr: %s\n stdout: %s\n", stderr.String(), stdout.String()) //nolint:revive } if err := xbcloudCmd.Start(); err != nil { diff --git a/agent/runner/jobs/pbm_helpers.go b/agent/runner/jobs/pbm_helpers.go index 0ede95084a..4161c5816a 100644 --- a/agent/runner/jobs/pbm_helpers.go +++ b/agent/runner/jobs/pbm_helpers.go @@ -379,7 +379,7 @@ func waitForPBMRestore(ctx context.Context, l logrus.FieldLogger, dbURL *string, maxRetryCount-- l.Warnf("PMM failed to get backup restore status and will retry: %s", err) continue - } else { + } else { //nolint:revive return errors.Wrap(err, "failed to get restore status") } } diff --git a/agent/runner/runner_test.go b/agent/runner/runner_test.go index b5ed9ddb7a..a98f160164 100644 --- a/agent/runner/runner_test.go +++ b/agent/runner/runner_test.go @@ -251,7 +251,7 @@ func (t testJob) Timeout() time.Duration { return t.timeout } -func (t testJob) Run(ctx context.Context, send jobs.Send) error { +func (t testJob) Run(ctx context.Context, send jobs.Send) error { //nolint:revive <-ctx.Done() return nil } diff --git a/agent/utils/backoff/backoff_test.go b/agent/utils/backoff/backoff_test.go index fe10a7e0d4..34e0149288 100644 --- a/agent/utils/backoff/backoff_test.go +++ b/agent/utils/backoff/backoff_test.go @@ -16,6 +16,6 @@ package backoff import "testing" -func TestBackoff(t *testing.T) { +func TestBackoff(t *testing.T) { //nolint:revive // we need at least one test per package to correctly calculate coverage } diff --git a/agent/utils/mongo_fix/mongo_fix.go b/agent/utils/mongo_fix/mongo_fix.go index ea56431b47..118328f5d4 100644 --- a/agent/utils/mongo_fix/mongo_fix.go +++ b/agent/utils/mongo_fix/mongo_fix.go @@ -4,16 +4,19 @@ // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. +// +// Package mongo_fix provides utilities for fixing MongoDB-related issues. +// //nolint:stylecheck -package mongo_fix +package mongo_fix //nolint:revive import ( "net/url" diff --git a/agent/utils/mongo_fix/mongo_fix_test.go b/agent/utils/mongo_fix/mongo_fix_test.go index 146a6135de..6716e48979 100644 --- a/agent/utils/mongo_fix/mongo_fix_test.go +++ b/agent/utils/mongo_fix/mongo_fix_test.go @@ -13,7 +13,7 @@ // limitations under the License. //nolint:stylecheck -package mongo_fix +package mongo_fix //nolint:revive import ( "net/url" diff --git a/agent/utils/version/postgresql.go b/agent/utils/version/postgresql.go index f88f906a13..369260a533 100644 --- a/agent/utils/version/postgresql.go +++ b/agent/utils/version/postgresql.go @@ -24,6 +24,7 @@ var ( postgresDBRegexp = regexp.MustCompile(`PostgreSQL ([\d\.]+)`) ) +// ParsePostgreSQLVersion parses the given PostgreSQL version string. func ParsePostgreSQLVersion(v string) string { m := postgresDBRegexp.FindStringSubmatch(v) if len(m) != 2 { diff --git a/api-tests/helpers.go b/api-tests/helpers.go index 5ef69250b9..e3cd51c598 100644 --- a/api-tests/helpers.go +++ b/api-tests/helpers.go @@ -32,6 +32,7 @@ import ( "github.com/percona/pmm/api/inventorypb/json/client/services" ) +// ErrorResponse represents the response structure for error scenarios. type ErrorResponse interface { Code() int } @@ -80,7 +81,8 @@ func AssertAPIErrorf(t TestingT, actual error, httpStatus int, grpcCode codes.Co assert.Contains(t, errorField.String(), format) } -func ExpectFailure(t *testing.T, link string) *expectedFailureTestingT { +// ExpectFailure sets up expectations for a test case to fail. +func ExpectFailure(t *testing.T, link string) *expectedFailureTestingT { //nolint:revive t.Helper() return &expectedFailureTestingT{ t: t, @@ -128,6 +130,7 @@ func (tt *expectedFailureTestingT) Check() { tt.t.Fatalf("%s expected to fail, but didn't: %s", tt.Name(), tt.link) } +// RemoveNodes removes specified nodes. func RemoveNodes(t TestingT, nodeIDs ...string) { t.Helper() @@ -144,6 +147,7 @@ func RemoveNodes(t TestingT, nodeIDs ...string) { } } +// RemoveServices removes specified services. func RemoveServices(t TestingT, serviceIDs ...string) { t.Helper() @@ -161,6 +165,7 @@ func RemoveServices(t TestingT, serviceIDs ...string) { } } +// RemoveAgents removes specified agents. func RemoveAgents(t TestingT, agentIDs ...string) { t.Helper() @@ -177,6 +182,7 @@ func RemoveAgents(t TestingT, agentIDs ...string) { } } +// AddGenericNode adds a generic node. func AddGenericNode(t TestingT, nodeName string) *nodes.AddGenericNodeOKBodyGeneric { t.Helper() @@ -195,6 +201,7 @@ func AddGenericNode(t TestingT, nodeName string) *nodes.AddGenericNodeOKBodyGene return res.Payload.Generic } +// AddRemoteNode adds a remote node. func AddRemoteNode(t TestingT, nodeName string) *nodes.AddRemoteNodeOKBody { t.Helper() @@ -211,6 +218,7 @@ func AddRemoteNode(t TestingT, nodeName string) *nodes.AddRemoteNodeOKBody { return res.Payload } +// AddNode adds a node. func AddNode(t TestingT, nodeBody *nodes.AddNodeBody) *nodes.AddNodeOKBody { t.Helper() @@ -226,6 +234,7 @@ func AddNode(t TestingT, nodeBody *nodes.AddNodeBody) *nodes.AddNodeOKBody { return res.Payload } +// AddPMMAgent adds a PMM agent. func AddPMMAgent(t TestingT, nodeID string) *agents.AddPMMAgentOKBody { t.Helper() diff --git a/api-tests/management/helpers.go b/api-tests/management/helpers.go index 9a69dd3eff..3f00f54eb7 100644 --- a/api-tests/management/helpers.go +++ b/api-tests/management/helpers.go @@ -34,6 +34,7 @@ import ( // AgentStatusUnknown means agent is not connected and we don't know anything about its status. var AgentStatusUnknown = inventorypb.AgentStatus_name[int32(inventorypb.AgentStatus_UNKNOWN)] +// RegisterGenericNode registers a generic node using the provided parameters. func RegisterGenericNode(t pmmapitests.TestingT, body node.RegisterNodeBody) (string, string) { t.Helper() params := node.RegisterNodeParams{ @@ -119,6 +120,7 @@ func assertNodeCreated(t pmmapitests.TestingT, nodeID string, expectedResult nod assert.Equal(t, expectedResult, *nodeOK.Payload) } +// RemovePMMAgentWithSubAgents removes a PMM Agent along with its sub-agents. func RemovePMMAgentWithSubAgents(t pmmapitests.TestingT, pmmAgentID string) { t.Helper() diff --git a/api/agentpb/agent.go b/api/agentpb/agent.go index 1b59732ace..738c9e6a21 100644 --- a/api/agentpb/agent.go +++ b/api/agentpb/agent.go @@ -56,152 +56,188 @@ type ServerRequestPayload interface { // A list of AgentMessage request payloads. +// AgentMessageRequestPayload returns the payload for the AgentMessageRequest. func (m *Ping) AgentMessageRequestPayload() isAgentMessage_Payload { //nolint:ireturn return &AgentMessage_Ping{Ping: m} } +// AgentMessageRequestPayload returns the payload for the AgentMessageRequest. func (m *StateChangedRequest) AgentMessageRequestPayload() isAgentMessage_Payload { //nolint:ireturn return &AgentMessage_StateChanged{StateChanged: m} } +// AgentMessageRequestPayload returns the payload for the AgentMessageRequest. func (m *QANCollectRequest) AgentMessageRequestPayload() isAgentMessage_Payload { //nolint:ireturn return &AgentMessage_QanCollect{QanCollect: m} } +// AgentMessageRequestPayload returns the payload for the AgentMessageRequest. func (m *ActionResultRequest) AgentMessageRequestPayload() isAgentMessage_Payload { //nolint:ireturn return &AgentMessage_ActionResult{ActionResult: m} } +// AgentMessageRequestPayload returns the payload for the AgentMessageRequest. func (m *JobProgress) AgentMessageRequestPayload() isAgentMessage_Payload { //nolint:ireturn return &AgentMessage_JobProgress{JobProgress: m} } +// AgentMessageRequestPayload returns the payload for the AgentMessageRequest. func (m *JobResult) AgentMessageRequestPayload() isAgentMessage_Payload { //nolint:ireturn return &AgentMessage_JobResult{JobResult: m} } // A list of AgentMessage response payloads. +// AgentMessageResponsePayload returns the payload for the AgentMessageResponse. func (m *Pong) AgentMessageResponsePayload() isAgentMessage_Payload { //nolint:ireturn return &AgentMessage_Pong{Pong: m} } +// AgentMessageResponsePayload returns the payload for the AgentMessageResponse. func (m *SetStateResponse) AgentMessageResponsePayload() isAgentMessage_Payload { //nolint:ireturn return &AgentMessage_SetState{SetState: m} } +// AgentMessageResponsePayload returns the payload for the AgentMessageResponse. func (m *StartActionResponse) AgentMessageResponsePayload() isAgentMessage_Payload { //nolint:ireturn return &AgentMessage_StartAction{StartAction: m} } +// AgentMessageResponsePayload returns the payload for the AgentMessageResponse. func (m *StopActionResponse) AgentMessageResponsePayload() isAgentMessage_Payload { //nolint:ireturn return &AgentMessage_StopAction{StopAction: m} } +// AgentMessageResponsePayload returns the payload for the AgentMessageResponse. func (m *CheckConnectionResponse) AgentMessageResponsePayload() isAgentMessage_Payload { //nolint:ireturn return &AgentMessage_CheckConnection{CheckConnection: m} } +// AgentMessageResponsePayload returns the payload for the AgentMessageResponse. func (m *ServiceInfoResponse) AgentMessageResponsePayload() isAgentMessage_Payload { //nolint:ireturn return &AgentMessage_ServiceInfo{ServiceInfo: m} } +// AgentMessageResponsePayload returns the payload for the AgentMessageResponse. func (m *JobStatusResponse) AgentMessageResponsePayload() isAgentMessage_Payload { //nolint:ireturn return &AgentMessage_JobStatus{JobStatus: m} } +// AgentMessageResponsePayload returns the payload for the AgentMessageResponse. func (m *StartJobResponse) AgentMessageResponsePayload() isAgentMessage_Payload { //nolint:ireturn return &AgentMessage_StartJob{StartJob: m} } +// AgentMessageResponsePayload returns the payload for the AgentMessageResponse. func (m *StopJobResponse) AgentMessageResponsePayload() isAgentMessage_Payload { //nolint:ireturn return &AgentMessage_StopJob{StopJob: m} } +// AgentMessageResponsePayload returns the payload for the AgentMessageResponse. func (m *JobProgress) AgentMessageResponsePayload() isAgentMessage_Payload { //nolint:ireturn return &AgentMessage_JobProgress{JobProgress: m} } +// AgentMessageResponsePayload returns the payload for the AgentMessageResponse. func (m *JobResult) AgentMessageResponsePayload() isAgentMessage_Payload { //nolint:ireturn return &AgentMessage_JobResult{JobResult: m} } +// AgentMessageResponsePayload returns the payload for the AgentMessageResponse. func (m *GetVersionsResponse) AgentMessageResponsePayload() isAgentMessage_Payload { //nolint:ireturn return &AgentMessage_GetVersions{GetVersions: m} } +// AgentMessageResponsePayload returns the payload for the AgentMessageResponse. func (m *PBMSwitchPITRResponse) AgentMessageResponsePayload() isAgentMessage_Payload { //nolint:ireturn return &AgentMessage_PbmSwitchPitr{PbmSwitchPitr: m} } +// AgentMessageResponsePayload returns the payload for the AgentMessageResponse. func (m *AgentLogsResponse) AgentMessageResponsePayload() isAgentMessage_Payload { //nolint:ireturn return &AgentMessage_AgentLogs{AgentLogs: m} } // A list of ServerMessage response payloads. +// ServerMessageResponsePayload returns the payload for the ServerMessageResponse. func (m *Pong) ServerMessageResponsePayload() isServerMessage_Payload { //nolint:ireturn return &ServerMessage_Pong{Pong: m} } +// ServerMessageResponsePayload returns the payload for the ServerMessageResponse. func (m *StateChangedResponse) ServerMessageResponsePayload() isServerMessage_Payload { //nolint:ireturn return &ServerMessage_StateChanged{StateChanged: m} } +// ServerMessageResponsePayload returns the payload for the ServerMessageResponse. func (m *QANCollectResponse) ServerMessageResponsePayload() isServerMessage_Payload { //nolint:ireturn return &ServerMessage_QanCollect{QanCollect: m} } +// ServerMessageResponsePayload returns the payload for the ServerMessageResponse. func (m *ActionResultResponse) ServerMessageResponsePayload() isServerMessage_Payload { //nolint:ireturn return &ServerMessage_ActionResult{ActionResult: m} } // A list of ServerMessage request payloads. +// ServerMessageRequestPayload returns the payload for the ServerMessageRequestPayload. func (m *Ping) ServerMessageRequestPayload() isServerMessage_Payload { //nolint:ireturn return &ServerMessage_Ping{Ping: m} } +// ServerMessageRequestPayload returns the payload for the ServerMessageRequestPayload. func (m *SetStateRequest) ServerMessageRequestPayload() isServerMessage_Payload { //nolint:ireturn return &ServerMessage_SetState{SetState: m} } +// ServerMessageRequestPayload returns the payload for the ServerMessageRequestPayload. func (m *StartActionRequest) ServerMessageRequestPayload() isServerMessage_Payload { //nolint:ireturn return &ServerMessage_StartAction{StartAction: m} } +// ServerMessageRequestPayload returns the payload for the ServerMessageRequestPayload. func (m *StopActionRequest) ServerMessageRequestPayload() isServerMessage_Payload { //nolint:ireturn return &ServerMessage_StopAction{StopAction: m} } +// ServerMessageRequestPayload returns the payload for the ServerMessageRequestPayload. func (m *CheckConnectionRequest) ServerMessageRequestPayload() isServerMessage_Payload { //nolint:ireturn return &ServerMessage_CheckConnection{CheckConnection: m} } +// ServerMessageRequestPayload returns the payload for the ServerMessageRequestPayload. func (m *StartJobRequest) ServerMessageRequestPayload() isServerMessage_Payload { //nolint:ireturn return &ServerMessage_StartJob{StartJob: m} } +// ServerMessageRequestPayload returns the payload for the ServerMessageRequestPayload. func (m *StopJobRequest) ServerMessageRequestPayload() isServerMessage_Payload { //nolint:ireturn return &ServerMessage_StopJob{StopJob: m} } +// ServerMessageRequestPayload returns the payload for the ServerMessageRequestPayload. func (m *JobStatusRequest) ServerMessageRequestPayload() isServerMessage_Payload { //nolint:ireturn return &ServerMessage_JobStatus{JobStatus: m} } +// ServerMessageRequestPayload returns the payload for the ServerMessageRequestPayload. func (m *GetVersionsRequest) ServerMessageRequestPayload() isServerMessage_Payload { //nolint:ireturn return &ServerMessage_GetVersions{GetVersions: m} } +// ServerMessageRequestPayload returns the payload for the ServerMessageRequestPayload. func (m *PBMSwitchPITRRequest) ServerMessageRequestPayload() isServerMessage_Payload { //nolint:ireturn return &ServerMessage_PbmSwitchPitr{PbmSwitchPitr: m} } +// ServerMessageRequestPayload returns the payload for the ServerMessageRequestPayload. func (m *AgentLogsRequest) ServerMessageRequestPayload() isServerMessage_Payload { //nolint:ireturn return &ServerMessage_AgentLogs{AgentLogs: m} } +// ServerMessageRequestPayload returns the payload for the ServerMessageRequestPayload. func (m *ServiceInfoRequest) ServerMessageRequestPayload() isServerMessage_Payload { //nolint:ireturn return &ServerMessage_ServiceInfo{ServiceInfo: m} } diff --git a/api/inventorypb/agents.go b/api/inventorypb/agents.go index 578b3f389c..97277314af 100644 --- a/api/inventorypb/agents.go +++ b/api/inventorypb/agents.go @@ -1,3 +1,4 @@ +// Package inventorypb ... // Copyright (C) 2023 Percona LLC // // This program is free software: you can redistribute it and/or modify @@ -12,7 +13,6 @@ // // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . - package inventorypb //go-sumtype:decl Agent diff --git a/managed/cmd/pmm-managed-init/main.go b/managed/cmd/pmm-managed-init/main.go index 8aa0046e3b..2a3a076ea7 100644 --- a/managed/cmd/pmm-managed-init/main.go +++ b/managed/cmd/pmm-managed-init/main.go @@ -12,7 +12,7 @@ // // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . - +// Package main provides the entry point for the pmm-managed-init application. package main import ( diff --git a/managed/cmd/pmm-managed-starlark/main.go b/managed/cmd/pmm-managed-starlark/main.go index f976d67a7f..b574e8db9c 100644 --- a/managed/cmd/pmm-managed-starlark/main.go +++ b/managed/cmd/pmm-managed-starlark/main.go @@ -12,7 +12,7 @@ // // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . - +// Package main. package main import ( diff --git a/managed/cmd/pmm-managed/main.go b/managed/cmd/pmm-managed/main.go index 1ca3eddd00..6bf24e6ac2 100644 --- a/managed/cmd/pmm-managed/main.go +++ b/managed/cmd/pmm-managed/main.go @@ -12,7 +12,7 @@ // // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . - +// Package main provides the entry point for the update application. package main import ( diff --git a/managed/data/gen.go b/managed/data/gen.go index 13a2804e8d..8e67598fa9 100644 --- a/managed/data/gen.go +++ b/managed/data/gen.go @@ -23,5 +23,7 @@ import "embed" //go:embed iatemplates/* var IATemplates embed.FS +// OLMCRDs ... +// //go:embed crds/* var OLMCRDs embed.FS diff --git a/managed/models/agent_model.go b/managed/models/agent_model.go index 4a9502853e..2068c937b8 100644 --- a/managed/models/agent_model.go +++ b/managed/models/agent_model.go @@ -301,6 +301,7 @@ func (s *Agent) DBConfig(service *Service) *DBConfig { } } +// DSNParams represents the parameters for configuring a Data Source Name (DSN). type DSNParams struct { DialTimeout time.Duration Database string diff --git a/managed/models/agentversion.go b/managed/models/agentversion.go index 272b19e4de..701dd113b5 100644 --- a/managed/models/agentversion.go +++ b/managed/models/agentversion.go @@ -23,6 +23,7 @@ import ( "gopkg.in/reform.v1" ) +// PMMAgentMinVersionForPostgreSQLSSLSni is the minimum required version of PMM Agent. var PMMAgentMinVersionForPostgreSQLSSLSni = version.Must(version.NewVersion("2.41.0-0")) // AgentNotSupportedError is used when the target PMM agent doesn't support the requested functionality. @@ -71,6 +72,7 @@ func IsAgentSupported(agentModel *Agent, functionalityPrefix string, pmmMinVersi return nil } +// IsPostgreSQLSSLSniSupported checks if PostgreSQL SSL SNI is supported by the PMM Agent. func IsPostgreSQLSSLSniSupported(q *reform.Querier, pmmAgentID string) (bool, error) { err := PMMAgentSupported(q, pmmAgentID, "postgresql SSL sni check", PMMAgentMinVersionForPostgreSQLSSLSni) switch { diff --git a/managed/models/artifact_helpers.go b/managed/models/artifact_helpers.go index ed8a95a0cd..70f03c06fd 100644 --- a/managed/models/artifact_helpers.go +++ b/managed/models/artifact_helpers.go @@ -148,7 +148,7 @@ func FindArtifactByName(q *reform.Querier, name string) (*Artifact, error) { err := q.FindOneTo(artifact, "name", name) if err != nil { if errors.Is(err, reform.ErrNoRows) { - return nil, errors.Wrapf(ErrNotFound, "backup artifact with name %q not found.", name) + return nil, errors.Wrapf(ErrNotFound, "backup artifact with name %q not found.", name) //nolint:revive } return nil, errors.WithStack(err) } diff --git a/managed/models/artifact_model.go b/managed/models/artifact_model.go index 2ec01b4c6b..88b4f62e0e 100644 --- a/managed/models/artifact_model.go +++ b/managed/models/artifact_model.go @@ -142,6 +142,7 @@ type Metadata struct { BackupToolData *BackupToolData `json:"backup_tool_data"` } +// MetadataList is a list of metadata associated with artifacts. type MetadataList []Metadata // Value implements database/sql/driver.Valuer interface. Should be defined on the value. diff --git a/managed/models/database.go b/managed/models/database.go index 4880f07f64..84cc025285 100644 --- a/managed/models/database.go +++ b/managed/models/database.go @@ -12,7 +12,11 @@ // // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . +// Package models provides the data models for the managed package. +// +// Package models provides functionality for handling database models and related tasks. +// //nolint:lll package models @@ -1246,7 +1250,7 @@ func setupFixture1(q *reform.Querier, params SetupDBParams) error { return nil } -func setupFixture2(q *reform.Querier, username, password string) error { +func setupFixture2(q *reform.Querier, username, password string) error { //nolint:revive // TODO add clickhouse_exporter return nil diff --git a/managed/models/dump.go b/managed/models/dump.go index d7adcee5c7..97b4e02314 100644 --- a/managed/models/dump.go +++ b/managed/models/dump.go @@ -22,14 +22,15 @@ import ( "gopkg.in/reform.v1" ) +// DumpStatus represents the status of a dump process. +// //go:generate ../../bin/reform - type DumpStatus string const ( - DumpStatusInProgress = DumpStatus("in_progress") - DumpStatusSuccess = DumpStatus("success") - DumpStatusError = DumpStatus("error") + DumpStatusInProgress = DumpStatus("in_progress") //nolint:revive + DumpStatusSuccess = DumpStatus("success") //nolint:revive + DumpStatusError = DumpStatus("error") //nolint:revive ) // Validate validates Dumps status. diff --git a/managed/models/dump_helpers.go b/managed/models/dump_helpers.go index b5c0626ef1..dc4beb1072 100644 --- a/managed/models/dump_helpers.go +++ b/managed/models/dump_helpers.go @@ -50,6 +50,7 @@ type DumpFilters struct { Status DumpStatus } +// CreateDumpParams represents the parameters for creating a dump. type CreateDumpParams struct { ServiceNames []string StartTime *time.Time @@ -58,6 +59,7 @@ type CreateDumpParams struct { IgnoreLoad bool } +// Validate checks the validity of CreateDumpParams. func (p *CreateDumpParams) Validate() error { if p.StartTime != nil && p.EndTime != nil && p.StartTime.After(*p.EndTime) { return errors.Errorf("dump start time can't be greater than end time") @@ -66,6 +68,7 @@ func (p *CreateDumpParams) Validate() error { return nil } +// CreateDump creates a dump using the specified parameters. func CreateDump(q *reform.Querier, params CreateDumpParams) (*Dump, error) { if err := params.Validate(); err != nil { return nil, errors.Wrap(err, "invalid dump creation params") @@ -165,6 +168,7 @@ func FindDumpByID(q *reform.Querier, id string) (*Dump, error) { return dump, nil } +// UpdateDumpStatus updates the status of a dump with the given ID. func UpdateDumpStatus(q *reform.Querier, id string, status DumpStatus) error { dump, err := FindDumpByID(q, id) if err != nil { diff --git a/managed/models/models.go b/managed/models/models.go index 2ee68f37f4..b715dd8526 100644 --- a/managed/models/models.go +++ b/managed/models/models.go @@ -231,9 +231,12 @@ const ( String = ParamType("string") ) +// ParamUnit represents the unit of a parameter. type ParamUnit string const ( + // Percent represents a parameter unit for percentage values. Percent = ParamUnit("%") + // Seconds represents a parameter unit for time values in seconds. Seconds = ParamUnit("s") ) diff --git a/managed/models/percona_sso_model_helpers.go b/managed/models/percona_sso_model_helpers.go index 4f9b6a112e..67c716983a 100644 --- a/managed/models/percona_sso_model_helpers.go +++ b/managed/models/percona_sso_model_helpers.go @@ -31,7 +31,8 @@ import ( ) var ( - perconaSSOMtx sync.Mutex + perconaSSOMtx sync.Mutex + // ErrNotConnectedToPortal is an error indicating that PMM Server is not connected to the Portal. ErrNotConnectedToPortal = errors.New("PMM Server is not connected to Portal") ) diff --git a/managed/models/scheduled_tasks_helpers.go b/managed/models/scheduled_tasks_helpers.go index be58f5eaf5..067c9aa0e2 100644 --- a/managed/models/scheduled_tasks_helpers.go +++ b/managed/models/scheduled_tasks_helpers.go @@ -383,6 +383,7 @@ func (s *ScheduledTask) ServiceID() (string, error) { return data.ServiceID, nil } +// CommonBackupData returns the common backup data for the scheduled task. func (s *ScheduledTask) CommonBackupData() (*CommonBackupTaskData, error) { if s.Data != nil { switch s.Type { diff --git a/managed/models/service_model.go b/managed/models/service_model.go index f05446e945..126720ccd8 100644 --- a/managed/models/service_model.go +++ b/managed/models/service_model.go @@ -25,14 +25,16 @@ import ( // ServiceType represents Service type as stored in databases: // pmm-managed's PostgreSQL, qan-api's ClickHouse, and VictoriaMetrics. -type ServiceType string - -type ServiceStandardLabelsParams struct { - Cluster *string - Environment *string - ReplicationSet *string - ExternalGroup *string -} +type ( + ServiceType string + // ServiceStandardLabelsParams represents the parameters for standard labels in a service. + ServiceStandardLabelsParams struct { + Cluster *string + Environment *string + ReplicationSet *string + ExternalGroup *string + } +) // Service types (in the same order as in services.proto). const ( diff --git a/managed/models/template_helpers.go b/managed/models/template_helpers.go index 7c0ca1ee57..071db6e7e9 100644 --- a/managed/models/template_helpers.go +++ b/managed/models/template_helpers.go @@ -174,10 +174,11 @@ func RemoveTemplate(q *reform.Querier, name string) error { return nil } +// ConvertTemplate converts an alert template to the internal representation. func ConvertTemplate(template *alert.Template, source Source) (*Template, error) { p, err := ConvertParamsDefinitions(template.Params) if err != nil { - return nil, errors.Errorf("invalid rule template parameters: %v.", err) + return nil, errors.Errorf("invalid rule template parameters: %v.", err) //nolint:revive } yaml, err := alert.ToYAML([]alert.Template{*template}) diff --git a/managed/models/victoriametrics_params.go b/managed/models/victoriametrics_params.go index 14a86a5d41..2acc22cac2 100644 --- a/managed/models/victoriametrics_params.go +++ b/managed/models/victoriametrics_params.go @@ -29,7 +29,8 @@ const ( // BasePrometheusConfigPath - basic path with prometheus config, // that user can mount to container. BasePrometheusConfigPath = "/srv/prometheus/prometheus.base.yml" - VMBaseURL = "http://127.0.0.1:9090/prometheus/" + // VMBaseURL is the base URL for VictoriaMetrics. + VMBaseURL = "http://127.0.0.1:9090/prometheus/" ) // VictoriaMetricsParams - defines flags and settings for victoriametrics. @@ -100,14 +101,17 @@ func (vmp *VictoriaMetricsParams) loadVMAlertParams() error { return nil } +// ExternalVM returns true if VictoriaMetrics is configured to run externally. func (vmp *VictoriaMetricsParams) ExternalVM() bool { return vmp.url.Hostname() != "127.0.0.1" } +// URL returns the base URL for VictoriaMetrics. func (vmp *VictoriaMetricsParams) URL() string { return vmp.url.String() } +// URLFor returns the URL for a specific path in VictoriaMetrics. func (vmp *VictoriaMetricsParams) URLFor(path string) (*url.URL, error) { if path == "" { return vmp.url, nil diff --git a/managed/services/agents/agents.go b/managed/services/agents/agents.go index 7d71672f7d..281dcbef25 100644 --- a/managed/services/agents/agents.go +++ b/managed/services/agents/agents.go @@ -143,7 +143,7 @@ func ensureAuthParams(exporter *models.Agent, params *agentpb.SetStateRequest_Ag } // getExporterListenAddress returns the appropriate listen address to use for a given exporter. -func getExporterListenAddress(node *models.Node, exporter *models.Agent) string { +func getExporterListenAddress(_ *models.Node, exporter *models.Agent) string { switch { case exporter.ExposeExporter: return "0.0.0.0" diff --git a/managed/services/agents/channel/channel.go b/managed/services/agents/channel/channel.go index 5e36142352..448010495e 100644 --- a/managed/services/agents/channel/channel.go +++ b/managed/services/agents/channel/channel.go @@ -67,7 +67,7 @@ type Response struct { Error error } -type Stream interface { +type Stream interface { //nolint:revive Send(*agentpb.ServerMessage) error Recv() (*agentpb.AgentMessage, error) } diff --git a/managed/services/agents/jobs.go b/managed/services/agents/jobs.go index 35eaba8b9d..ba9477f099 100644 --- a/managed/services/agents/jobs.go +++ b/managed/services/agents/jobs.go @@ -67,6 +67,7 @@ func NewJobsService(db *reform.DB, registry *Registry, retention retentionServic } } +// RestartJob restarts a job with the given jobID. func (s *JobsService) RestartJob(ctx context.Context, jobID string) error { var job *models.Job var artifact *models.Artifact diff --git a/managed/services/agents/registry.go b/managed/services/agents/registry.go index 6db039248f..a9cad30d51 100644 --- a/managed/services/agents/registry.go +++ b/managed/services/agents/registry.go @@ -417,6 +417,7 @@ func (r *Registry) Collect(ch chan<- prom.Metric) { r.mClockDrift.Collect(ch) } +// KickAll sends a signal to all registered agents in the registry to perform a kick action. func (r *Registry) KickAll(ctx context.Context) { for _, agentInfo := range r.agents { r.Kick(ctx, agentInfo.id) diff --git a/managed/services/agents/versioner.go b/managed/services/agents/versioner.go index e278fb87d0..1bc5563603 100644 --- a/managed/services/agents/versioner.go +++ b/managed/services/agents/versioner.go @@ -56,8 +56,12 @@ type Software interface { // Mysqld represents mysqld software. type Mysqld struct{} -func (*Mysqld) isSoftware() {} +func (*Mysqld) isSoftware() {} + +// Name returns the software name for Mysqld.{}. func (*Mysqld) Name() models.SoftwareName { return models.MysqldSoftwareName } + +// GetVersionRequest returns the GetVersionsRequest_Software for Mysqld. func (*Mysqld) GetVersionRequest() *agentpb.GetVersionsRequest_Software { return &agentpb.GetVersionsRequest_Software{ Software: &agentpb.GetVersionsRequest_Software_Mysqld{}, @@ -67,8 +71,12 @@ func (*Mysqld) GetVersionRequest() *agentpb.GetVersionsRequest_Software { // Xtrabackup represents xtrabackup software. type Xtrabackup struct{} -func (*Xtrabackup) isSoftware() {} +func (*Xtrabackup) isSoftware() {} + +// Name returns the software name for Xtrabackup. func (*Xtrabackup) Name() models.SoftwareName { return models.XtrabackupSoftwareName } + +// GetVersionRequest returns the GetVersionsRequest_Software for Xtrabackup. func (*Xtrabackup) GetVersionRequest() *agentpb.GetVersionsRequest_Software { return &agentpb.GetVersionsRequest_Software{ Software: &agentpb.GetVersionsRequest_Software_Xtrabackup{}, @@ -78,8 +86,12 @@ func (*Xtrabackup) GetVersionRequest() *agentpb.GetVersionsRequest_Software { // Xbcloud represents xbcloud software. type Xbcloud struct{} -func (*Xbcloud) isSoftware() {} +func (*Xbcloud) isSoftware() {} + +// Name returns the software name for Qpress. func (*Xbcloud) Name() models.SoftwareName { return models.XbcloudSoftwareName } + +// GetVersionRequest returns the GetVersionsRequest_Software for Qpress. func (*Xbcloud) GetVersionRequest() *agentpb.GetVersionsRequest_Software { return &agentpb.GetVersionsRequest_Software{ Software: &agentpb.GetVersionsRequest_Software_Xbcloud{}, @@ -89,8 +101,12 @@ func (*Xbcloud) GetVersionRequest() *agentpb.GetVersionsRequest_Software { // Qpress represents qpress software. type Qpress struct{} -func (*Qpress) isSoftware() {} +func (*Qpress) isSoftware() {} + +// Name returns the software name for Qpress. func (*Qpress) Name() models.SoftwareName { return models.QpressSoftwareName } + +// GetVersionRequest returns the GetVersionsRequest for Qpress. func (*Qpress) GetVersionRequest() *agentpb.GetVersionsRequest_Software { return &agentpb.GetVersionsRequest_Software{ Software: &agentpb.GetVersionsRequest_Software_Qpress{}, @@ -100,8 +116,12 @@ func (*Qpress) GetVersionRequest() *agentpb.GetVersionsRequest_Software { // MongoDB represents mongod software. type MongoDB struct{} -func (*MongoDB) isSoftware() {} +func (*MongoDB) isSoftware() {} + +// Name returns the software name for MongoDB. func (*MongoDB) Name() models.SoftwareName { return models.MongoDBSoftwareName } + +// GetVersionRequest returns the GetVersionsRequest_Software for Qpress. func (*MongoDB) GetVersionRequest() *agentpb.GetVersionsRequest_Software { return &agentpb.GetVersionsRequest_Software{ Software: &agentpb.GetVersionsRequest_Software_Mongod{}, @@ -111,8 +131,12 @@ func (*MongoDB) GetVersionRequest() *agentpb.GetVersionsRequest_Software { // PBM represents pbm software. type PBM struct{} -func (*PBM) isSoftware() {} +func (*PBM) isSoftware() {} + +// Name returns the software name for PBM. func (*PBM) Name() models.SoftwareName { return models.PBMSoftwareName } + +// GetVersionRequest returns the GetVersionsRequest for PBM. func (*PBM) GetVersionRequest() *agentpb.GetVersionsRequest_Software { return &agentpb.GetVersionsRequest_Software{ Software: &agentpb.GetVersionsRequest_Software_Pbm{}, diff --git a/managed/services/backup/deps.go b/managed/services/backup/deps.go index 3ec7340976..b0197c62a5 100644 --- a/managed/services/backup/deps.go +++ b/managed/services/backup/deps.go @@ -116,6 +116,7 @@ type pbmPITRService interface { GetPITRFiles(ctx context.Context, locationClient Storage, location *models.BackupLocation, artifact *models.Artifact, until *time.Time) ([]*oplogChunk, error) } +// Storage represents the interface for interacting with storage. type Storage interface { // FileStat returns file info. It returns error if file is empty or not exists. FileStat(ctx context.Context, endpoint, accessKey, secretKey, bucketName, name string) (minio.FileInfo, error) diff --git a/managed/services/backup/metrics.go b/managed/services/backup/metrics.go index 1aa661deca..7f717262ba 100644 --- a/managed/services/backup/metrics.go +++ b/managed/services/backup/metrics.go @@ -34,6 +34,7 @@ const ( prometheusSubsystem = "backups" ) +// MetricsCollector is responsible for collecting metrics related to backup. type MetricsCollector struct { db *reform.DB l *logrus.Entry @@ -41,6 +42,7 @@ type MetricsCollector struct { mArtifactsDesc *prom.Desc } +// NewMetricsCollector creates a new instance of MetricsCollector. func NewMetricsCollector(db *reform.DB) *MetricsCollector { return &MetricsCollector{ db: db, @@ -56,10 +58,12 @@ func NewMetricsCollector(db *reform.DB) *MetricsCollector { } } +// Describe sends the metrics descriptions to the provided channel. func (c *MetricsCollector) Describe(ch chan<- *prom.Desc) { ch <- c.mArtifactsDesc } +// Collect sends the collected metrics to the provided channel. func (c *MetricsCollector) Collect(ch chan<- prom.Metric) { ctx, cancelCtx := context.WithTimeout(context.Background(), requestTimeout) defer cancelCtx() diff --git a/managed/services/backup/pitr_timerange_service.go b/managed/services/backup/pitr_timerange_service.go index 84050aa139..8dc956da40 100644 --- a/managed/services/backup/pitr_timerange_service.go +++ b/managed/services/backup/pitr_timerange_service.go @@ -181,7 +181,7 @@ func (s *PBMPITRService) ListPITRTimeranges(ctx context.Context, storage Storage // trimTimelines adds one second to the Start value of every timeline record. Required to fit PBM values. func trimTimelines(timelines []Timeline) { for i := range timelines { - timelines[i].Start += 1 + timelines[i].Start += 1 //nolint:revive } } diff --git a/managed/services/checks/checks.go b/managed/services/checks/checks.go index e8499ac61b..e591cd119a 100644 --- a/managed/services/checks/checks.go +++ b/managed/services/checks/checks.go @@ -370,6 +370,7 @@ func (s *Service) GetAdvisors() ([]check.Advisor, error) { return res, nil } +// GetChecks retrieves a map of checks from the service. func (s *Service) GetChecks() (map[string]check.Check, error) { cs, err := models.FindCheckSettings(s.db.Querier) if err != nil { @@ -1438,7 +1439,7 @@ func (s *Service) loadLocalChecks(file string) ([]check.Check, error) { for _, c := range checks { if c.Advisor != "dev" { - return nil, errors.Errorf("Local checks are supposed to be linked to the 'dev' advisor.") + return nil, errors.Errorf("Local checks are supposed to be linked to the 'dev' advisor.") //nolint:revive } } diff --git a/managed/services/dbaas/dbaas_client.go b/managed/services/dbaas/dbaas_client.go index 2768eea2b1..b4bb9e9537 100644 --- a/managed/services/dbaas/dbaas_client.go +++ b/managed/services/dbaas/dbaas_client.go @@ -153,6 +153,7 @@ func (c *Client) StopMonitoring(ctx context.Context, in *controllerv1beta1.StopM return c.kubernetesClient.StopMonitoring(ctx, in, opts...) } +// GetKubeConfig returns Kubernetes config. func (c *Client) GetKubeConfig(ctx context.Context, _ *controllerv1beta1.GetKubeconfigRequest, _ ...grpc.CallOption) (*controllerv1beta1.GetKubeconfigResponse, error) { c.connM.RLock() defer c.connM.RUnlock() diff --git a/managed/services/dbaas/kubernetes/client/client.go b/managed/services/dbaas/kubernetes/client/client.go index 5515dd5814..5c78936045 100644 --- a/managed/services/dbaas/kubernetes/client/client.go +++ b/managed/services/dbaas/kubernetes/client/client.go @@ -89,11 +89,11 @@ const ( // //nolint:stylecheck const ( - LEVEL_0 = iota - LEVEL_1 - LEVEL_2 - LEVEL_3 - LEVEL_4 + LEVEL_0 = iota //nolint:revive + LEVEL_1 //nolint:revive + LEVEL_2 //nolint:revive + LEVEL_3 //nolint:revive + LEVEL_4 //nolint:revive ) // Client is the internal client for Kubernetes. @@ -101,7 +101,7 @@ type Client struct { clientset kubernetes.Interface apiextClientset apiextv1clientset.Interface dynamicClientset dynamic.Interface - dbClusterClient *database.DatabaseClusterClient + dbClusterClient *database.ClusterClient rcLock *sync.Mutex restConfig *rest.Config namespace string @@ -377,6 +377,7 @@ func deleteObject(helper *resource.Helper, namespace, name string) error { return nil } +// ApplyObject update new values on object. func (c *Client) ApplyObject(obj runtime.Object) error { groupResources, err := restmapper.GetAPIGroupResources(c.clientset.Discovery()) if err != nil { @@ -504,6 +505,7 @@ func (c *Client) GetLogs(ctx context.Context, pod, container string) (string, er return buf.String(), nil } +// GetEvents return events. func (c *Client) GetEvents(ctx context.Context, name string) (string, error) { pod, err := c.clientset.CoreV1().Pods(c.namespace).Get(ctx, name, metav1.GetOptions{}) if err != nil { @@ -572,6 +574,7 @@ func tabbedString(f func(io.Writer) error) (string, error) { return str, nil } +// DescribeEvents show more detailed info. func DescribeEvents(el *corev1.EventList, w PrefixWriter) { if len(el.Items) == 0 { w.Writef(LEVEL_0, "Events:\t\n") diff --git a/managed/services/dbaas/kubernetes/client/database/database.go b/managed/services/dbaas/kubernetes/client/database/database.go index 3b659927ab..0718e56d67 100644 --- a/managed/services/dbaas/kubernetes/client/database/database.go +++ b/managed/services/dbaas/kubernetes/client/database/database.go @@ -28,21 +28,18 @@ import ( ) const ( - DBClusterKind = "DatabaseCluster" - apiKind = "databaseclusters" + apiKind = "databaseclusters" ) -type DatabaseClusterClientInterface interface { - DBClusters(namespace string) DatabaseClusterInterface -} - -type DatabaseClusterClient struct { +// ClusterClient contains client for database cluster. +type ClusterClient struct { restClient rest.Interface } var addToScheme sync.Once -func NewForConfig(c *rest.Config) (*DatabaseClusterClient, error) { +// NewForConfig create database cluster client from given config. +func NewForConfig(c *rest.Config) (*ClusterClient, error) { config := *c config.ContentConfig.GroupVersion = &dbaasv1.GroupVersion config.APIPath = "/apis" @@ -59,17 +56,18 @@ func NewForConfig(c *rest.Config) (*DatabaseClusterClient, error) { return nil, err } - return &DatabaseClusterClient{restClient: client}, nil + return &ClusterClient{restClient: client}, nil } -func (c *DatabaseClusterClient) DBClusters(namespace string) DatabaseClusterInterface { //nolint:ireturn +// DBClusters returns database cluster client. +func (c *ClusterClient) DBClusters(namespace string) databaseClusterInterface { //nolint:ireturn return &dbClusterClient{ restClient: c.restClient, namespace: namespace, } } -type DatabaseClusterInterface interface { +type databaseClusterInterface interface { List(ctx context.Context, opts metav1.ListOptions) (*dbaasv1.DatabaseClusterList, error) Get(ctx context.Context, name string, options metav1.GetOptions) (*dbaasv1.DatabaseCluster, error) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) diff --git a/managed/services/dbaas/kubernetes/client/kubeclient_interface.go b/managed/services/dbaas/kubernetes/client/kubeclient_interface.go index 4a258117c6..8a71556ecd 100644 --- a/managed/services/dbaas/kubernetes/client/kubeclient_interface.go +++ b/managed/services/dbaas/kubernetes/client/kubeclient_interface.go @@ -43,6 +43,7 @@ type KubeClientConnector interface { ListSecrets(ctx context.Context) (*corev1.SecretList, error) // DeleteObject deletes object from the k8s cluster. DeleteObject(obj runtime.Object) error + // ApplyObject update new values on object. ApplyObject(obj runtime.Object) error // GetPersistentVolumes returns Persistent Volumes available in the cluster. GetPersistentVolumes(ctx context.Context) (*corev1.PersistentVolumeList, error) @@ -52,6 +53,7 @@ type KubeClientConnector interface { GetNodes(ctx context.Context) (*corev1.NodeList, error) // GetLogs returns logs for pod. GetLogs(ctx context.Context, pod, container string) (string, error) + // GetEvents return events. GetEvents(ctx context.Context, name string) (string, error) // ApplyFile accepts manifest file contents, parses into []runtime.Object // and applies them against the cluster. diff --git a/managed/services/dbaas/kubernetes/client/load_config.go b/managed/services/dbaas/kubernetes/client/load_config.go index c8fd78cc7d..bdb39cb481 100644 --- a/managed/services/dbaas/kubernetes/client/load_config.go +++ b/managed/services/dbaas/kubernetes/client/load_config.go @@ -26,7 +26,7 @@ type configGetter struct { } // NewConfigGetter creates a new configGetter struct. -func NewConfigGetter(kubeconfig string) *configGetter { +func NewConfigGetter(kubeconfig string) *configGetter { //nolint:revive return &configGetter{kubeconfig: kubeconfig} } diff --git a/managed/services/dbaas/kubernetes/kubernetes.go b/managed/services/dbaas/kubernetes/kubernetes.go index 0a0253a002..10da60596c 100644 --- a/managed/services/dbaas/kubernetes/kubernetes.go +++ b/managed/services/dbaas/kubernetes/kubernetes.go @@ -51,13 +51,14 @@ import ( "github.com/percona/pmm/managed/services/dbaas/utils/convertors" ) +// ClusterType is used by Kubernetes. type ClusterType string const ( - ClusterTypeUnknown ClusterType = "unknown" - ClusterTypeMinikube ClusterType = "minikube" - ClusterTypeEKS ClusterType = "eks" - ClusterTypeGeneric ClusterType = "generic" + ClusterTypeUnknown ClusterType = "unknown" //nolint:revive + ClusterTypeMinikube ClusterType = "minikube" //nolint:revive + ClusterTypeEKS ClusterType = "eks" //nolint:revive + ClusterTypeGeneric ClusterType = "generic" //nolint:revive pxcDeploymentName = "percona-xtradb-cluster-operator" psmdbDeploymentName = "percona-server-mongodb-operator" dbaasDeploymentName = "dbaas-operator-controller-manager" @@ -381,6 +382,7 @@ func (k *Kubernetes) CreatePMMSecret(secretName string, secrets map[string][]byt return k.client.ApplyObject(secret) } +// CreateRestore will apply restore. func (k *Kubernetes) CreateRestore(restore *dbaasv1.DatabaseClusterRestore) error { k.lock.Lock() defer k.lock.Unlock() diff --git a/managed/services/dbaas/kubernetes/types.go b/managed/services/dbaas/kubernetes/types.go index d6876f8d89..9540a0803a 100644 --- a/managed/services/dbaas/kubernetes/types.go +++ b/managed/services/dbaas/kubernetes/types.go @@ -589,6 +589,7 @@ func UpdatePatchForPXC(dbCluster *dbaasv1.DatabaseCluster, updateRequest *dbaasv return nil } +// SecretForBackup returns a AWS secrets. func SecretForBackup(backupLocation *models.BackupLocation) map[string][]byte { return map[string][]byte{ "AWS_ACCESS_KEY_ID": []byte(backupLocation.S3Config.AccessKey), diff --git a/managed/services/dump/dump.go b/managed/services/dump/dump.go index 4f028eb452..c35126c0fc 100644 --- a/managed/services/dump/dump.go +++ b/managed/services/dump/dump.go @@ -37,6 +37,7 @@ import ( "github.com/percona/pmm/managed/models" ) +// ErrDumpAlreadyRunning is an exported error indicating that pmm-dump is already running. var ErrDumpAlreadyRunning = status.Error(codes.FailedPrecondition, "pmm-dump already running.") const ( @@ -44,6 +45,7 @@ const ( dumpsDir = "/srv/dump" ) +// Service represents the dump service. type Service struct { l *logrus.Entry @@ -55,6 +57,7 @@ type Service struct { cancel context.CancelFunc } +// New creates a new instance of the dump service.. func New(db *reform.DB) *Service { return &Service{ l: logrus.WithField("component", "management/backup/backup"), @@ -62,6 +65,7 @@ func New(db *reform.DB) *Service { } } +// Params represents the parameters for configuring the dump service. type Params struct { APIKey string Cookie string @@ -74,6 +78,7 @@ type Params struct { IgnoreLoad bool } +// StartDump initiates the process of creating and managing dumps in the dump service. func (s *Service) StartDump(params *Params) (string, error) { // Check if some pmm-dump already running. if !s.running.CompareAndSwap(false, true) { @@ -175,6 +180,7 @@ func (s *Service) StartDump(params *Params) (string, error) { return dump.ID, nil } +// DeleteDump removes a specific dump associated with the dump service. func (s *Service) DeleteDump(dumpID string) error { dump, err := models.FindDumpByID(s.db.Querier, dumpID) if err != nil { @@ -199,6 +205,7 @@ func (s *Service) DeleteDump(dumpID string) error { return nil } +// GetFilePathsForDumps retrieves the file paths associated with the dumps managed by the dump service. func (s *Service) GetFilePathsForDumps(dumpIDs []string) (map[string]string, error) { dumps, err := models.FindDumpsByIDs(s.db.Querier, dumpIDs) if err != nil { @@ -272,6 +279,7 @@ func (s *Service) saveLogChunk(dumpID string, chunkN uint32, text string, last b return nil } +// StopDump stops the ongoing dump process in the dump service. func (s *Service) StopDump() { s.rw.RLock() defer s.rw.RUnlock() diff --git a/managed/services/grafana/client.go b/managed/services/grafana/client.go index 505776cd62..55b8949793 100644 --- a/managed/services/grafana/client.go +++ b/managed/services/grafana/client.go @@ -14,8 +14,6 @@ // along with this program. If not, see . // Package grafana provides facilities for working with Grafana. -// - package grafana import ( diff --git a/managed/services/ha/highavailability.go b/managed/services/ha/highavailability.go index cec144b4d8..20bfcb33eb 100644 --- a/managed/services/ha/highavailability.go +++ b/managed/services/ha/highavailability.go @@ -32,6 +32,7 @@ import ( "github.com/percona/pmm/managed/models" ) +// Service represents the high-availability service. type Service struct { params *models.HAParams bootstrapCluster bool @@ -50,20 +51,24 @@ type Service struct { memberlist *memberlist.Memberlist } +// Apply applies a log entry to the high-availability service. func (s *Service) Apply(logEntry *raft.Log) interface{} { s.l.Printf("raft: got a message: %s", string(logEntry.Data)) s.receivedMessages <- logEntry.Data return nil } +// Snapshot returns a snapshot of the high-availability service. func (s *Service) Snapshot() (raft.FSMSnapshot, error) { //nolint:ireturn return nil, nil } +// Restore restores the high availability service to a previous state. func (s *Service) Restore(_ io.ReadCloser) error { return nil } +// New provides a new instance of the high availability service. func New(params *models.HAParams) *Service { return &Service{ params: params, @@ -77,6 +82,7 @@ func New(params *models.HAParams) *Service { } } +// Run runs the high availability service. func (s *Service) Run(ctx context.Context) error { s.wg.Add(1) go func() { @@ -290,6 +296,7 @@ func (s *Service) runLeaderObserver(ctx context.Context) { } } +// AddLeaderService adds a leader service to the high availability service. func (s *Service) AddLeaderService(leaderService LeaderService) { err := s.services.Add(leaderService) if err != nil { @@ -297,6 +304,7 @@ func (s *Service) AddLeaderService(leaderService LeaderService) { } } +// BroadcastMessage broadcasts a message from the high availability service. func (s *Service) BroadcastMessage(message []byte) { if s.params.Enabled { s.rw.RLock() @@ -307,12 +315,14 @@ func (s *Service) BroadcastMessage(message []byte) { } } +// IsLeader checks if the current instance of the high availability service is the leader. func (s *Service) IsLeader() bool { s.rw.RLock() defer s.rw.RUnlock() return (s.raftNode != nil && s.raftNode.State() == raft.Leader) || !s.params.Enabled } +// Bootstrap performs the necessary steps to initialize the high availability service. func (s *Service) Bootstrap() bool { return s.params.Bootstrap || !s.params.Enabled } diff --git a/managed/services/ha/leaderservice.go b/managed/services/ha/leaderservice.go index 9ec5185629..9c251d2f50 100644 --- a/managed/services/ha/leaderservice.go +++ b/managed/services/ha/leaderservice.go @@ -20,12 +20,14 @@ import ( "sync" ) +// LeaderService represents a leader service in the high-availability setup. type LeaderService interface { Start(ctx context.Context) error Stop() ID() string } +// StandardService represents a standard service in the high-availability setup. type StandardService struct { id string @@ -33,6 +35,7 @@ type StandardService struct { stopFunc func() } +// NewStandardService creates a new standard service. func NewStandardService(id string, startFunc func(context.Context) error, stopFunc func()) *StandardService { return &StandardService{ id: id, @@ -41,18 +44,22 @@ func NewStandardService(id string, startFunc func(context.Context) error, stopFu } } +// ID returns the ID of the standard service. func (s *StandardService) ID() string { return s.id } +// Start starts the standard service. func (s *StandardService) Start(ctx context.Context) error { return s.startFunc(ctx) } +// Stop stops the standard service. func (s *StandardService) Stop() { s.stopFunc() } +// ContextService represents a context service. type ContextService struct { id string @@ -62,6 +69,7 @@ type ContextService struct { cancel context.CancelFunc } +// NewContextService creates a new context service. func NewContextService(id string, startFunc func(context.Context) error) *ContextService { return &ContextService{ id: id, @@ -69,10 +77,12 @@ func NewContextService(id string, startFunc func(context.Context) error) *Contex } } +// ID returns the ID of the context service. func (s *ContextService) ID() string { return s.id } +// Start starts the context service. func (s *ContextService) Start(ctx context.Context) error { s.m.Lock() ctx, s.cancel = context.WithCancel(ctx) @@ -80,6 +90,7 @@ func (s *ContextService) Start(ctx context.Context) error { return s.startFunc(ctx) } +// Stop stops the context service. func (s *ContextService) Stop() { s.m.Lock() defer s.m.Unlock() diff --git a/managed/services/inventory/agents.go b/managed/services/inventory/agents.go index f39535eb9a..15ad1709f4 100644 --- a/managed/services/inventory/agents.go +++ b/managed/services/inventory/agents.go @@ -113,7 +113,7 @@ func (as *AgentsService) changeAgent(agentID string, common *inventorypb.ChangeC // List selects all Agents in a stable order for a given service. // //nolint:unparam -func (as *AgentsService) List(ctx context.Context, filters models.AgentFilters) ([]inventorypb.Agent, error) { +func (as *AgentsService) List(_ context.Context, filters models.AgentFilters) ([]inventorypb.Agent, error) { var res []inventorypb.Agent e := as.db.InTransaction(func(tx *reform.TX) error { got := 0 @@ -149,7 +149,7 @@ func (as *AgentsService) List(ctx context.Context, filters models.AgentFilters) } // Get selects a single Agent by ID. -func (as *AgentsService) Get(ctx context.Context, id string) (inventorypb.Agent, error) { //nolint:ireturn,unparam +func (as *AgentsService) Get(_ context.Context, id string) (inventorypb.Agent, error) { //nolint:ireturn var res inventorypb.Agent e := as.db.InTransaction(func(tx *reform.TX) error { row, err := models.FindAgentByID(tx.Querier, id) @@ -181,7 +181,7 @@ func (as *AgentsService) Logs(ctx context.Context, id string, limit uint32) ([]s // AddPMMAgent inserts pmm-agent Agent with given parameters. // //nolint:unparam -func (as *AgentsService) AddPMMAgent(ctx context.Context, req *inventorypb.AddPMMAgentRequest) (*inventorypb.PMMAgent, error) { +func (as *AgentsService) AddPMMAgent(_ context.Context, req *inventorypb.AddPMMAgentRequest) (*inventorypb.PMMAgent, error) { var res *inventorypb.PMMAgent e := as.db.InTransaction(func(tx *reform.TX) error { row, err := models.CreatePMMAgent(tx.Querier, req.RunsOnNodeId, req.CustomLabels) diff --git a/managed/services/inventory/grpc/agents_server.go b/managed/services/inventory/grpc/agents_server.go index 3e4277d394..76c4de99db 100644 --- a/managed/services/inventory/grpc/agents_server.go +++ b/managed/services/inventory/grpc/agents_server.go @@ -497,7 +497,7 @@ func (s *agentsServer) AddExternalExporter(ctx context.Context, req *inventorypb return res, nil } -func (s *agentsServer) ChangeExternalExporter(ctx context.Context, req *inventorypb.ChangeExternalExporterRequest) (*inventorypb.ChangeExternalExporterResponse, error) { +func (s *agentsServer) ChangeExternalExporter(_ context.Context, req *inventorypb.ChangeExternalExporterRequest) (*inventorypb.ChangeExternalExporterResponse, error) { agent, err := s.s.ChangeExternalExporter(req) if err != nil { return nil, err diff --git a/managed/services/inventory/grpc/services_server.go b/managed/services/inventory/grpc/services_server.go index 0a6207ce87..76168d3af2 100644 --- a/managed/services/inventory/grpc/services_server.go +++ b/managed/services/inventory/grpc/services_server.go @@ -99,7 +99,7 @@ func (s *servicesServer) ListServices(ctx context.Context, req *inventorypb.List // ListActiveServiceTypes returns list of active Services. func (s *servicesServer) ListActiveServiceTypes( ctx context.Context, - req *inventorypb.ListActiveServiceTypesRequest, + req *inventorypb.ListActiveServiceTypesRequest, //nolint:revive ) (*inventorypb.ListActiveServiceTypesResponse, error) { types, err := s.s.ListActiveServiceTypes(ctx) if err != nil { diff --git a/managed/services/inventory/inventory_metrics.go b/managed/services/inventory/inventory_metrics.go index d390b95b73..74407d0c3d 100644 --- a/managed/services/inventory/inventory_metrics.go +++ b/managed/services/inventory/inventory_metrics.go @@ -36,19 +36,20 @@ const ( prometheusSubsystem = "inventory" ) +// Metric represents a metric for inventory purposes. type Metric struct { labels []string value float64 } -//goland:noinspection GoNameStartsWithPackageName -type InventoryMetrics struct { +// InventoryMetrics represents a collection of inventory metrics. +type InventoryMetrics struct { //nolint:revive db *reform.DB registry agentsRegistry } -//goland:noinspection GoNameStartsWithPackageName -type InventoryMetricsCollector struct { +// InventoryMetricsCollector collects inventory metrics. +type InventoryMetricsCollector struct { //nolint:revive mAgentsDesc *prom.Desc mNodesDesc *prom.Desc mServicesDesc *prom.Desc @@ -56,6 +57,7 @@ type InventoryMetricsCollector struct { metrics inventoryMetrics } +// NewInventoryMetrics creates a new instance of InventoryMetrics. func NewInventoryMetrics(db *reform.DB, registry agentsRegistry) *InventoryMetrics { return &InventoryMetrics{ db: db, @@ -63,6 +65,7 @@ func NewInventoryMetrics(db *reform.DB, registry agentsRegistry) *InventoryMetri } } +// NewInventoryMetricsCollector creates a new instance of InventoryMetricsCollector. func NewInventoryMetricsCollector(metrics inventoryMetrics) *InventoryMetricsCollector { return &InventoryMetricsCollector{ mAgentsDesc: prom.NewDesc( @@ -94,6 +97,7 @@ func getRunsOnNodeIDByPMMAgentID(agents []*models.Agent, pmmAgentID string) stri return "" } +// GetAgentMetrics retrieves agent metrics from InventoryMetrics. func (i *InventoryMetrics) GetAgentMetrics(ctx context.Context) ([]Metric, error) { metrics := []Metric{} @@ -157,6 +161,7 @@ func (i *InventoryMetrics) GetAgentMetrics(ctx context.Context) ([]Metric, error return metrics, nil } +// GetNodeMetrics retrieves node metrics from InventoryMetrics. func (i *InventoryMetrics) GetNodeMetrics(ctx context.Context) ([]Metric, error) { var metrics []Metric @@ -186,6 +191,7 @@ func (i *InventoryMetrics) GetNodeMetrics(ctx context.Context) ([]Metric, error) return metrics, nil } +// GetServiceMetrics retrieves service metrics from InventoryMetrics. func (i *InventoryMetrics) GetServiceMetrics(ctx context.Context) ([]Metric, error) { var metrics []Metric @@ -214,10 +220,12 @@ func (i *InventoryMetrics) GetServiceMetrics(ctx context.Context) ([]Metric, err return metrics, nil } +// Describe describes the InventoryMetricsCollector for Prometheus. func (i *InventoryMetricsCollector) Describe(ch chan<- *prom.Desc) { prom.DescribeByCollect(i, ch) } +// Collect collects metrics for the InventoryMetricsCollector. func (i *InventoryMetricsCollector) Collect(ch chan<- prom.Metric) { ctx, cancelCtx := context.WithTimeout(context.Background(), requestTimeout) defer cancelCtx() diff --git a/managed/services/inventory/services.go b/managed/services/inventory/services.go index 89e6d3b966..f9774b54b2 100644 --- a/managed/services/inventory/services.go +++ b/managed/services/inventory/services.go @@ -56,7 +56,7 @@ func NewServicesService( // List selects all Services in a stable order. // //nolint:unparam -func (ss *ServicesService) List(ctx context.Context, filters models.ServiceFilters) ([]inventorypb.Service, error) { +func (ss *ServicesService) List(_ context.Context, filters models.ServiceFilters) ([]inventorypb.Service, error) { var servicesM []*models.Service e := ss.db.InTransaction(func(tx *reform.TX) error { var err error @@ -80,7 +80,7 @@ func (ss *ServicesService) List(ctx context.Context, filters models.ServiceFilte // ListActiveServiceTypes lists all active Service Types // //nolint:unparam -func (ss *ServicesService) ListActiveServiceTypes(ctx context.Context) ([]inventorypb.ServiceType, error) { +func (ss *ServicesService) ListActiveServiceTypes(_ context.Context) ([]inventorypb.ServiceType, error) { var types []models.ServiceType e := ss.db.InTransaction(func(tx *reform.TX) error { var err error @@ -112,7 +112,7 @@ func (ss *ServicesService) ListActiveServiceTypes(ctx context.Context) ([]invent } // Get selects a single Service by ID. -func (ss *ServicesService) Get(ctx context.Context, id string) (inventorypb.Service, error) { //nolint:unparam,ireturn +func (ss *ServicesService) Get(_ context.Context, id string) (inventorypb.Service, error) { //nolint:ireturn service := &models.Service{} e := ss.db.InTransaction(func(tx *reform.TX) error { var err error @@ -133,7 +133,7 @@ func (ss *ServicesService) Get(ctx context.Context, id string) (inventorypb.Serv // AddMySQL inserts MySQL Service with given parameters. // //nolint:dupl,unparam -func (ss *ServicesService) AddMySQL(ctx context.Context, params *models.AddDBMSServiceParams) (*inventorypb.MySQLService, error) { +func (ss *ServicesService) AddMySQL(_ context.Context, params *models.AddDBMSServiceParams) (*inventorypb.MySQLService, error) { service := &models.Service{} e := ss.db.InTransaction(func(tx *reform.TX) error { var err error @@ -160,7 +160,7 @@ func (ss *ServicesService) AddMySQL(ctx context.Context, params *models.AddDBMSS // AddMongoDB inserts MongoDB Service with given parameters. // //nolint:dupl,unparam -func (ss *ServicesService) AddMongoDB(ctx context.Context, params *models.AddDBMSServiceParams) (*inventorypb.MongoDBService, error) { +func (ss *ServicesService) AddMongoDB(_ context.Context, params *models.AddDBMSServiceParams) (*inventorypb.MongoDBService, error) { service := &models.Service{} e := ss.db.InTransaction(func(tx *reform.TX) error { var err error @@ -184,7 +184,7 @@ func (ss *ServicesService) AddMongoDB(ctx context.Context, params *models.AddDBM // AddPostgreSQL inserts PostgreSQL Service with given parameters. // //nolint:dupl,unparam -func (ss *ServicesService) AddPostgreSQL(ctx context.Context, params *models.AddDBMSServiceParams) (*inventorypb.PostgreSQLService, error) { +func (ss *ServicesService) AddPostgreSQL(_ context.Context, params *models.AddDBMSServiceParams) (*inventorypb.PostgreSQLService, error) { service := &models.Service{} e := ss.db.InTransaction(func(tx *reform.TX) error { var err error @@ -208,7 +208,7 @@ func (ss *ServicesService) AddPostgreSQL(ctx context.Context, params *models.Add // AddProxySQL inserts ProxySQL Service with given parameters. // //nolint:dupl,unparam -func (ss *ServicesService) AddProxySQL(ctx context.Context, params *models.AddDBMSServiceParams) (*inventorypb.ProxySQLService, error) { +func (ss *ServicesService) AddProxySQL(_ context.Context, params *models.AddDBMSServiceParams) (*inventorypb.ProxySQLService, error) { service := &models.Service{} e := ss.db.InTransaction(func(tx *reform.TX) error { var err error @@ -251,7 +251,7 @@ func (ss *ServicesService) AddHAProxyService(_ context.Context, params *models.A // AddExternalService inserts External Service with given parameters. // //nolint:dupl,unparam -func (ss *ServicesService) AddExternalService(ctx context.Context, params *models.AddDBMSServiceParams) (*inventorypb.ExternalService, error) { +func (ss *ServicesService) AddExternalService(_ context.Context, params *models.AddDBMSServiceParams) (*inventorypb.ExternalService, error) { service := &models.Service{} e := ss.db.InTransaction(func(tx *reform.TX) error { var err error diff --git a/managed/services/management/backup/artifacts_service.go b/managed/services/management/backup/artifacts_service.go index c478591a3b..d864546f83 100644 --- a/managed/services/management/backup/artifacts_service.go +++ b/managed/services/management/backup/artifacts_service.go @@ -107,7 +107,7 @@ func (s *ArtifactsService) ListArtifacts(context.Context, *backuppb.ListArtifact // DeleteArtifact deletes specified artifact and its files. func (s *ArtifactsService) DeleteArtifact( - ctx context.Context, + ctx context.Context, //nolint:revive req *backuppb.DeleteArtifactRequest, ) (*backuppb.DeleteArtifactResponse, error) { artifact, err := models.FindArtifactByID(s.db.Querier, req.ArtifactId) diff --git a/managed/services/management/backup/backups_service.go b/managed/services/management/backup/backups_service.go index f3d58b3d91..d66b4a075e 100644 --- a/managed/services/management/backup/backups_service.go +++ b/managed/services/management/backup/backups_service.go @@ -265,7 +265,7 @@ func (s *BackupsService) ScheduleBackup(ctx context.Context, req *backuppb.Sched } // ListScheduledBackups lists all tasks related to a backup. -func (s *BackupsService) ListScheduledBackups(ctx context.Context, req *backuppb.ListScheduledBackupsRequest) (*backuppb.ListScheduledBackupsResponse, error) { +func (s *BackupsService) ListScheduledBackups(ctx context.Context, req *backuppb.ListScheduledBackupsRequest) (*backuppb.ListScheduledBackupsResponse, error) { //nolint:revive,lll tasks, err := models.FindScheduledTasks(s.db.Querier, models.ScheduledTasksFilter{ Types: []models.ScheduledTaskType{ models.ScheduledMySQLBackupTask, @@ -446,7 +446,7 @@ func (s *BackupsService) RemoveScheduledBackup(ctx context.Context, req *backupp } // GetLogs returns logs from the underlying tools for a backup/restore job. -func (s *BackupsService) GetLogs(ctx context.Context, req *backuppb.GetLogsRequest) (*backuppb.GetLogsResponse, error) { +func (s *BackupsService) GetLogs(_ context.Context, req *backuppb.GetLogsRequest) (*backuppb.GetLogsResponse, error) { jobsFilter := models.JobsFilter{ Types: []models.JobType{ models.MySQLBackupJob, diff --git a/managed/services/management/backup/locations_service.go b/managed/services/management/backup/locations_service.go index a81dca8aa0..537bb01411 100644 --- a/managed/services/management/backup/locations_service.go +++ b/managed/services/management/backup/locations_service.go @@ -58,7 +58,7 @@ func (s *LocationsService) Enabled() bool { } // ListLocations returns list of all available backup locations. -func (s *LocationsService) ListLocations(ctx context.Context, req *backuppb.ListLocationsRequest) (*backuppb.ListLocationsResponse, error) { +func (s *LocationsService) ListLocations(_ context.Context, _ *backuppb.ListLocationsRequest) (*backuppb.ListLocationsResponse, error) { locations, err := models.FindBackupLocations(s.db.Querier) if err != nil { return nil, err @@ -222,7 +222,7 @@ func (s *LocationsService) TestLocationConfig( } // RemoveLocation removes backup location. -func (s *LocationsService) RemoveLocation(ctx context.Context, req *backuppb.RemoveLocationRequest) (*backuppb.RemoveLocationResponse, error) { +func (s *LocationsService) RemoveLocation(_ context.Context, req *backuppb.RemoveLocationRequest) (*backuppb.RemoveLocationResponse, error) { mode := models.RemoveRestrict if req.Force { mode = models.RemoveCascade diff --git a/managed/services/management/checks.go b/managed/services/management/checks.go index d1d8049c2b..012f58b72d 100644 --- a/managed/services/management/checks.go +++ b/managed/services/management/checks.go @@ -172,7 +172,7 @@ func (s *ChecksAPIService) GetFailedChecks(ctx context.Context, req *managementp } // ToggleCheckAlert toggles the silence state of the check with the provided alertID. -func (s *ChecksAPIService) ToggleCheckAlert(ctx context.Context, req *managementpb.ToggleCheckAlertRequest) (*managementpb.ToggleCheckAlertResponse, error) { +func (s *ChecksAPIService) ToggleCheckAlert(ctx context.Context, req *managementpb.ToggleCheckAlertRequest) (*managementpb.ToggleCheckAlertResponse, error) { //nolint:revive,lll return nil, status.Error(codes.NotFound, "Advisor alerts silencing is not supported anymore.") } @@ -250,6 +250,7 @@ func (s *ChecksAPIService) ListSecurityChecks(_ context.Context, _ *managementpb return &managementpb.ListSecurityChecksResponse{Checks: res}, nil } +// ListAdvisors retrieves a list of advisors based on the provided request. func (s *ChecksAPIService) ListAdvisors(_ context.Context, _ *managementpb.ListAdvisorsRequest) (*managementpb.ListAdvisorsResponse, error) { disChecks, err := s.checksService.GetDisabledChecks() if err != nil { diff --git a/managed/services/management/common/common.go b/managed/services/management/common/common.go index 9697e70451..5a901ce90b 100644 --- a/managed/services/management/common/common.go +++ b/managed/services/management/common/common.go @@ -30,6 +30,7 @@ import ( // ErrClusterLocked is returned when there is an unfinished job that doesn't allow to change service cluster name. var ErrClusterLocked = errors.New("cluster/service is locked") +// MgmtServices represents a collection of management services. type MgmtServices struct { BackupsService *managementbackup.BackupsService ArtifactsService *managementbackup.ArtifactsService diff --git a/managed/services/management/dbaas/components_service.go b/managed/services/management/dbaas/components_service.go index 38441b1226..315c464107 100644 --- a/managed/services/management/dbaas/components_service.go +++ b/managed/services/management/dbaas/components_service.go @@ -118,6 +118,7 @@ func (c ComponentsService) GetPSMDBComponents(ctx context.Context, req *dbaasv1b return &dbaasv1beta1.GetPSMDBComponentsResponse{Versions: versions}, nil } +// GetPXCComponents returns versions details. func (c ComponentsService) GetPXCComponents(ctx context.Context, req *dbaasv1beta1.GetPXCComponentsRequest) (*dbaasv1beta1.GetPXCComponentsResponse, error) { var kubernetesCluster *models.KubernetesCluster params := componentsParams{ @@ -149,6 +150,7 @@ func (c ComponentsService) GetPXCComponents(ctx context.Context, req *dbaasv1bet return &dbaasv1beta1.GetPXCComponentsResponse{Versions: versions}, nil } +// ChangePSMDBComponents will apply changes on cluster. func (c ComponentsService) ChangePSMDBComponents(_ context.Context, req *dbaasv1beta1.ChangePSMDBComponentsRequest) (*dbaasv1beta1.ChangePSMDBComponentsResponse, error) { err := c.db.InTransaction(func(tx *reform.TX) error { kubernetesCluster, e := models.FindKubernetesClusterByName(tx.Querier, req.KubernetesClusterName) @@ -178,7 +180,8 @@ func (c ComponentsService) ChangePSMDBComponents(_ context.Context, req *dbaasv1 return &dbaasv1beta1.ChangePSMDBComponentsResponse{}, nil } -func (c ComponentsService) ChangePXCComponents(ctx context.Context, req *dbaasv1beta1.ChangePXCComponentsRequest) (*dbaasv1beta1.ChangePXCComponentsResponse, error) { +// ChangePXCComponents apply new values on PXC components. +func (c ComponentsService) ChangePXCComponents(_ context.Context, req *dbaasv1beta1.ChangePXCComponentsRequest) (*dbaasv1beta1.ChangePXCComponentsResponse, error) { err := c.db.InTransaction(func(tx *reform.TX) error { kubernetesCluster, e := models.FindKubernetesClusterByName(tx.Querier, req.KubernetesClusterName) if e != nil { @@ -248,6 +251,7 @@ func (c ComponentsService) installedOperatorsVersion(ctx context.Context, wg *sy } } +// CheckForOperatorUpdate check if update for operator is available. func (c ComponentsService) CheckForOperatorUpdate(ctx context.Context, _ *dbaasv1beta1.CheckForOperatorUpdateRequest) (*dbaasv1beta1.CheckForOperatorUpdateResponse, error) { //nolint:lll if pmmversion.PMMVersion == "" { return nil, status.Error(codes.Internal, "failed to get current PMM version") @@ -429,6 +433,7 @@ func setComponent(kc *models.Component, rc *dbaasv1beta1.ChangeComponent) (*mode return kc, nil } +// InstallOperator upgrade current operator. func (c ComponentsService) InstallOperator(ctx context.Context, req *dbaasv1beta1.InstallOperatorRequest) (*dbaasv1beta1.InstallOperatorResponse, error) { kubernetesCluster, err := models.FindKubernetesClusterByName(c.db.Querier, req.KubernetesClusterName) if err != nil { diff --git a/managed/services/management/dbaas/db_cluster_service.go b/managed/services/management/dbaas/db_cluster_service.go index 603c31b59d..774df9c407 100644 --- a/managed/services/management/dbaas/db_cluster_service.go +++ b/managed/services/management/dbaas/db_cluster_service.go @@ -318,6 +318,7 @@ func (s DBClusterService) getPSMDBCluster(ctx context.Context, cluster dbaasv1.D return c, nil } +// GetDBCluster returns info about PXC and PSMDB clusters. func (s DBClusterService) GetDBCluster(ctx context.Context, req *dbaasv1beta1.GetDBClusterRequest) (*dbaasv1beta1.GetDBClusterResponse, error) { kubeClient, err := s.kubeStorage.GetOrSetClient(req.KubernetesClusterName) if err != nil { @@ -399,7 +400,7 @@ func (s DBClusterService) DeleteDBCluster(ctx context.Context, req *dbaasv1beta1 } // ListS3Backups returns list of backup artifacts stored on s3. -func (s DBClusterService) ListS3Backups(ctx context.Context, req *dbaasv1beta1.ListS3BackupsRequest) (*dbaasv1beta1.ListS3BackupsResponse, error) { +func (s DBClusterService) ListS3Backups(_ context.Context, req *dbaasv1beta1.ListS3BackupsRequest) (*dbaasv1beta1.ListS3BackupsResponse, error) { if req == nil || (req != nil && req.LocationId == "") { return nil, errors.New("location_id cannot be empty") } diff --git a/managed/services/management/dbaas/kube_clients.go b/managed/services/management/dbaas/kube_clients.go index 0e7e34d3c0..d81c6eb51d 100644 --- a/managed/services/management/dbaas/kube_clients.go +++ b/managed/services/management/dbaas/kube_clients.go @@ -32,7 +32,7 @@ type KubeStorage struct { clients map[string]kubernetesClient } -var ErrDatabaseNotSet = errors.New("Database connection not set") +var errDatabaseNotSet = errors.New("Database connection not set") // NewKubeStorage returns a created KubeStorage. func NewKubeStorage(db *reform.DB) *KubeStorage { @@ -53,7 +53,7 @@ func (k *KubeStorage) GetOrSetClient(name string) (kubernetesClient, error) { // } if k.db == nil { - return nil, ErrDatabaseNotSet + return nil, errDatabaseNotSet } kubernetesCluster, err := models.FindKubernetesClusterByName(k.db.Querier, name) diff --git a/managed/services/management/dbaas/psmdb_cluster_service.go b/managed/services/management/dbaas/psmdb_cluster_service.go index 7a9fdea706..c49adb48aa 100644 --- a/managed/services/management/dbaas/psmdb_cluster_service.go +++ b/managed/services/management/dbaas/psmdb_cluster_service.go @@ -329,7 +329,7 @@ func (s PSMDBClusterService) getBackupLocation(req *dbaasv1beta1.CreatePSMDBClus } // GetPSMDBClusterResources returns expected resources to be consumed by the cluster. -func (s PSMDBClusterService) GetPSMDBClusterResources(ctx context.Context, req *dbaasv1beta1.GetPSMDBClusterResourcesRequest) (*dbaasv1beta1.GetPSMDBClusterResourcesResponse, error) { //nolint:lll +func (s PSMDBClusterService) GetPSMDBClusterResources(_ context.Context, req *dbaasv1beta1.GetPSMDBClusterResourcesRequest) (*dbaasv1beta1.GetPSMDBClusterResourcesResponse, error) { //nolint:lll settings, err := models.GetSettings(s.db.Querier) if err != nil { return nil, err diff --git a/managed/services/management/dbaas/template_service.go b/managed/services/management/dbaas/template_service.go index 8680164533..e0a99b8241 100644 --- a/managed/services/management/dbaas/template_service.go +++ b/managed/services/management/dbaas/template_service.go @@ -28,7 +28,7 @@ import ( "github.com/percona/pmm/managed/services/dbaas/kubernetes" ) -type TemplateService struct { +type templateService struct { db *reform.DB l *logrus.Entry kubeStorage *KubeStorage @@ -39,7 +39,7 @@ type TemplateService struct { // NewTemplateService creates DB Clusters Service. func NewTemplateService(db *reform.DB) dbaasv1beta1.TemplatesServer { //nolint:ireturn l := logrus.WithField("component", "dbaas_db_cluster") - return &TemplateService{ + return &templateService{ db: db, l: l, kubeStorage: NewKubeStorage(db), @@ -47,7 +47,7 @@ func NewTemplateService(db *reform.DB) dbaasv1beta1.TemplatesServer { //nolint:i } // ListTemplates returns a list of templates. -func (s TemplateService) ListTemplates(ctx context.Context, req *dbaasv1beta1.ListTemplatesRequest) (*dbaasv1beta1.ListTemplatesResponse, error) { +func (s templateService) ListTemplates(ctx context.Context, req *dbaasv1beta1.ListTemplatesRequest) (*dbaasv1beta1.ListTemplatesResponse, error) { var clusterType string switch req.ClusterType { case dbaasv1beta1.DBClusterType_DB_CLUSTER_TYPE_PXC: diff --git a/managed/services/management/dbaas/version_service_client.go b/managed/services/management/dbaas/version_service_client.go index a5a0196515..ec06ffab9d 100644 --- a/managed/services/management/dbaas/version_service_client.go +++ b/managed/services/management/dbaas/version_service_client.go @@ -62,6 +62,7 @@ type matrix struct { PSMDBOperator map[string]componentVersion `json:"psmdbOperator,omitempty"` } +// Version contains versions info. type Version struct { Product string `json:"product"` ProductVersion string `json:"operator"` diff --git a/managed/services/management/dump/dump.go b/managed/services/management/dump/dump.go index 6ea6026c6b..98b20794b1 100644 --- a/managed/services/management/dump/dump.go +++ b/managed/services/management/dump/dump.go @@ -42,6 +42,7 @@ import ( "github.com/percona/pmm/managed/services/grafana" ) +// Service represents a structure for managing dump-related operations. type Service struct { db *reform.DB l *logrus.Entry @@ -52,6 +53,7 @@ type Service struct { dumpv1beta1.UnimplementedDumpsServer } +// New creates a new instance of the Service with the provided dependencies. func New(db *reform.DB, grafanaClient *grafana.Client, dumpService dumpService) *Service { return &Service{ db: db, @@ -61,6 +63,7 @@ func New(db *reform.DB, grafanaClient *grafana.Client, dumpService dumpService) } } +// StartDump starts a dump based on the provided context and request. func (s *Service) StartDump(ctx context.Context, req *dumpv1beta1.StartDumpRequest) (*dumpv1beta1.StartDumpResponse, error) { md, ok := metadata.FromIncomingContext(ctx) if !ok { @@ -137,6 +140,7 @@ func (s *Service) StartDump(ctx context.Context, req *dumpv1beta1.StartDumpReque return &dumpv1beta1.StartDumpResponse{DumpId: dumpID}, nil } +// ListDumps lists dumps based on the provided context and request. func (s *Service) ListDumps(_ context.Context, _ *dumpv1beta1.ListDumpsRequest) (*dumpv1beta1.ListDumpsResponse, error) { dumps, err := models.FindDumps(s.db.Querier, models.DumpFilters{}) if err != nil { @@ -158,6 +162,7 @@ func (s *Service) ListDumps(_ context.Context, _ *dumpv1beta1.ListDumpsRequest) }, nil } +// DeleteDump deletes a dump based on the provided context and request. func (s *Service) DeleteDump(_ context.Context, req *dumpv1beta1.DeleteDumpRequest) (*dumpv1beta1.DeleteDumpResponse, error) { for _, id := range req.DumpIds { if err := s.dumpService.DeleteDump(id); err != nil { @@ -168,6 +173,7 @@ func (s *Service) DeleteDump(_ context.Context, req *dumpv1beta1.DeleteDumpReque return &dumpv1beta1.DeleteDumpResponse{}, nil } +// GetDumpLogs retrieves dump logs based on the provided context and request. func (s *Service) GetDumpLogs(_ context.Context, req *dumpv1beta1.GetLogsRequest) (*dumpv1beta1.GetLogsResponse, error) { filter := models.DumpLogsFilter{ DumpID: req.DumpId, @@ -199,6 +205,7 @@ func (s *Service) GetDumpLogs(_ context.Context, req *dumpv1beta1.GetLogsRequest return res, nil } +// UploadDump uploads a dump based on the provided context and request. func (s *Service) UploadDump(_ context.Context, req *dumpv1beta1.UploadDumpRequest) (*dumpv1beta1.UploadDumpResponse, error) { filePaths, err := s.dumpService.GetFilePathsForDumps(req.DumpIds) if err != nil { diff --git a/managed/services/management/external.go b/managed/services/management/external.go index 7bb3253f8c..138d03f8cf 100644 --- a/managed/services/management/external.go +++ b/managed/services/management/external.go @@ -48,6 +48,7 @@ func NewExternalService(db *reform.DB, vmdb prometheusService, state agentsState } } +// AddExternal adds an external service based on the provided request. func (e *ExternalService) AddExternal(ctx context.Context, req *managementpb.AddExternalRequest) (*managementpb.AddExternalResponse, error) { res := &managementpb.AddExternalResponse{} var pmmAgentID *string diff --git a/managed/services/management/grpc/actions_server.go b/managed/services/management/grpc/actions_server.go index b1c2ba947a..da05fdac73 100644 --- a/managed/services/management/grpc/actions_server.go +++ b/managed/services/management/grpc/actions_server.go @@ -51,7 +51,7 @@ func NewActionsServer(a *agents.ActionsService, db *reform.DB) managementpb.Acti } // GetAction gets an action result. -func (s *actionsServer) GetAction(ctx context.Context, req *managementpb.GetActionRequest) (*managementpb.GetActionResponse, error) { +func (s *actionsServer) GetAction(ctx context.Context, req *managementpb.GetActionRequest) (*managementpb.GetActionResponse, error) { //nolint:revive res, err := models.FindActionResultByID(s.db.Querier, req.ActionId) if err != nil { return nil, err diff --git a/managed/services/management/haproxy.go b/managed/services/management/haproxy.go index 320b7bd1b5..94731d6de5 100644 --- a/managed/services/management/haproxy.go +++ b/managed/services/management/haproxy.go @@ -48,6 +48,7 @@ func NewHAProxyService(db *reform.DB, vmdb prometheusService, state agentsStateU } } +// AddHAProxy adds an HAProxy service based on the provided request. func (e HAProxyService) AddHAProxy(ctx context.Context, req *managementpb.AddHAProxyRequest) (*managementpb.AddHAProxyResponse, error) { res := &managementpb.AddHAProxyResponse{} var pmmAgentID *string diff --git a/managed/services/management/ia/channels_service.go b/managed/services/management/ia/channels_service.go index 72cf0de5b3..5c0f064334 100644 --- a/managed/services/management/ia/channels_service.go +++ b/managed/services/management/ia/channels_service.go @@ -60,7 +60,7 @@ func (s *ChannelsService) Enabled() bool { // ListChannels returns list of available channels. // Deprecated. Do not use. -func (s *ChannelsService) ListChannels(ctx context.Context, req *iav1beta1.ListChannelsRequest) (*iav1beta1.ListChannelsResponse, error) { //nolint:staticcheck +func (s *ChannelsService) ListChannels(ctx context.Context, req *iav1beta1.ListChannelsRequest) (*iav1beta1.ListChannelsResponse, error) { //nolint:staticcheck,revive var pageIndex int var pageSize int if req.PageParams != nil { @@ -161,7 +161,7 @@ func (s *ChannelsService) getNotificationChannelsPage(pageIndex, pageSize int) ( // AddChannel adds new notification channel. // Deprecated. Do not use. -func (s *ChannelsService) AddChannel(ctx context.Context, req *iav1beta1.AddChannelRequest) (*iav1beta1.AddChannelResponse, error) { //nolint:staticcheck +func (s *ChannelsService) AddChannel(ctx context.Context, req *iav1beta1.AddChannelRequest) (*iav1beta1.AddChannelResponse, error) { //nolint:staticcheck,revive params := &models.CreateChannelParams{ Summary: req.Summary, Disabled: req.Disabled, @@ -212,7 +212,7 @@ func (s *ChannelsService) AddChannel(ctx context.Context, req *iav1beta1.AddChan // ChangeChannel changes existing notification channel. // Deprecated. Do not use. -func (s *ChannelsService) ChangeChannel(ctx context.Context, req *iav1beta1.ChangeChannelRequest) (*iav1beta1.ChangeChannelResponse, error) { //nolint:staticcheck +func (s *ChannelsService) ChangeChannel(ctx context.Context, req *iav1beta1.ChangeChannelRequest) (*iav1beta1.ChangeChannelResponse, error) { //nolint:staticcheck,revive params := &models.ChangeChannelParams{ Summary: req.Summary, Disabled: req.Disabled, @@ -261,7 +261,7 @@ func (s *ChannelsService) ChangeChannel(ctx context.Context, req *iav1beta1.Chan // RemoveChannel removes notification channel. // Deprecated. Do not use. -func (s *ChannelsService) RemoveChannel(ctx context.Context, req *iav1beta1.RemoveChannelRequest) (*iav1beta1.RemoveChannelResponse, error) { //nolint:staticcheck +func (s *ChannelsService) RemoveChannel(ctx context.Context, req *iav1beta1.RemoveChannelRequest) (*iav1beta1.RemoveChannelResponse, error) { //nolint:staticcheck,revive e := s.db.InTransaction(func(tx *reform.TX) error { return models.RemoveChannel(tx.Querier, req.ChannelId) }) diff --git a/managed/services/management/ia/rules_service.go b/managed/services/management/ia/rules_service.go index 1e217d91a2..d7427bbc0d 100644 --- a/managed/services/management/ia/rules_service.go +++ b/managed/services/management/ia/rules_service.go @@ -272,7 +272,7 @@ func (s *RulesService) writeRuleFile(rule *ruleFile) error { // ListAlertRules returns a list of all Integrated Alerting rules. // Deprecated. Do not use. -func (s *RulesService) ListAlertRules(ctx context.Context, req *iav1beta1.ListAlertRulesRequest) (*iav1beta1.ListAlertRulesResponse, error) { //nolint:staticcheck +func (s *RulesService) ListAlertRules(ctx context.Context, req *iav1beta1.ListAlertRulesRequest) (*iav1beta1.ListAlertRulesResponse, error) { //nolint:staticcheck,revive var pageIndex int pageSize := math.MaxInt32 if req.PageParams != nil { @@ -346,7 +346,7 @@ func (s *RulesService) convertAlertRules(rules []*models.Rule, channels []*model // CreateAlertRule creates Integrated Alerting rule. // Deprecated. Do not use. -func (s *RulesService) CreateAlertRule(ctx context.Context, req *iav1beta1.CreateAlertRuleRequest) (*iav1beta1.CreateAlertRuleResponse, error) { //nolint:staticcheck +func (s *RulesService) CreateAlertRule(ctx context.Context, req *iav1beta1.CreateAlertRuleRequest) (*iav1beta1.CreateAlertRuleResponse, error) { //nolint:staticcheck,revive,lll if req.TemplateName != "" && req.SourceRuleId != "" { return nil, status.Errorf(codes.InvalidArgument, "Both template name and source rule id are specified.") } @@ -447,7 +447,7 @@ func (s *RulesService) CreateAlertRule(ctx context.Context, req *iav1beta1.Creat // UpdateAlertRule updates Integrated Alerting rule. // Deprecated. Do not use. -func (s *RulesService) UpdateAlertRule(ctx context.Context, req *iav1beta1.UpdateAlertRuleRequest) (*iav1beta1.UpdateAlertRuleResponse, error) { //nolint:staticcheck +func (s *RulesService) UpdateAlertRule(ctx context.Context, req *iav1beta1.UpdateAlertRuleRequest) (*iav1beta1.UpdateAlertRuleResponse, error) { //nolint:staticcheck,revive,lll params := &models.ChangeRuleParams{ Name: req.Name, Disabled: req.Disabled, @@ -496,7 +496,7 @@ func (s *RulesService) UpdateAlertRule(ctx context.Context, req *iav1beta1.Updat // ToggleAlertRule allows switching between disabled and enabled states of an Alert Rule. // Deprecated. Do not use. -func (s *RulesService) ToggleAlertRule(ctx context.Context, req *iav1beta1.ToggleAlertRuleRequest) (*iav1beta1.ToggleAlertRuleResponse, error) { //nolint:staticcheck +func (s *RulesService) ToggleAlertRule(ctx context.Context, req *iav1beta1.ToggleAlertRuleRequest) (*iav1beta1.ToggleAlertRuleResponse, error) { //nolint:staticcheck,revive,lll params := &models.ToggleRuleParams{Disabled: parseBooleanFlag(req.Disabled)} e := s.db.InTransaction(func(tx *reform.TX) error { _, err := models.ToggleRule(tx.Querier, req.RuleId, params) @@ -513,7 +513,7 @@ func (s *RulesService) ToggleAlertRule(ctx context.Context, req *iav1beta1.Toggl // DeleteAlertRule deletes Integrated Alerting rule. // Deprecated. Do not use. -func (s *RulesService) DeleteAlertRule(ctx context.Context, req *iav1beta1.DeleteAlertRuleRequest) (*iav1beta1.DeleteAlertRuleResponse, error) { //nolint:staticcheck +func (s *RulesService) DeleteAlertRule(ctx context.Context, req *iav1beta1.DeleteAlertRuleRequest) (*iav1beta1.DeleteAlertRuleResponse, error) { //nolint:staticcheck,revive,lll e := s.db.InTransaction(func(tx *reform.TX) error { return models.RemoveRule(tx.Querier, req.RuleId) }) diff --git a/managed/services/platform/platform.go b/managed/services/platform/platform.go index 4b75510ed9..90df9c0506 100644 --- a/managed/services/platform/platform.go +++ b/managed/services/platform/platform.go @@ -203,6 +203,7 @@ func (s *Service) forceDisconnect(ctx context.Context) error { return nil } +// UpdateSupervisordConfigurations updates supervisord configurations for the service. func (s *Service) UpdateSupervisordConfigurations(ctx context.Context) error { settings, err := models.GetSettings(s.db) if err != nil { @@ -378,6 +379,7 @@ func (s *Service) GetContactInformation(ctx context.Context, _ *platformpb.GetCo return response, nil } +// ServerInfo retrieves server information based on the provided context and request. func (s *Service) ServerInfo(ctx context.Context, _ *platformpb.ServerInfoRequest) (*platformpb.ServerInfoResponse, error) { settings, err := models.GetSettings(s.db) if err != nil { diff --git a/managed/services/server/server.go b/managed/services/server/server.go index 6db57e23e4..748230d94e 100644 --- a/managed/services/server/server.go +++ b/managed/services/server/server.go @@ -222,7 +222,7 @@ func (s *Server) Version(ctx context.Context, req *serverpb.VersionRequest) (*se // Readiness returns an error when some PMM Server component is not ready yet or is being restarted. // It can be used as for Docker health check or Kubernetes readiness probe. -func (s *Server) Readiness(ctx context.Context, req *serverpb.ReadinessRequest) (*serverpb.ReadinessResponse, error) { +func (s *Server) Readiness(ctx context.Context, req *serverpb.ReadinessRequest) (*serverpb.ReadinessResponse, error) { //nolint:revive var notReady bool for n, svc := range map[string]healthChecker{ "alertmanager": s.alertmanager, @@ -246,7 +246,7 @@ func (s *Server) Readiness(ctx context.Context, req *serverpb.ReadinessRequest) // LeaderHealthCheck checks if the instance is the leader in a cluster. // Returns an error if the instance isn't the leader. // It's used for HA purpose. -func (s *Server) LeaderHealthCheck(ctx context.Context, req *serverpb.LeaderHealthCheckRequest) (*serverpb.LeaderHealthCheckResponse, error) { +func (s *Server) LeaderHealthCheck(ctx context.Context, req *serverpb.LeaderHealthCheckRequest) (*serverpb.LeaderHealthCheckResponse, error) { //nolint:revive if s.haService.IsLeader() { return &serverpb.LeaderHealthCheckResponse{}, nil } @@ -326,7 +326,7 @@ func (s *Server) CheckUpdates(ctx context.Context, req *serverpb.CheckUpdatesReq } // StartUpdate starts PMM Server update. -func (s *Server) StartUpdate(ctx context.Context, req *serverpb.StartUpdateRequest) (*serverpb.StartUpdateResponse, error) { +func (s *Server) StartUpdate(ctx context.Context, req *serverpb.StartUpdateRequest) (*serverpb.StartUpdateResponse, error) { //nolint:revive s.envRW.RLock() updatesDisabled := s.envSettings.DisableUpdates s.envRW.RUnlock() @@ -501,7 +501,7 @@ func (s *Server) convertSettings(settings *models.Settings, connectedToPlatform } // GetSettings returns current PMM Server settings. -func (s *Server) GetSettings(ctx context.Context, req *serverpb.GetSettingsRequest) (*serverpb.GetSettingsResponse, error) { +func (s *Server) GetSettings(ctx context.Context, req *serverpb.GetSettingsRequest) (*serverpb.GetSettingsResponse, error) { //nolint:revive s.envRW.RLock() defer s.envRW.RUnlock() @@ -877,7 +877,7 @@ func (s *Server) writeSSHKey(sshKey string) error { } // AWSInstanceCheck checks AWS EC2 instance ID. -func (s *Server) AWSInstanceCheck(ctx context.Context, req *serverpb.AWSInstanceCheckRequest) (*serverpb.AWSInstanceCheckResponse, error) { +func (s *Server) AWSInstanceCheck(ctx context.Context, req *serverpb.AWSInstanceCheckRequest) (*serverpb.AWSInstanceCheckResponse, error) { //nolint:revive if err := s.awsInstanceChecker.check(req.InstanceId); err != nil { return nil, err } diff --git a/managed/services/supervisord/supervisord.go b/managed/services/supervisord/supervisord.go index fa3d564f3d..e3bb1ede24 100644 --- a/managed/services/supervisord/supervisord.go +++ b/managed/services/supervisord/supervisord.go @@ -471,11 +471,11 @@ func (s *Service) marshalConfig(tmpl *template.Template, settings *models.Settin if settings.PMMPublicAddress != "" { publicURL, err := url.Parse(settings.PMMPublicAddress) if err != nil { - return nil, errors.Wrap(err, "failed to parse PMM public address.") + return nil, errors.Wrap(err, "failed to parse PMM public address.") //nolint:revive } if publicURL.Host == "" { if publicURL, err = url.Parse(fmt.Sprintf("https://%s", settings.PMMPublicAddress)); err != nil { - return nil, errors.Wrap(err, "failed to parse PMM public address.") + return nil, errors.Wrap(err, "failed to parse PMM public address.") //nolint:revive } } templateParams["PMMServerHost"] = publicURL.Host diff --git a/managed/services/telemetry/config.go b/managed/services/telemetry/config.go index 361aa4a561..006d0fb3ba 100644 --- a/managed/services/telemetry/config.go +++ b/managed/services/telemetry/config.go @@ -169,9 +169,11 @@ type ReportingConfig struct { //go:embed config.default.yml var defaultConfig string +// ExtensionType represents the type of telemetry extension. type ExtensionType string const ( + // UIEventsExtension is a constant for the UI events telemetry extension. UIEventsExtension = ExtensionType("UIEventsExtension") ) diff --git a/managed/services/telemetry/datasource_grafanadb_select.go b/managed/services/telemetry/datasource_grafanadb_select.go index 9361ff93c4..172f9acc7c 100644 --- a/managed/services/telemetry/datasource_grafanadb_select.go +++ b/managed/services/telemetry/datasource_grafanadb_select.go @@ -52,7 +52,7 @@ func NewDsGrafanaDBSelect(config DSConfigGrafanaDB, l *logrus.Entry) DataSource } } -func (d *dsGrafanaDBSelect) Init(ctx context.Context) error { +func (d *dsGrafanaDBSelect) Init(ctx context.Context) error { //nolint:revive db, err := openGrafanaDBConnection(d.config, d.l) if err != nil { return err @@ -99,6 +99,6 @@ func (d *dsGrafanaDBSelect) FetchMetrics(ctx context.Context, config Config) ([] return fetchMetricsFromDB(ctx, d.l, d.config.Timeout, d.db, config) } -func (d *dsGrafanaDBSelect) Dispose(ctx context.Context) error { +func (d *dsGrafanaDBSelect) Dispose(ctx context.Context) error { //nolint:revive return d.db.Close() } diff --git a/managed/services/telemetry/datasource_pmmdb_select.go b/managed/services/telemetry/datasource_pmmdb_select.go index 09c9249b8c..bc230cb2b9 100644 --- a/managed/services/telemetry/datasource_pmmdb_select.go +++ b/managed/services/telemetry/datasource_pmmdb_select.go @@ -98,10 +98,10 @@ func (d *dsPmmDBSelect) FetchMetrics(ctx context.Context, config Config) ([]*pmm return fetchMetricsFromDB(ctx, d.l, d.config.Timeout, d.db, config) } -func (d *dsPmmDBSelect) Init(ctx context.Context) error { +func (d *dsPmmDBSelect) Init(ctx context.Context) error { //nolint:revive return nil } -func (d *dsPmmDBSelect) Dispose(ctx context.Context) error { +func (d *dsPmmDBSelect) Dispose(ctx context.Context) error { //nolint:revive return nil } diff --git a/managed/services/telemetry/datasource_qandb_select.go b/managed/services/telemetry/datasource_qandb_select.go index b458a0872c..17e20e583c 100644 --- a/managed/services/telemetry/datasource_qandb_select.go +++ b/managed/services/telemetry/datasource_qandb_select.go @@ -73,10 +73,10 @@ func (d *dsQanDBSelect) FetchMetrics(ctx context.Context, config Config) ([]*pmm return fetchMetricsFromDB(ctx, d.l, d.config.Timeout, d.db, config) } -func (d *dsQanDBSelect) Init(ctx context.Context) error { +func (d *dsQanDBSelect) Init(ctx context.Context) error { //nolint:revive return nil } -func (d *dsQanDBSelect) Dispose(ctx context.Context) error { +func (d *dsQanDBSelect) Dispose(ctx context.Context) error { //nolint:revive return nil } diff --git a/managed/services/telemetry/datasource_victoria_metrics.go b/managed/services/telemetry/datasource_victoria_metrics.go index 1757a774ac..91d8b77659 100644 --- a/managed/services/telemetry/datasource_victoria_metrics.go +++ b/managed/services/telemetry/datasource_victoria_metrics.go @@ -99,10 +99,10 @@ func (d *dataSourceVictoriaMetrics) FetchMetrics(ctx context.Context, config Con return metrics, nil } -func (d *dataSourceVictoriaMetrics) Init(ctx context.Context) error { +func (d *dataSourceVictoriaMetrics) Init(ctx context.Context) error { //nolint:revive return nil } -func (d *dataSourceVictoriaMetrics) Dispose(ctx context.Context) error { +func (d *dataSourceVictoriaMetrics) Dispose(ctx context.Context) error { //nolint:revive return nil } diff --git a/managed/services/telemetry/telemetry.go b/managed/services/telemetry/telemetry.go index d6951ae405..4106cee802 100644 --- a/managed/services/telemetry/telemetry.go +++ b/managed/services/telemetry/telemetry.go @@ -412,6 +412,7 @@ func (s *Service) send(ctx context.Context, report *reporter.ReportRequest) erro } } +// Format returns the formatted representation of the provided server metric. func (s *Service) Format(report *pmmv1.ServerMetric) string { var builder strings.Builder for _, m := range report.Metrics { diff --git a/managed/services/telemetry/uievents/uievents.go b/managed/services/telemetry/uievents/uievents.go index e66be330ba..7e58ca1f88 100644 --- a/managed/services/telemetry/uievents/uievents.go +++ b/managed/services/telemetry/uievents/uievents.go @@ -50,6 +50,7 @@ type Service struct { uievents.UnimplementedUIEventsServer } +// DashboardUsageStat represents a structure for dashboard usage statistics. type DashboardUsageStat struct { title string uid string @@ -57,6 +58,7 @@ type DashboardUsageStat struct { loadTime *hdrhistogram.Histogram } +// ComponentsUsageStat represents a structure for component usage statistics. type ComponentsUsageStat struct { uid string useCount int32 @@ -93,6 +95,7 @@ func (s *Service) ScheduleCleanup(ctx context.Context) { }() } +// FetchMetrics fetches metrics for the service based on the provided context and telemetry configuration. func (s *Service) FetchMetrics(_ context.Context, _ telemetry.Config) ([]*pmmv1.ServerMetric_Metric, error) { //nolint:unparam s.stateM.RLock() defer s.stateM.RUnlock() diff --git a/managed/services/types.go b/managed/services/types.go index 9573660b91..946a41df16 100644 --- a/managed/services/types.go +++ b/managed/services/types.go @@ -35,6 +35,7 @@ type Target struct { TLSSkipVerify bool } +// Copy creates a copy of the Target instance. func (t *Target) Copy() Target { labels := make(map[string]string, len(t.Labels)) for k, v := range t.Labels { diff --git a/managed/services/versioncache/errors.go b/managed/services/versioncache/errors.go index 9ae6404f2d..7a0eba21b5 100644 --- a/managed/services/versioncache/errors.go +++ b/managed/services/versioncache/errors.go @@ -14,7 +14,6 @@ // along with this program. If not, see . // Package versioncache provides service software version cache functionality. - package versioncache import "github.com/pkg/errors" diff --git a/managed/utils/envvars/parser.go b/managed/utils/envvars/parser.go index 780aca1433..5a679a45e8 100644 --- a/managed/utils/envvars/parser.go +++ b/managed/utils/envvars/parser.go @@ -42,7 +42,8 @@ const ( envEnableAccessControl = "ENABLE_RBAC" envPlatformAPITimeout = "PERCONA_PLATFORM_API_TIMEOUT" defaultPlatformAPITimeout = 30 * time.Second - ENVvmAgentPrefix = "VMAGENT_" + // ENVvmAgentPrefix is the prefix for environment variables related to the VM agent. + ENVvmAgentPrefix = "VMAGENT_" ) // InvalidDurationError invalid duration error. @@ -316,6 +317,7 @@ func GetPlatformPublicKeys() []string { return nil } +// GetInterfaceToBind retrieves the network interface to bind based on environment variables. func GetInterfaceToBind() string { return GetEnv(evnInterfaceToBind, "127.0.0.1") } diff --git a/managed/utils/interceptors/grpc_extension.go b/managed/utils/interceptors/grpc_extension.go index 19046adefc..ccd944b206 100644 --- a/managed/utils/interceptors/grpc_extension.go +++ b/managed/utils/interceptors/grpc_extension.go @@ -37,14 +37,17 @@ type GRPCMetricsExtension struct { grpc_prometheus.DefaultExtension } +// MetricsNameAdjust adjusts the given metric name and returns the adjusted name. func (e GRPCMetricsExtension) MetricsNameAdjust(name string) string { return "pmm_" + name } +// ServerStreamMsgReceivedCounterCustomLabels returns custom labels for the server stream message received counter. func (e *GRPCMetricsExtension) ServerStreamMsgReceivedCounterCustomLabels() []string { return []string{"caller_origin"} } +// ServerStreamMsgReceivedCounterValues returns custom values for the server stream message received counter. func (e *GRPCMetricsExtension) ServerStreamMsgReceivedCounterValues(ctx context.Context) []string { return []string{getCallerOriginStr(ctx)} } diff --git a/managed/utils/interceptors/interceptors.go b/managed/utils/interceptors/interceptors.go index 039de49143..8a3a4e7173 100644 --- a/managed/utils/interceptors/interceptors.go +++ b/managed/utils/interceptors/interceptors.go @@ -79,6 +79,7 @@ func logRequest(l *logrus.Entry, prefix string, f func() error) (err error) { return //nolint:nakedret } +// UnaryInterceptorType represents the type of a unary gRPC interceptor. type UnaryInterceptorType = func(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) // Unary adds context logger and Prometheus metrics to unary server RPC. diff --git a/managed/utils/platform/client.go b/managed/utils/platform/client.go index 9651e514f8..189ed78e21 100644 --- a/managed/utils/platform/client.go +++ b/managed/utils/platform/client.go @@ -282,6 +282,7 @@ func (c *Client) makeRequest(ctx context.Context, accessToken, method, path stri return bodyBytes, nil } +// SsoDetails represents the Single Sign-On details containing information. type SsoDetails struct { GrafanaClientID string `json:"grafana_client_id"` PMMManagedClientID string `json:"pmm_managed_client_id"` @@ -290,15 +291,18 @@ type SsoDetails struct { IssuerURL string `json:"issuer_url"` } +// ConnectPMMResponse represents the response structure for the ConnectPMM API. type ConnectPMMResponse struct { SSODetails *SsoDetails `json:"sso_details"` OrganizationID string `json:"org_id"` } +// SearchOrganizationEntitlementsResponse represents the response structure. type SearchOrganizationEntitlementsResponse struct { Entitlement []*EntitlementResponse `json:"entitlements"` } +// EntitlementResponse represents the response structure for entitlement-related APIs. type EntitlementResponse struct { Number string `json:"number"` Name string `json:"name"` @@ -313,6 +317,7 @@ type EntitlementResponse struct { Platform Response `json:"platform"` } +// Response represents a generic API response structure. type Response struct { SecurityAdvisor string `json:"security_advisor"` ConfigAdvisor string `json:"config_advisor"` @@ -322,6 +327,7 @@ type SearchOrganizationTicketsResponse struct { Tickets []*TicketResponse `json:"tickets"` } +// TicketResponse represents the response structure for ticket-related APIs. type TicketResponse struct { Number string `json:"number"` ShortDescription string `json:"short_description"` @@ -334,6 +340,7 @@ type TicketResponse struct { URL string `json:"url"` } +// ContactInformation represents information about a contact. type ContactInformation struct { Contacts struct { CustomerSuccess struct { diff --git a/managed/utils/validators/validators.go b/managed/utils/validators/validators.go index 8a4fd3d983..89fc58d692 100644 --- a/managed/utils/validators/validators.go +++ b/managed/utils/validators/validators.go @@ -25,15 +25,15 @@ import ( const ( // MetricsResolutionMin is the smallest value metric resolution can accept. - MetricsResolutionMin = time.Second + MetricsResolutionMin = time.Second //nolint:revive // MetricsResolutionMultipleOf is value metrics resolution should be multiple of. MetricsResolutionMultipleOf = time.Second // STTCheckIntervalMin is the smallest value STT check intervals can accept. - STTCheckIntervalMin = time.Second + STTCheckIntervalMin = time.Second //nolint:revive // STTCheckIntervalMultipleOf is value STT check intervals should be multiple of. STTCheckIntervalMultipleOf = time.Second // DataRetentionMin is the smallest value data retention can accept. - DataRetentionMin = 24 * time.Hour + DataRetentionMin = 24 * time.Hour //nolint:revive // DataRetentionMultipleOf is a value of data retention should be multiple of. DataRetentionMultipleOf = 24 * time.Hour ) diff --git a/my_changes.patch b/my_changes.patch new file mode 100644 index 0000000000..7be53d90a2 --- /dev/null +++ b/my_changes.patch @@ -0,0 +1,3734 @@ +From c0ebbc60be42078324843e9396f04332b29970cf Mon Sep 17 00:00:00 2001 +From: vishwas-sharma2480 +Date: Tue, 9 Jan 2024 07:26:16 +0530 +Subject: [PATCH 01/15] enabled revive rule + +--- + .golangci.yml | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/.golangci.yml b/.golangci.yml +index ac80308c..6f14244a 100644 +--- a/.golangci.yml ++++ b/.golangci.yml +@@ -116,7 +116,7 @@ linters: + # TODO: carefully review all the rules below and either fix the code + # or leave disabled and provide a reason why + - tagliatelle +- - revive ++ #- revive + - paralleltest + - gocognit + - tagalign +-- +2.34.1 + + +From 2351da4171ed16c58c5473fe5aaaa5dbcd56f65d Mon Sep 17 00:00:00 2001 +From: vishwas-sharma2480 +Date: Thu, 11 Jan 2024 04:20:49 +0530 +Subject: [PATCH 02/15] parameter 't' seems to be unused renaming it as _ + +--- + agent/utils/backoff/backoff_test.go | 2 +- + managed/data/gen.go | 1 + + 2 files changed, 2 insertions(+), 1 deletion(-) + +diff --git a/agent/utils/backoff/backoff_test.go b/agent/utils/backoff/backoff_test.go +index fe10a7e0..fd68d0b7 100644 +--- a/agent/utils/backoff/backoff_test.go ++++ b/agent/utils/backoff/backoff_test.go +@@ -16,6 +16,6 @@ package backoff + + import "testing" + +-func TestBackoff(t *testing.T) { ++func TestBackoff(_ *testing.T) { + // we need at least one test per package to correctly calculate coverage + } +diff --git a/managed/data/gen.go b/managed/data/gen.go +index 13a2804e..ebc918e5 100644 +--- a/managed/data/gen.go ++++ b/managed/data/gen.go +@@ -23,5 +23,6 @@ import "embed" + //go:embed iatemplates/* + var IATemplates embed.FS + ++// OLMCRDs ... + //go:embed crds/* + var OLMCRDs embed.FS +-- +2.34.1 + + +From bf49ede640783186cdcb04b8bf27588e494578ff Mon Sep 17 00:00:00 2001 +From: vishwas-sharma2480 +Date: Thu, 11 Jan 2024 04:22:05 +0530 +Subject: [PATCH 03/15] parameter 'l' seems to be unused, consider removing or + renaming it as _ + +--- + qan-api2/utils/logger/grpc.go | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/qan-api2/utils/logger/grpc.go b/qan-api2/utils/logger/grpc.go +index 7fa6342b..5c97a6e6 100644 +--- a/qan-api2/utils/logger/grpc.go ++++ b/qan-api2/utils/logger/grpc.go +@@ -26,7 +26,7 @@ type GRPC struct { + } + + // V reports whether verbosity level l is at least the requested verbose level. +-func (v *GRPC) V(l int) bool { ++func (v *GRPC) V(_ int) bool { + // we don't need real implementation ATM + return true + } +-- +2.34.1 + + +From 5d5e81e92213f8d3950523d1550702e5b8ae0085 Mon Sep 17 00:00:00 2001 +From: vishwas-sharma2480 +Date: Thu, 11 Jan 2024 04:38:20 +0530 +Subject: [PATCH 04/15] comment on exported method + +--- + qan-api2/utils/logger/grpc.go | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/qan-api2/utils/logger/grpc.go b/qan-api2/utils/logger/grpc.go +index 5c97a6e6..c9bff487 100644 +--- a/qan-api2/utils/logger/grpc.go ++++ b/qan-api2/utils/logger/grpc.go +@@ -34,8 +34,11 @@ func (v *GRPC) V(_ int) bool { + // Override InfoXXX methods with TraceXXX to keep gRPC and logrus levels in sync. + // + //nolint:stylecheck ++// Info logs a message at the Info level. + func (v *GRPC) Info(args ...interface{}) { v.Trace(args...) } ++// Infoln logs a message at the Info level + func (v *GRPC) Infoln(args ...interface{}) { v.Traceln(args...) } ++// Infof logs a formatted message at the Info level. + func (v *GRPC) Infof(format string, args ...interface{}) { v.Tracef(format, args...) } + + // check interfaces. +-- +2.34.1 + + +From 8156995d75d0c72b567ee64e4f7b0141e9bdbd95 Mon Sep 17 00:00:00 2001 +From: vishwas-sharma2480 +Date: Thu, 11 Jan 2024 04:40:27 +0530 +Subject: [PATCH 05/15] parameter 'l' seems to be unused, consider removing or + renaming it as _ + +--- + qan-api2/utils/logger/grpc.go | 2 +- + utils/logger/grpc.go | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +diff --git a/qan-api2/utils/logger/grpc.go b/qan-api2/utils/logger/grpc.go +index c9bff487..e5b29790 100644 +--- a/qan-api2/utils/logger/grpc.go ++++ b/qan-api2/utils/logger/grpc.go +@@ -30,7 +30,7 @@ func (v *GRPC) V(_ int) bool { + // we don't need real implementation ATM + return true + } +- ++// Info logs a message at the Info level. + // Override InfoXXX methods with TraceXXX to keep gRPC and logrus levels in sync. + // + //nolint:stylecheck +diff --git a/utils/logger/grpc.go b/utils/logger/grpc.go +index fcc4f221..c8b285a0 100644 +--- a/utils/logger/grpc.go ++++ b/utils/logger/grpc.go +@@ -26,7 +26,7 @@ type GRPC struct { + } + + // V reports whether verbosity level l is at least the requested verbose level. +-func (v *GRPC) V(l int) bool { ++func (v *GRPC) V(_ int) bool { + // we don't need real implementation ATM + return true + } +-- +2.34.1 + + +From 567d45eace7d01d37881993148223f864e8ca0fc Mon Sep 17 00:00:00 2001 +From: vishwas-sharma2480 +Date: Thu, 11 Jan 2024 04:42:23 +0530 +Subject: [PATCH 06/15] comment on exported method + +--- + utils/logger/grpc.go | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +diff --git a/utils/logger/grpc.go b/utils/logger/grpc.go +index c8b285a0..ee4e3dc7 100644 +--- a/utils/logger/grpc.go ++++ b/utils/logger/grpc.go +@@ -30,12 +30,14 @@ func (v *GRPC) V(_ int) bool { + // we don't need real implementation ATM + return true + } +- ++// Info logs a message at the Info level. + // override InfoXXX methods with TraceXXX to keep gRPC and logrus levels in sync + // + //nolint:stylecheck + func (v *GRPC) Info(args ...interface{}) { v.Trace(args...) } ++// Infoln logs a message at the Info level. + func (v *GRPC) Infoln(args ...interface{}) { v.Traceln(args...) } ++// Infof logs a formatted message at the Info level. + func (v *GRPC) Infof(format string, args ...interface{}) { v.Tracef(format, args...) } + + // check interfaces. +-- +2.34.1 + + +From fb8234d9c8a1fff3d11af51bc2260b9b85de1621 Mon Sep 17 00:00:00 2001 +From: vishwas-sharma2480 +Date: Thu, 11 Jan 2024 04:44:50 +0530 +Subject: [PATCH 07/15] comment for package main + +--- + agent/cmd/pmm-agent-entrypoint/main.go | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/agent/cmd/pmm-agent-entrypoint/main.go b/agent/cmd/pmm-agent-entrypoint/main.go +index a8d22267..820a886c 100644 +--- a/agent/cmd/pmm-agent-entrypoint/main.go ++++ b/agent/cmd/pmm-agent-entrypoint/main.go +@@ -11,7 +11,7 @@ + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. +- ++// Package main provides the entry point for the PMM Agent. + package main + + import ( +-- +2.34.1 + + +From be55d95271db963b19207cb946209d85cb5eb4bc Mon Sep 17 00:00:00 2001 +From: vishwas-sharma2480 +Date: Fri, 12 Jan 2024 04:13:34 +0530 +Subject: [PATCH 08/15] added nolint for these warnings + +--- + managed/utils/validators/validators.go | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +diff --git a/managed/utils/validators/validators.go b/managed/utils/validators/validators.go +index 8a4fd3d9..89fc58d6 100644 +--- a/managed/utils/validators/validators.go ++++ b/managed/utils/validators/validators.go +@@ -25,15 +25,15 @@ import ( + + const ( + // MetricsResolutionMin is the smallest value metric resolution can accept. +- MetricsResolutionMin = time.Second ++ MetricsResolutionMin = time.Second //nolint:revive + // MetricsResolutionMultipleOf is value metrics resolution should be multiple of. + MetricsResolutionMultipleOf = time.Second + // STTCheckIntervalMin is the smallest value STT check intervals can accept. +- STTCheckIntervalMin = time.Second ++ STTCheckIntervalMin = time.Second //nolint:revive + // STTCheckIntervalMultipleOf is value STT check intervals should be multiple of. + STTCheckIntervalMultipleOf = time.Second + // DataRetentionMin is the smallest value data retention can accept. +- DataRetentionMin = 24 * time.Hour ++ DataRetentionMin = 24 * time.Hour //nolint:revive + // DataRetentionMultipleOf is a value of data retention should be multiple of. + DataRetentionMultipleOf = 24 * time.Hour + ) +-- +2.34.1 + + +From d1e2d2fdf01b0118afed65ca8199431b7d79ed26 Mon Sep 17 00:00:00 2001 +From: vishwas-sharma2480 +Date: Fri, 12 Jan 2024 04:28:35 +0530 +Subject: [PATCH 09/15] added nolint for these warnings because required code + change + +--- + admin/pkg/client/tarball/tarball.go | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +diff --git a/admin/pkg/client/tarball/tarball.go b/admin/pkg/client/tarball/tarball.go +index cadd02e7..b1fd26b6 100644 +--- a/admin/pkg/client/tarball/tarball.go ++++ b/admin/pkg/client/tarball/tarball.go +@@ -87,7 +87,7 @@ func (b *Base) Install(ctx context.Context) error { + extractedPath := path.Join(os.TempDir(), fmt.Sprintf("pmm2-client-%s", b.Version)) + defer os.RemoveAll(extractedPath) //nolint:errcheck + +- if err := b.installTarball(ctx, extractedPath); err != nil { ++ if err := b.installTarball(ctx, extractedPath); err != nil { //nolint:revive + return err + } + +@@ -195,7 +195,7 @@ func (b *Base) extractTarball(tarPath string) error { + cmd.Stdout = os.Stdout + cmd.Stderr = os.Stderr + +- if err := cmd.Run(); err != nil { ++ if err := cmd.Run(); err != nil { //nolint:revive + return err + } + +@@ -228,7 +228,7 @@ func (b *Base) installTarball(ctx context.Context, extractedPath string) error { + cmd.Env = append(cmd.Env, "PMM_DIR="+b.InstallPath) + } + +- if err := cmd.Run(); err != nil { ++ if err := cmd.Run(); err != nil { //nolint:revive + return err + } + +-- +2.34.1 + + +From 1f91ada852c52080817c7043bbd28c054fd2ede0 Mon Sep 17 00:00:00 2001 +From: vishwas-sharma2480 +Date: Fri, 12 Jan 2024 04:42:51 +0530 +Subject: [PATCH 10/15] comment for the warnings + +--- + admin/pkg/docker/docker.go | 2 +- + agent/agents/mysql/slowlog/parser/logger.go | 2 +- + agent/utils/version/postgresql.go | 2 +- + update/main.go | 2 +- + 4 files changed, 4 insertions(+), 4 deletions(-) + +diff --git a/admin/pkg/docker/docker.go b/admin/pkg/docker/docker.go +index 569bdb2f..cd7d5482 100644 +--- a/admin/pkg/docker/docker.go ++++ b/admin/pkg/docker/docker.go +@@ -35,7 +35,7 @@ import ( + + "github.com/percona/pmm/admin/pkg/common" + ) +- ++// ErrPasswordChangeFailed represents an error indicating that password change failed. + var ErrPasswordChangeFailed = errors.New("ErrPasswordChangeFailed") + + // Base contains methods to interact with Docker. +diff --git a/agent/agents/mysql/slowlog/parser/logger.go b/agent/agents/mysql/slowlog/parser/logger.go +index 2dd916f8..46e4f8af 100644 +--- a/agent/agents/mysql/slowlog/parser/logger.go ++++ b/agent/agents/mysql/slowlog/parser/logger.go +@@ -13,7 +13,7 @@ + // limitations under the License. + + package parser +- ++// Logger defines the interface for a MySQL slow log parser logger. + type Logger interface { + Warnf(format string, v ...interface{}) + Infof(format string, v ...interface{}) +diff --git a/agent/utils/version/postgresql.go b/agent/utils/version/postgresql.go +index f88f906a..6ea24025 100644 +--- a/agent/utils/version/postgresql.go ++++ b/agent/utils/version/postgresql.go +@@ -23,7 +23,7 @@ import ( + var ( + postgresDBRegexp = regexp.MustCompile(`PostgreSQL ([\d\.]+)`) + ) +- ++// ParsePostgreSQLVersion parses the given PostgreSQL version string. + func ParsePostgreSQLVersion(v string) string { + m := postgresDBRegexp.FindStringSubmatch(v) + if len(m) != 2 { +diff --git a/update/main.go b/update/main.go +index e1f87f92..4ecffaf3 100644 +--- a/update/main.go ++++ b/update/main.go +@@ -12,7 +12,7 @@ + // + // You should have received a copy of the GNU Affero General Public License + // along with this program. If not, see . +- ++// Package main provides the entry point for the update application. + package main + + import ( +-- +2.34.1 + + +From 39b2900fc9e32d2025f23c425b7b850d7de39433 Mon Sep 17 00:00:00 2001 +From: vishwas-sharma2480 +Date: Fri, 12 Jan 2024 04:55:38 +0530 +Subject: [PATCH 11/15] made the changes for the warnings + +--- + agent/agents/mysql/slowlog/parser/parser_bench_test.go | 2 +- + agent/config/config.go | 2 +- + agent/config/logger.go | 2 +- + agent/utils/mongo_fix/mongo_fix.go | 4 ++-- + agent/utils/mongo_fix/mongo_fix_test.go | 2 +- + 5 files changed, 6 insertions(+), 6 deletions(-) + +diff --git a/agent/agents/mysql/slowlog/parser/parser_bench_test.go b/agent/agents/mysql/slowlog/parser/parser_bench_test.go +index 26f466dd..947827f1 100644 +--- a/agent/agents/mysql/slowlog/parser/parser_bench_test.go ++++ b/agent/agents/mysql/slowlog/parser/parser_bench_test.go +@@ -54,7 +54,7 @@ func benchmarkFile(b *testing.B, name string) { + b.StartTimer() + + go p.Run() +- for p.Parse() != nil { ++ for p.Parse() != nil { //nolint:revive + } + + b.StopTimer() +diff --git a/agent/config/config.go b/agent/config/config.go +index 551ce451..9ba26d69 100644 +--- a/agent/config/config.go ++++ b/agent/config/config.go +@@ -169,7 +169,7 @@ type Config struct { //nolint:musttag + + // ConfigFileDoesNotExistError error is returned from Get method if configuration file is expected, + // but does not exist. +-type ConfigFileDoesNotExistError string ++type ConfigFileDoesNotExistError string //nolint:revive + + func (e ConfigFileDoesNotExistError) Error() string { + return fmt.Sprintf("configuration file %s does not exist", string(e)) +diff --git a/agent/config/logger.go b/agent/config/logger.go +index a2930f37..6915fb0e 100644 +--- a/agent/config/logger.go ++++ b/agent/config/logger.go +@@ -27,7 +27,7 @@ type gRPCLogger struct { + } + + // V reports whether verbosity level l is at least the requested verbose level. +-func (v *gRPCLogger) V(l int) bool { ++func (v *gRPCLogger) V(_ int) bool { + // we don't need real implementation ATM + return true + } +diff --git a/agent/utils/mongo_fix/mongo_fix.go b/agent/utils/mongo_fix/mongo_fix.go +index ea56431b..66784e1f 100644 +--- a/agent/utils/mongo_fix/mongo_fix.go ++++ b/agent/utils/mongo_fix/mongo_fix.go +@@ -12,8 +12,8 @@ + // See the License for the specific language governing permissions and + // limitations under the License. + +-//nolint:stylecheck +-package mongo_fix ++//nolint:stylecheck,revive ++package mongo_fix //nolint:revive + + import ( + "net/url" +diff --git a/agent/utils/mongo_fix/mongo_fix_test.go b/agent/utils/mongo_fix/mongo_fix_test.go +index 146a6135..6716e489 100644 +--- a/agent/utils/mongo_fix/mongo_fix_test.go ++++ b/agent/utils/mongo_fix/mongo_fix_test.go +@@ -13,7 +13,7 @@ + // limitations under the License. + + //nolint:stylecheck +-package mongo_fix ++package mongo_fix //nolint:revive + + import ( + "net/url" +-- +2.34.1 + + +From 9cf495cf975ad5127329ef5e983044fea8228c06 Mon Sep 17 00:00:00 2001 +From: vishwas-sharma2480 +Date: Tue, 16 Jan 2024 04:00:00 +0530 +Subject: [PATCH 12/15] added comments and used nolint were required + +--- + admin/agentlocal/agentlocal.go | 12 +++++------ + api-tests/helpers.go | 20 +++++++++---------- + managed/models/agent_model.go | 2 +- + managed/models/artifact_model.go | 2 +- + managed/models/database.go | 6 +++--- + managed/models/dump.go | 2 +- + managed/models/dump_helpers.go | 2 +- + managed/models/models.go | 2 +- + managed/models/percona_sso_model_helpers.go | 1 + + managed/models/scheduled_tasks_helpers.go | 2 +- + managed/models/service_model.go | 2 +- + managed/models/victoriametrics_params.go | 1 + + managed/services/dump/dump.go | 16 +++++++-------- + managed/services/ha/highavailability.go | 20 +++++++++---------- + managed/services/ha/leaderservice.go | 22 ++++++++++----------- + managed/utils/envvars/parser.go | 3 ++- + utils/sqlmetrics/sqlmetrics.go | 4 ++-- + 17 files changed, 61 insertions(+), 58 deletions(-) + +diff --git a/admin/agentlocal/agentlocal.go b/admin/agentlocal/agentlocal.go +index 26a7aa18..feca0599 100644 +--- a/admin/agentlocal/agentlocal.go ++++ b/admin/agentlocal/agentlocal.go +@@ -45,14 +45,14 @@ func SetTransport(ctx context.Context, debug bool, port uint32) { + + client.Default.SetTransport(transport) + } +- ++// NetworkInfo represents information about the network. + type NetworkInfo bool + + const ( +- RequestNetworkInfo NetworkInfo = true +- DoNotRequestNetworkInfo NetworkInfo = false +- Localhost = "127.0.0.1" +- DefaultPMMAgentListenPort = 7777 ++ RequestNetworkInfo NetworkInfo = true //nolint:revive ++ DoNotRequestNetworkInfo NetworkInfo = false //nolint:revive ++ Localhost = "127.0.0.1"//nolint:revive ++ DefaultPMMAgentListenPort = 7777//nolint:revive + ) + + // ErrNotSetUp is returned by GetStatus when pmm-agent is running, but not set up. +@@ -80,7 +80,7 @@ type Status struct { + + ConnectionUptime float32 `json:"connection_uptime"` + } +- ++// AgentStatus represents the status of the agent. + type AgentStatus struct { + AgentID string `json:"agent_id"` + AgentType string `json:"agent_type"` +diff --git a/api-tests/helpers.go b/api-tests/helpers.go +index 5ef69250..47a6bc40 100644 +--- a/api-tests/helpers.go ++++ b/api-tests/helpers.go +@@ -31,7 +31,7 @@ import ( + "github.com/percona/pmm/api/inventorypb/json/client/nodes" + "github.com/percona/pmm/api/inventorypb/json/client/services" + ) +- ++// ErrorResponse represents the response structure for error scenarios. + type ErrorResponse interface { + Code() int + } +@@ -79,8 +79,8 @@ func AssertAPIErrorf(t TestingT, actual error, httpStatus int, grpcCode codes.Co + // (e.g. the line number in the proto file). + assert.Contains(t, errorField.String(), format) + } +- +-func ExpectFailure(t *testing.T, link string) *expectedFailureTestingT { ++// ExpectFailure sets up expectations for a test case to fail. ++func ExpectFailure(t *testing.T, link string) *expectedFailureTestingT {//nolint:revive + t.Helper() + return &expectedFailureTestingT{ + t: t, +@@ -127,7 +127,7 @@ func (tt *expectedFailureTestingT) Check() { + + tt.t.Fatalf("%s expected to fail, but didn't: %s", tt.Name(), tt.link) + } +- ++// RemoveNodes removes specified nodes. + func RemoveNodes(t TestingT, nodeIDs ...string) { + t.Helper() + +@@ -143,7 +143,7 @@ func RemoveNodes(t TestingT, nodeIDs ...string) { + assert.NotNil(t, res) + } + } +- ++// RemoveServices removes specified services. + func RemoveServices(t TestingT, serviceIDs ...string) { + t.Helper() + +@@ -160,7 +160,7 @@ func RemoveServices(t TestingT, serviceIDs ...string) { + assert.NotNil(t, res) + } + } +- ++// RemoveAgents removes specified agents + func RemoveAgents(t TestingT, agentIDs ...string) { + t.Helper() + +@@ -176,7 +176,7 @@ func RemoveAgents(t TestingT, agentIDs ...string) { + assert.NotNil(t, res) + } + } +- ++// AddGenericNode adds a generic node. + func AddGenericNode(t TestingT, nodeName string) *nodes.AddGenericNodeOKBodyGeneric { + t.Helper() + +@@ -194,7 +194,7 @@ func AddGenericNode(t TestingT, nodeName string) *nodes.AddGenericNodeOKBodyGene + require.NotNil(t, res.Payload.Generic) + return res.Payload.Generic + } +- ++// AddRemoteNode adds a remote node. + func AddRemoteNode(t TestingT, nodeName string) *nodes.AddRemoteNodeOKBody { + t.Helper() + +@@ -210,7 +210,7 @@ func AddRemoteNode(t TestingT, nodeName string) *nodes.AddRemoteNodeOKBody { + require.NotNil(t, res) + return res.Payload + } +- ++// AddNode adds a node. + func AddNode(t TestingT, nodeBody *nodes.AddNodeBody) *nodes.AddNodeOKBody { + t.Helper() + +@@ -225,7 +225,7 @@ func AddNode(t TestingT, nodeBody *nodes.AddNodeBody) *nodes.AddNodeOKBody { + + return res.Payload + } +- ++// AddPMMAgent adds a PMM agent. + func AddPMMAgent(t TestingT, nodeID string) *agents.AddPMMAgentOKBody { + t.Helper() + +diff --git a/managed/models/agent_model.go b/managed/models/agent_model.go +index 0233183e..c556b26b 100644 +--- a/managed/models/agent_model.go ++++ b/managed/models/agent_model.go +@@ -300,7 +300,7 @@ func (s *Agent) DBConfig(service *Service) *DBConfig { + Socket: pointer.GetString(service.Socket), + } + } +- ++// DSNParams represents the parameters for configuring a Data Source Name (DSN). + type DSNParams struct { + DialTimeout time.Duration + Database string +diff --git a/managed/models/artifact_model.go b/managed/models/artifact_model.go +index 2ec01b4c..e7e90895 100644 +--- a/managed/models/artifact_model.go ++++ b/managed/models/artifact_model.go +@@ -141,7 +141,7 @@ type Metadata struct { + RestoreTo *time.Time `json:"restore_to"` + BackupToolData *BackupToolData `json:"backup_tool_data"` + } +- ++// MetadataList is a list of metadata associated with artifacts. + type MetadataList []Metadata + + // Value implements database/sql/driver.Valuer interface. Should be defined on the value. +diff --git a/managed/models/database.go b/managed/models/database.go +index 4880f07f..a512ea61 100644 +--- a/managed/models/database.go ++++ b/managed/models/database.go +@@ -12,7 +12,7 @@ + // + // You should have received a copy of the GNU Affero General Public License + // along with this program. If not, see . +- ++// Package models provides functionality for handling database models and related tasks. + //nolint:lll + package models + +@@ -1156,7 +1156,7 @@ func migrateDB(db *reform.DB, params SetupDBParams) error { + if err = setupFixture1(tx.Querier, params); err != nil { + return err + } +- if err = setupFixture2(tx.Querier, params.Username, params.Password); err != nil { ++ if err = setupFixture2(tx.Querier, params.Username, params.Password); err != nil {//nolint:revive + return err + } + return nil +@@ -1246,7 +1246,7 @@ func setupFixture1(q *reform.Querier, params SetupDBParams) error { + return nil + } + +-func setupFixture2(q *reform.Querier, username, password string) error { ++func setupFixture2(q *reform.Querier, username, password string) error {//nolint:revive + // TODO add clickhouse_exporter + + return nil +diff --git a/managed/models/dump.go b/managed/models/dump.go +index d7adcee5..dfcbedeb 100644 +--- a/managed/models/dump.go ++++ b/managed/models/dump.go +@@ -23,7 +23,7 @@ import ( + ) + + //go:generate ../../bin/reform +- ++// DumpStatus represents the status of a dump process. + type DumpStatus string + + const ( +diff --git a/managed/models/dump_helpers.go b/managed/models/dump_helpers.go +index b5c0626e..65c307a8 100644 +--- a/managed/models/dump_helpers.go ++++ b/managed/models/dump_helpers.go +@@ -49,7 +49,7 @@ type DumpFilters struct { + // Return only dumps by specified status. + Status DumpStatus + } +- ++// CreateDumpParams represents the parameters for creating a dump. + type CreateDumpParams struct { + ServiceNames []string + StartTime *time.Time +diff --git a/managed/models/models.go b/managed/models/models.go +index 2ee68f37..c1024ea4 100644 +--- a/managed/models/models.go ++++ b/managed/models/models.go +@@ -230,7 +230,7 @@ const ( + Bool = ParamType("bool") + String = ParamType("string") + ) +- ++// ParamUnit represents the unit of a parameter. + type ParamUnit string + + const ( +diff --git a/managed/models/percona_sso_model_helpers.go b/managed/models/percona_sso_model_helpers.go +index 4f9b6a11..5fdd313f 100644 +--- a/managed/models/percona_sso_model_helpers.go ++++ b/managed/models/percona_sso_model_helpers.go +@@ -32,6 +32,7 @@ import ( + + var ( + perconaSSOMtx sync.Mutex ++ // ErrNotConnectedToPortal is an error indicating that PMM Server is not connected to the Portal. + ErrNotConnectedToPortal = errors.New("PMM Server is not connected to Portal") + ) + +diff --git a/managed/models/scheduled_tasks_helpers.go b/managed/models/scheduled_tasks_helpers.go +index be58f5ea..18a7e4b2 100644 +--- a/managed/models/scheduled_tasks_helpers.go ++++ b/managed/models/scheduled_tasks_helpers.go +@@ -382,7 +382,7 @@ func (s *ScheduledTask) ServiceID() (string, error) { + } + return data.ServiceID, nil + } +- ++// CommonBackupData returns the common backup data for the scheduled task. + func (s *ScheduledTask) CommonBackupData() (*CommonBackupTaskData, error) { + if s.Data != nil { + switch s.Type { +diff --git a/managed/models/service_model.go b/managed/models/service_model.go +index f05446e9..7a8e4b27 100644 +--- a/managed/models/service_model.go ++++ b/managed/models/service_model.go +@@ -26,7 +26,7 @@ import ( + // ServiceType represents Service type as stored in databases: + // pmm-managed's PostgreSQL, qan-api's ClickHouse, and VictoriaMetrics. + type ServiceType string +- ++// ServiceStandardLabelsParams represents the parameters for standard labels in a service. + type ServiceStandardLabelsParams struct { + Cluster *string + Environment *string +diff --git a/managed/models/victoriametrics_params.go b/managed/models/victoriametrics_params.go +index 14a86a5d..112467ce 100644 +--- a/managed/models/victoriametrics_params.go ++++ b/managed/models/victoriametrics_params.go +@@ -29,6 +29,7 @@ const ( + // BasePrometheusConfigPath - basic path with prometheus config, + // that user can mount to container. + BasePrometheusConfigPath = "/srv/prometheus/prometheus.base.yml" ++ // VMBaseURL is the base URL for VictoriaMetrics. + VMBaseURL = "http://127.0.0.1:9090/prometheus/" + ) + +diff --git a/managed/services/dump/dump.go b/managed/services/dump/dump.go +index 4f028eb4..7d9faf92 100644 +--- a/managed/services/dump/dump.go ++++ b/managed/services/dump/dump.go +@@ -36,14 +36,14 @@ import ( + + "github.com/percona/pmm/managed/models" + ) +- ++// ErrDumpAlreadyRunning is an exported error indicating that pmm-dump is already running. + var ErrDumpAlreadyRunning = status.Error(codes.FailedPrecondition, "pmm-dump already running.") + + const ( + pmmDumpBin = "pmm-dump" + dumpsDir = "/srv/dump" + ) +- ++// Service represents the dump service. + type Service struct { + l *logrus.Entry + +@@ -54,14 +54,14 @@ type Service struct { + rw sync.RWMutex + cancel context.CancelFunc + } +- ++// New creates a new instance of the dump service.. + func New(db *reform.DB) *Service { + return &Service{ + l: logrus.WithField("component", "management/backup/backup"), + db: db, + } + } +- ++// Params represents the parameters for configuring the dump service. + type Params struct { + APIKey string + Cookie string +@@ -73,7 +73,7 @@ type Params struct { + ExportQAN bool + IgnoreLoad bool + } +- ++// StartDump initiates the process of creating and managing dumps in the dump service. + func (s *Service) StartDump(params *Params) (string, error) { + // Check if some pmm-dump already running. + if !s.running.CompareAndSwap(false, true) { +@@ -174,7 +174,7 @@ func (s *Service) StartDump(params *Params) (string, error) { + + return dump.ID, nil + } +- ++// DeleteDump removes a specific dump associated with the dump service. + func (s *Service) DeleteDump(dumpID string) error { + dump, err := models.FindDumpByID(s.db.Querier, dumpID) + if err != nil { +@@ -198,7 +198,7 @@ func (s *Service) DeleteDump(dumpID string) error { + + return nil + } +- ++// GetFilePathsForDumps retrieves the file paths associated with the dumps managed by the dump service. + func (s *Service) GetFilePathsForDumps(dumpIDs []string) (map[string]string, error) { + dumps, err := models.FindDumpsByIDs(s.db.Querier, dumpIDs) + if err != nil { +@@ -271,7 +271,7 @@ func (s *Service) saveLogChunk(dumpID string, chunkN uint32, text string, last b + + return nil + } +- ++// StopDump stops the ongoing dump process in the dump service. + func (s *Service) StopDump() { + s.rw.RLock() + defer s.rw.RUnlock() +diff --git a/managed/services/ha/highavailability.go b/managed/services/ha/highavailability.go +index cec144b4..fb0cab97 100644 +--- a/managed/services/ha/highavailability.go ++++ b/managed/services/ha/highavailability.go +@@ -31,7 +31,7 @@ import ( + + "github.com/percona/pmm/managed/models" + ) +- ++// Service represents the high-availability service. + type Service struct { + params *models.HAParams + bootstrapCluster bool +@@ -49,21 +49,21 @@ type Service struct { + raftNode *raft.Raft + memberlist *memberlist.Memberlist + } +- ++// Apply applies a log entry to the high-availability service. + func (s *Service) Apply(logEntry *raft.Log) interface{} { + s.l.Printf("raft: got a message: %s", string(logEntry.Data)) + s.receivedMessages <- logEntry.Data + return nil + } +- ++// Snapshot returns a snapshot of the high-availability service. + func (s *Service) Snapshot() (raft.FSMSnapshot, error) { //nolint:ireturn + return nil, nil + } +- ++// Restore restores the high availability service to a previous state. + func (s *Service) Restore(_ io.ReadCloser) error { + return nil + } +- ++//Service provides new instance of the high availability service. + func New(params *models.HAParams) *Service { + return &Service{ + params: params, +@@ -76,7 +76,7 @@ func New(params *models.HAParams) *Service { + wg: &sync.WaitGroup{}, + } + } +- ++// Run runs the high availability service. + func (s *Service) Run(ctx context.Context) error { + s.wg.Add(1) + go func() { +@@ -289,14 +289,14 @@ func (s *Service) runLeaderObserver(ctx context.Context) { + } + } + } +- ++// AddLeaderService adds a leader service to the high availability service. + func (s *Service) AddLeaderService(leaderService LeaderService) { + err := s.services.Add(leaderService) + if err != nil { + s.l.Errorf("couldn't add HA service: +%v", err) + } + } +- ++// BroadcastMessage broadcasts a message from the high availability service. + func (s *Service) BroadcastMessage(message []byte) { + if s.params.Enabled { + s.rw.RLock() +@@ -306,13 +306,13 @@ func (s *Service) BroadcastMessage(message []byte) { + s.receivedMessages <- message + } + } +- ++// IsLeader checks if the current instance of the high availability service is the leader. + func (s *Service) IsLeader() bool { + s.rw.RLock() + defer s.rw.RUnlock() + return (s.raftNode != nil && s.raftNode.State() == raft.Leader) || !s.params.Enabled + } +- ++// Bootstrap performs the necessary steps to initialize the high availability service. + func (s *Service) Bootstrap() bool { + return s.params.Bootstrap || !s.params.Enabled + } +diff --git a/managed/services/ha/leaderservice.go b/managed/services/ha/leaderservice.go +index 9ec51856..fc776bf4 100644 +--- a/managed/services/ha/leaderservice.go ++++ b/managed/services/ha/leaderservice.go +@@ -19,20 +19,20 @@ import ( + "context" + "sync" + ) +- ++// LeaderService represents a leader service in the high-availability setup. + type LeaderService interface { + Start(ctx context.Context) error + Stop() + ID() string + } +- ++// StandardService represents a standard service in the high-availability setup. + type StandardService struct { + id string + + startFunc func(context.Context) error + stopFunc func() + } +- ++// NewStandardService creates a new standard service. + func NewStandardService(id string, startFunc func(context.Context) error, stopFunc func()) *StandardService { + return &StandardService{ + id: id, +@@ -40,19 +40,19 @@ func NewStandardService(id string, startFunc func(context.Context) error, stopFu + stopFunc: stopFunc, + } + } +- ++// ID returns the ID of the standard service. + func (s *StandardService) ID() string { + return s.id + } +- ++// Start starts the standard service. + func (s *StandardService) Start(ctx context.Context) error { + return s.startFunc(ctx) + } +- ++// Stop stops the standard service. + func (s *StandardService) Stop() { + s.stopFunc() + } +- ++// ContextService represents a context service. + type ContextService struct { + id string + +@@ -61,25 +61,25 @@ type ContextService struct { + m sync.Mutex + cancel context.CancelFunc + } +- ++// NewContextService creates a new context service. + func NewContextService(id string, startFunc func(context.Context) error) *ContextService { + return &ContextService{ + id: id, + startFunc: startFunc, + } + } +- ++// ID returns the ID of the context service. + func (s *ContextService) ID() string { + return s.id + } +- ++// Start starts the context service. + func (s *ContextService) Start(ctx context.Context) error { + s.m.Lock() + ctx, s.cancel = context.WithCancel(ctx) + s.m.Unlock() + return s.startFunc(ctx) + } +- ++// Stop stops the context service. + func (s *ContextService) Stop() { + s.m.Lock() + defer s.m.Unlock() +diff --git a/managed/utils/envvars/parser.go b/managed/utils/envvars/parser.go +index 780aca14..790d0ac3 100644 +--- a/managed/utils/envvars/parser.go ++++ b/managed/utils/envvars/parser.go +@@ -42,6 +42,7 @@ const ( + envEnableAccessControl = "ENABLE_RBAC" + envPlatformAPITimeout = "PERCONA_PLATFORM_API_TIMEOUT" + defaultPlatformAPITimeout = 30 * time.Second ++ // ENVvmAgentPrefix is the prefix for environment variables related to the VM agent. + ENVvmAgentPrefix = "VMAGENT_" + ) + +@@ -315,7 +316,7 @@ func GetPlatformPublicKeys() []string { + + return nil + } +- ++// GetInterfaceToBind retrieves the network interface to bind based on environment variables. + func GetInterfaceToBind() string { + return GetEnv(evnInterfaceToBind, "127.0.0.1") + } +diff --git a/utils/sqlmetrics/sqlmetrics.go b/utils/sqlmetrics/sqlmetrics.go +index 00a582ef..af284598 100644 +--- a/utils/sqlmetrics/sqlmetrics.go ++++ b/utils/sqlmetrics/sqlmetrics.go +@@ -84,7 +84,7 @@ func NewCollector(driver, dbName string, db *sql.DB) *Collector { + nil, constLabels), + } + } +- ++//nolint:revive + func (c *Collector) Describe(ch chan<- *prom.Desc) { + ch <- c.maxOpenConnections + +@@ -97,7 +97,7 @@ func (c *Collector) Describe(ch chan<- *prom.Desc) { + ch <- c.maxIdleClosed + ch <- c.maxLifetimeClosed + } +- ++//nolint:revive + func (c *Collector) Collect(ch chan<- prom.Metric) { + stats := c.db.Stats() + +-- +2.34.1 + + +From c3143dcb942b9e03b89a4e0be39c9ed0de006b1a Mon Sep 17 00:00:00 2001 +From: vishwas-sharma2480 +Date: Tue, 16 Jan 2024 23:38:58 +0530 +Subject: [PATCH 13/15] added comments and nolint were needed + +--- + 2 | 201 ++++++++++++++++++ + admin/cli/cli.go | 4 +- + admin/cmd/pmm-admin/main.go | 2 +- + admin/cmd/pmm/main.go | 2 +- + admin/commands/base.go | 8 +- + .../inventory/add_agent_external_exporter.go | 2 +- + .../inventory/add_agent_mongodb_exporter.go | 2 +- + .../inventory/add_agent_mysqld_exporter.go | 2 +- + .../inventory/add_agent_node_exporter.go | 2 +- + .../commands/inventory/add_agent_pmm_agent.go | 2 +- + .../inventory/add_agent_postgres_exporter.go | 2 +- + .../inventory/add_agent_proxysql_exporter.go | 2 +- + .../add_agent_qan_mongodb_profiler_agent.go | 2 +- + .../add_agent_qan_mysql_perfschema_agent.go | 2 +- + .../add_agent_qan_mysql_slowlog_agent.go | 2 +- + ...d_agent_qan_postgres_pgstatements_agent.go | 2 +- + ..._agent_qan_postgres_pgstatmonitor_agent.go | 2 +- + .../inventory/add_agent_rds_exporter.go | 2 +- + .../commands/inventory/add_node_container.go | 2 +- + admin/commands/inventory/add_node_generic.go | 2 +- + admin/commands/inventory/add_node_remote.go | 2 +- + .../commands/inventory/add_node_remote_rds.go | 2 +- + .../inventory/add_service_external.go | 2 +- + .../commands/inventory/add_service_haproxy.go | 2 +- + .../commands/inventory/add_service_mongodb.go | 2 +- + admin/commands/inventory/add_service_mysql.go | 2 +- + .../inventory/add_service_postgresql.go | 2 +- + .../inventory/add_service_proxysql.go | 2 +- + admin/commands/inventory/inventory.go | 2 +- + admin/commands/inventory/list_agents.go | 2 +- + admin/commands/inventory/list_nodes.go | 2 +- + admin/commands/inventory/list_services.go | 2 +- + admin/commands/inventory/remove_agent.go | 2 +- + admin/commands/inventory/remove_node.go | 2 +- + admin/commands/inventory/remove_service.go | 2 +- + admin/commands/list.go | 2 +- + admin/commands/management/add_external.go | 4 +- + .../management/add_external_serverless.go | 4 +- + admin/commands/management/add_haproxy.go | 4 +- + admin/commands/management/add_mongodb.go | 12 +- + admin/commands/management/add_mysql.go | 10 +- + admin/commands/management/add_postgresql.go | 12 +- + admin/commands/management/add_proxysql.go | 12 +- + admin/commands/management/register.go | 2 +- + admin/commands/management/remove.go | 2 +- + admin/commands/management/unregister.go | 2 +- + admin/commands/pmm/client/upgrade.go | 2 +- + admin/commands/pmm/server/docker/base.go | 2 +- + admin/commands/pmm/server/docker/upgrade.go | 2 +- + admin/commands/status.go | 2 +- + agent/agentlocal/agent_local.go | 2 +- + agent/agents/agents_test.go | 2 +- + agent/runner/jobs/mysql_restore_job.go | 2 +- + agent/runner/jobs/pbm_helpers.go | 4 +- + api-tests/management/helpers.go | 4 +- + api/agentpb/agent.go | 72 +++---- + api/inventorypb/agents.go | 2 +- + managed/cmd/pmm-managed-init/main.go | 2 +- + managed/models/agentversion.go | 4 +- + managed/models/artifact_helpers.go | 2 +- + managed/models/database.go | 2 +- + managed/models/dump.go | 6 +- + managed/models/dump_helpers.go | 6 +- + managed/models/models.go | 3 +- + managed/models/role_helpers.go | 2 +- + managed/models/service_helpers.go | 2 +- + managed/models/settings_helpers.go | 2 +- + managed/models/template_helpers.go | 4 +- + managed/models/victoriametrics_params.go | 6 +- + managed/services/agents/agents.go | 2 +- + managed/services/agents/registry.go | 2 +- + managed/services/agents/versioner.go | 15 +- + managed/services/checks/checks.go | 4 +- + managed/services/grafana/client.go | 2 - + managed/services/management/checks.go | 2 +- + managed/services/management/dump/dump.go | 14 +- + managed/services/management/external.go | 2 +- + managed/services/management/haproxy.go | 2 +- + managed/services/platform/platform.go | 4 +- + managed/services/server/server.go | 11 +- + managed/services/supervisord/supervisord.go | 4 +- + managed/services/telemetry/config.go | 3 +- + .../telemetry/datasource_pmmdb_select.go | 4 +- + .../telemetry/datasource_victoria_metrics.go | 4 +- + managed/services/telemetry/telemetry.go | 2 +- + .../services/telemetry/uievents/uievents.go | 7 +- + managed/services/types.go | 2 +- + managed/utils/interceptors/grpc_extension.go | 6 +- + managed/utils/interceptors/interceptors.go | 2 +- + managed/utils/platform/client.go | 16 +- + qan-api2/db.go | 2 +- + 91 files changed, 400 insertions(+), 192 deletions(-) + create mode 100644 2 + +diff --git a/2 b/2 +new file mode 100644 +index 00000000..9ef37dce +--- /dev/null ++++ b/2 +@@ -0,0 +1,201 @@ ++// Copyright (C) 2023 Percona LLC ++// ++// Licensed under the Apache License, Version 2.0 (the "License"); ++// you may not use this file except in compliance with the License. ++// You may obtain a copy of the License at ++// ++// http://www.apache.org/licenses/LICENSE-2.0 ++// ++// Unless required by applicable law or agreed to in writing, software ++// distributed under the License is distributed on an "AS IS" BASIS, ++// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ++// See the License for the specific language governing permissions and ++// limitations under the License. ++ ++package client ++ ++import ( ++ "context" ++ "fmt" ++ "os" ++ "os/exec" ++ "strings" ++ ++ "github.com/sirupsen/logrus" ++ ++ "github.com/percona/pmm/admin/cli/flags" ++ "github.com/percona/pmm/admin/commands" ++ "github.com/percona/pmm/admin/pkg/client" ++ "github.com/percona/pmm/admin/pkg/client/tarball" ++ "github.com/percona/pmm/admin/pkg/common" ++) ++ ++// UpgradeCommand is used by Kong for CLI flags and commands. ++type UpgradeCommand struct { ++ Distribution string `enum:"autodetect,package-manager,tarball,docker" default:"autodetect" help:"Type of PMM Client distribution. One of: autodetect,package-manager,tarball,docker"` //nolint:lll ++ Version string `name:"use-version" help:"PMM Client version to upgrade to (default: latest)"` ++ ++ InstallPath string `group:"Tarball flags" default:"/usr/local/percona/pmm2" help:"Path where PMM Client is installed"` ++ User string `group:"Tarball flags" help:"Set file ownership instead of the current user"` ++ Group string `group:"Tarball flags" help:"Set group ownership instead of the current group"` ++ SkipChecksum bool `group:"Tarball flags" help:"Skip checksum validation of the downloaded files"` ++} ++ ++type distributionType string ++ ++const ( ++ distributionAutodetect distributionType = "autodetect" ++ distributionPackageManager distributionType = "package-manager" ++ distributionTar distributionType = "tarball" ++ distributionDocker distributionType = "docker" ++) ++ ++const versionLatest = "latest" ++ ++type packageManager int ++ ++const ( ++ dnf packageManager = iota ++ yum ++ apt ++) ++ ++type upgradeResult struct{} ++ ++// Result is a command run result. ++func (res *upgradeResult) Result() {} ++ ++// String stringifies command result. ++func (res *upgradeResult) String() string { ++ return "ok" ++} ++ ++// RunCmdWithContext runs install command. ++func (c *UpgradeCommand) RunCmdWithContext(ctx context.Context, _ *flags.GlobalFlags) (commands.Result, error) { ++ distributionType, err := c.distributionType(ctx) ++ if err != nil { ++ return nil, err ++ } ++ ++ switch distributionType { ++ case client.PackageManager: ++ err = c.upgradeViaPackageManager(ctx) ++ case client.Tarball: ++ err = c.upgradeViaTarball(ctx) ++ default: ++ logrus.Panicf("Unsupported distribution type %q", distributionType) ++ } ++ ++ if err != nil { ++ return nil, err ++ } ++ ++ return &upgradeResult{}, nil ++} ++ ++func (c *UpgradeCommand) distributionType(ctx context.Context) (client.DistributionType, error) { ++ var distType client.DistributionType ++ var err error ++ switch distributionType(c.Distribution) { ++ case distributionAutodetect: ++ distType, err = client.DetectDistributionType(ctx, c.InstallPath) ++ if err != nil { ++ return client.Unknown, err ++ } ++ case distributionPackageManager: ++ distType = client.PackageManager ++ case distributionTar: ++ distType = client.Tarball ++ case distributionDocker: ++ distType = client.Docker ++ } ++ ++ return distType, nil ++} ++ ++func (c *UpgradeCommand) upgradeViaTarball(ctx context.Context) error { ++ t := tarball.Base{ ++ InstallPath: c.InstallPath, ++ User: c.User, ++ Group: c.Group, ++ Version: c.Version, ++ SkipChecksum: c.SkipChecksum, ++ IsUpgrade: true, ++ } ++ if err := t.Install(ctx); err != nil {//nolint:revive ++ return err ++ } ++ ++ return nil ++} ++ ++func (c *UpgradeCommand) upgradeViaPackageManager(ctx context.Context) error { ++ cmds, err := c.getUpgradeCommands() ++ if err != nil { ++ return err ++ } ++ ++ for _, cmd := range cmds { ++ logrus.Infof("Running command %q", strings.Join(cmd, " ")) ++ ++ cmd := exec.CommandContext(ctx, cmd[0], cmd[1:]...) //nolint:gosec ++ cmd.Stdin = os.Stdin ++ cmd.Stdout = os.Stdout ++ cmd.Stderr = os.Stderr ++ ++ if err := cmd.Run(); err != nil { ++ return err ++ } ++ } ++ ++ return nil ++} ++ ++// ErrNoUpgradeCommandFound is returned when yum/dnf/apt/... Package manager cannot be detected. ++var ErrNoUpgradeCommandFound = fmt.Errorf("NoUpgradeCommandFound") ++ ++func (c *UpgradeCommand) getUpgradeCommands() ([][]string, error) { ++ cmd, err := common.DetectPackageManager() ++ if err != nil { ++ return nil, err ++ } ++ ++ switch cmd { ++ case common.Dnf: ++ return [][]string{ ++ {"dnf", "upgrade", "-y", fmt.Sprintf("pmm2-client%s", c.getVersionSuffix(dnf))}, ++ }, nil ++ case common.Yum: ++ return [][]string{ ++ {"yum", "upgrade", "-y", fmt.Sprintf("pmm2-client%s", c.getVersionSuffix(yum))}, ++ }, nil ++ case common.Apt: ++ return [][]string{ ++ {"percona-release", "enable", "pmm2-client", "release"}, ++ {"apt", "update"}, ++ {"apt", "install", "--only-upgrade", "-y", fmt.Sprintf("pmm2-client%s", c.getVersionSuffix(apt))}, ++ }, nil ++ case common.UnknownPackageManager: ++ return nil, fmt.Errorf("%w: cannot detect package manager (yum/dnf/apt)", ErrNoUpgradeCommandFound) ++ } ++ ++ return nil, fmt.Errorf("%w: cannot detect package manager (yum/dnf/apt)", ErrNoUpgradeCommandFound) ++} ++ ++func (c *UpgradeCommand) getVersionSuffix(pm packageManager) string { ++ if c.Version == "" || c.Version == versionLatest { ++ return "" ++ } ++ ++ switch pm { ++ case dnf: ++ return fmt.Sprintf("-%s", c.Version) ++ case yum: ++ return fmt.Sprintf("-%s", c.Version) ++ case apt: ++ return fmt.Sprintf("=%s*", c.Version) ++ } ++ ++ logrus.Panic("Invalid package manager provided") ++ return "" ++} +diff --git a/admin/cli/cli.go b/admin/cli/cli.go +index 9db76727..65dbc65b 100644 +--- a/admin/cli/cli.go ++++ b/admin/cli/cli.go +@@ -67,7 +67,7 @@ type PMMAdminCommands struct { + func (c *PMMAdminCommands) Run(ctx *kong.Context, globals *flags.GlobalFlags) error { + return run(ctx, globals) + } +- ++// GetGlobalFlags returns the global flags for PMMAdminCommands. + func (c *PMMAdminCommands) GetGlobalFlags() *flags.GlobalFlags { + return &c.GlobalFlags + } +@@ -80,7 +80,7 @@ type PMMCommands struct { + Client client.BaseCommand `cmd:"" help:"PMM client related commands"` + Completion commands.CompletionCommand `cmd:"" help:"Outputs shell code for initialising tab completions"` + } +- ++// GetGlobalFlags returns the global flags for PMMAdminCommands. + func (c *PMMCommands) GetGlobalFlags() *flags.GlobalFlags { + return &c.GlobalFlags + } +diff --git a/admin/cmd/pmm-admin/main.go b/admin/cmd/pmm-admin/main.go +index c376184e..199c4796 100644 +--- a/admin/cmd/pmm-admin/main.go ++++ b/admin/cmd/pmm-admin/main.go +@@ -11,7 +11,7 @@ + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. +- ++// Package main + package main + + import ( +diff --git a/admin/cmd/pmm/main.go b/admin/cmd/pmm/main.go +index 6800636f..d796d43b 100644 +--- a/admin/cmd/pmm/main.go ++++ b/admin/cmd/pmm/main.go +@@ -11,7 +11,7 @@ + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. +- ++// Package main + package main + + import ( +diff --git a/admin/commands/base.go b/admin/commands/base.go +index 92897899..d20c4649 100644 +--- a/admin/commands/base.go ++++ b/admin/commands/base.go +@@ -110,17 +110,17 @@ func ReadFromSource(src string) (*Credentials, error) { + + return &creds, nil + } +- ++// ErrorResponse defines the interface for error responses. + type ErrorResponse interface { + error + Code() int + } +- ++// Error represents an error with additional information. + type Error struct { + Code int `json:"code"` + Error string `json:"error"` + } +- ++// GetError converts an ErrorResponse to an Error. + func GetError(err ErrorResponse) Error { + v := reflect.ValueOf(err) + p := v.Elem().FieldByName("Payload") +@@ -130,7 +130,7 @@ func GetError(err ErrorResponse) Error { + Error: e.String(), + } + } +- ++// ParseTemplate parses the input text into a template.Template. + func ParseTemplate(text string) *template.Template { + t := template.New("").Option("missingkey=error") + return template.Must(t.Parse(strings.TrimSpace(text))) +diff --git a/admin/commands/inventory/add_agent_external_exporter.go b/admin/commands/inventory/add_agent_external_exporter.go +index 8d83d924..88cb404d 100644 +--- a/admin/commands/inventory/add_agent_external_exporter.go ++++ b/admin/commands/inventory/add_agent_external_exporter.go +@@ -59,7 +59,7 @@ type AddAgentExternalExporterCommand struct { + CustomLabels map[string]string `mapsep:"," help:"Custom user-assigned labels"` + PushMetrics bool `help:"Enables push metrics model flow, it will be sent to the server by an agent"` + } +- ++// RunCmd executes the AddAgentExternalExporterCommand and returns the result. + func (cmd *AddAgentExternalExporterCommand) RunCmd() (commands.Result, error) { + customLabels := commands.ParseCustomLabels(cmd.CustomLabels) + +diff --git a/admin/commands/inventory/add_agent_mongodb_exporter.go b/admin/commands/inventory/add_agent_mongodb_exporter.go +index fb258a39..e40f68b6 100644 +--- a/admin/commands/inventory/add_agent_mongodb_exporter.go ++++ b/admin/commands/inventory/add_agent_mongodb_exporter.go +@@ -68,7 +68,7 @@ type AddAgentMongodbExporterCommand struct { + CollectionsLimit int32 `name:"max-collections-limit" placeholder:"number" help:"Disable collstats & indexstats if there are more than collections"` //nolint:lll + LogLevel string `enum:"debug,info,warn,error,fatal" default:"warn" help:"Service logging level. One of: [debug, info, warn, error, fatal]"` + } +- ++// RunCmd executes the AddAgentMongodbExporterCommand and returns the result. + func (cmd *AddAgentMongodbExporterCommand) RunCmd() (commands.Result, error) { + customLabels := commands.ParseCustomLabels(cmd.CustomLabels) + +diff --git a/admin/commands/inventory/add_agent_mysqld_exporter.go b/admin/commands/inventory/add_agent_mysqld_exporter.go +index 0753670a..b18271a3 100644 +--- a/admin/commands/inventory/add_agent_mysqld_exporter.go ++++ b/admin/commands/inventory/add_agent_mysqld_exporter.go +@@ -100,7 +100,7 @@ type AddAgentMysqldExporterCommand struct { + DisableCollectors []string `help:"Comma-separated list of collector names to exclude from exporter"` + LogLevel string `enum:"debug,info,warn,error" default:"warn" help:"Service logging level. One of: [debug, info, warn, error]"` + } +- ++// RunCmd executes the AddAgentMysqldExporterCommand and returns the result. + func (cmd *AddAgentMysqldExporterCommand) RunCmd() (commands.Result, error) { + customLabels := commands.ParseCustomLabels(cmd.CustomLabels) + +diff --git a/admin/commands/inventory/add_agent_node_exporter.go b/admin/commands/inventory/add_agent_node_exporter.go +index 0e8f4f3e..9f5e0d26 100644 +--- a/admin/commands/inventory/add_agent_node_exporter.go ++++ b/admin/commands/inventory/add_agent_node_exporter.go +@@ -50,7 +50,7 @@ type AddAgentNodeExporterCommand struct { + DisableCollectors []string `help:"Comma-separated list of collector names to exclude from exporter"` + LogLevel string `enum:"debug,info,warn,error" default:"warn" help:"Service logging level. One of: [debug, info, warn, error]"` + } +- ++// RunCmd runs the command for AddAgentNodeExporterCommand. + func (cmd *AddAgentNodeExporterCommand) RunCmd() (commands.Result, error) { + customLabels := commands.ParseCustomLabels(cmd.CustomLabels) + params := &agents.AddNodeExporterParams{ +diff --git a/admin/commands/inventory/add_agent_pmm_agent.go b/admin/commands/inventory/add_agent_pmm_agent.go +index df8057e7..f27bf553 100644 +--- a/admin/commands/inventory/add_agent_pmm_agent.go ++++ b/admin/commands/inventory/add_agent_pmm_agent.go +@@ -43,7 +43,7 @@ type AddPMMAgentCommand struct { + RunsOnNodeID string `arg:"" help:"Node identifier where this instance runs"` + CustomLabels map[string]string `mapsep:"," help:"Custom user-assigned labels"` + } +- ++// RunCmd executes the AddPMMAgentCommand and returns the result. + func (cmd *AddPMMAgentCommand) RunCmd() (commands.Result, error) { + customLabels := commands.ParseCustomLabels(cmd.CustomLabels) + params := &agents.AddPMMAgentParams{ +diff --git a/admin/commands/inventory/add_agent_postgres_exporter.go b/admin/commands/inventory/add_agent_postgres_exporter.go +index 0ee39234..134a9d84 100644 +--- a/admin/commands/inventory/add_agent_postgres_exporter.go ++++ b/admin/commands/inventory/add_agent_postgres_exporter.go +@@ -67,7 +67,7 @@ type AddAgentPostgresExporterCommand struct { + LogLevel string `enum:"debug,info,warn,error" default:"warn" help:"Service logging level. One of: [debug, info, warn, error]"` + AutoDiscoveryLimit int32 `default:"0" placeholder:"NUMBER" help:"Auto-discovery will be disabled if there are more than that number of databases (default: server-defined, -1: always disabled)"` + } +- ++// RunCmd executes the AddAgentPostgresExporterCommand and returns the result. + func (cmd *AddAgentPostgresExporterCommand) RunCmd() (commands.Result, error) { + customLabels := commands.ParseCustomLabels(cmd.CustomLabels) + +diff --git a/admin/commands/inventory/add_agent_proxysql_exporter.go b/admin/commands/inventory/add_agent_proxysql_exporter.go +index d0e53aa7..5a356b74 100644 +--- a/admin/commands/inventory/add_agent_proxysql_exporter.go ++++ b/admin/commands/inventory/add_agent_proxysql_exporter.go +@@ -61,7 +61,7 @@ type AddAgentProxysqlExporterCommand struct { + DisableCollectors []string `help:"Comma-separated list of collector names to exclude from exporter"` + LogLevel string `enum:"debug,info,warn,error,fatal" default:"warn" help:"Service logging level. One of: [debug, info, warn, error, fatal]"` + } +- ++// RunCmd executes the AddAgentProxysqlExporterCommand and returns the result. + func (cmd *AddAgentProxysqlExporterCommand) RunCmd() (commands.Result, error) { + customLabels := commands.ParseCustomLabels(cmd.CustomLabels) + params := &agents.AddProxySQLExporterParams{ +diff --git a/admin/commands/inventory/add_agent_qan_mongodb_profiler_agent.go b/admin/commands/inventory/add_agent_qan_mongodb_profiler_agent.go +index 22fbd3da..47626ecb 100644 +--- a/admin/commands/inventory/add_agent_qan_mongodb_profiler_agent.go ++++ b/admin/commands/inventory/add_agent_qan_mongodb_profiler_agent.go +@@ -64,7 +64,7 @@ type AddAgentQANMongoDBProfilerAgentCommand struct { + AuthenticationMechanism string `help:"Authentication mechanism. Default is empty. Use MONGODB-X509 for ssl certificates"` + LogLevel string `enum:"debug,info,warn,error,fatal" default:"warn" help:"Service logging level. One of: [debug, info, warn, error, fatal]"` + } +- ++// RunCmd executes the AddAgentQANMongoDBProfilerAgentCommand and returns the result. + func (cmd *AddAgentQANMongoDBProfilerAgentCommand) RunCmd() (commands.Result, error) { + customLabels := commands.ParseCustomLabels(cmd.CustomLabels) + +diff --git a/admin/commands/inventory/add_agent_qan_mysql_perfschema_agent.go b/admin/commands/inventory/add_agent_qan_mysql_perfschema_agent.go +index 82492ad3..d1924fbf 100644 +--- a/admin/commands/inventory/add_agent_qan_mysql_perfschema_agent.go ++++ b/admin/commands/inventory/add_agent_qan_mysql_perfschema_agent.go +@@ -70,7 +70,7 @@ type AddAgentQANMySQLPerfSchemaAgentCommand struct { + TLSKeyFile string `name:"tls-key" help:"Path to client key file"` + LogLevel string `enum:"debug,info,warn,error,fatal" default:"warn" help:"Service logging level. One of: [debug, info, warn, error, fatal]"` + } +- ++// RunCmd runs the command for AddAgentQANMySQLPerfSchemaAgentCommand. + func (cmd *AddAgentQANMySQLPerfSchemaAgentCommand) RunCmd() (commands.Result, error) { + customLabels := commands.ParseCustomLabels(cmd.CustomLabels) + +diff --git a/admin/commands/inventory/add_agent_qan_mysql_slowlog_agent.go b/admin/commands/inventory/add_agent_qan_mysql_slowlog_agent.go +index 1ca83e9b..2e645093 100644 +--- a/admin/commands/inventory/add_agent_qan_mysql_slowlog_agent.go ++++ b/admin/commands/inventory/add_agent_qan_mysql_slowlog_agent.go +@@ -83,7 +83,7 @@ type AddAgentQANMySQLSlowlogAgentCommand struct { + TLSKeyFile string `name:"tls-key" help:"Path to client key file"` + LogLevel string `enum:"debug,info,warn,error,fatal" default:"warn" help:"Service logging level. One of: [debug, info, warn, error, fatal]"` + } +- ++// RunCmd executes the AddAgentQANMySQLSlowlogAgentCommand and returns the result. + func (cmd *AddAgentQANMySQLSlowlogAgentCommand) RunCmd() (commands.Result, error) { + customLabels := commands.ParseCustomLabels(cmd.CustomLabels) + +diff --git a/admin/commands/inventory/add_agent_qan_postgres_pgstatements_agent.go b/admin/commands/inventory/add_agent_qan_postgres_pgstatements_agent.go +index 8800accb..4827f9df 100644 +--- a/admin/commands/inventory/add_agent_qan_postgres_pgstatements_agent.go ++++ b/admin/commands/inventory/add_agent_qan_postgres_pgstatements_agent.go +@@ -61,7 +61,7 @@ type AddAgentQANPostgreSQLPgStatementsAgentCommand struct { + TLSKeyFile string `help:"TLS certificate key file"` + LogLevel string `enum:"debug,info,warn,error,fatal" default:"warn" help:"Service logging level. One of: [debug, info, warn, error, fatal]"` + } +- ++// RunCmd executes the AddAgentQANPostgreSQLPgStatementsAgentCommand and returns the result. + func (cmd *AddAgentQANPostgreSQLPgStatementsAgentCommand) RunCmd() (commands.Result, error) { + customLabels := commands.ParseCustomLabels(cmd.CustomLabels) + +diff --git a/admin/commands/inventory/add_agent_qan_postgres_pgstatmonitor_agent.go b/admin/commands/inventory/add_agent_qan_postgres_pgstatmonitor_agent.go +index 53df775c..1713f647 100644 +--- a/admin/commands/inventory/add_agent_qan_postgres_pgstatmonitor_agent.go ++++ b/admin/commands/inventory/add_agent_qan_postgres_pgstatmonitor_agent.go +@@ -63,7 +63,7 @@ type AddAgentQANPostgreSQLPgStatMonitorAgentCommand struct { + TLSKeyFile string `help:"TLS certificate key file"` + LogLevel string `enum:"debug,info,warn,error,fatal" default:"warn" help:"Service logging level. One of: [debug, info, warn, error, fatal]"` + } +- ++// RunCmd runs the command for AddAgentQANPostgreSQLPgStatMonitorAgentCommand. + func (cmd *AddAgentQANPostgreSQLPgStatMonitorAgentCommand) RunCmd() (commands.Result, error) { + customLabels := commands.ParseCustomLabels(cmd.CustomLabels) + +diff --git a/admin/commands/inventory/add_agent_rds_exporter.go b/admin/commands/inventory/add_agent_rds_exporter.go +index 5d694ec7..b53329c9 100644 +--- a/admin/commands/inventory/add_agent_rds_exporter.go ++++ b/admin/commands/inventory/add_agent_rds_exporter.go +@@ -57,7 +57,7 @@ type AddAgentRDSExporterCommand struct { + PushMetrics bool `help:"Enables push metrics model flow, it will be sent to the server by an agent"` + LogLevel string `enum:"debug,info,warn,error,fatal" default:"warn" help:"Service logging level. One of: [debug, info, warn, error, fatal]"` + } +- ++// RunCmd executes the AddAgentRDSExporterCommand and returns the result. + func (cmd *AddAgentRDSExporterCommand) RunCmd() (commands.Result, error) { + customLabels := commands.ParseCustomLabels(cmd.CustomLabels) + params := &agents.AddRDSExporterParams{ +diff --git a/admin/commands/inventory/add_node_container.go b/admin/commands/inventory/add_node_container.go +index 18fabfe1..fd27c8ac 100644 +--- a/admin/commands/inventory/add_node_container.go ++++ b/admin/commands/inventory/add_node_container.go +@@ -57,7 +57,7 @@ type AddNodeContainerCommand struct { + Az string `help:"Node availability zone"` + NodeModel string `help:"Node model"` + } +- ++// RunCmd executes the AddNodeContainerCommand and returns the result. + func (cmd *AddNodeContainerCommand) RunCmd() (commands.Result, error) { + customLabels := commands.ParseCustomLabels(cmd.CustomLabels) + params := &nodes.AddContainerNodeParams{ +diff --git a/admin/commands/inventory/add_node_generic.go b/admin/commands/inventory/add_node_generic.go +index 6bd51dc1..2faaf2d1 100644 +--- a/admin/commands/inventory/add_node_generic.go ++++ b/admin/commands/inventory/add_node_generic.go +@@ -56,7 +56,7 @@ type AddNodeGenericCommand struct { + Az string `help:"Node availability zone"` + NodeModel string `help:"Node mddel"` + } +- ++// RunCmd executes the AddNodeGenericCommand and returns the result. + func (cmd *AddNodeGenericCommand) RunCmd() (commands.Result, error) { + customLabels := commands.ParseCustomLabels(cmd.CustomLabels) + params := &nodes.AddGenericNodeParams{ +diff --git a/admin/commands/inventory/add_node_remote.go b/admin/commands/inventory/add_node_remote.go +index 38fef755..22991f45 100644 +--- a/admin/commands/inventory/add_node_remote.go ++++ b/admin/commands/inventory/add_node_remote.go +@@ -50,7 +50,7 @@ type AddNodeRemoteCommand struct { + Region string `help:"Node region"` + Az string `help:"Node availability zone"` + } +- ++// RunCmd executes the AddNodeRemoteCommand and returns the result. + func (cmd *AddNodeRemoteCommand) RunCmd() (commands.Result, error) { + customLabels := commands.ParseCustomLabels(cmd.CustomLabels) + params := &nodes.AddRemoteNodeParams{ +diff --git a/admin/commands/inventory/add_node_remote_rds.go b/admin/commands/inventory/add_node_remote_rds.go +index fb045bfb..b656ba35 100644 +--- a/admin/commands/inventory/add_node_remote_rds.go ++++ b/admin/commands/inventory/add_node_remote_rds.go +@@ -52,7 +52,7 @@ type AddNodeRemoteRDSCommand struct { + Az string `help:"Node availability zone"` + CustomLabels map[string]string `mapsep:"," help:"Custom user-assigned labels"` + } +- ++// RunCmd executes the AddNodeRemoteRDSCommand and returns the result. + func (cmd *AddNodeRemoteRDSCommand) RunCmd() (commands.Result, error) { + customLabels := commands.ParseCustomLabels(cmd.CustomLabels) + params := &nodes.AddRemoteRDSNodeParams{ +diff --git a/admin/commands/inventory/add_service_external.go b/admin/commands/inventory/add_service_external.go +index 4b957148..2477fe3b 100644 +--- a/admin/commands/inventory/add_service_external.go ++++ b/admin/commands/inventory/add_service_external.go +@@ -52,7 +52,7 @@ type AddServiceExternalCommand struct { + CustomLabels map[string]string `mapsep:"," help:"Custom user-assigned labels"` + Group string `help:"Group name of external service"` + } +- ++// RunCmd executes the AddServiceExternalCommand and returns the result. + func (cmd *AddServiceExternalCommand) RunCmd() (commands.Result, error) { + customLabels := commands.ParseCustomLabels(cmd.CustomLabels) + +diff --git a/admin/commands/inventory/add_service_haproxy.go b/admin/commands/inventory/add_service_haproxy.go +index a7fd48b9..b0729caf 100644 +--- a/admin/commands/inventory/add_service_haproxy.go ++++ b/admin/commands/inventory/add_service_haproxy.go +@@ -51,7 +51,7 @@ type AddServiceHAProxyCommand struct { + ReplicationSet string `placeholder:"rs1" help:"Replication set name"` + CustomLabels map[string]string `mapsep:"," help:"Custom user-assigned labels"` + } +- ++// RunCmd executes the AddServiceHAProxyCommand and returns the result. + func (cmd *AddServiceHAProxyCommand) RunCmd() (commands.Result, error) { + isSupported, err := helpers.IsHAProxySupported() + if !isSupported { +diff --git a/admin/commands/inventory/add_service_mongodb.go b/admin/commands/inventory/add_service_mongodb.go +index 33143249..27608a5c 100644 +--- a/admin/commands/inventory/add_service_mongodb.go ++++ b/admin/commands/inventory/add_service_mongodb.go +@@ -59,7 +59,7 @@ type AddServiceMongoDBCommand struct { + ReplicationSet string `help:"Replication set name"` + CustomLabels map[string]string `mapsep:"," help:"Custom user-assigned labels"` + } +- ++// RunCmd executes the AddServiceMongoDBCommand and returns the result. + func (cmd *AddServiceMongoDBCommand) RunCmd() (commands.Result, error) { + customLabels := commands.ParseCustomLabels(cmd.CustomLabels) + params := &services.AddMongoDBServiceParams{ +diff --git a/admin/commands/inventory/add_service_mysql.go b/admin/commands/inventory/add_service_mysql.go +index ad05f1f0..6ce60032 100644 +--- a/admin/commands/inventory/add_service_mysql.go ++++ b/admin/commands/inventory/add_service_mysql.go +@@ -59,7 +59,7 @@ type AddServiceMySQLCommand struct { + ReplicationSet string `help:"Replication set name"` + CustomLabels map[string]string `mapsep:"," help:"Custom user-assigned labels"` + } +- ++// RunCmd runs the command for AddServiceMySQLCommand. + func (cmd *AddServiceMySQLCommand) RunCmd() (commands.Result, error) { + customLabels := commands.ParseCustomLabels(cmd.CustomLabels) + params := &services.AddMySQLServiceParams{ +diff --git a/admin/commands/inventory/add_service_postgresql.go b/admin/commands/inventory/add_service_postgresql.go +index 992c3883..d08826c8 100644 +--- a/admin/commands/inventory/add_service_postgresql.go ++++ b/admin/commands/inventory/add_service_postgresql.go +@@ -59,7 +59,7 @@ type AddServicePostgreSQLCommand struct { + ReplicationSet string `help:"Replication set name"` + CustomLabels map[string]string `mapsep:"," help:"Custom user-assigned labels"` + } +- ++// RunCmd executes the AddServicePostgreSQLCommand and returns the result. + func (cmd *AddServicePostgreSQLCommand) RunCmd() (commands.Result, error) { + customLabels := commands.ParseCustomLabels(cmd.CustomLabels) + +diff --git a/admin/commands/inventory/add_service_proxysql.go b/admin/commands/inventory/add_service_proxysql.go +index 60f50ea6..086806a8 100644 +--- a/admin/commands/inventory/add_service_proxysql.go ++++ b/admin/commands/inventory/add_service_proxysql.go +@@ -59,7 +59,7 @@ type AddServiceProxySQLCommand struct { + ReplicationSet string `help:"Replication set name"` + CustomLabels map[string]string `mapsep:"," help:"Custom user-assigned labels"` + } +- ++// RunCmd executes the AddServiceProxySQLCommand and returns the result. + func (cmd *AddServiceProxySQLCommand) RunCmd() (commands.Result, error) { + customLabels := commands.ParseCustomLabels(cmd.CustomLabels) + params := &services.AddProxySQLServiceParams{ +diff --git a/admin/commands/inventory/inventory.go b/admin/commands/inventory/inventory.go +index 8de367d9..c492b2b5 100644 +--- a/admin/commands/inventory/inventory.go ++++ b/admin/commands/inventory/inventory.go +@@ -22,7 +22,7 @@ import ( + ) + + // InventoryCommand is used by Kong for CLI flags and commands. +-type InventoryCommand struct { ++type InventoryCommand struct {//nolint:revive + List ListCommand `cmd:"" help:"List inventory commands"` + Add AddCommand `cmd:"" help:"Add to inventory commands"` + Remove RemoveCommand `cmd:"" help:"Remove from inventory commands"` +diff --git a/admin/commands/inventory/list_agents.go b/admin/commands/inventory/list_agents.go +index 22ffc6da..77708638 100644 +--- a/admin/commands/inventory/list_agents.go ++++ b/admin/commands/inventory/list_agents.go +@@ -100,7 +100,7 @@ type ListAgentsCommand struct { + NodeID string `help:"Filter by Node identifier"` + AgentType string `help:"Filter by Agent type"` + } +- ++// RunCmd executes the ListAgentsCommand and returns the result. + func (cmd *ListAgentsCommand) RunCmd() (commands.Result, error) { + agentType, err := formatTypeValue(acceptableAgentTypes, cmd.AgentType) + if err != nil { +diff --git a/admin/commands/inventory/list_nodes.go b/admin/commands/inventory/list_nodes.go +index e9febcd0..be451cea 100644 +--- a/admin/commands/inventory/list_nodes.go ++++ b/admin/commands/inventory/list_nodes.go +@@ -62,7 +62,7 @@ func (res *listNodesResult) String() string { + type ListNodesCommand struct { + NodeType string `help:"Filter by Node type"` + } +- ++// RunCmd executes the ListNodesCommand and returns the result. + func (cmd *ListNodesCommand) RunCmd() (commands.Result, error) { + nodeType, err := formatTypeValue(acceptableNodeTypes, cmd.NodeType) + if err != nil { +diff --git a/admin/commands/inventory/list_services.go b/admin/commands/inventory/list_services.go +index d3808fb8..13551aec 100644 +--- a/admin/commands/inventory/list_services.go ++++ b/admin/commands/inventory/list_services.go +@@ -77,7 +77,7 @@ type ListServicesCommand struct { + ServiceType string `help:"Filter by Service type"` + ExternalGroup string `help:"Filter by external group"` + } +- ++// RunCmd executes the ListServicesCommand and returns the result. + func (cmd *ListServicesCommand) RunCmd() (commands.Result, error) { + serviceType, err := formatTypeValue(acceptableServiceTypes, cmd.ServiceType) + if err != nil { +diff --git a/admin/commands/inventory/remove_agent.go b/admin/commands/inventory/remove_agent.go +index ff04ba8c..3b8b4912 100644 +--- a/admin/commands/inventory/remove_agent.go ++++ b/admin/commands/inventory/remove_agent.go +@@ -37,7 +37,7 @@ type RemoveAgentCommand struct { + AgentID string `arg:"" optional:"" help:"Agent ID"` + Force bool `help:"Remove agent with all dependencies"` + } +- ++// RunCmd executes the RemoveAgentCommand and returns the result. + func (cmd *RemoveAgentCommand) RunCmd() (commands.Result, error) { + params := &agents.RemoveAgentParams{ + Body: agents.RemoveAgentBody{ +diff --git a/admin/commands/inventory/remove_node.go b/admin/commands/inventory/remove_node.go +index 6184a597..58223734 100644 +--- a/admin/commands/inventory/remove_node.go ++++ b/admin/commands/inventory/remove_node.go +@@ -37,7 +37,7 @@ type RemoveNodeCommand struct { + NodeID string `arg:"" optional:"" help:"Node ID"` + Force bool `help:"Remove node with all dependencies"` + } +- ++// RunCmd runs the command for RemoveNodeCommand. + func (cmd *RemoveNodeCommand) RunCmd() (commands.Result, error) { + params := &nodes.RemoveNodeParams{ + Body: nodes.RemoveNodeBody{ +diff --git a/admin/commands/inventory/remove_service.go b/admin/commands/inventory/remove_service.go +index 551a28ca..52bca44c 100644 +--- a/admin/commands/inventory/remove_service.go ++++ b/admin/commands/inventory/remove_service.go +@@ -37,7 +37,7 @@ type RemoveServiceCommand struct { + ServiceID string `arg:"" optional:"" help:"Service ID"` + Force bool `help:"Remove service with all dependencies"` + } +- ++// RunCmd executes the RemoveServiceCommand and returns the result. + func (cmd *RemoveServiceCommand) RunCmd() (commands.Result, error) { + params := &services.RemoveServiceParams{ + Body: services.RemoveServiceBody{ +diff --git a/admin/commands/list.go b/admin/commands/list.go +index 10e145c0..616ede1c 100644 +--- a/admin/commands/list.go ++++ b/admin/commands/list.go +@@ -122,7 +122,7 @@ func convertTabs(template string) (string, error) { + type ListCommand struct { + NodeID string `help:"Node ID (default is autodetected)"` + } +- ++// RunCmd executes the List command and returns the result. + func (cmd *ListCommand) RunCmd() (Result, error) { + if cmd.NodeID == "" { + status, err := agentlocal.GetStatus(agentlocal.DoNotRequestNetworkInfo) +diff --git a/admin/commands/management/add_external.go b/admin/commands/management/add_external.go +index 0b9ee64f..dd7c2979 100644 +--- a/admin/commands/management/add_external.go ++++ b/admin/commands/management/add_external.go +@@ -72,7 +72,7 @@ type AddExternalCommand struct { + Group string `default:"${externalDefaultGroupExporter}" help:"Group name of external service (default: ${externalDefaultGroupExporter})"` + SkipConnectionCheck bool `help:"Skip exporter connection checks"` + } +- ++// GetCredentials returns the credentials for AddExternalCommand. + func (cmd *AddExternalCommand) GetCredentials() error { + creds, err := commands.ReadFromSource(cmd.CredentialsSource) + if err != nil { +@@ -84,7 +84,7 @@ func (cmd *AddExternalCommand) GetCredentials() error { + + return nil + } +- ++// RunCmd runs the command for AddExternalCommand. + func (cmd *AddExternalCommand) RunCmd() (commands.Result, error) { + customLabels := commands.ParseCustomLabels(cmd.CustomLabels) + +diff --git a/admin/commands/management/add_external_serverless.go b/admin/commands/management/add_external_serverless.go +index f7a7d08c..2d4f54dd 100644 +--- a/admin/commands/management/add_external_serverless.go ++++ b/admin/commands/management/add_external_serverless.go +@@ -87,7 +87,7 @@ if you specify --host you must provide all other parameters needed to build the + or even you can specify --address instead of host and port as individual parameters. + ` + } +- ++// GetCredentials returns the credentials for AddExternalServerlessCommand. + func (cmd *AddExternalServerlessCommand) GetCredentials() error { + creds, err := commands.ReadFromSource(cmd.CredentialsSource) + if err != nil { +@@ -99,7 +99,7 @@ func (cmd *AddExternalServerlessCommand) GetCredentials() error { + + return nil + } +- ++// RunCmd runs the command for AddExternalServerlessCommand. + func (cmd *AddExternalServerlessCommand) RunCmd() (commands.Result, error) { + customLabels := commands.ParseCustomLabels(cmd.CustomLabels) + +diff --git a/admin/commands/management/add_haproxy.go b/admin/commands/management/add_haproxy.go +index b6e7c556..6b829a89 100644 +--- a/admin/commands/management/add_haproxy.go ++++ b/admin/commands/management/add_haproxy.go +@@ -62,7 +62,7 @@ type AddHAProxyCommand struct { + MetricsMode string `enum:"${metricsModesEnum}" default:"auto" help:"Metrics flow mode, can be push - agent will push metrics, pull - server scrape metrics from agent or auto - chosen by server"` + SkipConnectionCheck bool `help:"Skip connection check"` + } +- ++// GetCredentials returns the credentials for AddHAProxyCommand. + func (cmd *AddHAProxyCommand) GetCredentials() error { + creds, err := commands.ReadFromSource(cmd.CredentialsSource) + if err != nil { +@@ -74,7 +74,7 @@ func (cmd *AddHAProxyCommand) GetCredentials() error { + + return nil + } +- ++// RunCmd runs the command for AddHAProxyCommand. + func (cmd *AddHAProxyCommand) RunCmd() (commands.Result, error) { + isSupported, err := helpers.IsHAProxySupported() + if !isSupported { +diff --git a/admin/commands/management/add_mongodb.go b/admin/commands/management/add_mongodb.go +index 1d9fa14b..5369eb51 100644 +--- a/admin/commands/management/add_mongodb.go ++++ b/admin/commands/management/add_mongodb.go +@@ -87,23 +87,23 @@ type AddMongoDBCommand struct { + AddCommonFlags + AddLogLevelFatalFlags + } +- ++// GetServiceName returns the service name for AddMongoDBCommand. + func (cmd *AddMongoDBCommand) GetServiceName() string { + return cmd.ServiceName + } +- ++// GetAddress returns the address for AddMongoDBCommand. + func (cmd *AddMongoDBCommand) GetAddress() string { + return cmd.Address + } +- ++// GetDefaultAddress returns the default address for AddMongoDBCommand. + func (cmd *AddMongoDBCommand) GetDefaultAddress() string { + return "127.0.0.1:27017" + } +- ++// GetSocket returns the socket for AddMongoDBCommand. + func (cmd *AddMongoDBCommand) GetSocket() string { + return cmd.Socket + } +- ++// GetCredentials returns the credentials for AddMongoDBCommand. + func (cmd *AddMongoDBCommand) GetCredentials() error { + creds, err := commands.ReadFromSource(cmd.CredentialsSource) + if err != nil { +@@ -116,7 +116,7 @@ func (cmd *AddMongoDBCommand) GetCredentials() error { + + return nil + } +- ++// RunCmd runs the command for AddMongoDBCommand. + func (cmd *AddMongoDBCommand) RunCmd() (commands.Result, error) { + customLabels := commands.ParseCustomLabels(cmd.CustomLabels) + +diff --git a/admin/commands/management/add_mysql.go b/admin/commands/management/add_mysql.go +index 79a5820d..91f074b9 100644 +--- a/admin/commands/management/add_mysql.go ++++ b/admin/commands/management/add_mysql.go +@@ -125,23 +125,23 @@ type AddMySQLCommand struct { + AddCommonFlags + AddLogLevelNoFatalFlags + } +- ++// GetServiceName returns the service name for AddMySQLCommand. + func (cmd *AddMySQLCommand) GetServiceName() string { + return cmd.ServiceName + } +- ++// GetAddress returns the address for AddMySQLCommand. + func (cmd *AddMySQLCommand) GetAddress() string { + return cmd.Address + } +- ++// GetDefaultAddress returns the default address for AddMySQLCommand. + func (cmd *AddMySQLCommand) GetDefaultAddress() string { + return "127.0.0.1:3306" + } +- ++// GetSocket returns the socket for AddMySQLCommand. + func (cmd *AddMySQLCommand) GetSocket() string { + return cmd.Socket + } +- ++// RunCmd runs the command for AddMySQLCommand + func (cmd *AddMySQLCommand) RunCmd() (commands.Result, error) { + customLabels := commands.ParseCustomLabels(cmd.CustomLabels) + +diff --git a/admin/commands/management/add_postgresql.go b/admin/commands/management/add_postgresql.go +index e2fc461e..ecab8d7b 100644 +--- a/admin/commands/management/add_postgresql.go ++++ b/admin/commands/management/add_postgresql.go +@@ -79,23 +79,23 @@ type AddPostgreSQLCommand struct { + AddCommonFlags + AddLogLevelNoFatalFlags + } +- ++// GetServiceName returns the service name for AddPostgreSQLCommand. + func (cmd *AddPostgreSQLCommand) GetServiceName() string { + return cmd.ServiceName + } +- ++// GetAddress returns the address for AddPostgreSQLCommand. + func (cmd *AddPostgreSQLCommand) GetAddress() string { + return cmd.Address + } +- ++// GetDefaultAddress returns the default address for AddPostgreSQLCommand. + func (cmd *AddPostgreSQLCommand) GetDefaultAddress() string { + return "127.0.0.1:5432" + } +- ++// GetSocket returns the socket for AddPostgreSQLCommand + func (cmd *AddPostgreSQLCommand) GetSocket() string { + return cmd.Socket + } +- ++// GetCredentials returns the credentials for AddPostgreSQLCommand. + func (cmd *AddPostgreSQLCommand) GetCredentials() error { + creds, err := commands.ReadFromSource(cmd.CredentialsSource) + if err != nil { +@@ -108,7 +108,7 @@ func (cmd *AddPostgreSQLCommand) GetCredentials() error { + + return nil + } +- ++// RunCmd runs the command for AddPostgreSQLCommand. + func (cmd *AddPostgreSQLCommand) RunCmd() (commands.Result, error) { + customLabels := commands.ParseCustomLabels(cmd.CustomLabels) + +diff --git a/admin/commands/management/add_proxysql.go b/admin/commands/management/add_proxysql.go +index 5f3da141..c508df95 100644 +--- a/admin/commands/management/add_proxysql.go ++++ b/admin/commands/management/add_proxysql.go +@@ -69,23 +69,23 @@ type AddProxySQLCommand struct { + AddCommonFlags + AddLogLevelFatalFlags + } +- ++// GetServiceName returns the service name for AddProxySQLCommand. + func (cmd *AddProxySQLCommand) GetServiceName() string { + return cmd.ServiceName + } +- ++// GetAddress returns the address for AddProxySQLCommand. + func (cmd *AddProxySQLCommand) GetAddress() string { + return cmd.Address + } +- ++// GetDefaultAddress returns the default address for AddProxySQLCommand. + func (cmd *AddProxySQLCommand) GetDefaultAddress() string { + return "127.0.0.1:6032" + } +- ++// GetSocket returns the socket for AddProxySQLCommand. + func (cmd *AddProxySQLCommand) GetSocket() string { + return cmd.Socket + } +- ++// GetCredentials returns the credentials for AddProxySQLCommand. + func (cmd *AddProxySQLCommand) GetCredentials() error { + creds, err := commands.ReadFromSource(cmd.CredentialsSource) + if err != nil { +@@ -98,7 +98,7 @@ func (cmd *AddProxySQLCommand) GetCredentials() error { + + return nil + } +- ++// RunCmd runs the command for AddProxySQLCommand. + func (cmd *AddProxySQLCommand) RunCmd() (commands.Result, error) { + customLabels := commands.ParseCustomLabels(cmd.CustomLabels) + +diff --git a/admin/commands/management/register.go b/admin/commands/management/register.go +index b075eb53..d1df03e1 100644 +--- a/admin/commands/management/register.go ++++ b/admin/commands/management/register.go +@@ -66,7 +66,7 @@ type RegisterCommand struct { + MetricsMode string `enum:"${metricsModesEnum}" default:"auto" help:"Metrics flow mode, can be push - agent will push metrics, pull - server scrape metrics from agent or auto - chosen by server"` + DisableCollectors []string `help:"Comma-separated list of collector names to exclude from exporter"` + } +- ++// RunCmd runs the command for RegisterCommand. + func (cmd *RegisterCommand) RunCmd() (commands.Result, error) { + customLabels := commands.ParseCustomLabels(cmd.CustomLabels) + +diff --git a/admin/commands/management/remove.go b/admin/commands/management/remove.go +index 94b1107e..98871df1 100644 +--- a/admin/commands/management/remove.go ++++ b/admin/commands/management/remove.go +@@ -43,7 +43,7 @@ type RemoveCommand struct { + ServiceName string `arg:"" default:"" help:"Service name"` + ServiceID string `help:"Service ID"` + } +- ++// RunCmd runs the command for RemoveCommand. + func (cmd *RemoveCommand) RunCmd() (commands.Result, error) { + if cmd.ServiceID == "" && cmd.ServiceName == "" { + // Automatic service lookup during removal +diff --git a/admin/commands/management/unregister.go b/admin/commands/management/unregister.go +index 7632b344..09990193 100644 +--- a/admin/commands/management/unregister.go ++++ b/admin/commands/management/unregister.go +@@ -44,7 +44,7 @@ type UnregisterCommand struct { + Force bool `help:"Remove this node with all dependencies"` + NodeName string `help:"Node name (autodetected default: ${hostname})"` + } +- ++// RunCmd runs the command for UnregisterCommand. + func (cmd *UnregisterCommand) RunCmd() (commands.Result, error) { + var nodeName string + var nodeID string +diff --git a/admin/commands/pmm/client/upgrade.go b/admin/commands/pmm/client/upgrade.go +index b61c39c5..9ef37dce 100644 +--- a/admin/commands/pmm/client/upgrade.go ++++ b/admin/commands/pmm/client/upgrade.go +@@ -122,7 +122,7 @@ func (c *UpgradeCommand) upgradeViaTarball(ctx context.Context) error { + SkipChecksum: c.SkipChecksum, + IsUpgrade: true, + } +- if err := t.Install(ctx); err != nil { ++ if err := t.Install(ctx); err != nil {//nolint:revive + return err + } + +diff --git a/admin/commands/pmm/server/docker/base.go b/admin/commands/pmm/server/docker/base.go +index 32a16a82..30223353 100644 +--- a/admin/commands/pmm/server/docker/base.go ++++ b/admin/commands/pmm/server/docker/base.go +@@ -69,7 +69,7 @@ func installDocker(ctx context.Context, dockerFn Functions) error { + } + + logrus.Infoln("Installing Docker") +- if err = dockerFn.InstallDocker(ctx); err != nil { ++ if err = dockerFn.InstallDocker(ctx); err != nil {//nolint:revive + return err + } + +diff --git a/admin/commands/pmm/server/docker/upgrade.go b/admin/commands/pmm/server/docker/upgrade.go +index c8ce3a41..b7e54ecf 100644 +--- a/admin/commands/pmm/server/docker/upgrade.go ++++ b/admin/commands/pmm/server/docker/upgrade.go +@@ -74,7 +74,7 @@ func (u *upgradeResult) String() string { + } + + // RunCmdWithContext runs upgrade command. +-func (c *UpgradeCommand) RunCmdWithContext(ctx context.Context, globals *flags.GlobalFlags) (commands.Result, error) { //nolint:unparam ++func (c *UpgradeCommand) RunCmdWithContext(ctx context.Context, globals *flags.GlobalFlags) (commands.Result, error) { //nolint:unparam,revive + logrus.Info("Starting PMM Server upgrade via Docker") + + d, err := prepareDocker(ctx, c.dockerFn, prepareOpts{install: false}) +diff --git a/admin/commands/status.go b/admin/commands/status.go +index b46281f0..9395cb12 100644 +--- a/admin/commands/status.go ++++ b/admin/commands/status.go +@@ -127,7 +127,7 @@ func (cmd *StatusCommand) RunCmd() (Result, error) { + return newStatusResult(status), nil + } + +- return nil, errors.Errorf("Failed to get PMM Agent status from local pmm-agent: %s.", err) //nolint:golint ++ return nil, errors.Errorf("Failed to get PMM Agent status from local pmm-agent: %s.", err) //nolint:golint,revive + default: + time.Sleep(1 * time.Second) + } +diff --git a/agent/agentlocal/agent_local.go b/agent/agentlocal/agent_local.go +index d23f2a82..b4adb321 100644 +--- a/agent/agentlocal/agent_local.go ++++ b/agent/agentlocal/agent_local.go +@@ -365,7 +365,7 @@ func addData(zipW *zip.Writer, name string, data []byte) error { + } + + // ZipLogs Handle function for generate zip file with logs. +-func (s *Server) ZipLogs(w http.ResponseWriter, r *http.Request) { ++func (s *Server) ZipLogs(w http.ResponseWriter, r *http.Request) {//nolint:revive + zipBuffer := &bytes.Buffer{} + zipWriter := zip.NewWriter(zipBuffer) + +diff --git a/agent/agents/agents_test.go b/agent/agents/agents_test.go +index 49a11eca..60eb612b 100644 +--- a/agent/agents/agents_test.go ++++ b/agent/agents/agents_test.go +@@ -15,7 +15,7 @@ + package agents + + import "testing" +- ++// TestAgents is a test function for the Agents module. + func TestAgents(t *testing.T) { + // we need at least one test per package to correctly calculate coverage + } +diff --git a/agent/runner/jobs/mysql_restore_job.go b/agent/runner/jobs/mysql_restore_job.go +index 0c8fb7ab..dbe2414b 100644 +--- a/agent/runner/jobs/mysql_restore_job.go ++++ b/agent/runner/jobs/mysql_restore_job.go +@@ -228,7 +228,7 @@ func (j *MySQLRestoreJob) restoreMySQLFromS3(ctx context.Context, targetDirector + } + + wrapError := func(err error) error { +- return errors.Wrapf(err, "stderr: %s\n stdout: %s\n", stderr.String(), stdout.String()) ++ return errors.Wrapf(err, "stderr: %s\n stdout: %s\n", stderr.String(), stdout.String())//nolint:revive + } + + if err := xbcloudCmd.Start(); err != nil { +diff --git a/agent/runner/jobs/pbm_helpers.go b/agent/runner/jobs/pbm_helpers.go +index 0ede9508..b3683791 100644 +--- a/agent/runner/jobs/pbm_helpers.go ++++ b/agent/runner/jobs/pbm_helpers.go +@@ -335,7 +335,7 @@ func findPITRRestoreName(ctx context.Context, dbURL *string, restoreInfo *pbmRes + return "", errors.Errorf("failed to start restore") + } + continue +- } else { ++ } else {//nolint:revive + return entry.Name, nil + } + case <-ctx.Done(): +@@ -379,7 +379,7 @@ func waitForPBMRestore(ctx context.Context, l logrus.FieldLogger, dbURL *string, + maxRetryCount-- + l.Warnf("PMM failed to get backup restore status and will retry: %s", err) + continue +- } else { ++ } else {//nolint:revive + return errors.Wrap(err, "failed to get restore status") + } + } +diff --git a/api-tests/management/helpers.go b/api-tests/management/helpers.go +index 9a69dd3e..f68deede 100644 +--- a/api-tests/management/helpers.go ++++ b/api-tests/management/helpers.go +@@ -33,7 +33,7 @@ import ( + + // AgentStatusUnknown means agent is not connected and we don't know anything about its status. + var AgentStatusUnknown = inventorypb.AgentStatus_name[int32(inventorypb.AgentStatus_UNKNOWN)] +- ++// RegisterGenericNode registers a generic node using the provided parameters. + func RegisterGenericNode(t pmmapitests.TestingT, body node.RegisterNodeBody) (string, string) { + t.Helper() + params := node.RegisterNodeParams{ +@@ -118,7 +118,7 @@ func assertNodeCreated(t pmmapitests.TestingT, nodeID string, expectedResult nod + assert.NoError(t, err) + assert.Equal(t, expectedResult, *nodeOK.Payload) + } +- ++// RemovePMMAgentWithSubAgents removes a PMM Agent along with its sub-agents. + func RemovePMMAgentWithSubAgents(t pmmapitests.TestingT, pmmAgentID string) { + t.Helper() + +diff --git a/api/agentpb/agent.go b/api/agentpb/agent.go +index 1b59732a..aae3bb38 100644 +--- a/api/agentpb/agent.go ++++ b/api/agentpb/agent.go +@@ -54,154 +54,154 @@ type ServerRequestPayload interface { + sealed() + } + +-// A list of AgentMessage request payloads. + ++// AgentMessageRequestPayload returns the payload for the AgentMessageRequest. + func (m *Ping) AgentMessageRequestPayload() isAgentMessage_Payload { //nolint:ireturn + return &AgentMessage_Ping{Ping: m} + } +- ++// AgentMessageRequestPayload returns the payload for the AgentMessageRequest. + func (m *StateChangedRequest) AgentMessageRequestPayload() isAgentMessage_Payload { //nolint:ireturn + return &AgentMessage_StateChanged{StateChanged: m} + } +- ++// AgentMessageRequestPayload returns the payload for the AgentMessageRequest. + func (m *QANCollectRequest) AgentMessageRequestPayload() isAgentMessage_Payload { //nolint:ireturn + return &AgentMessage_QanCollect{QanCollect: m} + } +- ++// AgentMessageRequestPayload returns the payload for the AgentMessageRequest. + func (m *ActionResultRequest) AgentMessageRequestPayload() isAgentMessage_Payload { //nolint:ireturn + return &AgentMessage_ActionResult{ActionResult: m} + } +- ++// AgentMessageRequestPayload returns the payload for the AgentMessageRequest. + func (m *JobProgress) AgentMessageRequestPayload() isAgentMessage_Payload { //nolint:ireturn + return &AgentMessage_JobProgress{JobProgress: m} + } +- ++// AgentMessageRequestPayload returns the payload for the AgentMessageRequest. + func (m *JobResult) AgentMessageRequestPayload() isAgentMessage_Payload { //nolint:ireturn + return &AgentMessage_JobResult{JobResult: m} + } + +-// A list of AgentMessage response payloads. + ++// AgentMessageResponsePayload returns the payload for the AgentMessageResponse. + func (m *Pong) AgentMessageResponsePayload() isAgentMessage_Payload { //nolint:ireturn + return &AgentMessage_Pong{Pong: m} + } +- ++// AgentMessageResponsePayload returns the payload for the AgentMessageResponse. + func (m *SetStateResponse) AgentMessageResponsePayload() isAgentMessage_Payload { //nolint:ireturn + return &AgentMessage_SetState{SetState: m} + } +- ++// AgentMessageResponsePayload returns the payload for the AgentMessageResponse. + func (m *StartActionResponse) AgentMessageResponsePayload() isAgentMessage_Payload { //nolint:ireturn + return &AgentMessage_StartAction{StartAction: m} + } +- ++// AgentMessageResponsePayload returns the payload for the AgentMessageResponse. + func (m *StopActionResponse) AgentMessageResponsePayload() isAgentMessage_Payload { //nolint:ireturn + return &AgentMessage_StopAction{StopAction: m} + } +- ++// AgentMessageResponsePayload returns the payload for the AgentMessageResponse. + func (m *CheckConnectionResponse) AgentMessageResponsePayload() isAgentMessage_Payload { //nolint:ireturn + return &AgentMessage_CheckConnection{CheckConnection: m} + } +- ++// AgentMessageResponsePayload returns the payload for the AgentMessageResponse. + func (m *ServiceInfoResponse) AgentMessageResponsePayload() isAgentMessage_Payload { //nolint:ireturn + return &AgentMessage_ServiceInfo{ServiceInfo: m} + } +- ++// AgentMessageResponsePayload returns the payload for the AgentMessageResponse. + func (m *JobStatusResponse) AgentMessageResponsePayload() isAgentMessage_Payload { //nolint:ireturn + return &AgentMessage_JobStatus{JobStatus: m} + } +- ++// AgentMessageResponsePayload returns the payload for the AgentMessageResponse. + func (m *StartJobResponse) AgentMessageResponsePayload() isAgentMessage_Payload { //nolint:ireturn + return &AgentMessage_StartJob{StartJob: m} + } +- ++// AgentMessageResponsePayload returns the payload for the AgentMessageResponse. + func (m *StopJobResponse) AgentMessageResponsePayload() isAgentMessage_Payload { //nolint:ireturn + return &AgentMessage_StopJob{StopJob: m} + } +- ++// AgentMessageResponsePayload returns the payload for the AgentMessageResponse. + func (m *JobProgress) AgentMessageResponsePayload() isAgentMessage_Payload { //nolint:ireturn + return &AgentMessage_JobProgress{JobProgress: m} + } +- ++// AgentMessageResponsePayload returns the payload for the AgentMessageResponse. + func (m *JobResult) AgentMessageResponsePayload() isAgentMessage_Payload { //nolint:ireturn + return &AgentMessage_JobResult{JobResult: m} + } +- ++// AgentMessageResponsePayload returns the payload for the AgentMessageResponse. + func (m *GetVersionsResponse) AgentMessageResponsePayload() isAgentMessage_Payload { //nolint:ireturn + return &AgentMessage_GetVersions{GetVersions: m} + } +- ++// AgentMessageResponsePayload returns the payload for the AgentMessageResponse. + func (m *PBMSwitchPITRResponse) AgentMessageResponsePayload() isAgentMessage_Payload { //nolint:ireturn + return &AgentMessage_PbmSwitchPitr{PbmSwitchPitr: m} + } +- ++// AgentMessageResponsePayload returns the payload for the AgentMessageResponse. + func (m *AgentLogsResponse) AgentMessageResponsePayload() isAgentMessage_Payload { //nolint:ireturn + return &AgentMessage_AgentLogs{AgentLogs: m} + } + +-// A list of ServerMessage response payloads. + ++// ServerMessageResponsePayload returns the payload for the ServerMessageResponse. + func (m *Pong) ServerMessageResponsePayload() isServerMessage_Payload { //nolint:ireturn + return &ServerMessage_Pong{Pong: m} + } +- ++// ServerMessageResponsePayload returns the payload for the ServerMessageResponse. + func (m *StateChangedResponse) ServerMessageResponsePayload() isServerMessage_Payload { //nolint:ireturn + return &ServerMessage_StateChanged{StateChanged: m} + } +- ++// ServerMessageResponsePayload returns the payload for the ServerMessageResponse. + func (m *QANCollectResponse) ServerMessageResponsePayload() isServerMessage_Payload { //nolint:ireturn + return &ServerMessage_QanCollect{QanCollect: m} + } +- ++// ServerMessageResponsePayload returns the payload for the ServerMessageResponse. + func (m *ActionResultResponse) ServerMessageResponsePayload() isServerMessage_Payload { //nolint:ireturn + return &ServerMessage_ActionResult{ActionResult: m} + } + +-// A list of ServerMessage request payloads. + ++// ServerMessageRequestPayload returns the payload for the ServerMessageRequestPayload. + func (m *Ping) ServerMessageRequestPayload() isServerMessage_Payload { //nolint:ireturn + return &ServerMessage_Ping{Ping: m} + } +- ++// ServerMessageRequestPayload returns the payload for the ServerMessageRequestPayload. + func (m *SetStateRequest) ServerMessageRequestPayload() isServerMessage_Payload { //nolint:ireturn + return &ServerMessage_SetState{SetState: m} + } +- ++// ServerMessageRequestPayload returns the payload for the ServerMessageRequestPayload. + func (m *StartActionRequest) ServerMessageRequestPayload() isServerMessage_Payload { //nolint:ireturn + return &ServerMessage_StartAction{StartAction: m} + } +- ++// ServerMessageRequestPayload returns the payload for the ServerMessageRequestPayload. + func (m *StopActionRequest) ServerMessageRequestPayload() isServerMessage_Payload { //nolint:ireturn + return &ServerMessage_StopAction{StopAction: m} + } +- ++// ServerMessageRequestPayload returns the payload for the ServerMessageRequestPayload. + func (m *CheckConnectionRequest) ServerMessageRequestPayload() isServerMessage_Payload { //nolint:ireturn + return &ServerMessage_CheckConnection{CheckConnection: m} + } +- ++// ServerMessageRequestPayload returns the payload for the ServerMessageRequestPayload. + func (m *StartJobRequest) ServerMessageRequestPayload() isServerMessage_Payload { //nolint:ireturn + return &ServerMessage_StartJob{StartJob: m} + } +- ++// ServerMessageRequestPayload returns the payload for the ServerMessageRequestPayload. + func (m *StopJobRequest) ServerMessageRequestPayload() isServerMessage_Payload { //nolint:ireturn + return &ServerMessage_StopJob{StopJob: m} + } +- ++// ServerMessageRequestPayload returns the payload for the ServerMessageRequestPayload. + func (m *JobStatusRequest) ServerMessageRequestPayload() isServerMessage_Payload { //nolint:ireturn + return &ServerMessage_JobStatus{JobStatus: m} + } +- ++// ServerMessageRequestPayload returns the payload for the ServerMessageRequestPayload. + func (m *GetVersionsRequest) ServerMessageRequestPayload() isServerMessage_Payload { //nolint:ireturn + return &ServerMessage_GetVersions{GetVersions: m} + } +- ++// ServerMessageRequestPayload returns the payload for the ServerMessageRequestPayload. + func (m *PBMSwitchPITRRequest) ServerMessageRequestPayload() isServerMessage_Payload { //nolint:ireturn + return &ServerMessage_PbmSwitchPitr{PbmSwitchPitr: m} + } +- ++// ServerMessageRequestPayload returns the payload for the ServerMessageRequestPayload. + func (m *AgentLogsRequest) ServerMessageRequestPayload() isServerMessage_Payload { //nolint:ireturn + return &ServerMessage_AgentLogs{AgentLogs: m} + } +- ++// ServerMessageRequestPayload returns the payload for the ServerMessageRequestPayload. + func (m *ServiceInfoRequest) ServerMessageRequestPayload() isServerMessage_Payload { //nolint:ireturn + return &ServerMessage_ServiceInfo{ServiceInfo: m} + } +diff --git a/api/inventorypb/agents.go b/api/inventorypb/agents.go +index 578b3f38..8af5e1e5 100644 +--- a/api/inventorypb/agents.go ++++ b/api/inventorypb/agents.go +@@ -1,3 +1,4 @@ ++// Package inventorypb provides protobuf definitions for agent inventory. + // Copyright (C) 2023 Percona LLC + // + // This program is free software: you can redistribute it and/or modify +@@ -12,7 +13,6 @@ + // + // You should have received a copy of the GNU Affero General Public License + // along with this program. If not, see . +- + package inventorypb + + //go-sumtype:decl Agent +diff --git a/managed/cmd/pmm-managed-init/main.go b/managed/cmd/pmm-managed-init/main.go +index 8aa0046e..4b686f15 100644 +--- a/managed/cmd/pmm-managed-init/main.go ++++ b/managed/cmd/pmm-managed-init/main.go +@@ -12,7 +12,7 @@ + // + // You should have received a copy of the GNU Affero General Public License + // along with this program. If not, see . +- ++// Package main provides the entry point for the pmm-managed-init command. + package main + + import ( +diff --git a/managed/models/agentversion.go b/managed/models/agentversion.go +index 272b19e4..719379c3 100644 +--- a/managed/models/agentversion.go ++++ b/managed/models/agentversion.go +@@ -22,7 +22,7 @@ import ( + "github.com/pkg/errors" + "gopkg.in/reform.v1" + ) +- ++// PMMAgentMinVersionForPostgreSQLSSLSni is the minimum required version of PMM Agent + var PMMAgentMinVersionForPostgreSQLSSLSni = version.Must(version.NewVersion("2.41.0-0")) + + // AgentNotSupportedError is used when the target PMM agent doesn't support the requested functionality. +@@ -70,7 +70,7 @@ func IsAgentSupported(agentModel *Agent, functionalityPrefix string, pmmMinVersi + } + return nil + } +- ++// IsPostgreSQLSSLSniSupported checks if PostgreSQL SSL SNI is supported by the PMM Agent. + func IsPostgreSQLSSLSniSupported(q *reform.Querier, pmmAgentID string) (bool, error) { + err := PMMAgentSupported(q, pmmAgentID, "postgresql SSL sni check", PMMAgentMinVersionForPostgreSQLSSLSni) + switch { +diff --git a/managed/models/artifact_helpers.go b/managed/models/artifact_helpers.go +index ed8a95a0..348ffaa8 100644 +--- a/managed/models/artifact_helpers.go ++++ b/managed/models/artifact_helpers.go +@@ -148,7 +148,7 @@ func FindArtifactByName(q *reform.Querier, name string) (*Artifact, error) { + err := q.FindOneTo(artifact, "name", name) + if err != nil { + if errors.Is(err, reform.ErrNoRows) { +- return nil, errors.Wrapf(ErrNotFound, "backup artifact with name %q not found.", name) ++ return nil, errors.Wrapf(ErrNotFound, "backup artifact with name %q not found.", name)//nolint:revive + } + return nil, errors.WithStack(err) + } +diff --git a/managed/models/database.go b/managed/models/database.go +index a512ea61..ee453e18 100644 +--- a/managed/models/database.go ++++ b/managed/models/database.go +@@ -1,3 +1,4 @@ ++// Package models provides functionality for handling database models and related tasks. + // Copyright (C) 2023 Percona LLC + // + // This program is free software: you can redistribute it and/or modify +@@ -12,7 +13,6 @@ + // + // You should have received a copy of the GNU Affero General Public License + // along with this program. If not, see . +-// Package models provides functionality for handling database models and related tasks. + //nolint:lll + package models + +diff --git a/managed/models/dump.go b/managed/models/dump.go +index dfcbedeb..df5700e5 100644 +--- a/managed/models/dump.go ++++ b/managed/models/dump.go +@@ -27,9 +27,9 @@ import ( + type DumpStatus string + + const ( +- DumpStatusInProgress = DumpStatus("in_progress") +- DumpStatusSuccess = DumpStatus("success") +- DumpStatusError = DumpStatus("error") ++ DumpStatusInProgress = DumpStatus("in_progress")//nolint:revive ++ DumpStatusSuccess = DumpStatus("success")//nolint:revive ++ DumpStatusError = DumpStatus("error")//nolint:revive + ) + + // Validate validates Dumps status. +diff --git a/managed/models/dump_helpers.go b/managed/models/dump_helpers.go +index 65c307a8..d86f51bf 100644 +--- a/managed/models/dump_helpers.go ++++ b/managed/models/dump_helpers.go +@@ -57,7 +57,7 @@ type CreateDumpParams struct { + ExportQAN bool + IgnoreLoad bool + } +- ++// Validate checks the validity of CreateDumpParams. + func (p *CreateDumpParams) Validate() error { + if p.StartTime != nil && p.EndTime != nil && p.StartTime.After(*p.EndTime) { + return errors.Errorf("dump start time can't be greater than end time") +@@ -65,7 +65,7 @@ func (p *CreateDumpParams) Validate() error { + + return nil + } +- ++// CreateDump creates a dump using the specified parameters. + func CreateDump(q *reform.Querier, params CreateDumpParams) (*Dump, error) { + if err := params.Validate(); err != nil { + return nil, errors.Wrap(err, "invalid dump creation params") +@@ -164,7 +164,7 @@ func FindDumpByID(q *reform.Querier, id string) (*Dump, error) { + + return dump, nil + } +- ++// UpdateDumpStatus updates the status of a dump with the given ID. + func UpdateDumpStatus(q *reform.Querier, id string, status DumpStatus) error { + dump, err := FindDumpByID(q, id) + if err != nil { +diff --git a/managed/models/models.go b/managed/models/models.go +index c1024ea4..ff5dbd57 100644 +--- a/managed/models/models.go ++++ b/managed/models/models.go +@@ -234,6 +234,7 @@ const ( + type ParamUnit string + + const ( +- Percent = ParamUnit("%") ++ Percent = ParamUnit("%")//noiint:revive ++ // Seconds ... + Seconds = ParamUnit("s") + ) +diff --git a/managed/models/role_helpers.go b/managed/models/role_helpers.go +index da1c2505..9a104776 100644 +--- a/managed/models/role_helpers.go ++++ b/managed/models/role_helpers.go +@@ -33,7 +33,7 @@ var ( + + // CreateRole creates a new role. + func CreateRole(q *reform.Querier, role *Role) error { +- if err := q.Insert(role); err != nil { ++ if err := q.Insert(role); err != nil {//nolint:revive + return err + } + +diff --git a/managed/models/service_helpers.go b/managed/models/service_helpers.go +index 257fae1f..272742f5 100644 +--- a/managed/models/service_helpers.go ++++ b/managed/models/service_helpers.go +@@ -440,7 +440,7 @@ func ChangeStandardLabels(q *reform.Querier, serviceID string, labels ServiceSta + s.ExternalGroup = *labels.ExternalGroup + } + +- if err = q.UpdateColumns(s, columns...); err != nil { ++ if err = q.UpdateColumns(s, columns...); err != nil {//nolint:revive + return err + } + +diff --git a/managed/models/settings_helpers.go b/managed/models/settings_helpers.go +index b439121c..21f8e696 100644 +--- a/managed/models/settings_helpers.go ++++ b/managed/models/settings_helpers.go +@@ -322,7 +322,7 @@ func UpdateSettings(q reform.DBTX, params *ChangeSettingsParams) (*Settings, err + + func lockRoleForChange(tx *reform.TX, roleID int) error { + var r Role +- if err := FindAndLockRole(tx, roleID, &r); err != nil { ++ if err := FindAndLockRole(tx, roleID, &r); err != nil {//nolint:revive + return err + } + +diff --git a/managed/models/template_helpers.go b/managed/models/template_helpers.go +index 7c0ca1ee..d13ffc32 100644 +--- a/managed/models/template_helpers.go ++++ b/managed/models/template_helpers.go +@@ -173,11 +173,11 @@ func RemoveTemplate(q *reform.Querier, name string) error { + } + return nil + } +- ++// ConvertTemplate converts an alert template to the internal representation. + func ConvertTemplate(template *alert.Template, source Source) (*Template, error) { + p, err := ConvertParamsDefinitions(template.Params) + if err != nil { +- return nil, errors.Errorf("invalid rule template parameters: %v.", err) ++ return nil, errors.Errorf("invalid rule template parameters: %v.", err)//nolint:revive + } + + yaml, err := alert.ToYAML([]alert.Template{*template}) +diff --git a/managed/models/victoriametrics_params.go b/managed/models/victoriametrics_params.go +index 112467ce..4b1c2a9f 100644 +--- a/managed/models/victoriametrics_params.go ++++ b/managed/models/victoriametrics_params.go +@@ -100,15 +100,15 @@ func (vmp *VictoriaMetricsParams) loadVMAlertParams() error { + + return nil + } +- ++// ExternalVM returns true if VictoriaMetrics is configured to run externally. + func (vmp *VictoriaMetricsParams) ExternalVM() bool { + return vmp.url.Hostname() != "127.0.0.1" + } +- ++// URL returns the base URL for VictoriaMetrics. + func (vmp *VictoriaMetricsParams) URL() string { + return vmp.url.String() + } +- ++// URLFor returns the URL for a specific path in VictoriaMetrics. + func (vmp *VictoriaMetricsParams) URLFor(path string) (*url.URL, error) { + if path == "" { + return vmp.url, nil +diff --git a/managed/services/agents/agents.go b/managed/services/agents/agents.go +index 7d71672f..85ff58a4 100644 +--- a/managed/services/agents/agents.go ++++ b/managed/services/agents/agents.go +@@ -143,7 +143,7 @@ func ensureAuthParams(exporter *models.Agent, params *agentpb.SetStateRequest_Ag + } + + // getExporterListenAddress returns the appropriate listen address to use for a given exporter. +-func getExporterListenAddress(node *models.Node, exporter *models.Agent) string { ++func getExporterListenAddress(node *models.Node, exporter *models.Agent) string {//nolint:revive + switch { + case exporter.ExposeExporter: + return "0.0.0.0" +diff --git a/managed/services/agents/registry.go b/managed/services/agents/registry.go +index 6db03924..e9cdf1e1 100644 +--- a/managed/services/agents/registry.go ++++ b/managed/services/agents/registry.go +@@ -416,7 +416,7 @@ func (r *Registry) Collect(ch chan<- prom.Metric) { + r.mRoundTrip.Collect(ch) + r.mClockDrift.Collect(ch) + } +- ++// KickAll sends a signal to all registered agents in the registry to perform a kick action. + func (r *Registry) KickAll(ctx context.Context) { + for _, agentInfo := range r.agents { + r.Kick(ctx, agentInfo.id) +diff --git a/managed/services/agents/versioner.go b/managed/services/agents/versioner.go +index e278fb87..174d377d 100644 +--- a/managed/services/agents/versioner.go ++++ b/managed/services/agents/versioner.go +@@ -56,8 +56,10 @@ type Software interface { + // Mysqld represents mysqld software. + type Mysqld struct{} + +-func (*Mysqld) isSoftware() {} ++func (*Mysqld) isSoftware() ++// Name returns the software name for Mysqld.{} + func (*Mysqld) Name() models.SoftwareName { return models.MysqldSoftwareName } ++// GetVersionRequest returns the GetVersionsRequest_Software for Mysqld. + func (*Mysqld) GetVersionRequest() *agentpb.GetVersionsRequest_Software { + return &agentpb.GetVersionsRequest_Software{ + Software: &agentpb.GetVersionsRequest_Software_Mysqld{}, +@@ -68,7 +70,9 @@ func (*Mysqld) GetVersionRequest() *agentpb.GetVersionsRequest_Software { + type Xtrabackup struct{} + + func (*Xtrabackup) isSoftware() {} ++// Name returns the software name for Xtrabackup. + func (*Xtrabackup) Name() models.SoftwareName { return models.XtrabackupSoftwareName } ++// GetVersionRequest returns the GetVersionsRequest_Software for Xtrabackup. + func (*Xtrabackup) GetVersionRequest() *agentpb.GetVersionsRequest_Software { + return &agentpb.GetVersionsRequest_Software{ + Software: &agentpb.GetVersionsRequest_Software_Xtrabackup{}, +@@ -77,9 +81,10 @@ func (*Xtrabackup) GetVersionRequest() *agentpb.GetVersionsRequest_Software { + + // Xbcloud represents xbcloud software. + type Xbcloud struct{} +- + func (*Xbcloud) isSoftware() {} ++// Name returns the software name for Xbcloud. + func (*Xbcloud) Name() models.SoftwareName { return models.XbcloudSoftwareName } ++// GetVersionRequest returns the GetVersionsRequest_Software for Xbcloud. + func (*Xbcloud) GetVersionRequest() *agentpb.GetVersionsRequest_Software { + return &agentpb.GetVersionsRequest_Software{ + Software: &agentpb.GetVersionsRequest_Software_Xbcloud{}, +@@ -90,7 +95,9 @@ func (*Xbcloud) GetVersionRequest() *agentpb.GetVersionsRequest_Software { + type Qpress struct{} + + func (*Qpress) isSoftware() {} ++// Name returns the software name for Qpress. + func (*Qpress) Name() models.SoftwareName { return models.QpressSoftwareName } ++// GetVersionRequest returns the GetVersionsRequest_Software for Qpress. + func (*Qpress) GetVersionRequest() *agentpb.GetVersionsRequest_Software { + return &agentpb.GetVersionsRequest_Software{ + Software: &agentpb.GetVersionsRequest_Software_Qpress{}, +@@ -100,8 +107,10 @@ func (*Qpress) GetVersionRequest() *agentpb.GetVersionsRequest_Software { + // MongoDB represents mongod software. + type MongoDB struct{} + +-func (*MongoDB) isSoftware() {} ++func (*MongoDB) isSoftware() ++// Name returns the software name for MongoDB.{} + func (*MongoDB) Name() models.SoftwareName { return models.MongoDBSoftwareName } ++// GetVersionRequest returns the GetVersionsRequest_Software for Qpress. + func (*MongoDB) GetVersionRequest() *agentpb.GetVersionsRequest_Software { + return &agentpb.GetVersionsRequest_Software{ + Software: &agentpb.GetVersionsRequest_Software_Mongod{}, +diff --git a/managed/services/checks/checks.go b/managed/services/checks/checks.go +index e8499ac6..df7a89e3 100644 +--- a/managed/services/checks/checks.go ++++ b/managed/services/checks/checks.go +@@ -369,7 +369,7 @@ func (s *Service) GetAdvisors() ([]check.Advisor, error) { + } + return res, nil + } +- ++// GetChecks retrieves a map of checks from the service. + func (s *Service) GetChecks() (map[string]check.Check, error) { + cs, err := models.FindCheckSettings(s.db.Querier) + if err != nil { +@@ -1438,7 +1438,7 @@ func (s *Service) loadLocalChecks(file string) ([]check.Check, error) { + + for _, c := range checks { + if c.Advisor != "dev" { +- return nil, errors.Errorf("Local checks are supposed to be linked to the 'dev' advisor.") ++ return nil, errors.Errorf("Local checks are supposed to be linked to the 'dev' advisor.")//nolint:revive + } + } + +diff --git a/managed/services/grafana/client.go b/managed/services/grafana/client.go +index 8dda69cb..1514c6c7 100644 +--- a/managed/services/grafana/client.go ++++ b/managed/services/grafana/client.go +@@ -14,8 +14,6 @@ + // along with this program. If not, see . + + // Package grafana provides facilities for working with Grafana. +-// +- + package grafana + + import ( +diff --git a/managed/services/management/checks.go b/managed/services/management/checks.go +index d1d8049c..6a704d24 100644 +--- a/managed/services/management/checks.go ++++ b/managed/services/management/checks.go +@@ -249,7 +249,7 @@ func (s *ChecksAPIService) ListSecurityChecks(_ context.Context, _ *managementpb + + return &managementpb.ListSecurityChecksResponse{Checks: res}, nil + } +- ++// ListAdvisors retrieves a list of advisors based on the provided request. + func (s *ChecksAPIService) ListAdvisors(_ context.Context, _ *managementpb.ListAdvisorsRequest) (*managementpb.ListAdvisorsResponse, error) { + disChecks, err := s.checksService.GetDisabledChecks() + if err != nil { +diff --git a/managed/services/management/dump/dump.go b/managed/services/management/dump/dump.go +index 6ea6026c..fd8c7b8a 100644 +--- a/managed/services/management/dump/dump.go ++++ b/managed/services/management/dump/dump.go +@@ -41,7 +41,7 @@ import ( + "github.com/percona/pmm/managed/services/dump" + "github.com/percona/pmm/managed/services/grafana" + ) +- ++// Service represents a structure for managing dump-related operations. + type Service struct { + db *reform.DB + l *logrus.Entry +@@ -51,7 +51,7 @@ type Service struct { + + dumpv1beta1.UnimplementedDumpsServer + } +- ++// New creates a new instance of the Service with the provided dependencies. + func New(db *reform.DB, grafanaClient *grafana.Client, dumpService dumpService) *Service { + return &Service{ + db: db, +@@ -60,7 +60,7 @@ func New(db *reform.DB, grafanaClient *grafana.Client, dumpService dumpService) + l: logrus.WithField("component", "management/dump"), + } + } +- ++// StartDump starts a dump based on the provided context and request. + func (s *Service) StartDump(ctx context.Context, req *dumpv1beta1.StartDumpRequest) (*dumpv1beta1.StartDumpResponse, error) { + md, ok := metadata.FromIncomingContext(ctx) + if !ok { +@@ -136,7 +136,7 @@ func (s *Service) StartDump(ctx context.Context, req *dumpv1beta1.StartDumpReque + + return &dumpv1beta1.StartDumpResponse{DumpId: dumpID}, nil + } +- ++// ListDumps lists dumps based on the provided context and request. + func (s *Service) ListDumps(_ context.Context, _ *dumpv1beta1.ListDumpsRequest) (*dumpv1beta1.ListDumpsResponse, error) { + dumps, err := models.FindDumps(s.db.Querier, models.DumpFilters{}) + if err != nil { +@@ -157,7 +157,7 @@ func (s *Service) ListDumps(_ context.Context, _ *dumpv1beta1.ListDumpsRequest) + Dumps: dumpsResponse, + }, nil + } +- ++// DeleteDump deletes a dump based on the provided context and request. + func (s *Service) DeleteDump(_ context.Context, req *dumpv1beta1.DeleteDumpRequest) (*dumpv1beta1.DeleteDumpResponse, error) { + for _, id := range req.DumpIds { + if err := s.dumpService.DeleteDump(id); err != nil { +@@ -167,7 +167,7 @@ func (s *Service) DeleteDump(_ context.Context, req *dumpv1beta1.DeleteDumpReque + + return &dumpv1beta1.DeleteDumpResponse{}, nil + } +- ++// GetDumpLogs retrieves dump logs based on the provided context and request. + func (s *Service) GetDumpLogs(_ context.Context, req *dumpv1beta1.GetLogsRequest) (*dumpv1beta1.GetLogsResponse, error) { + filter := models.DumpLogsFilter{ + DumpID: req.DumpId, +@@ -198,7 +198,7 @@ func (s *Service) GetDumpLogs(_ context.Context, req *dumpv1beta1.GetLogsRequest + + return res, nil + } +- ++// UploadDump uploads a dump based on the provided context and request. + func (s *Service) UploadDump(_ context.Context, req *dumpv1beta1.UploadDumpRequest) (*dumpv1beta1.UploadDumpResponse, error) { + filePaths, err := s.dumpService.GetFilePathsForDumps(req.DumpIds) + if err != nil { +diff --git a/managed/services/management/external.go b/managed/services/management/external.go +index 7bb3253f..b12aa8fe 100644 +--- a/managed/services/management/external.go ++++ b/managed/services/management/external.go +@@ -47,7 +47,7 @@ func NewExternalService(db *reform.DB, vmdb prometheusService, state agentsState + cc: cc, + } + } +- ++// AddExternal adds an external service based on the provided request + func (e *ExternalService) AddExternal(ctx context.Context, req *managementpb.AddExternalRequest) (*managementpb.AddExternalResponse, error) { + res := &managementpb.AddExternalResponse{} + var pmmAgentID *string +diff --git a/managed/services/management/haproxy.go b/managed/services/management/haproxy.go +index 320b7bd1..6b563a71 100644 +--- a/managed/services/management/haproxy.go ++++ b/managed/services/management/haproxy.go +@@ -47,7 +47,7 @@ func NewHAProxyService(db *reform.DB, vmdb prometheusService, state agentsStateU + cc: cc, + } + } +- ++// AddHAProxy adds an HAProxy service based on the provided request. + func (e HAProxyService) AddHAProxy(ctx context.Context, req *managementpb.AddHAProxyRequest) (*managementpb.AddHAProxyResponse, error) { + res := &managementpb.AddHAProxyResponse{} + var pmmAgentID *string +diff --git a/managed/services/platform/platform.go b/managed/services/platform/platform.go +index 4b75510e..ff45f5c4 100644 +--- a/managed/services/platform/platform.go ++++ b/managed/services/platform/platform.go +@@ -202,7 +202,7 @@ func (s *Service) forceDisconnect(ctx context.Context) error { + } + return nil + } +- ++// UpdateSupervisordConfigurations updates supervisord configurations for the service. + func (s *Service) UpdateSupervisordConfigurations(ctx context.Context) error { + settings, err := models.GetSettings(s.db) + if err != nil { +@@ -377,7 +377,7 @@ func (s *Service) GetContactInformation(ctx context.Context, _ *platformpb.GetCo + + return response, nil + } +- ++// ServerInfo retrieves server information based on the provided context and request. + func (s *Service) ServerInfo(ctx context.Context, _ *platformpb.ServerInfoRequest) (*platformpb.ServerInfoResponse, error) { + settings, err := models.GetSettings(s.db) + if err != nil { +diff --git a/managed/services/server/server.go b/managed/services/server/server.go +index 6db57e23..456fe161 100644 +--- a/managed/services/server/server.go ++++ b/managed/services/server/server.go +@@ -221,8 +221,7 @@ func (s *Server) Version(ctx context.Context, req *serverpb.VersionRequest) (*se + } + + // Readiness returns an error when some PMM Server component is not ready yet or is being restarted. +-// It can be used as for Docker health check or Kubernetes readiness probe. +-func (s *Server) Readiness(ctx context.Context, req *serverpb.ReadinessRequest) (*serverpb.ReadinessResponse, error) { ++func (s *Server) Readiness(ctx context.Context, req *serverpb.ReadinessRequest) (*serverpb.ReadinessResponse, error) {//nolint:revive + var notReady bool + for n, svc := range map[string]healthChecker{ + "alertmanager": s.alertmanager, +@@ -246,7 +245,7 @@ func (s *Server) Readiness(ctx context.Context, req *serverpb.ReadinessRequest) + // LeaderHealthCheck checks if the instance is the leader in a cluster. + // Returns an error if the instance isn't the leader. + // It's used for HA purpose. +-func (s *Server) LeaderHealthCheck(ctx context.Context, req *serverpb.LeaderHealthCheckRequest) (*serverpb.LeaderHealthCheckResponse, error) { ++func (s *Server) LeaderHealthCheck(ctx context.Context, req *serverpb.LeaderHealthCheckRequest) (*serverpb.LeaderHealthCheckResponse, error) {//nolint:revive + if s.haService.IsLeader() { + return &serverpb.LeaderHealthCheckResponse{}, nil + } +@@ -326,7 +325,7 @@ func (s *Server) CheckUpdates(ctx context.Context, req *serverpb.CheckUpdatesReq + } + + // StartUpdate starts PMM Server update. +-func (s *Server) StartUpdate(ctx context.Context, req *serverpb.StartUpdateRequest) (*serverpb.StartUpdateResponse, error) { ++func (s *Server) StartUpdate(ctx context.Context, req *serverpb.StartUpdateRequest) (*serverpb.StartUpdateResponse, error) {//nolint:revive + s.envRW.RLock() + updatesDisabled := s.envSettings.DisableUpdates + s.envRW.RUnlock() +@@ -501,7 +500,7 @@ func (s *Server) convertSettings(settings *models.Settings, connectedToPlatform + } + + // GetSettings returns current PMM Server settings. +-func (s *Server) GetSettings(ctx context.Context, req *serverpb.GetSettingsRequest) (*serverpb.GetSettingsResponse, error) { ++func (s *Server) GetSettings(ctx context.Context, req *serverpb.GetSettingsRequest) (*serverpb.GetSettingsResponse, error) {//nolint:revive + s.envRW.RLock() + defer s.envRW.RUnlock() + +@@ -877,7 +876,7 @@ func (s *Server) writeSSHKey(sshKey string) error { + } + + // AWSInstanceCheck checks AWS EC2 instance ID. +-func (s *Server) AWSInstanceCheck(ctx context.Context, req *serverpb.AWSInstanceCheckRequest) (*serverpb.AWSInstanceCheckResponse, error) { ++func (s *Server) AWSInstanceCheck(ctx context.Context, req *serverpb.AWSInstanceCheckRequest) (*serverpb.AWSInstanceCheckResponse, error) {//nolint:revive + if err := s.awsInstanceChecker.check(req.InstanceId); err != nil { + return nil, err + } +diff --git a/managed/services/supervisord/supervisord.go b/managed/services/supervisord/supervisord.go +index 33826cd2..125956d5 100644 +--- a/managed/services/supervisord/supervisord.go ++++ b/managed/services/supervisord/supervisord.go +@@ -445,11 +445,11 @@ func (s *Service) marshalConfig(tmpl *template.Template, settings *models.Settin + if settings.PMMPublicAddress != "" { + publicURL, err := url.Parse(settings.PMMPublicAddress) + if err != nil { +- return nil, errors.Wrap(err, "failed to parse PMM public address.") ++ return nil, errors.Wrap(err, "failed to parse PMM public address.")//nolint:revive + } + if publicURL.Host == "" { + if publicURL, err = url.Parse(fmt.Sprintf("https://%s", settings.PMMPublicAddress)); err != nil { +- return nil, errors.Wrap(err, "failed to parse PMM public address.") ++ return nil, errors.Wrap(err, "failed to parse PMM public address.")//nolint:revive + } + } + templateParams["PMMServerHost"] = publicURL.Host +diff --git a/managed/services/telemetry/config.go b/managed/services/telemetry/config.go +index 361aa4a5..4783f61a 100644 +--- a/managed/services/telemetry/config.go ++++ b/managed/services/telemetry/config.go +@@ -168,10 +168,11 @@ type ReportingConfig struct { + + //go:embed config.default.yml + var defaultConfig string +- ++// ExtensionType represents the type of telemetry extension. + type ExtensionType string + + const ( ++ // UIEventsExtension is a constant for the UI events telemetry extension. + UIEventsExtension = ExtensionType("UIEventsExtension") + ) + +diff --git a/managed/services/telemetry/datasource_pmmdb_select.go b/managed/services/telemetry/datasource_pmmdb_select.go +index 09c9249b..c502e44f 100644 +--- a/managed/services/telemetry/datasource_pmmdb_select.go ++++ b/managed/services/telemetry/datasource_pmmdb_select.go +@@ -98,10 +98,10 @@ func (d *dsPmmDBSelect) FetchMetrics(ctx context.Context, config Config) ([]*pmm + return fetchMetricsFromDB(ctx, d.l, d.config.Timeout, d.db, config) + } + +-func (d *dsPmmDBSelect) Init(ctx context.Context) error { ++func (d *dsPmmDBSelect) Init(ctx context.Context) error {//nolint:revive + return nil + } + +-func (d *dsPmmDBSelect) Dispose(ctx context.Context) error { ++func (d *dsPmmDBSelect) Dispose(ctx context.Context) error {//nolint:revive + return nil + } +diff --git a/managed/services/telemetry/datasource_victoria_metrics.go b/managed/services/telemetry/datasource_victoria_metrics.go +index 1757a774..507c361f 100644 +--- a/managed/services/telemetry/datasource_victoria_metrics.go ++++ b/managed/services/telemetry/datasource_victoria_metrics.go +@@ -99,10 +99,10 @@ func (d *dataSourceVictoriaMetrics) FetchMetrics(ctx context.Context, config Con + return metrics, nil + } + +-func (d *dataSourceVictoriaMetrics) Init(ctx context.Context) error { ++func (d *dataSourceVictoriaMetrics) Init(ctx context.Context) error {//nolint:revive + return nil + } + +-func (d *dataSourceVictoriaMetrics) Dispose(ctx context.Context) error { ++func (d *dataSourceVictoriaMetrics) Dispose(ctx context.Context) error {//nolint:revive + return nil + } +diff --git a/managed/services/telemetry/telemetry.go b/managed/services/telemetry/telemetry.go +index d6951ae4..0f4a05bb 100644 +--- a/managed/services/telemetry/telemetry.go ++++ b/managed/services/telemetry/telemetry.go +@@ -411,7 +411,7 @@ func (s *Service) send(ctx context.Context, report *reporter.ReportRequest) erro + } + } + } +- ++// Format returns the formatted representation of the provided server metric. + func (s *Service) Format(report *pmmv1.ServerMetric) string { + var builder strings.Builder + for _, m := range report.Metrics { +diff --git a/managed/services/telemetry/uievents/uievents.go b/managed/services/telemetry/uievents/uievents.go +index e66be330..bb266200 100644 +--- a/managed/services/telemetry/uievents/uievents.go ++++ b/managed/services/telemetry/uievents/uievents.go +@@ -1,4 +1,3 @@ +-// Copyright (C) 2023 Percona LLC + // + // This program is free software: you can redistribute it and/or modify + // it under the terms of the GNU Affero General Public License as published by +@@ -49,14 +48,14 @@ type Service struct { + + uievents.UnimplementedUIEventsServer + } +- ++// DashboardUsageStat represents a structure for dashboard usage statistics. + type DashboardUsageStat struct { + title string + uid string + useCount int32 + loadTime *hdrhistogram.Histogram + } +- ++// ComponentsUsageStat represents a structure for component usage statistics. + type ComponentsUsageStat struct { + uid string + useCount int32 +@@ -92,7 +91,7 @@ func (s *Service) ScheduleCleanup(ctx context.Context) { + } + }() + } +- ++// FetchMetrics fetches metrics for the service based on the provided context and telemetry configuration. + func (s *Service) FetchMetrics(_ context.Context, _ telemetry.Config) ([]*pmmv1.ServerMetric_Metric, error) { //nolint:unparam + s.stateM.RLock() + defer s.stateM.RUnlock() +diff --git a/managed/services/types.go b/managed/services/types.go +index 9573660b..f1c5d570 100644 +--- a/managed/services/types.go ++++ b/managed/services/types.go +@@ -34,7 +34,7 @@ type Target struct { + TDP *models.DelimiterPair + TLSSkipVerify bool + } +- ++// Copy creates a copy of the Target instance. + func (t *Target) Copy() Target { + labels := make(map[string]string, len(t.Labels)) + for k, v := range t.Labels { +diff --git a/managed/utils/interceptors/grpc_extension.go b/managed/utils/interceptors/grpc_extension.go +index 19046ade..3a59efbb 100644 +--- a/managed/utils/interceptors/grpc_extension.go ++++ b/managed/utils/interceptors/grpc_extension.go +@@ -36,15 +36,15 @@ const ( + type GRPCMetricsExtension struct { + grpc_prometheus.DefaultExtension + } +- ++// MetricsNameAdjust adjusts the given metric name and returns the adjusted name. + func (e GRPCMetricsExtension) MetricsNameAdjust(name string) string { + return "pmm_" + name + } +- ++// ServerStreamMsgReceivedCounterCustomLabels returns custom labels for the server stream message received counter. + func (e *GRPCMetricsExtension) ServerStreamMsgReceivedCounterCustomLabels() []string { + return []string{"caller_origin"} + } +- ++// ServerStreamMsgReceivedCounterValues returns custom values for the server stream message received counter. + func (e *GRPCMetricsExtension) ServerStreamMsgReceivedCounterValues(ctx context.Context) []string { + return []string{getCallerOriginStr(ctx)} + } +diff --git a/managed/utils/interceptors/interceptors.go b/managed/utils/interceptors/interceptors.go +index 039de491..e9b33754 100644 +--- a/managed/utils/interceptors/interceptors.go ++++ b/managed/utils/interceptors/interceptors.go +@@ -78,7 +78,7 @@ func logRequest(l *logrus.Entry, prefix string, f func() error) (err error) { + err = f() + return //nolint:nakedret + } +- ++// UnaryInterceptorType represents the type of a unary gRPC interceptor. + type UnaryInterceptorType = func(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) + + // Unary adds context logger and Prometheus metrics to unary server RPC. +diff --git a/managed/utils/platform/client.go b/managed/utils/platform/client.go +index 0956f789..685b2d0e 100644 +--- a/managed/utils/platform/client.go ++++ b/managed/utils/platform/client.go +@@ -281,7 +281,7 @@ func (c *Client) makeRequest(ctx context.Context, accessToken, method, path stri + + return bodyBytes, nil + } +- ++// SsoDetails represents the Single Sign-On details containing information + type SsoDetails struct { + GrafanaClientID string `json:"grafana_client_id"` //nolint:tagliatelle + PMMManagedClientID string `json:"pmm_managed_client_id"` //nolint:tagliatelle +@@ -289,16 +289,16 @@ type SsoDetails struct { + Scope string `json:"scope"` + IssuerURL string `json:"issuer_url"` //nolint:tagliatelle + } +- ++// ConnectPMMResponse represents the response structure for the ConnectPMM API. + type ConnectPMMResponse struct { + SSODetails *SsoDetails `json:"sso_details"` + OrganizationID string `json:"org_id"` + } +- ++// SearchOrganizationEntitlementsResponse represents the response structure + type SearchOrganizationEntitlementsResponse struct { + Entitlement []*EntitlementResponse `json:"entitlements"` + } +- ++// EntitlementResponse represents the response structure for entitlement-related APIs. + type EntitlementResponse struct { + Number string `json:"number"` + Name string `json:"name"` +@@ -312,16 +312,16 @@ type EntitlementResponse struct { + EndDate string `json:"end_date"` //nolint:tagliatelle + Platform Response `json:"platform"` + } +- ++// Response represents a generic API response structure. + type Response struct { + SecurityAdvisor string `json:"security_advisor"` //nolint:tagliatelle + ConfigAdvisor string `json:"config_advisor"` //nolint:tagliatelle + } +- ++// SearchOrganizationTicketsResponse represents the response structure + type SearchOrganizationTicketsResponse struct { + Tickets []*TicketResponse `json:"tickets"` + } +- ++// TicketResponse represents the response structure for ticket-related APIs. + type TicketResponse struct { + Number string `json:"number"` + ShortDescription string `json:"short_description"` //nolint:tagliatelle +@@ -333,7 +333,7 @@ type TicketResponse struct { + TaskType string `json:"task_type"` //nolint:tagliatelle + URL string `json:"url"` + } +- ++// ContactInformation represents information about a contact. + type ContactInformation struct { + Contacts struct { + CustomerSuccess struct { +diff --git a/qan-api2/db.go b/qan-api2/db.go +index 4e0f9d16..f265879c 100644 +--- a/qan-api2/db.go ++++ b/qan-api2/db.go +@@ -12,7 +12,7 @@ + // + // You should have received a copy of the GNU Affero General Public License + // along with this program. If not, see . +- ++// Package main ... + package main + + import ( +-- +2.34.1 + + +From c04a4144b288f2cb44cf154b6f31b45ac2118657 Mon Sep 17 00:00:00 2001 +From: vishwas-sharma2480 +Date: Wed, 17 Jan 2024 03:19:10 +0530 +Subject: [PATCH 14/15] added comments and used nolint were required + +--- + agent/agentlocal/agent_local.go | 2 +- + agent/agents/agents_test.go | 2 +- + agent/agents/mongodb/mongodb.go | 2 +- + agent/agents/mysql/slowlog/slowlog.go | 2 +- + agent/agents/mysql/slowlog/slowlog_test.go | 6 +++--- + agent/agents/noop/noop.go | 4 ++-- + agent/agents/noop/noop_test.go | 2 +- + agent/agents/postgres/pgstatmonitor/pgstatmonitor.go | 6 +++--- + .../agents/postgres/pgstatstatements/pgstatstatements.go | 4 ++-- + agent/agents/supervisor/supervisor.go | 8 ++++---- + agent/commands/setup.go | 2 +- + agent/connectionchecker/connection_checker.go | 2 +- + agent/main.go | 2 +- + agent/runner/actions/mysql_explain_action.go | 2 +- + agent/runner/runner_test.go | 2 +- + managed/cmd/pmm-managed-starlark/main.go | 2 +- + managed/services/agents/channel/channel.go | 2 +- + managed/services/management/checks.go | 2 +- + managed/services/telemetry/datasource_grafanadb_select.go | 4 ++-- + managed/services/telemetry/datasource_qandb_select.go | 2 +- + 20 files changed, 30 insertions(+), 30 deletions(-) + +diff --git a/agent/agentlocal/agent_local.go b/agent/agentlocal/agent_local.go +index b4adb321..da651077 100644 +--- a/agent/agentlocal/agent_local.go ++++ b/agent/agentlocal/agent_local.go +@@ -136,7 +136,7 @@ func (s *Server) Run(ctx context.Context, reloadCh chan bool) { + } + + // Status returns current pmm-agent status. +-func (s *Server) Status(ctx context.Context, req *agentlocalpb.StatusRequest) (*agentlocalpb.StatusResponse, error) { ++func (s *Server) Status(ctx context.Context, req *agentlocalpb.StatusRequest) (*agentlocalpb.StatusResponse, error) {//nolint:revive + connected := true + md := s.client.GetServerConnectMetadata() + if md == nil { +diff --git a/agent/agents/agents_test.go b/agent/agents/agents_test.go +index 60eb612b..98b83d68 100644 +--- a/agent/agents/agents_test.go ++++ b/agent/agents/agents_test.go +@@ -16,6 +16,6 @@ package agents + + import "testing" + // TestAgents is a test function for the Agents module. +-func TestAgents(t *testing.T) { ++func TestAgents(t *testing.T) {//nolint:revive + // we need at least one test per package to correctly calculate coverage + } +diff --git a/agent/agents/mongodb/mongodb.go b/agent/agents/mongodb/mongodb.go +index f3a0dc8d..728bc3c0 100644 +--- a/agent/agents/mongodb/mongodb.go ++++ b/agent/agents/mongodb/mongodb.go +@@ -104,7 +104,7 @@ func (m *MongoDB) Write(r *report.Report) error { + return nil + } + +-type Profiler interface { ++type Profiler interface {//nolint:revive + Start() error + Stop() error + } +diff --git a/agent/agents/mysql/slowlog/slowlog.go b/agent/agents/mysql/slowlog/slowlog.go +index 398c117d..b2c52741 100644 +--- a/agent/agents/mysql/slowlog/slowlog.go ++++ b/agent/agents/mysql/slowlog/slowlog.go +@@ -715,7 +715,7 @@ func errListsToMap(k, v []uint64) map[uint64]uint64 { + } + + // Describe implements prometheus.Collector. +-func (s *SlowLog) Describe(ch chan<- *prometheus.Desc) { ++func (s *SlowLog) Describe(ch chan<- *prometheus.Desc) {//nolint:revive + // This method is needed to satisfy interface. + } + +diff --git a/agent/agents/mysql/slowlog/slowlog_test.go b/agent/agents/mysql/slowlog/slowlog_test.go +index f049ef1a..8ba0da38 100644 +--- a/agent/agents/mysql/slowlog/slowlog_test.go ++++ b/agent/agents/mysql/slowlog/slowlog_test.go +@@ -171,7 +171,7 @@ func TestSlowLog(t *testing.T) { + assert.Equal(t, expected, actual) + + cancel() +- for range s.Changes() { ++ for range s.Changes() {//nolint:revive + } + }) + +@@ -222,7 +222,7 @@ func TestSlowLog(t *testing.T) { + assert.Equal(t, expected, actual) + + cancel() +- for range s.Changes() { ++ for range s.Changes() {//nolint:revive + } + }) + +@@ -271,7 +271,7 @@ func TestSlowLog(t *testing.T) { + assert.Equal(t, expected, actual) + + cancel() +- for range s.Changes() { ++ for range s.Changes() {//nolint:revive + } + }) + } +diff --git a/agent/agents/noop/noop.go b/agent/agents/noop/noop.go +index d1081717..8c034d22 100644 +--- a/agent/agents/noop/noop.go ++++ b/agent/agents/noop/noop.go +@@ -57,12 +57,12 @@ func (n *NoOp) Changes() <-chan agents.Change { + } + + // Describe implements prometheus.Collector. +-func (n *NoOp) Describe(ch chan<- *prometheus.Desc) { ++func (n *NoOp) Describe(ch chan<- *prometheus.Desc) {//nolint:revive + // This method is needed to satisfy interface. + } + + // Collect implement prometheus.Collector. +-func (n *NoOp) Collect(ch chan<- prometheus.Metric) { ++func (n *NoOp) Collect(ch chan<- prometheus.Metric) {//nolint:revive + // This method is needed to satisfy interface. + } + +diff --git a/agent/agents/noop/noop_test.go b/agent/agents/noop/noop_test.go +index ccce0193..ab1e3d93 100644 +--- a/agent/agents/noop/noop_test.go ++++ b/agent/agents/noop/noop_test.go +@@ -16,6 +16,6 @@ package noop + + import "testing" + +-func TestNoOp(t *testing.T) { ++func TestNoOp(t *testing.T) {//nolint:revive + // we need at least one test per package to correctly calculate coverage + } +diff --git a/agent/agents/postgres/pgstatmonitor/pgstatmonitor.go b/agent/agents/postgres/pgstatmonitor/pgstatmonitor.go +index f489af40..79d5c54c 100644 +--- a/agent/agents/postgres/pgstatmonitor/pgstatmonitor.go ++++ b/agent/agents/postgres/pgstatmonitor/pgstatmonitor.go +@@ -43,7 +43,7 @@ import ( + const defaultWaitTime = 60 * time.Second + + // PGStatMonitorQAN QAN services connects to PostgreSQL and extracts stats. +-type PGStatMonitorQAN struct { ++type PGStatMonitorQAN struct {//nolint:revive + q *reform.Querier + dbCloser io.Closer + agentID string +@@ -715,12 +715,12 @@ func (m *PGStatMonitorQAN) Changes() <-chan agents.Change { + } + + // Describe implements prometheus.Collector. +-func (m *PGStatMonitorQAN) Describe(ch chan<- *prometheus.Desc) { ++func (m *PGStatMonitorQAN) Describe(ch chan<- *prometheus.Desc) {//nolint:revive + // This method is needed to satisfy interface. + } + + // Collect implement prometheus.Collector. +-func (m *PGStatMonitorQAN) Collect(ch chan<- prometheus.Metric) { ++func (m *PGStatMonitorQAN) Collect(ch chan<- prometheus.Metric) {//nolint:revive + // This method is needed to satisfy interface. + } + +diff --git a/agent/agents/postgres/pgstatstatements/pgstatstatements.go b/agent/agents/postgres/pgstatstatements/pgstatstatements.go +index 2f9a2702..4758dd6f 100644 +--- a/agent/agents/postgres/pgstatstatements/pgstatstatements.go ++++ b/agent/agents/postgres/pgstatstatements/pgstatstatements.go +@@ -53,7 +53,7 @@ var pgStatVer18 = semver.MustParse("1.8.0") + type statementsMap map[int64]*pgStatStatementsExtended + + // PGStatStatementsQAN QAN services connects to PostgreSQL and extracts stats. +-type PGStatStatementsQAN struct { ++type PGStatStatementsQAN struct {//nolint:revive + q *reform.Querier + dbCloser io.Closer + agentID string +@@ -409,7 +409,7 @@ func (m *PGStatStatementsQAN) Changes() <-chan agents.Change { + } + + // Describe implements prometheus.Collector. +-func (m *PGStatStatementsQAN) Describe(ch chan<- *prometheus.Desc) { ++func (m *PGStatStatementsQAN) Describe(ch chan<- *prometheus.Desc) {//nolint:revive + // This method is needed to satisfy interface. + } + +diff --git a/agent/agents/supervisor/supervisor.go b/agent/agents/supervisor/supervisor.go +index d4269809..f2d0cf52 100644 +--- a/agent/agents/supervisor/supervisor.go ++++ b/agent/agents/supervisor/supervisor.go +@@ -425,9 +425,9 @@ func filter(existing, ap map[string]agentpb.AgentParams) ([]string, []string, [] + return toStart, toRestart, toStop + } + +-//nolint:golint,stylecheck ++//nolint:golint,stylecheck,revive + const ( +- type_TEST_SLEEP inventorypb.AgentType = 998 // process ++ type_TEST_SLEEP inventorypb.AgentType = 998 // processe + type_TEST_NOOP inventorypb.AgentType = 999 // built-in + ) + +@@ -671,11 +671,11 @@ func (s *Supervisor) processParams(agentID string, agentProcess *agentpb.SetStat + templateParams["tmp_dir"] = cfg.Paths.TempDir + processParams.Path = cfg.Paths.VMAgent + default: +- return nil, errors.Errorf("unhandled agent type %[1]s (%[1]d).", agentProcess.Type) ++ return nil, errors.Errorf("unhandled agent type %[1]s (%[1]d).", agentProcess.Type)//nolint:revive + } + + if processParams.Path == "" { +- return nil, errors.Errorf("no path for agent type %[1]s (%[1]d).", agentProcess.Type) ++ return nil, errors.Errorf("no path for agent type %[1]s (%[1]d).", agentProcess.Type)//nolint:revive + } + + tr := &templates.TemplateRenderer{ +diff --git a/agent/commands/setup.go b/agent/commands/setup.go +index 16db5e6f..0cd218f9 100644 +--- a/agent/commands/setup.go ++++ b/agent/commands/setup.go +@@ -12,7 +12,7 @@ + // See the License for the specific language governing permissions and + // limitations under the License. + +-//nolint:forbidigo ++//nolint:forbidigo,revive + package commands + + import ( +diff --git a/agent/connectionchecker/connection_checker.go b/agent/connectionchecker/connection_checker.go +index 98378422..549c5af1 100644 +--- a/agent/connectionchecker/connection_checker.go ++++ b/agent/connectionchecker/connection_checker.go +@@ -94,7 +94,7 @@ func (cc *ConnectionChecker) sqlPing(ctx context.Context, db *sql.DB) error { + return err + } + +-func (cc *ConnectionChecker) checkMySQLConnection(ctx context.Context, dsn string, files *agentpb.TextFiles, tlsSkipVerify bool, id uint32) *agentpb.CheckConnectionResponse { //nolint:lll,unparam ++func (cc *ConnectionChecker) checkMySQLConnection(ctx context.Context, dsn string, files *agentpb.TextFiles, tlsSkipVerify bool, id uint32) *agentpb.CheckConnectionResponse { //nolint:lll,unparam,revive + var res agentpb.CheckConnectionResponse + var err error + +diff --git a/agent/main.go b/agent/main.go +index 7bf443c5..46ddb1b2 100644 +--- a/agent/main.go ++++ b/agent/main.go +@@ -11,7 +11,7 @@ + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. +- ++// Package main + package main + + import ( +diff --git a/agent/runner/actions/mysql_explain_action.go b/agent/runner/actions/mysql_explain_action.go +index 2ac3ff4c..4a01dd02 100644 +--- a/agent/runner/actions/mysql_explain_action.go ++++ b/agent/runner/actions/mysql_explain_action.go +@@ -85,7 +85,7 @@ func (a *mysqlExplainAction) Run(ctx context.Context) ([]byte, error) { + + // You cant run Explain on trimmed queries. + if strings.HasSuffix(a.params.Query, "...") { +- return nil, errors.New("EXPLAIN failed because the query was too long and trimmed. Set max-query-length to a larger value.") ++ return nil, errors.New("EXPLAIN failed because the query was too long and trimmed. Set max-query-length to a larger value.")//nolint:revive + } + + // Explain is supported only for DML queries. +diff --git a/agent/runner/runner_test.go b/agent/runner/runner_test.go +index b5ed9ddb..aa44992e 100644 +--- a/agent/runner/runner_test.go ++++ b/agent/runner/runner_test.go +@@ -251,7 +251,7 @@ func (t testJob) Timeout() time.Duration { + return t.timeout + } + +-func (t testJob) Run(ctx context.Context, send jobs.Send) error { ++func (t testJob) Run(ctx context.Context, send jobs.Send) error {//nolint:revive + <-ctx.Done() + return nil + } +diff --git a/managed/cmd/pmm-managed-starlark/main.go b/managed/cmd/pmm-managed-starlark/main.go +index f976d67a..7fef7c47 100644 +--- a/managed/cmd/pmm-managed-starlark/main.go ++++ b/managed/cmd/pmm-managed-starlark/main.go +@@ -12,7 +12,7 @@ + // + // You should have received a copy of the GNU Affero General Public License + // along with this program. If not, see . +- ++// Package main + package main + + import ( +diff --git a/managed/services/agents/channel/channel.go b/managed/services/agents/channel/channel.go +index 5e361423..d8d93daa 100644 +--- a/managed/services/agents/channel/channel.go ++++ b/managed/services/agents/channel/channel.go +@@ -67,7 +67,7 @@ type Response struct { + Error error + } + +-type Stream interface { ++type Stream interface {//nolint:revive + Send(*agentpb.ServerMessage) error + Recv() (*agentpb.AgentMessage, error) + } +diff --git a/managed/services/management/checks.go b/managed/services/management/checks.go +index 6a704d24..ea5252f5 100644 +--- a/managed/services/management/checks.go ++++ b/managed/services/management/checks.go +@@ -172,7 +172,7 @@ func (s *ChecksAPIService) GetFailedChecks(ctx context.Context, req *managementp + } + + // ToggleCheckAlert toggles the silence state of the check with the provided alertID. +-func (s *ChecksAPIService) ToggleCheckAlert(ctx context.Context, req *managementpb.ToggleCheckAlertRequest) (*managementpb.ToggleCheckAlertResponse, error) { ++func (s *ChecksAPIService) ToggleCheckAlert(ctx context.Context, req *managementpb.ToggleCheckAlertRequest) (*managementpb.ToggleCheckAlertResponse, error) {//nolint:revive + return nil, status.Error(codes.NotFound, "Advisor alerts silencing is not supported anymore.") + } + +diff --git a/managed/services/telemetry/datasource_grafanadb_select.go b/managed/services/telemetry/datasource_grafanadb_select.go +index 9361ff93..887b504d 100644 +--- a/managed/services/telemetry/datasource_grafanadb_select.go ++++ b/managed/services/telemetry/datasource_grafanadb_select.go +@@ -52,7 +52,7 @@ func NewDsGrafanaDBSelect(config DSConfigGrafanaDB, l *logrus.Entry) DataSource + } + } + +-func (d *dsGrafanaDBSelect) Init(ctx context.Context) error { ++func (d *dsGrafanaDBSelect) Init(ctx context.Context) error {//nolint:revive + db, err := openGrafanaDBConnection(d.config, d.l) + if err != nil { + return err +@@ -99,6 +99,6 @@ func (d *dsGrafanaDBSelect) FetchMetrics(ctx context.Context, config Config) ([] + return fetchMetricsFromDB(ctx, d.l, d.config.Timeout, d.db, config) + } + +-func (d *dsGrafanaDBSelect) Dispose(ctx context.Context) error { ++func (d *dsGrafanaDBSelect) Dispose(ctx context.Context) error {//nolint:revive + return d.db.Close() + } +diff --git a/managed/services/telemetry/datasource_qandb_select.go b/managed/services/telemetry/datasource_qandb_select.go +index b458a087..60379deb 100644 +--- a/managed/services/telemetry/datasource_qandb_select.go ++++ b/managed/services/telemetry/datasource_qandb_select.go +@@ -73,7 +73,7 @@ func (d *dsQanDBSelect) FetchMetrics(ctx context.Context, config Config) ([]*pmm + return fetchMetricsFromDB(ctx, d.l, d.config.Timeout, d.db, config) + } + +-func (d *dsQanDBSelect) Init(ctx context.Context) error { ++func (d *dsQanDBSelect) Init(ctx context.Context) error {//nolint:revive + return nil + } + +-- +2.34.1 + + +From 4033718466865599ff780a5382dfca61a14621a9 Mon Sep 17 00:00:00 2001 +From: vishwas-sharma2480 +Date: Wed, 17 Jan 2024 04:03:16 +0530 +Subject: [PATCH 15/15] added comments and used nolint were required + +--- + agent/agentlocal/agent_local.go | 2 +- + agent/agents/mongodb/mongodb.go | 4 ++-- + agent/agents/mysql/perfschema/perfschema.go | 2 +- + agent/agents/mysql/slowlog/slowlog.go | 2 +- + agent/client/basic_auth.go | 2 +- + managed/services/management/ia/channels_service.go | 8 ++++---- + managed/services/management/ia/rules_service.go | 10 +++++----- + managed/services/telemetry/datasource_qandb_select.go | 2 +- + 8 files changed, 16 insertions(+), 16 deletions(-) + +diff --git a/agent/agentlocal/agent_local.go b/agent/agentlocal/agent_local.go +index da651077..2f0987a9 100644 +--- a/agent/agentlocal/agent_local.go ++++ b/agent/agentlocal/agent_local.go +@@ -184,7 +184,7 @@ func roundFloat(upTime float32, numAfterDot int) float32 { + } + + // Reload reloads pmm-agent and its configuration. +-func (s *Server) Reload(ctx context.Context, req *agentlocalpb.ReloadRequest) (*agentlocalpb.ReloadResponse, error) { ++func (s *Server) Reload(ctx context.Context, req *agentlocalpb.ReloadRequest) (*agentlocalpb.ReloadResponse, error) {//nolint:revive + // sync errors with setup command + + if _, err := s.cfg.Reload(s.l); err != nil { +diff --git a/agent/agents/mongodb/mongodb.go b/agent/agents/mongodb/mongodb.go +index 728bc3c0..7c244490 100644 +--- a/agent/agents/mongodb/mongodb.go ++++ b/agent/agents/mongodb/mongodb.go +@@ -110,12 +110,12 @@ type Profiler interface {//nolint:revive + } + + // Describe implements prometheus.Collector. +-func (m *MongoDB) Describe(ch chan<- *prometheus.Desc) { ++func (m *MongoDB) Describe(ch chan<- *prometheus.Desc) {//nolint:revive + // This method is needed to satisfy interface. + } + + // Collect implement prometheus.Collector. +-func (m *MongoDB) Collect(ch chan<- prometheus.Metric) { ++func (m *MongoDB) Collect(ch chan<- prometheus.Metric) {//nolint:revive + // This method is needed to satisfy interface. + } + +diff --git a/agent/agents/mysql/perfschema/perfschema.go b/agent/agents/mysql/perfschema/perfschema.go +index ae4af57d..72c4b5a8 100644 +--- a/agent/agents/mysql/perfschema/perfschema.go ++++ b/agent/agents/mysql/perfschema/perfschema.go +@@ -462,7 +462,7 @@ func (m *PerfSchema) Changes() <-chan agents.Change { + } + + // Describe implements prometheus.Collector. +-func (m *PerfSchema) Describe(ch chan<- *prometheus.Desc) { ++func (m *PerfSchema) Describe(ch chan<- *prometheus.Desc) {//nolint:revive + // This method is needed to satisfy interface. + } + +diff --git a/agent/agents/mysql/slowlog/slowlog.go b/agent/agents/mysql/slowlog/slowlog.go +index b2c52741..44ffc718 100644 +--- a/agent/agents/mysql/slowlog/slowlog.go ++++ b/agent/agents/mysql/slowlog/slowlog.go +@@ -720,7 +720,7 @@ func (s *SlowLog) Describe(ch chan<- *prometheus.Desc) {//nolint:revive + } + + // Collect implement prometheus.Collector. +-func (s *SlowLog) Collect(ch chan<- prometheus.Metric) { ++func (s *SlowLog) Collect(ch chan<- prometheus.Metric) {//nolint:revive + // This method is needed to satisfy interface. + } + +diff --git a/agent/client/basic_auth.go b/agent/client/basic_auth.go +index 5055250f..a48b19cf 100644 +--- a/agent/client/basic_auth.go ++++ b/agent/client/basic_auth.go +@@ -27,7 +27,7 @@ type basicAuth struct { + } + + // GetRequestMetadata implements credentials.PerRPCCredentials interface. +-func (b *basicAuth) GetRequestMetadata(ctx context.Context, uri ...string) (map[string]string, error) { ++func (b *basicAuth) GetRequestMetadata(ctx context.Context, uri ...string) (map[string]string, error) {//nolint:revive + auth := b.username + ":" + b.password + enc := base64.StdEncoding.EncodeToString([]byte(auth)) + return map[string]string{ +diff --git a/managed/services/management/ia/channels_service.go b/managed/services/management/ia/channels_service.go +index 72cf0de5..5c0f0643 100644 +--- a/managed/services/management/ia/channels_service.go ++++ b/managed/services/management/ia/channels_service.go +@@ -60,7 +60,7 @@ func (s *ChannelsService) Enabled() bool { + + // ListChannels returns list of available channels. + // Deprecated. Do not use. +-func (s *ChannelsService) ListChannels(ctx context.Context, req *iav1beta1.ListChannelsRequest) (*iav1beta1.ListChannelsResponse, error) { //nolint:staticcheck ++func (s *ChannelsService) ListChannels(ctx context.Context, req *iav1beta1.ListChannelsRequest) (*iav1beta1.ListChannelsResponse, error) { //nolint:staticcheck,revive + var pageIndex int + var pageSize int + if req.PageParams != nil { +@@ -161,7 +161,7 @@ func (s *ChannelsService) getNotificationChannelsPage(pageIndex, pageSize int) ( + + // AddChannel adds new notification channel. + // Deprecated. Do not use. +-func (s *ChannelsService) AddChannel(ctx context.Context, req *iav1beta1.AddChannelRequest) (*iav1beta1.AddChannelResponse, error) { //nolint:staticcheck ++func (s *ChannelsService) AddChannel(ctx context.Context, req *iav1beta1.AddChannelRequest) (*iav1beta1.AddChannelResponse, error) { //nolint:staticcheck,revive + params := &models.CreateChannelParams{ + Summary: req.Summary, + Disabled: req.Disabled, +@@ -212,7 +212,7 @@ func (s *ChannelsService) AddChannel(ctx context.Context, req *iav1beta1.AddChan + + // ChangeChannel changes existing notification channel. + // Deprecated. Do not use. +-func (s *ChannelsService) ChangeChannel(ctx context.Context, req *iav1beta1.ChangeChannelRequest) (*iav1beta1.ChangeChannelResponse, error) { //nolint:staticcheck ++func (s *ChannelsService) ChangeChannel(ctx context.Context, req *iav1beta1.ChangeChannelRequest) (*iav1beta1.ChangeChannelResponse, error) { //nolint:staticcheck,revive + params := &models.ChangeChannelParams{ + Summary: req.Summary, + Disabled: req.Disabled, +@@ -261,7 +261,7 @@ func (s *ChannelsService) ChangeChannel(ctx context.Context, req *iav1beta1.Chan + + // RemoveChannel removes notification channel. + // Deprecated. Do not use. +-func (s *ChannelsService) RemoveChannel(ctx context.Context, req *iav1beta1.RemoveChannelRequest) (*iav1beta1.RemoveChannelResponse, error) { //nolint:staticcheck ++func (s *ChannelsService) RemoveChannel(ctx context.Context, req *iav1beta1.RemoveChannelRequest) (*iav1beta1.RemoveChannelResponse, error) { //nolint:staticcheck,revive + e := s.db.InTransaction(func(tx *reform.TX) error { + return models.RemoveChannel(tx.Querier, req.ChannelId) + }) +diff --git a/managed/services/management/ia/rules_service.go b/managed/services/management/ia/rules_service.go +index 1e217d91..f80920f0 100644 +--- a/managed/services/management/ia/rules_service.go ++++ b/managed/services/management/ia/rules_service.go +@@ -272,7 +272,7 @@ func (s *RulesService) writeRuleFile(rule *ruleFile) error { + + // ListAlertRules returns a list of all Integrated Alerting rules. + // Deprecated. Do not use. +-func (s *RulesService) ListAlertRules(ctx context.Context, req *iav1beta1.ListAlertRulesRequest) (*iav1beta1.ListAlertRulesResponse, error) { //nolint:staticcheck ++func (s *RulesService) ListAlertRules(ctx context.Context, req *iav1beta1.ListAlertRulesRequest) (*iav1beta1.ListAlertRulesResponse, error) { //nolint:staticcheck,revive + var pageIndex int + pageSize := math.MaxInt32 + if req.PageParams != nil { +@@ -346,7 +346,7 @@ func (s *RulesService) convertAlertRules(rules []*models.Rule, channels []*model + + // CreateAlertRule creates Integrated Alerting rule. + // Deprecated. Do not use. +-func (s *RulesService) CreateAlertRule(ctx context.Context, req *iav1beta1.CreateAlertRuleRequest) (*iav1beta1.CreateAlertRuleResponse, error) { //nolint:staticcheck ++func (s *RulesService) CreateAlertRule(ctx context.Context, req *iav1beta1.CreateAlertRuleRequest) (*iav1beta1.CreateAlertRuleResponse, error) { //nolint:staticcheck,revive + if req.TemplateName != "" && req.SourceRuleId != "" { + return nil, status.Errorf(codes.InvalidArgument, "Both template name and source rule id are specified.") + } +@@ -447,7 +447,7 @@ func (s *RulesService) CreateAlertRule(ctx context.Context, req *iav1beta1.Creat + + // UpdateAlertRule updates Integrated Alerting rule. + // Deprecated. Do not use. +-func (s *RulesService) UpdateAlertRule(ctx context.Context, req *iav1beta1.UpdateAlertRuleRequest) (*iav1beta1.UpdateAlertRuleResponse, error) { //nolint:staticcheck ++func (s *RulesService) UpdateAlertRule(ctx context.Context, req *iav1beta1.UpdateAlertRuleRequest) (*iav1beta1.UpdateAlertRuleResponse, error) { //nolint:staticcheck,revive + params := &models.ChangeRuleParams{ + Name: req.Name, + Disabled: req.Disabled, +@@ -496,7 +496,7 @@ func (s *RulesService) UpdateAlertRule(ctx context.Context, req *iav1beta1.Updat + + // ToggleAlertRule allows switching between disabled and enabled states of an Alert Rule. + // Deprecated. Do not use. +-func (s *RulesService) ToggleAlertRule(ctx context.Context, req *iav1beta1.ToggleAlertRuleRequest) (*iav1beta1.ToggleAlertRuleResponse, error) { //nolint:staticcheck ++func (s *RulesService) ToggleAlertRule(ctx context.Context, req *iav1beta1.ToggleAlertRuleRequest) (*iav1beta1.ToggleAlertRuleResponse, error) { //nolint:staticcheck,revive + params := &models.ToggleRuleParams{Disabled: parseBooleanFlag(req.Disabled)} + e := s.db.InTransaction(func(tx *reform.TX) error { + _, err := models.ToggleRule(tx.Querier, req.RuleId, params) +@@ -513,7 +513,7 @@ func (s *RulesService) ToggleAlertRule(ctx context.Context, req *iav1beta1.Toggl + + // DeleteAlertRule deletes Integrated Alerting rule. + // Deprecated. Do not use. +-func (s *RulesService) DeleteAlertRule(ctx context.Context, req *iav1beta1.DeleteAlertRuleRequest) (*iav1beta1.DeleteAlertRuleResponse, error) { //nolint:staticcheck ++func (s *RulesService) DeleteAlertRule(ctx context.Context, req *iav1beta1.DeleteAlertRuleRequest) (*iav1beta1.DeleteAlertRuleResponse, error) { //nolint:staticcheck,revive + e := s.db.InTransaction(func(tx *reform.TX) error { + return models.RemoveRule(tx.Querier, req.RuleId) + }) +diff --git a/managed/services/telemetry/datasource_qandb_select.go b/managed/services/telemetry/datasource_qandb_select.go +index 60379deb..ddac88d6 100644 +--- a/managed/services/telemetry/datasource_qandb_select.go ++++ b/managed/services/telemetry/datasource_qandb_select.go +@@ -77,6 +77,6 @@ func (d *dsQanDBSelect) Init(ctx context.Context) error {//nolint:revive + return nil + } + +-func (d *dsQanDBSelect) Dispose(ctx context.Context) error { ++func (d *dsQanDBSelect) Dispose(ctx context.Context) error {//nolint:revive + return nil + } +-- +2.34.1 + diff --git a/qan-api2/db.go b/qan-api2/db.go index 4e0f9d1646..060e137f70 100644 --- a/qan-api2/db.go +++ b/qan-api2/db.go @@ -12,7 +12,7 @@ // // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . - +// Package main. package main import ( diff --git a/qan-api2/utils/logger/grpc.go b/qan-api2/utils/logger/grpc.go index 7fa6342b83..80b2ba7d18 100644 --- a/qan-api2/utils/logger/grpc.go +++ b/qan-api2/utils/logger/grpc.go @@ -26,16 +26,23 @@ type GRPC struct { } // V reports whether verbosity level l is at least the requested verbose level. -func (v *GRPC) V(l int) bool { +func (v *GRPC) V(l int) bool { //nolint:revive // we don't need real implementation ATM return true } +// Info logs a message at the Info level. // Override InfoXXX methods with TraceXXX to keep gRPC and logrus levels in sync. // +// Info logs a message at the Info level. +// //nolint:stylecheck -func (v *GRPC) Info(args ...interface{}) { v.Trace(args...) } -func (v *GRPC) Infoln(args ...interface{}) { v.Traceln(args...) } +func (v *GRPC) Info(args ...interface{}) { v.Trace(args...) } + +// Infoln logs a message at the Info level. +func (v *GRPC) Infoln(args ...interface{}) { v.Traceln(args...) } + +// Infof logs a formatted message at the Info level. func (v *GRPC) Infof(format string, args ...interface{}) { v.Tracef(format, args...) } // check interfaces. diff --git a/update/main.go b/update/main.go index e1f87f921c..4ecffaf352 100644 --- a/update/main.go +++ b/update/main.go @@ -12,7 +12,7 @@ // // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . - +// Package main provides the entry point for the update application. package main import ( diff --git a/utils/logger/grpc.go b/utils/logger/grpc.go index fcc4f2219e..426b35eb80 100644 --- a/utils/logger/grpc.go +++ b/utils/logger/grpc.go @@ -26,16 +26,21 @@ type GRPC struct { } // V reports whether verbosity level l is at least the requested verbose level. -func (v *GRPC) V(l int) bool { +func (v *GRPC) V(l int) bool { //nolint:revive // we don't need real implementation ATM return true } +// Info logs a message at the Info level. // override InfoXXX methods with TraceXXX to keep gRPC and logrus levels in sync // //nolint:stylecheck -func (v *GRPC) Info(args ...interface{}) { v.Trace(args...) } -func (v *GRPC) Infoln(args ...interface{}) { v.Traceln(args...) } +func (v *GRPC) Info(args ...interface{}) { v.Trace(args...) } + +// Infoln logs a message at the Info level. +func (v *GRPC) Infoln(args ...interface{}) { v.Traceln(args...) } + +// Infof logs a formatted message at the Info level. func (v *GRPC) Infof(format string, args ...interface{}) { v.Tracef(format, args...) } // check interfaces. diff --git a/utils/pdeathsig/pdeathsig.go b/utils/pdeathsig/pdeathsig.go index cf31b6ee32..1f5c7dd4d6 100644 --- a/utils/pdeathsig/pdeathsig.go +++ b/utils/pdeathsig/pdeathsig.go @@ -26,6 +26,6 @@ import ( ) // Set works only on Linux. -func Set(cmd *exec.Cmd, s unix.Signal) { +func Set(_ *exec.Cmd, _ unix.Signal) { // nothing, see pdeathsig_linux.go } diff --git a/utils/sqlmetrics/sqlmetrics.go b/utils/sqlmetrics/sqlmetrics.go index 00a582ef4d..328c64144b 100644 --- a/utils/sqlmetrics/sqlmetrics.go +++ b/utils/sqlmetrics/sqlmetrics.go @@ -85,6 +85,7 @@ func NewCollector(driver, dbName string, db *sql.DB) *Collector { } } +//nolint:revive func (c *Collector) Describe(ch chan<- *prom.Desc) { ch <- c.maxOpenConnections @@ -98,6 +99,7 @@ func (c *Collector) Describe(ch chan<- *prom.Desc) { ch <- c.maxLifetimeClosed } +//nolint:revive func (c *Collector) Collect(ch chan<- prom.Metric) { stats := c.db.Stats()