Skip to content

Commit

Permalink
PMM-13416 Fix imports linter.
Browse files Browse the repository at this point in the history
  • Loading branch information
BupycHuk committed Nov 8, 2024
1 parent 3d98245 commit 0b883f6
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,14 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

package types
package inventoryv1

import (
"github.com/AlekSi/pointer"

inventoryv1 "github.com/percona/pmm/api/inventory/v1"
"github.com/percona/pmm/utils/enums"
)

func LogLevelAPIValue(l *string) inventoryv1.LogLevel {
return inventoryv1.LogLevel(inventoryv1.LogLevel_value[enums.ConvertEnum("LOG_LEVEL", pointer.Get(l))])
func LogLevelAPIValue(l *string) LogLevel {
return LogLevel(LogLevel_value[enums.ConvertEnum("LOG_LEVEL", pointer.Get(l))])
}
4 changes: 4 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ services:
# caching
- go-modules:/root/go/pkg/mod
- root-cache:/root/.cache
# grafana
# - "../grafana:/workspace"
# - "../grafana/public:/usr/share/grafana/public"
# - "../grafana/conf/grafana.local-dev.ini:/usr/share/grafana/conf/defaults.ini"
# command: >
# bash -c "
# rm -rf /tmp/certs
Expand Down
25 changes: 12 additions & 13 deletions managed/services/converters.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import (

"github.com/percona/pmm/api/common"
inventoryv1 "github.com/percona/pmm/api/inventory/v1"
"github.com/percona/pmm/api/inventory/v1/types"
"github.com/percona/pmm/managed/models"
)

Expand Down Expand Up @@ -240,7 +239,7 @@ func ToAPIAgent(q *reform.Querier, agent *models.Agent) (inventoryv1.Agent, erro
PushMetricsEnabled: agent.PushMetrics,
DisabledCollectors: agent.DisabledCollectors,
ProcessExecPath: processExecPath,
LogLevel: types.LogLevelAPIValue(agent.LogLevel),
LogLevel: inventoryv1.LogLevelAPIValue(agent.LogLevel),
ExposeExporter: agent.ExposeExporter,
MetricsResolutions: ConvertMetricsResolutions(agent.MetricsResolutions),
}, nil
Expand All @@ -263,7 +262,7 @@ func ToAPIAgent(q *reform.Querier, agent *models.Agent) (inventoryv1.Agent, erro
PushMetricsEnabled: agent.PushMetrics,
DisabledCollectors: agent.DisabledCollectors,
ProcessExecPath: processExecPath,
LogLevel: types.LogLevelAPIValue(agent.LogLevel),
LogLevel: inventoryv1.LogLevelAPIValue(agent.LogLevel),
ExposeExporter: agent.ExposeExporter,
MetricsResolutions: ConvertMetricsResolutions(agent.MetricsResolutions),
}, nil
Expand All @@ -283,7 +282,7 @@ func ToAPIAgent(q *reform.Querier, agent *models.Agent) (inventoryv1.Agent, erro
PushMetricsEnabled: agent.PushMetrics,
DisabledCollectors: agent.DisabledCollectors,
ProcessExecPath: processExecPath,
LogLevel: types.LogLevelAPIValue(agent.LogLevel),
LogLevel: inventoryv1.LogLevelAPIValue(agent.LogLevel),
ExposeExporter: agent.ExposeExporter,
MetricsResolutions: ConvertMetricsResolutions(agent.MetricsResolutions),
}
Expand All @@ -309,7 +308,7 @@ func ToAPIAgent(q *reform.Querier, agent *models.Agent) (inventoryv1.Agent, erro
PushMetricsEnabled: agent.PushMetrics,
DisabledCollectors: agent.DisabledCollectors,
ProcessExecPath: processExecPath,
LogLevel: types.LogLevelAPIValue(agent.LogLevel),
LogLevel: inventoryv1.LogLevelAPIValue(agent.LogLevel),
ExposeExporter: agent.ExposeExporter,
MetricsResolutions: ConvertMetricsResolutions(agent.MetricsResolutions),
}
Expand All @@ -333,7 +332,7 @@ func ToAPIAgent(q *reform.Querier, agent *models.Agent) (inventoryv1.Agent, erro
QueryExamplesDisabled: agent.QueryExamplesDisabled,
DisableCommentsParsing: agent.CommentsParsingDisabled,
ProcessExecPath: processExecPath,
LogLevel: types.LogLevelAPIValue(agent.LogLevel),
LogLevel: inventoryv1.LogLevelAPIValue(agent.LogLevel),
}, nil

case models.QANMySQLSlowlogAgentType:
Expand All @@ -351,7 +350,7 @@ func ToAPIAgent(q *reform.Querier, agent *models.Agent) (inventoryv1.Agent, erro
DisableCommentsParsing: agent.CommentsParsingDisabled,
MaxSlowlogFileSize: agent.MaxQueryLogSize,
ProcessExecPath: processExecPath,
LogLevel: types.LogLevelAPIValue(agent.LogLevel),
LogLevel: inventoryv1.LogLevelAPIValue(agent.LogLevel),
}, nil

case models.QANMongoDBProfilerAgentType:
Expand All @@ -367,7 +366,7 @@ func ToAPIAgent(q *reform.Querier, agent *models.Agent) (inventoryv1.Agent, erro
TlsSkipVerify: agent.TLSSkipVerify,
MaxQueryLength: agent.MaxQueryLength,
ProcessExecPath: processExecPath,
LogLevel: types.LogLevelAPIValue(agent.LogLevel),
LogLevel: inventoryv1.LogLevelAPIValue(agent.LogLevel),
// TODO QueryExamplesDisabled https://jira.percona.com/browse/PMM-4650
}, nil

Expand All @@ -386,7 +385,7 @@ func ToAPIAgent(q *reform.Querier, agent *models.Agent) (inventoryv1.Agent, erro
PushMetricsEnabled: agent.PushMetrics,
DisabledCollectors: agent.DisabledCollectors,
ProcessExecPath: processExecPath,
LogLevel: types.LogLevelAPIValue(agent.LogLevel),
LogLevel: inventoryv1.LogLevelAPIValue(agent.LogLevel),
ExposeExporter: agent.ExposeExporter,
MetricsResolutions: ConvertMetricsResolutions(agent.MetricsResolutions),
}, nil
Expand All @@ -405,7 +404,7 @@ func ToAPIAgent(q *reform.Querier, agent *models.Agent) (inventoryv1.Agent, erro
Tls: agent.TLS,
TlsSkipVerify: agent.TLSSkipVerify,
ProcessExecPath: processExecPath,
LogLevel: types.LogLevelAPIValue(agent.LogLevel),
LogLevel: inventoryv1.LogLevelAPIValue(agent.LogLevel),
}, nil

case models.QANPostgreSQLPgStatMonitorAgentType:
Expand All @@ -423,7 +422,7 @@ func ToAPIAgent(q *reform.Querier, agent *models.Agent) (inventoryv1.Agent, erro
QueryExamplesDisabled: agent.QueryExamplesDisabled,
DisableCommentsParsing: agent.CommentsParsingDisabled,
ProcessExecPath: processExecPath,
LogLevel: types.LogLevelAPIValue(agent.LogLevel),
LogLevel: inventoryv1.LogLevelAPIValue(agent.LogLevel),
}, nil

case models.RDSExporterType:
Expand All @@ -440,7 +439,7 @@ func ToAPIAgent(q *reform.Querier, agent *models.Agent) (inventoryv1.Agent, erro
EnhancedMetricsDisabled: agent.RDSEnhancedMetricsDisabled,
PushMetricsEnabled: agent.PushMetrics,
ProcessExecPath: processExecPath,
LogLevel: types.LogLevelAPIValue(agent.LogLevel),
LogLevel: inventoryv1.LogLevelAPIValue(agent.LogLevel),
MetricsResolutions: ConvertMetricsResolutions(agent.MetricsResolutions),
}, nil

Expand Down Expand Up @@ -478,7 +477,7 @@ func ToAPIAgent(q *reform.Querier, agent *models.Agent) (inventoryv1.Agent, erro
ListenPort: uint32(pointer.GetUint16(agent.ListenPort)),
CustomLabels: labels,
ProcessExecPath: processExecPath,
LogLevel: types.LogLevelAPIValue(agent.LogLevel),
LogLevel: inventoryv1.LogLevelAPIValue(agent.LogLevel),
MetricsResolutions: ConvertMetricsResolutions(agent.MetricsResolutions),
}, nil

Expand Down
4 changes: 2 additions & 2 deletions managed/services/management/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
"google.golang.org/protobuf/types/known/timestamppb"
"gopkg.in/reform.v1"

"github.com/percona/pmm/api/inventory/v1/types"
inventoryv1 "github.com/percona/pmm/api/inventory/v1"
managementv1 "github.com/percona/pmm/api/management/v1"
"github.com/percona/pmm/managed/models"
"github.com/percona/pmm/version"
Expand Down Expand Up @@ -135,7 +135,7 @@ func (s *ManagementService) agentToAPI(agent *models.Agent) (*managementv1.Unive
IsAwsSecretKeySet: pointer.GetString(agent.AWSSecretKey) != "",
IsPasswordSet: pointer.GetString(agent.Password) != "",
ListenPort: uint32(pointer.GetUint16(agent.ListenPort)),
LogLevel: types.LogLevelAPIValue(agent.LogLevel),
LogLevel: inventoryv1.LogLevelAPIValue(agent.LogLevel),
MaxQueryLength: agent.MaxQueryLength,
MaxQueryLogSize: agent.MaxQueryLogSize,
MetricsPath: pointer.GetString(agent.MetricsPath),
Expand Down

0 comments on commit 0b883f6

Please sign in to comment.