chore: linter

Signed-off-by: Leonardo Cecchi <leonardo.cecchi@enterprisedb.com>
This commit is contained in:
Leonardo Cecchi 2024-12-05 15:25:48 +01:00 committed by Francesco Canovai
parent db89bf4686
commit 127f94adaf
9 changed files with 20 additions and 17 deletions

View File

@ -24,7 +24,7 @@ import (
// InstanceSidecarConfiguration defines the configuration for the sidecar that runs in the instance pods.
type InstanceSidecarConfiguration struct {
// The environment to be explicitely passed to the sidecar
// The environment to be explicitly passed to the sidecar
// +optional
Env []corev1.EnvVar `json:"env,omitempty"`
}

View File

@ -1,8 +1,7 @@
package common
// WALNotFoundError is raised when a WAL file has not been found in the object store
type WALNotFoundError struct {
}
type WALNotFoundError struct{}
// ShouldPrintStackTrace tells whether the sidecar log stream should contain the stack trace
func (e WALNotFoundError) ShouldPrintStackTrace() bool {

View File

@ -242,9 +242,9 @@ func (w WALServiceImplementation) restoreFromBarmanObjectStore(
if walStatus[0].Err != nil {
if errors.Is(walStatus[0].Err, barmanRestorer.ErrWALNotFound) {
return WALNotFoundError{}
} else {
return walStatus[0].Err
}
return walStatus[0].Err
}
// We skip this step if streaming connection is not available

View File

@ -50,7 +50,7 @@ func (i IdentityImplementation) GetPluginCapabilities(
// Probe implements IdentityServer
func (i IdentityImplementation) Probe(
ctx context.Context,
_ context.Context,
_ *identity.ProbeRequest,
) (*identity.ProbeResponse, error) {
return &identity.ProbeResponse{

View File

@ -13,7 +13,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/client"
)
// The default TTL in seconds of cache entries
// DefaultTTLSeconds is the default TTL in seconds of cache entries
const DefaultTTLSeconds = 10
type cachedEntry struct {
@ -114,7 +114,7 @@ func (e *ExtendedClient) getCachedObject(
return nil
}
if err := e.Client.Get(ctx, key, obj); err != nil {
if err := e.Client.Get(ctx, key, obj, opts...); err != nil {
return err
}

View File

@ -59,6 +59,7 @@ type PluginConfiguration struct {
ReplicaSourceServerName string
}
// GetBarmanObjectKey gets the namespaced name of the barman object
func (config *PluginConfiguration) GetBarmanObjectKey() types.NamespacedName {
return types.NamespacedName{
Namespace: config.Cluster.Namespace,
@ -66,6 +67,7 @@ func (config *PluginConfiguration) GetBarmanObjectKey() types.NamespacedName {
}
}
// GetRecoveryBarmanObjectKey gets the namespaced name of the recovery barman object
func (config *PluginConfiguration) GetRecoveryBarmanObjectKey() types.NamespacedName {
return types.NamespacedName{
Namespace: config.Cluster.Namespace,
@ -73,6 +75,7 @@ func (config *PluginConfiguration) GetRecoveryBarmanObjectKey() types.Namespaced
}
}
// GetReplicaSourceBarmanObjectKey gets the namespaced name of the replica source barman object
func (config *PluginConfiguration) GetReplicaSourceBarmanObjectKey() types.NamespacedName {
return types.NamespacedName{
Namespace: config.Cluster.Namespace,
@ -80,6 +83,8 @@ func (config *PluginConfiguration) GetReplicaSourceBarmanObjectKey() types.Names
}
}
// GetReferredBarmanObjectsKey gets the list of barman objects referred by this
// plugin configuration
func (config *PluginConfiguration) GetReferredBarmanObjectsKey() []types.NamespacedName {
result := make([]types.NamespacedName, 0, 3)
@ -237,10 +242,10 @@ func getReplicaSourcePlugin(cluster *cnpgv1.Cluster) *cnpgv1.PluginConfiguration
}
// Validate checks if the barmanObjectName is set
func (p *PluginConfiguration) Validate() error {
func (config *PluginConfiguration) Validate() error {
err := NewConfigurationError()
if len(p.BarmanObjectName) == 0 && len(p.RecoveryBarmanObjectName) == 0 {
if len(config.BarmanObjectName) == 0 && len(config.RecoveryBarmanObjectName) == 0 {
return err.WithMessage("no reference to barmanObjectName have been included")
}

View File

@ -168,14 +168,13 @@ func (impl LifecycleImplementation) reconcileJob(
return nil, nil
}
return reconcileJob(ctx, cluster, request, pluginConfiguration, env)
return reconcileJob(ctx, cluster, request, env)
}
func reconcileJob(
ctx context.Context,
cluster *cnpgv1.Cluster,
request *lifecycle.OperatorLifecycleRequest,
pluginConfiguration *config.PluginConfiguration,
env []corev1.EnvVar,
) (*lifecycle.OperatorLifecycleResponse, error) {
contextLogger := log.FromContext(ctx).WithName("lifecycle")

View File

@ -107,7 +107,7 @@ var _ = Describe("LifecycleImplementation", func() {
ObjectDefinition: jobJSON,
}
response, err := reconcileJob(ctx, cluster, request, pluginConfiguration, nil)
response, err := reconcileJob(ctx, cluster, request, nil)
Expect(err).NotTo(HaveOccurred())
Expect(response).NotTo(BeNil())
Expect(response.JsonPatch).NotTo(BeEmpty())
@ -128,7 +128,7 @@ var _ = Describe("LifecycleImplementation", func() {
ObjectDefinition: jobJSON,
}
response, err := reconcileJob(ctx, cluster, request, pluginConfiguration, nil)
response, err := reconcileJob(ctx, cluster, request, nil)
Expect(err).NotTo(HaveOccurred())
Expect(response).To(BeNil())
})
@ -138,7 +138,7 @@ var _ = Describe("LifecycleImplementation", func() {
ObjectDefinition: []byte("invalid-json"),
}
response, err := reconcileJob(ctx, cluster, request, pluginConfiguration, nil)
response, err := reconcileJob(ctx, cluster, request, nil)
Expect(err).To(HaveOccurred())
Expect(response).To(BeNil())
})
@ -165,7 +165,7 @@ var _ = Describe("LifecycleImplementation", func() {
ObjectDefinition: jobJSON,
}
response, err := reconcileJob(ctx, cluster, request, pluginConfiguration, nil)
response, err := reconcileJob(ctx, cluster, request, nil)
Expect(err).NotTo(HaveOccurred())
Expect(response).To(BeNil())
})

View File

@ -75,7 +75,7 @@ func (r ReconcilerImplementation) Pre(
contextLogger.Debug("parsing barman object configuration")
var barmanObjects []barmancloudv1.ObjectStore
barmanObjects := make([]barmancloudv1.ObjectStore, 0, len(pluginConfiguration.GetReferredBarmanObjectsKey()))
for _, barmanObjectKey := range pluginConfiguration.GetReferredBarmanObjectsKey() {
var barmanObject barmancloudv1.ObjectStore
if err := r.Client.Get(ctx, barmanObjectKey, &barmanObject); err != nil {