Skip to content

Commit eb549ce

Browse files
authored
Add local golint-ci lint config file (open-telemetry#146)
Signed-off-by: Juraci Paixão Kröhling <[email protected]>
1 parent 5641805 commit eb549ce

File tree

79 files changed

+903
-107
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+903
-107
lines changed

.github/workflows/continuous-integration.yaml

+1-2
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,8 @@ jobs:
3737
- name: Lint
3838
uses: golangci/golangci-lint-action@v2
3939
with:
40+
args: -v
4041
version: v1.29
41-
args: --enable=gosec,maligned,misspell
42-
only-new-issues: true
4342

4443
security:
4544
name: Security

.golangci.yaml

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
run:
2+
timeout: 5m
3+
4+
# all available settings of specific linters
5+
linters-settings:
6+
goheader:
7+
template-path: header.txt
8+
goimports:
9+
local-prefixes: github.com/open-telemetry/opentelemetry-operator
10+
maligned:
11+
suggest-new: true
12+
misspell:
13+
locale: US
14+
15+
linters:
16+
enable:
17+
- goheader
18+
- goimports
19+
- maligned
20+
- misspell
21+
- gosec
22+
- exhaustive
23+
- godot
24+
- unparam

api/v1alpha1/groupversion_info.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ import (
2323
)
2424

2525
var (
26-
// GroupVersion is group version used to register these objects
26+
// GroupVersion is group version used to register these objects.
2727
GroupVersion = schema.GroupVersion{Group: "opentelemetry.io", Version: "v1alpha1"}
2828

29-
// SchemeBuilder is used to add go types to the GroupVersionKind scheme
29+
// SchemeBuilder is used to add go types to the GroupVersionKind scheme.
3030
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}
3131

3232
// AddToScheme adds the types in this group-version to the given scheme.

api/v1alpha1/mode.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ type (
2121
)
2222

2323
const (
24-
// ModeDaemonSet specifies that the collector should be deployed as a Kubernetes DaemonSet
24+
// ModeDaemonSet specifies that the collector should be deployed as a Kubernetes DaemonSet.
2525
ModeDaemonSet Mode = "daemonset"
2626

27-
// ModeDeployment specifies that the collector should be deployed as a Kubernetes Deployment
27+
// ModeDeployment specifies that the collector should be deployed as a Kubernetes Deployment.
2828
ModeDeployment Mode = "deployment"
2929

30-
// ModeSidecar specifies that the collector should be deployed as a sidecar to pods
30+
// ModeSidecar specifies that the collector should be deployed as a sidecar to pods.
3131
ModeSidecar Mode = "sidecar"
3232
)

api/v1alpha1/opentelemetrycollector_types.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import (
1919
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2020
)
2121

22-
// OpenTelemetryCollectorSpec defines the desired state of OpenTelemetryCollector
22+
// OpenTelemetryCollectorSpec defines the desired state of OpenTelemetryCollector.
2323
type OpenTelemetryCollectorSpec struct {
2424
// Config is the raw JSON to be used as the collector's configuration. Refer to the OpenTelemetry Collector documentation for details.
2525
// +required
@@ -78,7 +78,7 @@ type OpenTelemetryCollectorSpec struct {
7878
Env []v1.EnvVar `json:"env,omitempty"`
7979
}
8080

81-
// OpenTelemetryCollectorStatus defines the observed state of OpenTelemetryCollector
81+
// OpenTelemetryCollectorStatus defines the observed state of OpenTelemetryCollector.
8282
type OpenTelemetryCollectorStatus struct {
8383
// Replicas is currently not being set and might be removed in the next version.
8484
// +optional
@@ -102,7 +102,7 @@ type OpenTelemetryCollectorStatus struct {
102102
// +kubebuilder:printcolumn:name="Version",type="string",JSONPath=".status.version",description="OpenTelemetry Version"
103103
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp"
104104

105-
// OpenTelemetryCollector is the Schema for the opentelemetrycollectors API
105+
// OpenTelemetryCollector is the Schema for the opentelemetrycollectors API.
106106
type OpenTelemetryCollector struct {
107107
metav1.TypeMeta `json:",inline"`
108108
metav1.ObjectMeta `json:"metadata,omitempty"`
@@ -113,7 +113,7 @@ type OpenTelemetryCollector struct {
113113

114114
// +kubebuilder:object:root=true
115115

116-
// OpenTelemetryCollectorList contains a list of OpenTelemetryCollector
116+
// OpenTelemetryCollectorList contains a list of OpenTelemetryCollector.
117117
type OpenTelemetryCollectorList struct {
118118
metav1.TypeMeta `json:",inline"`
119119
metav1.ListMeta `json:"metadata,omitempty"`

api/v1alpha1/opentelemetrycollector_webhook.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ func (r *OpenTelemetryCollector) SetupWebhookWithManager(mgr ctrl.Manager) error
3434

3535
var _ webhook.Defaulter = &OpenTelemetryCollector{}
3636

37-
// Default implements webhook.Defaulter so a webhook will be registered for the type
37+
// Default implements webhook.Defaulter so a webhook will be registered for the type.
3838
func (r *OpenTelemetryCollector) Default() {
3939
if len(r.Spec.Mode) == 0 {
4040
r.Spec.Mode = ModeDeployment
@@ -54,19 +54,19 @@ func (r *OpenTelemetryCollector) Default() {
5454

5555
var _ webhook.Validator = &OpenTelemetryCollector{}
5656

57-
// ValidateCreate implements webhook.Validator so a webhook will be registered for the type
57+
// ValidateCreate implements webhook.Validator so a webhook will be registered for the type.
5858
func (r *OpenTelemetryCollector) ValidateCreate() error {
5959
opentelemetrycollectorlog.Info("validate create", "name", r.Name)
6060
return nil
6161
}
6262

63-
// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type
63+
// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type.
6464
func (r *OpenTelemetryCollector) ValidateUpdate(old runtime.Object) error {
6565
opentelemetrycollectorlog.Info("validate update", "name", r.Name)
6666
return nil
6767
}
6868

69-
// ValidateDelete implements webhook.Validator so a webhook will be registered for the type
69+
// ValidateDelete implements webhook.Validator so a webhook will be registered for the type.
7070
func (r *OpenTelemetryCollector) ValidateDelete() error {
7171
opentelemetrycollectorlog.Info("validate delete", "name", r.Name)
7272
return nil

config/crd/bases/opentelemetry.io_opentelemetrycollectors.yaml

+3-3
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ spec:
3939
validation:
4040
openAPIV3Schema:
4141
description: OpenTelemetryCollector is the Schema for the opentelemetrycollectors
42-
API
42+
API.
4343
properties:
4444
apiVersion:
4545
description: 'APIVersion defines the versioned schema of this representation
@@ -54,7 +54,7 @@ spec:
5454
metadata:
5555
type: object
5656
spec:
57-
description: OpenTelemetryCollectorSpec defines the desired state of OpenTelemetryCollector
57+
description: OpenTelemetryCollectorSpec defines the desired state of OpenTelemetryCollector.
5858
properties:
5959
args:
6060
additionalProperties:
@@ -1703,7 +1703,7 @@ spec:
17031703
type: object
17041704
status:
17051705
description: OpenTelemetryCollectorStatus defines the observed state of
1706-
OpenTelemetryCollector
1706+
OpenTelemetryCollector.
17071707
properties:
17081708
messages:
17091709
description: Messages about actions performed by the operator on this

controllers/opentelemetrycollector_controller.go

+7-7
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ import (
3232
"github.com/open-telemetry/opentelemetry-operator/pkg/collector/reconcile"
3333
)
3434

35-
// OpenTelemetryCollectorReconciler reconciles a OpenTelemetryCollector object
35+
// OpenTelemetryCollectorReconciler reconciles a OpenTelemetryCollector object.
3636
type OpenTelemetryCollectorReconciler struct {
3737
client.Client
3838
log logr.Logger
@@ -41,14 +41,14 @@ type OpenTelemetryCollectorReconciler struct {
4141
tasks []Task
4242
}
4343

44-
// Task represents a reconciliation task to be executed by the reconciler
44+
// Task represents a reconciliation task to be executed by the reconciler.
4545
type Task struct {
4646
Name string
4747
Do func(context.Context, reconcile.Params) error
4848
BailOnError bool
4949
}
5050

51-
// Params is the set of options to build a new openTelemetryCollectorReconciler
51+
// Params is the set of options to build a new openTelemetryCollectorReconciler.
5252
type Params struct {
5353
client.Client
5454
Log logr.Logger
@@ -57,7 +57,7 @@ type Params struct {
5757
Tasks []Task
5858
}
5959

60-
// NewReconciler creates a new reconciler for OpenTelemetryCollector objects
60+
// NewReconciler creates a new reconciler for OpenTelemetryCollector objects.
6161
func NewReconciler(p Params) *OpenTelemetryCollectorReconciler {
6262
if len(p.Tasks) == 0 {
6363
p.Tasks = []Task{
@@ -106,7 +106,7 @@ func NewReconciler(p Params) *OpenTelemetryCollectorReconciler {
106106
// +kubebuilder:rbac:groups=opentelemetry.io,resources=opentelemetrycollectors,verbs=get;list;watch;create;update;patch;delete
107107
// +kubebuilder:rbac:groups=opentelemetry.io,resources=opentelemetrycollectors/status,verbs=get;update;patch
108108

109-
// Reconcile the current state of an OpenTelemetry collector resource with the desired state
109+
// Reconcile the current state of an OpenTelemetry collector resource with the desired state.
110110
func (r *OpenTelemetryCollectorReconciler) Reconcile(_ context.Context, req ctrl.Request) (ctrl.Result, error) {
111111
ctx := context.Background()
112112
log := r.log.WithValues("opentelemetrycollector", req.NamespacedName)
@@ -138,7 +138,7 @@ func (r *OpenTelemetryCollectorReconciler) Reconcile(_ context.Context, req ctrl
138138
return ctrl.Result{}, nil
139139
}
140140

141-
// RunTasks runs all the tasks associated with this reconciler
141+
// RunTasks runs all the tasks associated with this reconciler.
142142
func (r *OpenTelemetryCollectorReconciler) RunTasks(ctx context.Context, params reconcile.Params) error {
143143
for _, task := range r.tasks {
144144
if err := task.Do(ctx, params); err != nil {
@@ -152,7 +152,7 @@ func (r *OpenTelemetryCollectorReconciler) RunTasks(ctx context.Context, params
152152
return nil
153153
}
154154

155-
// SetupWithManager tells the manager what our controller is interested in
155+
// SetupWithManager tells the manager what our controller is interested in.
156156
func (r *OpenTelemetryCollectorReconciler) SetupWithManager(mgr ctrl.Manager) error {
157157
return ctrl.NewControllerManagedBy(mgr).
158158
For(&v1alpha1.OpenTelemetryCollector{}).

controllers/opentelemetrycollector_controller_test.go

+14
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
// Copyright The OpenTelemetry Authors
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
115
package controllers_test
216

317
import (

header.txt

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Copyright The OpenTelemetry Authors
2+
3+
Licensed under the Apache License, Version 2.0 (the "License");
4+
you may not use this file except in compliance with the License.
5+
You may obtain a copy of the License at
6+
7+
http://www.apache.org/licenses/LICENSE-2.0
8+
9+
Unless required by applicable law or agreed to in writing, software
10+
distributed under the License is distributed on an "AS IS" BASIS,
11+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
See the License for the specific language governing permissions and
13+
limitations under the License.

internal/config/main.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ const (
3333
defaultCollectorConfigMapEntry = "collector.yaml"
3434
)
3535

36-
// Config holds the static configuration for this operator
36+
// Config holds the static configuration for this operator.
3737
type Config struct {
3838
// Registers a callback, to be called once a configuration change happens
3939
OnChange func() error
@@ -50,7 +50,7 @@ type Config struct {
5050
version version.Version
5151
}
5252

53-
// New constructs a new configuration based on the given options
53+
// New constructs a new configuration based on the given options.
5454
func New(opts ...Option) Config {
5555
// initialize with the default values
5656
o := options{
@@ -82,7 +82,7 @@ func New(opts ...Option) Config {
8282
}
8383
}
8484

85-
// FlagSet binds the flags to the user-modifiable values of the operator's configuration
85+
// FlagSet binds the flags to the user-modifiable values of the operator's configuration.
8686
func (c *Config) FlagSet() *pflag.FlagSet {
8787
fs := pflag.NewFlagSet("opentelemetry-operator", pflag.ExitOnError)
8888
pflag.StringVar(&c.collectorImage,
@@ -155,12 +155,12 @@ func (c *Config) CollectorConfigMapEntry() string {
155155
return c.collectorConfigMapEntry
156156
}
157157

158-
// Platform represents the type of the platform this operator is running
158+
// Platform represents the type of the platform this operator is running.
159159
func (c *Config) Platform() platform.Platform {
160160
return c.platform
161161
}
162162

163-
// Version holds the versions used by this operator
163+
// Version holds the versions used by this operator.
164164
func (c *Config) Version() version.Version {
165165
return c.version
166166
}

internal/config/main_test.go

+14
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
// Copyright The OpenTelemetry Authors
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
115
package config_test
216

317
import (

internal/config/options.go

+15-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
// Copyright The OpenTelemetry Authors
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
115
package config
216

317
import (
@@ -10,7 +24,7 @@ import (
1024
"github.com/open-telemetry/opentelemetry-operator/pkg/platform"
1125
)
1226

13-
// Option represents one specific configuration option
27+
// Option represents one specific configuration option.
1428
type Option func(c *options)
1529

1630
type options struct {

internal/podinjector/main.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -45,21 +45,21 @@ var (
4545

4646
var _ PodSidecarInjector = (*podSidecarInjector)(nil)
4747

48-
// PodSidecarInjector is a webhook handler that analyzes new pods and injects appropriate sidecars into it
48+
// PodSidecarInjector is a webhook handler that analyzes new pods and injects appropriate sidecars into it.
4949
type PodSidecarInjector interface {
5050
admission.Handler
5151
admission.DecoderInjector
5252
}
5353

54-
// the implementation
54+
// the implementation.
5555
type podSidecarInjector struct {
5656
config config.Config
5757
logger logr.Logger
5858
client client.Client
5959
decoder *admission.Decoder
6060
}
6161

62-
// NewPodSidecarInjector creates a new PodSidecarInjector
62+
// NewPodSidecarInjector creates a new PodSidecarInjector.
6363
func NewPodSidecarInjector(cfg config.Config, logger logr.Logger, cl client.Client) PodSidecarInjector {
6464
return &podSidecarInjector{
6565
config: cfg,
@@ -144,7 +144,7 @@ func (p *podSidecarInjector) mutate(ctx context.Context, ns corev1.Namespace, po
144144

145145
func (p *podSidecarInjector) getCollectorInstance(ctx context.Context, ns corev1.Namespace, ann string) (v1alpha1.OpenTelemetryCollector, error) {
146146
if strings.EqualFold(ann, "true") {
147-
return p.selectCollectorInstance(ctx, ns, ann)
147+
return p.selectCollectorInstance(ctx, ns)
148148
}
149149

150150
otelcol := v1alpha1.OpenTelemetryCollector{}
@@ -160,7 +160,7 @@ func (p *podSidecarInjector) getCollectorInstance(ctx context.Context, ns corev1
160160
return otelcol, nil
161161
}
162162

163-
func (p *podSidecarInjector) selectCollectorInstance(ctx context.Context, ns corev1.Namespace, ann string) (v1alpha1.OpenTelemetryCollector, error) {
163+
func (p *podSidecarInjector) selectCollectorInstance(ctx context.Context, ns corev1.Namespace) (v1alpha1.OpenTelemetryCollector, error) {
164164
otelcols := v1alpha1.OpenTelemetryCollectorList{}
165165
if err := p.client.List(ctx, &otelcols, client.InNamespace(ns.Name)); err != nil {
166166
return v1alpha1.OpenTelemetryCollector{}, err

0 commit comments

Comments
 (0)