1
0
Fork 0
mirror of https://github.com/prometheus-operator/prometheus-operator.git synced 2025-04-21 03:38:43 +00:00

Enable revive ()

* Enable revive linter in test/framework

Signed-off-by: Arthur Silva Sens <arthur.sens@coralogix.com>

* Fix revive issues

Signed-off-by: Arthur Silva Sens <arthur.sens@coralogix.com>

---------

Signed-off-by: Arthur Silva Sens <arthur.sens@coralogix.com>
This commit is contained in:
Arthur Silva Sens 2024-01-15 07:03:57 -03:00 committed by GitHub
parent 34836082f8
commit bfe114257c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 6 additions and 31 deletions

View file

@ -16,10 +16,6 @@ issues:
- path: _test.go
linters:
- errcheck
# TODO: fix linter errors before enabling it for the framework
- path: test/framework
linters:
- revive
linters-settings:
errcheck:

View file

@ -157,7 +157,7 @@ func createK8sResources(t *testing.T, ns, certsDir string, cKey testFramework.Ke
secrets = append(secrets, s)
}
} else if cCert.ResourceType == testFramework.CONFIGMAP {
cm = testFramework.MakeConfigMapWithCert(framework.KubeClient, ns, cCert.ResourceName,
cm = testFramework.MakeConfigMapWithCert(ns, cCert.ResourceName,
"", "cert.pem", "", nil, clientCert, nil)
configMaps = append(configMaps, cm)
} else {
@ -180,7 +180,7 @@ func createK8sResources(t *testing.T, ns, certsDir string, cKey testFramework.Ke
if ca.ResourceName == cCert.ResourceName {
cm.Data["ca.pem"] = string(caCert)
} else {
cm = testFramework.MakeConfigMapWithCert(framework.KubeClient, ns, ca.ResourceName,
cm = testFramework.MakeConfigMapWithCert(ns, ca.ResourceName,
"", "", "ca.pem", nil, nil, caCert)
configMaps = append(configMaps, cm)
}
@ -306,7 +306,7 @@ func createK8sAppMonitoring(name, ns string, prwtc testFramework.PromRemoteWrite
// Create prometheus receiver for remote writes
receiverName := fmt.Sprintf("%s-%s", name, "receiver")
prometheusReceiverCRD := framework.MakeBasicPrometheus(ns, receiverName, receiverName, 1)
framework.AddRemoteReceiveWithWebTLSToPrometheus(prometheusReceiverCRD, prwtc)
framework.AddRemoteReceiveWithWebTLSToPrometheus(prometheusReceiverCRD)
if _, err = framework.CreatePrometheusAndWaitUntilReady(context.Background(), ns, prometheusReceiverCRD); err != nil {
return nil, "", err

View file

@ -23,10 +23,9 @@ import (
apierrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/client-go/kubernetes"
)
func MakeConfigMapWithCert(kubeClient kubernetes.Interface, ns, name, keyKey, certKey, caKey string,
func MakeConfigMapWithCert(ns, name, keyKey, certKey, caKey string,
keyBytes, certBytes, caBytes []byte) *v1.ConfigMap {
cm := &v1.ConfigMap{

View file

@ -24,7 +24,6 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/apimachinery/pkg/util/yaml"
"k8s.io/client-go/kubernetes"
)
func (f *Framework) GetDeployment(ctx context.Context, ns, name string) (*appsv1.Deployment, error) {
@ -121,21 +120,3 @@ func (f *Framework) DeleteDeployment(ctx context.Context, namespace, name string
}
return f.KubeClient.AppsV1beta2().Deployments(namespace).Delete(ctx, d.Name, metav1.DeleteOptions{})
}
func (f *Framework) WaitUntilDeploymentGone(ctx context.Context, kubeClient kubernetes.Interface, namespace, name string, timeout time.Duration) error {
return wait.PollUntilContextTimeout(ctx, time.Second, timeout, false, func(ctx context.Context) (bool, error) {
_, err := f.KubeClient.
AppsV1beta2().Deployments(namespace).
Get(ctx, name, metav1.GetOptions{})
if err != nil {
if apierrors.IsNotFound(err) {
return true, nil
}
return false, err
}
return false, nil
})
}

View file

@ -37,9 +37,8 @@ import (
func SourceToIOReader(source string) (io.Reader, error) {
if strings.HasPrefix(source, "http") {
return URLToIOReader(source)
} else {
return PathToOSFile(source)
}
return PathToOSFile(source)
}
func PathToOSFile(relativePath string) (*os.File, error) {

View file

@ -166,7 +166,7 @@ func (f *Framework) AddRemoteWriteWithTLSToPrometheus(p *monitoringv1.Prometheus
}
}
func (f *Framework) AddRemoteReceiveWithWebTLSToPrometheus(p *monitoringv1.Prometheus, prwtc PromRemoteWriteTestConfig) {
func (f *Framework) AddRemoteReceiveWithWebTLSToPrometheus(p *monitoringv1.Prometheus) {
p.Spec.EnableFeatures = []string{"remote-write-receiver"}
p.Spec.Web = &monitoringv1.PrometheusWebSpec{}