Fix rubocop warnings
This commit is contained in:
parent
09473b192c
commit
57c1f7cae0
4 changed files with 19 additions and 13 deletions
|
@ -23,7 +23,7 @@ class PrometheusService < MonitoringService
|
|||
|
||||
def initialize_properties
|
||||
if properties.nil?
|
||||
self.properties = { }
|
||||
self.properties = {}
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -45,7 +45,8 @@ class PrometheusService < MonitoringService
|
|||
|
||||
def fields
|
||||
[
|
||||
{ type: 'fieldset',
|
||||
{
|
||||
type: 'fieldset',
|
||||
legend: 'Manual Configuration',
|
||||
fields: [
|
||||
{
|
||||
|
@ -100,6 +101,7 @@ class PrometheusService < MonitoringService
|
|||
# Cache metrics for specific environment
|
||||
def calculate_reactive_cache(query_class_name, environment_id, *args)
|
||||
return unless active? && project && !project.pending_delete?
|
||||
|
||||
client = client(environment_id)
|
||||
|
||||
data = Kernel.const_get(query_class_name).new(client).query(environment_id, *args)
|
||||
|
@ -118,9 +120,10 @@ class PrometheusService < MonitoringService
|
|||
else
|
||||
cluster = cluster_with_prometheus(environment_id)
|
||||
raise Gitlab::PrometheusError, "couldn't find cluster with Prometheus installed" unless cluster
|
||||
rest_client = client_from_cluster(cluster)
|
||||
|
||||
rest_client = client_from_cluster(cluster)
|
||||
raise Gitlab::PrometheusError, "couldn't create proxy Prometheus client" unless rest_client
|
||||
|
||||
Gitlab::PrometheusClient.new(rest_client)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -32,6 +32,6 @@ describe Gitlab::Prometheus::Queries::DeploymentQuery do
|
|||
time: stop_time)
|
||||
|
||||
expect(subject.query(environment.id, deployment.id)).to eq(memory_values: nil, memory_before: nil, memory_after: nil,
|
||||
cpu_values: nil, cpu_before: nil, cpu_after: nil)
|
||||
cpu_values: nil, cpu_before: nil, cpu_after: nil)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -51,13 +51,16 @@ describe Clusters::Applications::Prometheus do
|
|||
|
||||
context 'cluster has kubeclient' do
|
||||
let(:kubernetes_url) { 'http://example.com' }
|
||||
let(:k8s_discover_response) { {
|
||||
resources: [
|
||||
{
|
||||
name: 'service',
|
||||
kind: 'Service'
|
||||
}]
|
||||
} }
|
||||
let(:k8s_discover_response) do
|
||||
{
|
||||
resources: [
|
||||
{
|
||||
name: 'service',
|
||||
kind: 'Service'
|
||||
}
|
||||
]
|
||||
}
|
||||
end
|
||||
|
||||
let(:kube_client) { Kubeclient::Client.new(kubernetes_url) }
|
||||
|
||||
|
|
|
@ -205,7 +205,7 @@ describe PrometheusService, :use_clean_rails_memory_store_caching do
|
|||
context 'with cluster for all environments without prometheus installed' do
|
||||
context 'without environment supplied' do
|
||||
it 'raises PrometheusError because cluster was not found' do
|
||||
expect{service.client}.to raise_error(Gitlab::PrometheusError, /couldn't find cluster with Prometheus installed/)
|
||||
expect { service.client }.to raise_error(Gitlab::PrometheusError, /couldn't find cluster with Prometheus installed/)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -224,7 +224,7 @@ describe PrometheusService, :use_clean_rails_memory_store_caching do
|
|||
let!(:environment) { create(:environment, project: project, name: 'prod') }
|
||||
|
||||
it 'raises PrometheusError because cluster was not found' do
|
||||
expect{service.client}.to raise_error(Gitlab::PrometheusError, /couldn't find cluster with Prometheus installed/)
|
||||
expect { service.client }.to raise_error(Gitlab::PrometheusError, /couldn't find cluster with Prometheus installed/)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue