Skip to content

Commit 127f94a

Browse files
leonardocefcanovai
authored andcommitted
chore: linter
Signed-off-by: Leonardo Cecchi <[email protected]>
1 parent db89bf4 commit 127f94a

File tree

9 files changed

+20
-17
lines changed

9 files changed

+20
-17
lines changed

api/v1/objectstore_types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import (
2424

2525
// InstanceSidecarConfiguration defines the configuration for the sidecar that runs in the instance pods.
2626
type InstanceSidecarConfiguration struct {
27-
// The environment to be explicitely passed to the sidecar
27+
// The environment to be explicitly passed to the sidecar
2828
// +optional
2929
Env []corev1.EnvVar `json:"env,omitempty"`
3030
}

internal/cnpgi/common/errors.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
package common
22

33
// WALNotFoundError is raised when a WAL file has not been found in the object store
4-
type WALNotFoundError struct {
5-
}
4+
type WALNotFoundError struct{}
65

76
// ShouldPrintStackTrace tells whether the sidecar log stream should contain the stack trace
87
func (e WALNotFoundError) ShouldPrintStackTrace() bool {

internal/cnpgi/common/wal.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,9 +242,9 @@ func (w WALServiceImplementation) restoreFromBarmanObjectStore(
242242
if walStatus[0].Err != nil {
243243
if errors.Is(walStatus[0].Err, barmanRestorer.ErrWALNotFound) {
244244
return WALNotFoundError{}
245-
} else {
246-
return walStatus[0].Err
247245
}
246+
247+
return walStatus[0].Err
248248
}
249249

250250
// We skip this step if streaming connection is not available

internal/cnpgi/instance/identity.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ func (i IdentityImplementation) GetPluginCapabilities(
5050

5151
// Probe implements IdentityServer
5252
func (i IdentityImplementation) Probe(
53-
ctx context.Context,
53+
_ context.Context,
5454
_ *identity.ProbeRequest,
5555
) (*identity.ProbeResponse, error) {
5656
return &identity.ProbeResponse{

internal/cnpgi/instance/internal/client/client.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313
"sigs.k8s.io/controller-runtime/pkg/client"
1414
)
1515

16-
// The default TTL in seconds of cache entries
16+
// DefaultTTLSeconds is the default TTL in seconds of cache entries
1717
const DefaultTTLSeconds = 10
1818

1919
type cachedEntry struct {
@@ -114,7 +114,7 @@ func (e *ExtendedClient) getCachedObject(
114114
return nil
115115
}
116116

117-
if err := e.Client.Get(ctx, key, obj); err != nil {
117+
if err := e.Client.Get(ctx, key, obj, opts...); err != nil {
118118
return err
119119
}
120120

internal/cnpgi/operator/config/config.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,27 +59,32 @@ type PluginConfiguration struct {
5959
ReplicaSourceServerName string
6060
}
6161

62+
// GetBarmanObjectKey gets the namespaced name of the barman object
6263
func (config *PluginConfiguration) GetBarmanObjectKey() types.NamespacedName {
6364
return types.NamespacedName{
6465
Namespace: config.Cluster.Namespace,
6566
Name: config.BarmanObjectName,
6667
}
6768
}
6869

70+
// GetRecoveryBarmanObjectKey gets the namespaced name of the recovery barman object
6971
func (config *PluginConfiguration) GetRecoveryBarmanObjectKey() types.NamespacedName {
7072
return types.NamespacedName{
7173
Namespace: config.Cluster.Namespace,
7274
Name: config.RecoveryBarmanObjectName,
7375
}
7476
}
7577

78+
// GetReplicaSourceBarmanObjectKey gets the namespaced name of the replica source barman object
7679
func (config *PluginConfiguration) GetReplicaSourceBarmanObjectKey() types.NamespacedName {
7780
return types.NamespacedName{
7881
Namespace: config.Cluster.Namespace,
7982
Name: config.ReplicaSourceServerName,
8083
}
8184
}
8285

86+
// GetReferredBarmanObjectsKey gets the list of barman objects referred by this
87+
// plugin configuration
8388
func (config *PluginConfiguration) GetReferredBarmanObjectsKey() []types.NamespacedName {
8489
result := make([]types.NamespacedName, 0, 3)
8590

@@ -237,10 +242,10 @@ func getReplicaSourcePlugin(cluster *cnpgv1.Cluster) *cnpgv1.PluginConfiguration
237242
}
238243

239244
// Validate checks if the barmanObjectName is set
240-
func (p *PluginConfiguration) Validate() error {
245+
func (config *PluginConfiguration) Validate() error {
241246
err := NewConfigurationError()
242247

243-
if len(p.BarmanObjectName) == 0 && len(p.RecoveryBarmanObjectName) == 0 {
248+
if len(config.BarmanObjectName) == 0 && len(config.RecoveryBarmanObjectName) == 0 {
244249
return err.WithMessage("no reference to barmanObjectName have been included")
245250
}
246251

internal/cnpgi/operator/lifecycle.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,14 +168,13 @@ func (impl LifecycleImplementation) reconcileJob(
168168
return nil, nil
169169
}
170170

171-
return reconcileJob(ctx, cluster, request, pluginConfiguration, env)
171+
return reconcileJob(ctx, cluster, request, env)
172172
}
173173

174174
func reconcileJob(
175175
ctx context.Context,
176176
cluster *cnpgv1.Cluster,
177177
request *lifecycle.OperatorLifecycleRequest,
178-
pluginConfiguration *config.PluginConfiguration,
179178
env []corev1.EnvVar,
180179
) (*lifecycle.OperatorLifecycleResponse, error) {
181180
contextLogger := log.FromContext(ctx).WithName("lifecycle")

internal/cnpgi/operator/lifecycle_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ var _ = Describe("LifecycleImplementation", func() {
107107
ObjectDefinition: jobJSON,
108108
}
109109

110-
response, err := reconcileJob(ctx, cluster, request, pluginConfiguration, nil)
110+
response, err := reconcileJob(ctx, cluster, request, nil)
111111
Expect(err).NotTo(HaveOccurred())
112112
Expect(response).NotTo(BeNil())
113113
Expect(response.JsonPatch).NotTo(BeEmpty())
@@ -128,7 +128,7 @@ var _ = Describe("LifecycleImplementation", func() {
128128
ObjectDefinition: jobJSON,
129129
}
130130

131-
response, err := reconcileJob(ctx, cluster, request, pluginConfiguration, nil)
131+
response, err := reconcileJob(ctx, cluster, request, nil)
132132
Expect(err).NotTo(HaveOccurred())
133133
Expect(response).To(BeNil())
134134
})
@@ -138,7 +138,7 @@ var _ = Describe("LifecycleImplementation", func() {
138138
ObjectDefinition: []byte("invalid-json"),
139139
}
140140

141-
response, err := reconcileJob(ctx, cluster, request, pluginConfiguration, nil)
141+
response, err := reconcileJob(ctx, cluster, request, nil)
142142
Expect(err).To(HaveOccurred())
143143
Expect(response).To(BeNil())
144144
})
@@ -165,7 +165,7 @@ var _ = Describe("LifecycleImplementation", func() {
165165
ObjectDefinition: jobJSON,
166166
}
167167

168-
response, err := reconcileJob(ctx, cluster, request, pluginConfiguration, nil)
168+
response, err := reconcileJob(ctx, cluster, request, nil)
169169
Expect(err).NotTo(HaveOccurred())
170170
Expect(response).To(BeNil())
171171
})

internal/cnpgi/operator/reconciler.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ func (r ReconcilerImplementation) Pre(
7575

7676
contextLogger.Debug("parsing barman object configuration")
7777

78-
var barmanObjects []barmancloudv1.ObjectStore
78+
barmanObjects := make([]barmancloudv1.ObjectStore, 0, len(pluginConfiguration.GetReferredBarmanObjectsKey()))
7979
for _, barmanObjectKey := range pluginConfiguration.GetReferredBarmanObjectsKey() {
8080
var barmanObject barmancloudv1.ObjectStore
8181
if err := r.Client.Get(ctx, barmanObjectKey, &barmanObject); err != nil {

0 commit comments

Comments
 (0)