Skip to content

Commit 6913186

Browse files
committed
[chore](cmd): fix gofumpt issues part 1
#### Description fix gofumpt issues in cmd/otel-allocator/internal/config --- This commit was automatically created by review-helper. Changes are split into focused commits grouped by directory to simplify the review process. Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
1 parent ebb6ab9 commit 6913186

File tree

27 files changed

+100
-100
lines changed

27 files changed

+100
-100
lines changed

cmd/gather/cluster/cluster.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ func NewCluster(cfg *config.Config) Cluster {
4444
apiAvailabilityCache: make(map[schema.GroupVersionResource]bool),
4545
}
4646
}
47+
4748
func (c *Cluster) getOperatorNamespace() (string, error) {
4849
if c.config.OperatorNamespace != "" {
4950
return c.config.OperatorNamespace, nil
@@ -67,7 +68,6 @@ func (c *Cluster) getOperatorDeployment() (appsv1.Deployment, error) {
6768
"app.kubernetes.io/name": "opentelemetry-operator",
6869
}),
6970
})
70-
7171
if err != nil {
7272
return appsv1.Deployment{}, err
7373
}

cmd/operator-opamp-bridge/internal/agent/agent_test.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,8 @@ var (
9292
Phase: v1.PodRunning,
9393
},
9494
},
95-
}}
95+
},
96+
}
9697
mockPodListUnhealthy = &v1.PodList{
9798
TypeMeta: metav1.TypeMeta{
9899
Kind: "PodList",
@@ -117,7 +118,8 @@ var (
117118
Phase: v1.PodRunning,
118119
},
119120
},
120-
}}
121+
},
122+
}
121123
)
122124

