Skip to content

Commit

Permalink
PMM-12702 Fix linter and usage of As.
Browse files Browse the repository at this point in the history
  • Loading branch information
BupycHuk committed Nov 20, 2023
1 parent c67542a commit 3741149
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions managed/models/agentversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,11 @@ type AgentNotSupportedError struct {
MinAgentVersion string
}

func (e *AgentNotSupportedError) Error() string {
func (e AgentNotSupportedError) Error() string {
return fmt.Sprintf("'%s' functionality is not supported by pmm-agent %q version %q. Required minimum version is %q", e.Functionality,
e.AgentID, e.AgentVersion, e.MinAgentVersion)
}

func (e *AgentNotSupportedError) Is(err error) bool {
_, ok := err.(*AgentNotSupportedError)
return ok
}

// PMMAgentSupported checks if pmm agent version satisfies required min version.
func PMMAgentSupported(q *reform.Querier, pmmAgentID, functionalityPrefix string, pmmMinVersion *version.Version) error {
pmmAgent, err := FindAgentByID(q, pmmAgentID)
Expand All @@ -66,7 +61,7 @@ func IsAgentSupported(agentModel *Agent, functionalityPrefix string, pmmMinVersi
}

if pmmAgentVersion.LessThan(pmmMinVersion) {
return errors.WithStack(&AgentNotSupportedError{
return errors.WithStack(AgentNotSupportedError{
AgentID: agentModel.AgentID,
Functionality: functionalityPrefix,
AgentVersion: *agentModel.Version,
Expand All @@ -79,7 +74,7 @@ func IsAgentSupported(agentModel *Agent, functionalityPrefix string, pmmMinVersi
func IsPostgreSQLSSLSniSupported(q *reform.Querier, pmmAgentID string) (bool, error) {
err := PMMAgentSupported(q, pmmAgentID, "postgresql SSL sni check", PMMAgentMinVersionForPostgreSQLSSLSni)
switch {
case errors.Is(err, &AgentNotSupportedError{}):
case errors.As(err, &AgentNotSupportedError{}):
return false, nil
case err == nil:
return true, nil
Expand Down

0 comments on commit 3741149

Please sign in to comment.