1
0
mirror of https://github.com/coreos/prometheus-operator.git synced 2026-02-05 06:45:27 +01:00

chore: Upgrade golangci-lint to v2 and golangci-lint-action to v7.0.0 (#7430)

---------

Signed-off-by: dongjiang <dongjiang1989@126.com>
Co-authored-by: Simon Pasquier <spasquie@redhat.com>
This commit is contained in:
dongjiang
2025-03-31 15:51:44 +08:00
committed by GitHub
parent 8c3fa70cb9
commit 5a8daae34b
26 changed files with 229 additions and 186 deletions

View File

@@ -27,7 +27,7 @@ import (
func (f *Framework) createOrUpdateMutatingHook(ctx context.Context, certBytes []byte, namespace, source string) (FinalizerFn, error) {
hook, err := parseMutatingHookYaml(source)
if err != nil {
return nil, fmt.Errorf("Failed parsing mutating webhook: %w", err)
return nil, fmt.Errorf("failed parsing mutating webhook: %w", err)
}
hook.Webhooks[0].ClientConfig.Service.Namespace = namespace
@@ -46,7 +46,7 @@ func (f *Framework) createOrUpdateMutatingHook(ctx context.Context, certBytes []
}
} else {
// must set this field from existing MutatingWebhookConfiguration to prevent update fail
hook.ObjectMeta.ResourceVersion = h.ObjectMeta.ResourceVersion
hook.ResourceVersion = h.ResourceVersion
// MutatingWebhookConfiguration already exists -> Update
_, err = f.KubeClient.AdmissionregistrationV1().MutatingWebhookConfigurations().Update(ctx, hook, metav1.UpdateOptions{})
@@ -63,7 +63,7 @@ func (f *Framework) createOrUpdateMutatingHook(ctx context.Context, certBytes []
func (f *Framework) createOrUpdateValidatingHook(ctx context.Context, certBytes []byte, namespace, source string) (FinalizerFn, error) {
hook, err := parseValidatingHookYaml(source)
if err != nil {
return nil, fmt.Errorf("Failed parsing validating webhook: %w", err)
return nil, fmt.Errorf("failed parsing validating webhook: %w", err)
}
hook.Webhooks[0].ClientConfig.Service.Namespace = namespace
@@ -82,7 +82,7 @@ func (f *Framework) createOrUpdateValidatingHook(ctx context.Context, certBytes
}
} else {
// must set this field from existing ValidatingWebhookConfiguration to prevent update fail
hook.ObjectMeta.ResourceVersion = h.ObjectMeta.ResourceVersion
hook.ResourceVersion = h.ResourceVersion
// ValidatingWebhookConfiguration already exists -> Update
_, err = f.KubeClient.AdmissionregistrationV1().ValidatingWebhookConfigurations().Update(ctx, hook, metav1.UpdateOptions{})

View File

@@ -101,11 +101,10 @@ func (fdw *fileDiagnosticWriter) StartCollection(name string) {
func (f *Framework) NewTestCtx(t *testing.T) *TestCtx {
// TestCtx is used among others for namespace names where '/' is forbidden
prefix := strings.TrimPrefix(
strings.Replace(
strings.ReplaceAll(
strings.ToLower(t.Name()),
"/",
"-",
-1,
),
"test",
)

View File

@@ -65,7 +65,7 @@ func (f *Framework) CreateOrUpdateCRD(ctx context.Context, crd *v1.CustomResourc
}
} else {
// must set this field from existing CRD to prevent update fail
crd.ObjectMeta.ResourceVersion = c.ObjectMeta.ResourceVersion
crd.ResourceVersion = c.ResourceVersion
// CRD already exists -> Update
_, err := f.APIServerClient.ApiextensionsV1().CustomResourceDefinitions().Update(ctx, crd, metav1.UpdateOptions{})
@@ -139,7 +139,7 @@ func (f *Framework) CreateOrUpdateCRDAndWaitUntilReady(ctx context.Context, crdN
return fmt.Errorf("create CRD: %s from manifest: %s: %w", crdName, assetPath, err)
}
crd.ObjectMeta.Name = crd.Spec.Names.Plural + "." + group
crd.Name = crd.Spec.Names.Plural + "." + group
crd.Spec.Group = group
err = f.CreateOrUpdateCRD(ctx, crd)

View File

@@ -649,7 +649,7 @@ func (f *Framework) WaitForDiscoveryWorking(ctx context.Context, ns, svcName, pr
if loopErr != nil {
return false, loopErr
}
if 1 != len(pods.Items) {
if len(pods.Items) != 1 {
return false, nil
}
podIP := pods.Items[0].Status.PodIP

View File

@@ -156,18 +156,18 @@ func (f *Framework) WaitForPrometheusAgentDSReady(ctx context.Context, ns string
return false, nil
}
if dms.ObjectMeta.DeletionTimestamp != nil {
pollErr = fmt.Errorf("Prometheus Agent DaemonSet deletion in progress")
if dms.DeletionTimestamp != nil {
pollErr = fmt.Errorf("prometheus Agent DaemonSet deletion in progress")
return false, nil
}
if dms.Status.NumberUnavailable > 0 {
pollErr = fmt.Errorf("Prometheus Agent DaemonSet is not available")
pollErr = fmt.Errorf("prometheus Agent DaemonSet is not available")
return false, nil
}
if dms.Status.NumberReady == 0 {
pollErr = fmt.Errorf("Prometheus Agent DaemonSet is not ready")
pollErr = fmt.Errorf("prometheus Agent DaemonSet is not ready")
return false, nil
}
@@ -212,7 +212,7 @@ func (f *Framework) DeletePrometheusAgentDSAndWaitUntilGone(ctx context.Context,
dmsName := fmt.Sprintf("prom-agent-%s", p.Name)
dms, _ := f.KubeClient.AppsV1().DaemonSets(ns).Get(ctx, dmsName, metav1.GetOptions{})
if dms.Status.NumberAvailable != 0 {
pollErr = fmt.Errorf("Prometheus Agent DaemonSet still exists after deleting")
pollErr = fmt.Errorf("prometheus Agent DaemonSet still exists after deleting")
return false, nil
}

View File

@@ -54,7 +54,7 @@ func (f *Framework) CreateOrUpdateServiceAndWaitUntilReady(ctx context.Context,
}
} else {
// must set these immutable fields from the existing service to prevent update fail
service.ObjectMeta.ResourceVersion = s.ObjectMeta.ResourceVersion
service.ResourceVersion = s.ResourceVersion
service.Spec.ClusterIP = s.Spec.ClusterIP
service.Spec.ClusterIPs = s.Spec.ClusterIPs
service.Spec.IPFamilies = s.Spec.IPFamilies