123125
func getConfigHash(key, file string) string {
@@ -130,8 +132,10 @@ func getConfigHash(key, file string) string {
130132
return fmt.Sprintf("%s%d", key, size)
131133
}
132134

133-
var _ client.OpAMPClient = &mockOpampClient{}
134-
var _ proxy.Server = newMockProxy(nil, nil, nil)
135+
var (
136+
_ client.OpAMPClient = &mockOpampClient{}
137+
_ proxy.Server = newMockProxy(nil, nil, nil)
138+
)
135139

136140
func newMockProxy(configs map[uuid.UUID]*protobufs.EffectiveConfig, healths map[uuid.UUID]*protobufs.ComponentHealth, agentsByHostname map[string]uuid.UUID) *mockProxy {
137141
return &mockProxy{

cmd/operator-opamp-bridge/internal/agent/kube_resource_key.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ type kubeResourceKey struct {
1414
namespace string
1515
}
1616

17-
func newKubeResourceKey(namespace string, name string) kubeResourceKey {
17+
func newKubeResourceKey(namespace, name string) kubeResourceKey {
1818
return kubeResourceKey{name: name, namespace: namespace}
1919
}
2020

cmd/operator-opamp-bridge/internal/config/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ func (ad *AgentDescription) nonIdentifyingAttributes() []*protobufs.KeyValue {
194194
return toReturn
195195
}
196196

197-
func keyValuePair(key string, value string) *protobufs.KeyValue {
197+
func keyValuePair(key, value string) *protobufs.KeyValue {
198198
return &protobufs.KeyValue{
199199
Key: key,
200200
Value: &protobufs.AnyValue{

cmd/operator-opamp-bridge/internal/config/flags.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,7 @@ const (
2727
defaultHeartbeatInterval = 30 * time.Second
2828
)
2929

30-
var (
31-
defaultKubeConfigPath = filepath.Join(homedir.HomeDir(), ".kube", "config")
32-
)
30+
var defaultKubeConfigPath = filepath.Join(homedir.HomeDir(), ".kube", "config")
3331

3432
// We can't bind this flag to our FlagSet, so we need to handle it separately.
3533
var zapCmdLineOpts zap.Options
@@ -71,7 +69,7 @@ func getFlagValueAndChanged[T any](flagSet *pflag.FlagSet, flagName string) (val
7169
var zero T
7270
if changed = flagSet.Changed(flagName); !changed {
7371
value, err = zero, nil
74-
return
72+
return value, changed, err
7573
}
7674
switch any(zero).(type) {
7775
case string:
@@ -85,5 +83,5 @@ func getFlagValueAndChanged[T any](flagSet *pflag.FlagSet, flagName string) (val
8583
default:
8684
err = fmt.Errorf("unsupported flag type %T", zero)
8785
}
88-
return
86+
return value, changed, err
8987
}

cmd/operator-opamp-bridge/internal/metrics/reporter.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ type MetricReporter struct {
4343
// NewMetricReporter creates an OTLP/HTTP client to the destination address supplied by the server.
4444
// TODO: do more validation on the endpoint, allow for gRPC.
4545
// TODO: set global provider and add more metrics to be reported.
46-
func NewMetricReporter(logger logr.Logger, dest *protobufs.TelemetryConnectionSettings, agentType string, agentVersion string, instanceId uuid.UUID) (*MetricReporter, error) {
46+
func NewMetricReporter(logger logr.Logger, dest *protobufs.TelemetryConnectionSettings, agentType, agentVersion string, instanceId uuid.UUID) (*MetricReporter, error) {
4747
if dest.DestinationEndpoint == "" {
4848
return nil, errors.New("metric destination must specify DestinationEndpoint")
4949
}

cmd/operator-opamp-bridge/internal/operator/client.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,16 @@ const (
3030

3131
type ConfigApplier interface {
3232
// Apply receives a name and namespace to apply an OpenTelemetryCollector CRD that is contained in the configmap.
33-
Apply(name string, namespace string, configmap *protobufs.AgentConfigFile) error
33+
Apply(name, namespace string, configmap *protobufs.AgentConfigFile) error
3434

3535
// Delete attempts to delete an OpenTelemetryCollector object given a name and namespace.
36-
Delete(name string, namespace string) error
36+
Delete(name, namespace string) error
3737

3838
// ListInstances retrieves all OpenTelemetryCollector CRDs created by the operator-opamp-bridge agent.
3939
ListInstances() ([]v1beta1.OpenTelemetryCollector, error)
4040

4141
// GetInstance retrieves an OpenTelemetryCollector CRD given a name and namespace.
42-
GetInstance(name string, namespace string) (*v1beta1.OpenTelemetryCollector, error)
42+
GetInstance(name, namespace string) (*v1beta1.OpenTelemetryCollector, error)
4343

4444
// GetCollectorPods retrieves all pods that match the given collector's selector labels and namespace.
4545
GetCollectorPods(selectorLabels map[string]string, namespace string) (*v1.PodList, error)
@@ -65,7 +65,7 @@ func NewClient(name string, log logr.Logger, c client.Client, componentsAllowed
6565
}
6666
}
6767

68-
func (c Client) Apply(name string, namespace string, configmap *protobufs.AgentConfigFile) error {
68+
func (c Client) Apply(name, namespace string, configmap *protobufs.AgentConfigFile) error {
6969
c.log.Info("Received new config", "name", name, "namespace", namespace)
7070

7171
if len(configmap.Body) == 0 {
@@ -166,7 +166,7 @@ func labelSetContainsLabel(resourceLabelSet map[string]string, label, value stri
166166
return strings.EqualFold(resourceLabelSet[label], value)
167167
}
168168

169-
func (c Client) create(ctx context.Context, name string, namespace string, collector *v1beta1.OpenTelemetryCollector) error {
169+
func (c Client) create(ctx context.Context, name, namespace string, collector *v1beta1.OpenTelemetryCollector) error {
170170
// Set the defaults
171171
setTypedMeta(collector)
172172
collector.Name = name
@@ -181,15 +181,15 @@ func (c Client) create(ctx context.Context, name string, namespace string, colle
181181
return c.k8sClient.Create(ctx, collector)
182182
}
183183

184-
func (c Client) update(ctx context.Context, old *v1beta1.OpenTelemetryCollector, new *v1beta1.OpenTelemetryCollector) error {
184+
func (c Client) update(ctx context.Context, old, new *v1beta1.OpenTelemetryCollector) error {
185185
new.ObjectMeta = old.ObjectMeta
186186
new.TypeMeta = old.TypeMeta
187187

188188
c.log.Info("Updating collector")
189189
return c.k8sClient.Update(ctx, new)
190190
}
191191

192-
func (c Client) Delete(name string, namespace string) error {
192+
func (c Client) Delete(name, namespace string) error {
193193
ctx := context.Background()
194194
result := v1beta1.OpenTelemetryCollector{}
195195
err := c.k8sClient.Get(ctx, client.ObjectKey{
@@ -240,7 +240,7 @@ func (c Client) ListInstances() ([]v1beta1.OpenTelemetryCollector, error) {
240240
return instances, nil
241241
}
242242

243-
func (c Client) GetInstance(name string, namespace string) (*v1beta1.OpenTelemetryCollector, error) {
243+
func (c Client) GetInstance(name, namespace string) (*v1beta1.OpenTelemetryCollector, error) {
244244
ctx := context.Background()
245245
result := v1beta1.OpenTelemetryCollector{}
246246

cmd/operator-opamp-bridge/internal/operator/client_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,7 @@ import (
2424
"github.com/open-telemetry/opentelemetry-operator/apis/v1beta1"
2525
)
2626

27-
var (
28-
clientLogger = logr.Discard()
29-
)
27+
var clientLogger = logr.Discard()
3028

3129
const (
3230
bridgeName = "bridge-test"
@@ -285,9 +283,11 @@ func TestClient_GetCollectorPods(t *testing.T) {
285283
},
286284
Spec: v1.PodSpec{},
287285
},
288-
}}
286+
},
287+
}
289288
emptyList := &v1.PodList{
290-
Items: []v1.Pod{}}
289+
Items: []v1.Pod{},
290+
}
291291
type args struct {
292292
selector map[string]string
293293
namespace string

cmd/otel-allocator/internal/allocation/allocator.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ func (a *allocator) SetCollectors(collectors map[string]*Collector) {
162162
}
163163
}
164164

165-
func (a *allocator) GetTargetsForCollectorAndJob(collector string, job string) []*target.Item {
165+
func (a *allocator) GetTargetsForCollectorAndJob(collector, job string) []*target.Item {
166166
a.m.RLock()
167167
defer a.m.RUnlock()
168168
if _, ok := a.targetItemsPerJobPerCollector[collector]; !ok {

cmd/otel-allocator/internal/allocation/consistent_hashing_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ func TestRelativelyEvenDistribution(t *testing.T) {
1313
numCols := 15
1414
numItems := 10000
1515
cols := MakeNCollectors(numCols, 0)
16-
var expectedPerCollector = float64(numItems / numCols)
16+
expectedPerCollector := float64(numItems / numCols)
1717
expectedDelta := (expectedPerCollector * 1.5) - expectedPerCollector
1818
c, _ := New("consistent-hashing", logger)
1919
c.SetCollectors(cols)
@@ -106,7 +106,7 @@ func TestTargetsWithNoCollectorsConsistentHashing(t *testing.T) {
106106
numCols := 2
107107
cols := MakeNCollectors(2, 0)
108108
c.SetCollectors(cols)
109-
var expectedPerCollector = float64(numItemsUpdate / numCols)
109+
expectedPerCollector := float64(numItemsUpdate / numCols)
110110
expectedDelta := (expectedPerCollector * 1.5) - expectedPerCollector
111111
// Checking to see that there is no change to number of targets
112112
actualTargetItems = c.TargetItems()

0 commit comments

Comments
 (0)