diff --git a/.github/workflows/continuous-integration.yaml b/.github/workflows/continuous-integration.yaml index 29d35366fa..5d3019b386 100644 --- a/.github/workflows/continuous-integration.yaml +++ b/.github/workflows/continuous-integration.yaml @@ -37,9 +37,8 @@ jobs: - name: Lint uses: golangci/golangci-lint-action@v2 with: + args: -v version: v1.29 - args: --enable=gosec,maligned,misspell - only-new-issues: true security: name: Security diff --git a/.golangci.yaml b/.golangci.yaml new file mode 100644 index 0000000000..09c1d7f7d3 --- /dev/null +++ b/.golangci.yaml @@ -0,0 +1,24 @@ +run: + timeout: 5m + +# all available settings of specific linters +linters-settings: + goheader: + template-path: header.txt + goimports: + local-prefixes: github.com/open-telemetry/opentelemetry-operator + maligned: + suggest-new: true + misspell: + locale: US + +linters: + enable: + - goheader + - goimports + - maligned + - misspell + - gosec + - exhaustive + - godot + - unparam \ No newline at end of file diff --git a/api/v1alpha1/groupversion_info.go b/api/v1alpha1/groupversion_info.go index 52ce63bf5d..ef6601ea73 100644 --- a/api/v1alpha1/groupversion_info.go +++ b/api/v1alpha1/groupversion_info.go @@ -23,10 +23,10 @@ import ( ) var ( - // GroupVersion is group version used to register these objects + // GroupVersion is group version used to register these objects. GroupVersion = schema.GroupVersion{Group: "opentelemetry.io", Version: "v1alpha1"} - // SchemeBuilder is used to add go types to the GroupVersionKind scheme + // SchemeBuilder is used to add go types to the GroupVersionKind scheme. SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion} // AddToScheme adds the types in this group-version to the given scheme. diff --git a/api/v1alpha1/mode.go b/api/v1alpha1/mode.go index 72b97a47ce..16929a6c54 100644 --- a/api/v1alpha1/mode.go +++ b/api/v1alpha1/mode.go @@ -21,12 +21,12 @@ type ( ) const ( - // ModeDaemonSet specifies that the collector should be deployed as a Kubernetes DaemonSet + // ModeDaemonSet specifies that the collector should be deployed as a Kubernetes DaemonSet. ModeDaemonSet Mode = "daemonset" - // ModeDeployment specifies that the collector should be deployed as a Kubernetes Deployment + // ModeDeployment specifies that the collector should be deployed as a Kubernetes Deployment. ModeDeployment Mode = "deployment" - // ModeSidecar specifies that the collector should be deployed as a sidecar to pods + // ModeSidecar specifies that the collector should be deployed as a sidecar to pods. ModeSidecar Mode = "sidecar" ) diff --git a/api/v1alpha1/opentelemetrycollector_types.go b/api/v1alpha1/opentelemetrycollector_types.go index 5789155493..93c42a5c0e 100644 --- a/api/v1alpha1/opentelemetrycollector_types.go +++ b/api/v1alpha1/opentelemetrycollector_types.go @@ -19,7 +19,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) -// OpenTelemetryCollectorSpec defines the desired state of OpenTelemetryCollector +// OpenTelemetryCollectorSpec defines the desired state of OpenTelemetryCollector. type OpenTelemetryCollectorSpec struct { // Config is the raw JSON to be used as the collector's configuration. Refer to the OpenTelemetry Collector documentation for details. // +required @@ -78,7 +78,7 @@ type OpenTelemetryCollectorSpec struct { Env []v1.EnvVar `json:"env,omitempty"` } -// OpenTelemetryCollectorStatus defines the observed state of OpenTelemetryCollector +// OpenTelemetryCollectorStatus defines the observed state of OpenTelemetryCollector. type OpenTelemetryCollectorStatus struct { // Replicas is currently not being set and might be removed in the next version. // +optional @@ -102,7 +102,7 @@ type OpenTelemetryCollectorStatus struct { // +kubebuilder:printcolumn:name="Version",type="string",JSONPath=".status.version",description="OpenTelemetry Version" // +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp" -// OpenTelemetryCollector is the Schema for the opentelemetrycollectors API +// OpenTelemetryCollector is the Schema for the opentelemetrycollectors API. type OpenTelemetryCollector struct { metav1.TypeMeta `json:",inline"` metav1.ObjectMeta `json:"metadata,omitempty"` @@ -113,7 +113,7 @@ type OpenTelemetryCollector struct { // +kubebuilder:object:root=true -// OpenTelemetryCollectorList contains a list of OpenTelemetryCollector +// OpenTelemetryCollectorList contains a list of OpenTelemetryCollector. type OpenTelemetryCollectorList struct { metav1.TypeMeta `json:",inline"` metav1.ListMeta `json:"metadata,omitempty"` diff --git a/api/v1alpha1/opentelemetrycollector_webhook.go b/api/v1alpha1/opentelemetrycollector_webhook.go index 8680423890..0a51b0788d 100644 --- a/api/v1alpha1/opentelemetrycollector_webhook.go +++ b/api/v1alpha1/opentelemetrycollector_webhook.go @@ -34,7 +34,7 @@ func (r *OpenTelemetryCollector) SetupWebhookWithManager(mgr ctrl.Manager) error var _ webhook.Defaulter = &OpenTelemetryCollector{} -// Default implements webhook.Defaulter so a webhook will be registered for the type +// Default implements webhook.Defaulter so a webhook will be registered for the type. func (r *OpenTelemetryCollector) Default() { if len(r.Spec.Mode) == 0 { r.Spec.Mode = ModeDeployment @@ -54,19 +54,19 @@ func (r *OpenTelemetryCollector) Default() { var _ webhook.Validator = &OpenTelemetryCollector{} -// ValidateCreate implements webhook.Validator so a webhook will be registered for the type +// ValidateCreate implements webhook.Validator so a webhook will be registered for the type. func (r *OpenTelemetryCollector) ValidateCreate() error { opentelemetrycollectorlog.Info("validate create", "name", r.Name) return nil } -// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type +// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type. func (r *OpenTelemetryCollector) ValidateUpdate(old runtime.Object) error { opentelemetrycollectorlog.Info("validate update", "name", r.Name) return nil } -// ValidateDelete implements webhook.Validator so a webhook will be registered for the type +// ValidateDelete implements webhook.Validator so a webhook will be registered for the type. func (r *OpenTelemetryCollector) ValidateDelete() error { opentelemetrycollectorlog.Info("validate delete", "name", r.Name) return nil diff --git a/config/crd/bases/opentelemetry.io_opentelemetrycollectors.yaml b/config/crd/bases/opentelemetry.io_opentelemetrycollectors.yaml index f726c16580..75bc0ce2a1 100644 --- a/config/crd/bases/opentelemetry.io_opentelemetrycollectors.yaml +++ b/config/crd/bases/opentelemetry.io_opentelemetrycollectors.yaml @@ -39,7 +39,7 @@ spec: validation: openAPIV3Schema: description: OpenTelemetryCollector is the Schema for the opentelemetrycollectors - API + API. properties: apiVersion: description: 'APIVersion defines the versioned schema of this representation @@ -54,7 +54,7 @@ spec: metadata: type: object spec: - description: OpenTelemetryCollectorSpec defines the desired state of OpenTelemetryCollector + description: OpenTelemetryCollectorSpec defines the desired state of OpenTelemetryCollector. properties: args: additionalProperties: @@ -1703,7 +1703,7 @@ spec: type: object status: description: OpenTelemetryCollectorStatus defines the observed state of - OpenTelemetryCollector + OpenTelemetryCollector. properties: messages: description: Messages about actions performed by the operator on this diff --git a/controllers/opentelemetrycollector_controller.go b/controllers/opentelemetrycollector_controller.go index 1e9d0b2429..0a6955cdbe 100644 --- a/controllers/opentelemetrycollector_controller.go +++ b/controllers/opentelemetrycollector_controller.go @@ -32,7 +32,7 @@ import ( "github.com/open-telemetry/opentelemetry-operator/pkg/collector/reconcile" ) -// OpenTelemetryCollectorReconciler reconciles a OpenTelemetryCollector object +// OpenTelemetryCollectorReconciler reconciles a OpenTelemetryCollector object. type OpenTelemetryCollectorReconciler struct { client.Client log logr.Logger @@ -41,14 +41,14 @@ type OpenTelemetryCollectorReconciler struct { tasks []Task } -// Task represents a reconciliation task to be executed by the reconciler +// Task represents a reconciliation task to be executed by the reconciler. type Task struct { Name string Do func(context.Context, reconcile.Params) error BailOnError bool } -// Params is the set of options to build a new openTelemetryCollectorReconciler +// Params is the set of options to build a new openTelemetryCollectorReconciler. type Params struct { client.Client Log logr.Logger @@ -57,7 +57,7 @@ type Params struct { Tasks []Task } -// NewReconciler creates a new reconciler for OpenTelemetryCollector objects +// NewReconciler creates a new reconciler for OpenTelemetryCollector objects. func NewReconciler(p Params) *OpenTelemetryCollectorReconciler { if len(p.Tasks) == 0 { p.Tasks = []Task{ @@ -106,7 +106,7 @@ func NewReconciler(p Params) *OpenTelemetryCollectorReconciler { // +kubebuilder:rbac:groups=opentelemetry.io,resources=opentelemetrycollectors,verbs=get;list;watch;create;update;patch;delete // +kubebuilder:rbac:groups=opentelemetry.io,resources=opentelemetrycollectors/status,verbs=get;update;patch -// Reconcile the current state of an OpenTelemetry collector resource with the desired state +// Reconcile the current state of an OpenTelemetry collector resource with the desired state. func (r *OpenTelemetryCollectorReconciler) Reconcile(_ context.Context, req ctrl.Request) (ctrl.Result, error) { ctx := context.Background() log := r.log.WithValues("opentelemetrycollector", req.NamespacedName) @@ -138,7 +138,7 @@ func (r *OpenTelemetryCollectorReconciler) Reconcile(_ context.Context, req ctrl return ctrl.Result{}, nil } -// RunTasks runs all the tasks associated with this reconciler +// RunTasks runs all the tasks associated with this reconciler. func (r *OpenTelemetryCollectorReconciler) RunTasks(ctx context.Context, params reconcile.Params) error { for _, task := range r.tasks { if err := task.Do(ctx, params); err != nil { @@ -152,7 +152,7 @@ func (r *OpenTelemetryCollectorReconciler) RunTasks(ctx context.Context, params return nil } -// SetupWithManager tells the manager what our controller is interested in +// SetupWithManager tells the manager what our controller is interested in. func (r *OpenTelemetryCollectorReconciler) SetupWithManager(mgr ctrl.Manager) error { return ctrl.NewControllerManagedBy(mgr). For(&v1alpha1.OpenTelemetryCollector{}). diff --git a/controllers/opentelemetrycollector_controller_test.go b/controllers/opentelemetrycollector_controller_test.go index 34f20902b8..8a0944812a 100644 --- a/controllers/opentelemetrycollector_controller_test.go +++ b/controllers/opentelemetrycollector_controller_test.go @@ -1,3 +1,17 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package controllers_test import ( diff --git a/header.txt b/header.txt new file mode 100644 index 0000000000..3881885f31 --- /dev/null +++ b/header.txt @@ -0,0 +1,13 @@ +Copyright The OpenTelemetry Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. \ No newline at end of file diff --git a/internal/config/main.go b/internal/config/main.go index 74fb5a4c8b..52b9e49586 100644 --- a/internal/config/main.go +++ b/internal/config/main.go @@ -33,7 +33,7 @@ const ( defaultCollectorConfigMapEntry = "collector.yaml" ) -// Config holds the static configuration for this operator +// Config holds the static configuration for this operator. type Config struct { // Registers a callback, to be called once a configuration change happens OnChange func() error @@ -50,7 +50,7 @@ type Config struct { version version.Version } -// New constructs a new configuration based on the given options +// New constructs a new configuration based on the given options. func New(opts ...Option) Config { // initialize with the default values o := options{ @@ -82,7 +82,7 @@ func New(opts ...Option) Config { } } -// FlagSet binds the flags to the user-modifiable values of the operator's configuration +// FlagSet binds the flags to the user-modifiable values of the operator's configuration. func (c *Config) FlagSet() *pflag.FlagSet { fs := pflag.NewFlagSet("opentelemetry-operator", pflag.ExitOnError) pflag.StringVar(&c.collectorImage, @@ -155,12 +155,12 @@ func (c *Config) CollectorConfigMapEntry() string { return c.collectorConfigMapEntry } -// Platform represents the type of the platform this operator is running +// Platform represents the type of the platform this operator is running. func (c *Config) Platform() platform.Platform { return c.platform } -// Version holds the versions used by this operator +// Version holds the versions used by this operator. func (c *Config) Version() version.Version { return c.version } diff --git a/internal/config/main_test.go b/internal/config/main_test.go index 8159b22800..c586e6f0dc 100644 --- a/internal/config/main_test.go +++ b/internal/config/main_test.go @@ -1,3 +1,17 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package config_test import ( diff --git a/internal/config/options.go b/internal/config/options.go index 4e7d60aa54..41d39bfe39 100644 --- a/internal/config/options.go +++ b/internal/config/options.go @@ -1,3 +1,17 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package config import ( @@ -10,7 +24,7 @@ import ( "github.com/open-telemetry/opentelemetry-operator/pkg/platform" ) -// Option represents one specific configuration option +// Option represents one specific configuration option. type Option func(c *options) type options struct { diff --git a/internal/podinjector/main.go b/internal/podinjector/main.go index c097aa00c8..db4ed051e4 100644 --- a/internal/podinjector/main.go +++ b/internal/podinjector/main.go @@ -45,13 +45,13 @@ var ( var _ PodSidecarInjector = (*podSidecarInjector)(nil) -// PodSidecarInjector is a webhook handler that analyzes new pods and injects appropriate sidecars into it +// PodSidecarInjector is a webhook handler that analyzes new pods and injects appropriate sidecars into it. type PodSidecarInjector interface { admission.Handler admission.DecoderInjector } -// the implementation +// the implementation. type podSidecarInjector struct { config config.Config logger logr.Logger @@ -59,7 +59,7 @@ type podSidecarInjector struct { decoder *admission.Decoder } -// NewPodSidecarInjector creates a new PodSidecarInjector +// NewPodSidecarInjector creates a new PodSidecarInjector. func NewPodSidecarInjector(cfg config.Config, logger logr.Logger, cl client.Client) PodSidecarInjector { return &podSidecarInjector{ config: cfg, @@ -144,7 +144,7 @@ func (p *podSidecarInjector) mutate(ctx context.Context, ns corev1.Namespace, po func (p *podSidecarInjector) getCollectorInstance(ctx context.Context, ns corev1.Namespace, ann string) (v1alpha1.OpenTelemetryCollector, error) { if strings.EqualFold(ann, "true") { - return p.selectCollectorInstance(ctx, ns, ann) + return p.selectCollectorInstance(ctx, ns) } otelcol := v1alpha1.OpenTelemetryCollector{} @@ -160,7 +160,7 @@ func (p *podSidecarInjector) getCollectorInstance(ctx context.Context, ns corev1 return otelcol, nil } -func (p *podSidecarInjector) selectCollectorInstance(ctx context.Context, ns corev1.Namespace, ann string) (v1alpha1.OpenTelemetryCollector, error) { +func (p *podSidecarInjector) selectCollectorInstance(ctx context.Context, ns corev1.Namespace) (v1alpha1.OpenTelemetryCollector, error) { otelcols := v1alpha1.OpenTelemetryCollectorList{} if err := p.client.List(ctx, &otelcols, client.InNamespace(ns.Name)); err != nil { return v1alpha1.OpenTelemetryCollector{}, err diff --git a/internal/podinjector/main_test.go b/internal/podinjector/main_test.go index 4f542ba03b..9fa74e7169 100644 --- a/internal/podinjector/main_test.go +++ b/internal/podinjector/main_test.go @@ -1,3 +1,17 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package podinjector_test import ( diff --git a/internal/version/main.go b/internal/version/main.go index e10a8c2c6d..c0080a4b2a 100644 --- a/internal/version/main.go +++ b/internal/version/main.go @@ -1,3 +1,17 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + // Package version contains the operator's version, as well as versions of underlying components. package version @@ -12,7 +26,7 @@ var ( otelCol string ) -// Version holds this Operator's version as well as the version of some of the components it uses +// Version holds this Operator's version as well as the version of some of the components it uses. type Version struct { Operator string `json:"opentelemetry-operator"` BuildDate string `json:"build-date"` @@ -20,7 +34,7 @@ type Version struct { Go string `json:"go-version"` } -// Get returns the Version object with the relevant information +// Get returns the Version object with the relevant information. func Get() Version { return Version{ Operator: version, @@ -40,7 +54,7 @@ func (v Version) String() string { ) } -// OpenTelemetryCollector returns the default OpenTelemetryCollector to use when no versions are specified via CLI or configuration +// OpenTelemetryCollector returns the default OpenTelemetryCollector to use when no versions are specified via CLI or configuration. func OpenTelemetryCollector() string { if len(otelCol) > 0 { // this should always be set, as it's specified during the build diff --git a/internal/version/main_test.go b/internal/version/main_test.go index 682a2cfc9d..ec9a028605 100644 --- a/internal/version/main_test.go +++ b/internal/version/main_test.go @@ -1,3 +1,17 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package version import ( diff --git a/pkg/autodetect/main_test.go b/pkg/autodetect/main_test.go index 7855315ac9..6ffc1b9e79 100644 --- a/pkg/autodetect/main_test.go +++ b/pkg/autodetect/main_test.go @@ -1,3 +1,17 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package autodetect_test import ( diff --git a/pkg/collector/adapters/config_from.go b/pkg/collector/adapters/config_from.go index 79d83f6337..0f9883ce26 100644 --- a/pkg/collector/adapters/config_from.go +++ b/pkg/collector/adapters/config_from.go @@ -1,3 +1,17 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + // Package adapters is for data conversion. package adapters @@ -8,7 +22,7 @@ import ( ) var ( - // ErrInvalidYAML represents an error in the format of the configuration file + // ErrInvalidYAML represents an error in the format of the configuration file. ErrInvalidYAML = errors.New("couldn't parse the opentelemetry-collector configuration") ) diff --git a/pkg/collector/adapters/config_from_test.go b/pkg/collector/adapters/config_from_test.go index cc2081151c..92fb0569b3 100644 --- a/pkg/collector/adapters/config_from_test.go +++ b/pkg/collector/adapters/config_from_test.go @@ -1,3 +1,17 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package adapters_test import ( diff --git a/pkg/collector/adapters/config_to_ports.go b/pkg/collector/adapters/config_to_ports.go index b219b20510..70f12a388f 100644 --- a/pkg/collector/adapters/config_to_ports.go +++ b/pkg/collector/adapters/config_to_ports.go @@ -1,3 +1,17 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package adapters import ( @@ -10,10 +24,10 @@ import ( ) var ( - // ErrNoReceivers indicates that there are no receivers in the configuration + // ErrNoReceivers indicates that there are no receivers in the configuration. ErrNoReceivers = errors.New("no receivers available as part of the configuration") - // ErrReceiversNotAMap indicates that the receivers property isn't a map of values + // ErrReceiversNotAMap indicates that the receivers property isn't a map of values. ErrReceiversNotAMap = errors.New("receivers property in the configuration doesn't contain valid receivers") ) diff --git a/pkg/collector/adapters/config_to_ports_test.go b/pkg/collector/adapters/config_to_ports_test.go index f2d0ceb8fb..f13db7b868 100644 --- a/pkg/collector/adapters/config_to_ports_test.go +++ b/pkg/collector/adapters/config_to_ports_test.go @@ -1,3 +1,17 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package adapters_test import ( diff --git a/pkg/collector/container.go b/pkg/collector/container.go index 9fe069a0b9..e86d01902a 100644 --- a/pkg/collector/container.go +++ b/pkg/collector/container.go @@ -25,7 +25,7 @@ import ( "github.com/open-telemetry/opentelemetry-operator/pkg/naming" ) -// Container builds a container for the given collector +// Container builds a container for the given collector. func Container(cfg config.Config, logger logr.Logger, otelcol v1alpha1.OpenTelemetryCollector) corev1.Container { image := otelcol.Spec.Image if len(image) == 0 { diff --git a/pkg/collector/container_test.go b/pkg/collector/container_test.go index 69af8b5ec1..cfddf06424 100644 --- a/pkg/collector/container_test.go +++ b/pkg/collector/container_test.go @@ -1,3 +1,17 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package collector_test import ( @@ -6,10 +20,11 @@ import ( corev1 "k8s.io/api/core/v1" logf "sigs.k8s.io/controller-runtime/pkg/log" + "github.com/stretchr/testify/assert" + "github.com/open-telemetry/opentelemetry-operator/api/v1alpha1" "github.com/open-telemetry/opentelemetry-operator/internal/config" . "github.com/open-telemetry/opentelemetry-operator/pkg/collector" - "github.com/stretchr/testify/assert" ) var logger = logf.Log.WithName("unit-tests") diff --git a/pkg/collector/daemonset.go b/pkg/collector/daemonset.go index 06fc5af730..270e6650ec 100644 --- a/pkg/collector/daemonset.go +++ b/pkg/collector/daemonset.go @@ -25,7 +25,7 @@ import ( "github.com/open-telemetry/opentelemetry-operator/pkg/naming" ) -// DaemonSet builds the deployment for the given instance +// DaemonSet builds the deployment for the given instance. func DaemonSet(cfg config.Config, logger logr.Logger, otelcol v1alpha1.OpenTelemetryCollector) appsv1.DaemonSet { labels := Labels(otelcol) labels["app.kubernetes.io/name"] = naming.Collector(otelcol) diff --git a/pkg/collector/daemonset_test.go b/pkg/collector/daemonset_test.go index 53dacf8b6e..59702eece4 100644 --- a/pkg/collector/daemonset_test.go +++ b/pkg/collector/daemonset_test.go @@ -1,3 +1,17 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package collector_test import ( diff --git a/pkg/collector/deployment.go b/pkg/collector/deployment.go index 435124fdd9..87105d317a 100644 --- a/pkg/collector/deployment.go +++ b/pkg/collector/deployment.go @@ -25,7 +25,7 @@ import ( "github.com/open-telemetry/opentelemetry-operator/pkg/naming" ) -// Deployment builds the deployment for the given instance +// Deployment builds the deployment for the given instance. func Deployment(cfg config.Config, logger logr.Logger, otelcol v1alpha1.OpenTelemetryCollector) appsv1.Deployment { labels := Labels(otelcol) labels["app.kubernetes.io/name"] = naming.Collector(otelcol) diff --git a/pkg/collector/deployment_test.go b/pkg/collector/deployment_test.go index 10ed8f66e2..05f54e9720 100644 --- a/pkg/collector/deployment_test.go +++ b/pkg/collector/deployment_test.go @@ -1,3 +1,17 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package collector_test import ( @@ -5,10 +19,11 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "github.com/stretchr/testify/assert" + "github.com/open-telemetry/opentelemetry-operator/api/v1alpha1" "github.com/open-telemetry/opentelemetry-operator/internal/config" . "github.com/open-telemetry/opentelemetry-operator/pkg/collector" - "github.com/stretchr/testify/assert" ) func TestDeploymentNewDefault(t *testing.T) { diff --git a/pkg/collector/labels.go b/pkg/collector/labels.go index c0deb165d2..0d62e22704 100644 --- a/pkg/collector/labels.go +++ b/pkg/collector/labels.go @@ -20,7 +20,7 @@ import ( "github.com/open-telemetry/opentelemetry-operator/api/v1alpha1" ) -// Labels return the common labels to all objects that are part of a managed OpenTelemetryCollector +// Labels return the common labels to all objects that are part of a managed OpenTelemetryCollector. func Labels(instance v1alpha1.OpenTelemetryCollector) map[string]string { // new map every time, so that we don't touch the instance's label base := map[string]string{} diff --git a/pkg/collector/labels_test.go b/pkg/collector/labels_test.go index bccb005971..3a6a1e0d41 100644 --- a/pkg/collector/labels_test.go +++ b/pkg/collector/labels_test.go @@ -1,3 +1,17 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package collector_test import ( diff --git a/pkg/collector/parser/receiver.go b/pkg/collector/parser/receiver.go index ffdf3f1fc2..37cb6e55dc 100644 --- a/pkg/collector/parser/receiver.go +++ b/pkg/collector/parser/receiver.go @@ -1,3 +1,17 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + // Package parser is for parsing the OpenTelemetry Collector configuration. package parser @@ -17,7 +31,7 @@ var ( dnsLabelValidation = regexp.MustCompile("^(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])?$") ) -// ReceiverParser is an interface that should be implemented by all receiver parsers +// ReceiverParser is an interface that should be implemented by all receiver parsers. type ReceiverParser interface { // Ports returns the service ports parsed based on the receiver's configuration Ports() ([]corev1.ServicePort, error) @@ -26,13 +40,13 @@ type ReceiverParser interface { ParserName() string } -// Builder specifies the signature required for parser builders +// Builder specifies the signature required for parser builders. type Builder func(logr.Logger, string, map[interface{}]interface{}) ReceiverParser -// registry holds a record of all known parsers +// registry holds a record of all known parsers. var registry = make(map[string]Builder) -// BuilderFor returns a parser builder for the given receiver name +// BuilderFor returns a parser builder for the given receiver name. func BuilderFor(name string) Builder { builder := registry[receiverType(name)] if builder == nil { @@ -42,18 +56,18 @@ func BuilderFor(name string) Builder { return builder } -// For returns a new parser for the given receiver name + config +// For returns a new parser for the given receiver name + config. func For(logger logr.Logger, name string, config map[interface{}]interface{}) ReceiverParser { builder := BuilderFor(name) return builder(logger, name, config) } -// Register adds a new parser builder to the list of known builders +// Register adds a new parser builder to the list of known builders. func Register(name string, builder Builder) { registry[name] = builder } -// IsRegistered checks whether a parser is registered with the given name +// IsRegistered checks whether a parser is registered with the given name. func IsRegistered(name string) bool { _, ok := registry[name] return ok diff --git a/pkg/collector/parser/receiver_carbon.go b/pkg/collector/parser/receiver_carbon.go index 29b0daf340..26f073ebe8 100644 --- a/pkg/collector/parser/receiver_carbon.go +++ b/pkg/collector/parser/receiver_carbon.go @@ -1,10 +1,24 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package parser import "github.com/go-logr/logr" const parserNameCarbon = "__carbon" -// NewCarbonReceiverParser builds a new parser for Carbon receivers, from the contrib repository +// NewCarbonReceiverParser builds a new parser for Carbon receivers, from the contrib repository. func NewCarbonReceiverParser(logger logr.Logger, name string, config map[interface{}]interface{}) ReceiverParser { return &GenericReceiver{ logger: logger, diff --git a/pkg/collector/parser/receiver_carbon_test.go b/pkg/collector/parser/receiver_carbon_test.go index 233aedfbc1..22a5cb9273 100644 --- a/pkg/collector/parser/receiver_carbon_test.go +++ b/pkg/collector/parser/receiver_carbon_test.go @@ -1,3 +1,17 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package parser // all tests for the Carbon parser are currently part of the test TestDownstreamParsers diff --git a/pkg/collector/parser/receiver_collectd.go b/pkg/collector/parser/receiver_collectd.go index fa275633a0..9426399a45 100644 --- a/pkg/collector/parser/receiver_collectd.go +++ b/pkg/collector/parser/receiver_collectd.go @@ -1,10 +1,24 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package parser import "github.com/go-logr/logr" const parserNameCollectd = "__collectd" -// NewCollectdReceiverParser builds a new parser for Collectd receivers, from the contrib repository +// NewCollectdReceiverParser builds a new parser for Collectd receivers, from the contrib repository. func NewCollectdReceiverParser(logger logr.Logger, name string, config map[interface{}]interface{}) ReceiverParser { return &GenericReceiver{ logger: logger, diff --git a/pkg/collector/parser/receiver_collectd_test.go b/pkg/collector/parser/receiver_collectd_test.go index 819392f2a8..fe63c75cf5 100644 --- a/pkg/collector/parser/receiver_collectd_test.go +++ b/pkg/collector/parser/receiver_collectd_test.go @@ -1,3 +1,17 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package parser // all tests for the Collectd parser are currently part of the test TestDownstreamParsers diff --git a/pkg/collector/parser/receiver_generic.go b/pkg/collector/parser/receiver_generic.go index a62d719bf0..c4e4e1ae07 100644 --- a/pkg/collector/parser/receiver_generic.go +++ b/pkg/collector/parser/receiver_generic.go @@ -1,3 +1,17 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package parser import ( @@ -9,7 +23,7 @@ const parserNameGeneric = "__generic" var _ ReceiverParser = &GenericReceiver{} -// GenericReceiver is a special parser for generic receivers. It doesn't self-register and should be created/used directly +// GenericReceiver is a special parser for generic receivers. It doesn't self-register and should be created/used directly. type GenericReceiver struct { logger logr.Logger name string @@ -18,7 +32,7 @@ type GenericReceiver struct { parserName string } -// NewGenericReceiverParser builds a new parser for generic receivers +// NewGenericReceiverParser builds a new parser for generic receivers. func NewGenericReceiverParser(logger logr.Logger, name string, config map[interface{}]interface{}) ReceiverParser { return &GenericReceiver{ logger: logger, @@ -28,7 +42,7 @@ func NewGenericReceiverParser(logger logr.Logger, name string, config map[interf } } -// Ports returns all the service ports for all protocols in this parser +// Ports returns all the service ports for all protocols in this parser. func (g *GenericReceiver) Ports() ([]corev1.ServicePort, error) { port := singlePortFromConfigEndpoint(g.logger, g.name, g.config) if port != nil { @@ -45,7 +59,7 @@ func (g *GenericReceiver) Ports() ([]corev1.ServicePort, error) { return []corev1.ServicePort{}, nil } -// ParserName returns the name of this parser +// ParserName returns the name of this parser. func (g *GenericReceiver) ParserName() string { return g.parserName } diff --git a/pkg/collector/parser/receiver_generic_test.go b/pkg/collector/parser/receiver_generic_test.go index bf05cc342f..93c290c5f2 100644 --- a/pkg/collector/parser/receiver_generic_test.go +++ b/pkg/collector/parser/receiver_generic_test.go @@ -1,12 +1,27 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package parser_test import ( "testing" "github.com/go-logr/logr" - "github.com/open-telemetry/opentelemetry-operator/pkg/collector/parser" "github.com/stretchr/testify/assert" logf "sigs.k8s.io/controller-runtime/pkg/log" + + "github.com/open-telemetry/opentelemetry-operator/pkg/collector/parser" ) var logger = logf.Log.WithName("unit-tests") diff --git a/pkg/collector/parser/receiver_jaeger.go b/pkg/collector/parser/receiver_jaeger.go index 9ca3e3a037..460c0b6adc 100644 --- a/pkg/collector/parser/receiver_jaeger.go +++ b/pkg/collector/parser/receiver_jaeger.go @@ -1,3 +1,17 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package parser import ( @@ -18,14 +32,14 @@ const ( defaultThriftBinaryPort int32 = 6832 ) -// JaegerReceiverParser parses the configuration for Jaeger-specific receivers +// JaegerReceiverParser parses the configuration for Jaeger-specific receivers. type JaegerReceiverParser struct { logger logr.Logger name string config map[interface{}]interface{} } -// NewJaegerReceiverParser builds a new parser for Jaeger receivers +// NewJaegerReceiverParser builds a new parser for Jaeger receivers. func NewJaegerReceiverParser(logger logr.Logger, name string, config map[interface{}]interface{}) ReceiverParser { if protocols, ok := config["protocols"].(map[interface{}]interface{}); ok { return &JaegerReceiverParser{ @@ -41,7 +55,7 @@ func NewJaegerReceiverParser(logger logr.Logger, name string, config map[interfa } } -// Ports returns all the service ports for all protocols in this parser +// Ports returns all the service ports for all protocols in this parser. func (j *JaegerReceiverParser) Ports() ([]corev1.ServicePort, error) { ports := []corev1.ServicePort{} @@ -103,7 +117,7 @@ func (j *JaegerReceiverParser) Ports() ([]corev1.ServicePort, error) { return ports, nil } -// ParserName returns the name of this parser +// ParserName returns the name of this parser. func (j *JaegerReceiverParser) ParserName() string { return parserNameJaeger } diff --git a/pkg/collector/parser/receiver_jaeger_test.go b/pkg/collector/parser/receiver_jaeger_test.go index 3c1b12450f..92897a92c3 100644 --- a/pkg/collector/parser/receiver_jaeger_test.go +++ b/pkg/collector/parser/receiver_jaeger_test.go @@ -1,3 +1,17 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package parser import ( diff --git a/pkg/collector/parser/receiver_oc.go b/pkg/collector/parser/receiver_oc.go index ee188dd82a..5deb0fe5fc 100644 --- a/pkg/collector/parser/receiver_oc.go +++ b/pkg/collector/parser/receiver_oc.go @@ -1,10 +1,24 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package parser import "github.com/go-logr/logr" const parserNameOpenCensus = "__opencensus" -// NewOpenCensusReceiverParser builds a new parser for OpenCensus receivers +// NewOpenCensusReceiverParser builds a new parser for OpenCensus receivers. func NewOpenCensusReceiverParser(logger logr.Logger, name string, config map[interface{}]interface{}) ReceiverParser { return &GenericReceiver{ logger: logger, diff --git a/pkg/collector/parser/receiver_oc_test.go b/pkg/collector/parser/receiver_oc_test.go index 74660ed916..b14b4f9b10 100644 --- a/pkg/collector/parser/receiver_oc_test.go +++ b/pkg/collector/parser/receiver_oc_test.go @@ -1,3 +1,17 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package parser // all tests for the OpenCensus parser are currently part of the test TestDownstreamParsers diff --git a/pkg/collector/parser/receiver_otlp.go b/pkg/collector/parser/receiver_otlp.go index 57bd2706c2..292df6862c 100644 --- a/pkg/collector/parser/receiver_otlp.go +++ b/pkg/collector/parser/receiver_otlp.go @@ -1,3 +1,17 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package parser import ( @@ -18,14 +32,14 @@ const ( defaultOTLPHTTPPort int32 = 55681 ) -// OTLPReceiverParser parses the configuration for OTLP receivers +// OTLPReceiverParser parses the configuration for OTLP receivers. type OTLPReceiverParser struct { logger logr.Logger name string config map[interface{}]interface{} } -// NewOTLPReceiverParser builds a new parser for OTLP receivers +// NewOTLPReceiverParser builds a new parser for OTLP receivers. func NewOTLPReceiverParser(logger logr.Logger, name string, config map[interface{}]interface{}) ReceiverParser { if protocols, ok := config["protocols"].(map[interface{}]interface{}); ok { return &OTLPReceiverParser{ @@ -41,7 +55,7 @@ func NewOTLPReceiverParser(logger logr.Logger, name string, config map[interface } } -// Ports returns all the service ports for all protocols in this parser +// Ports returns all the service ports for all protocols in this parser. func (o *OTLPReceiverParser) Ports() ([]corev1.ServicePort, error) { ports := []corev1.ServicePort{} @@ -98,7 +112,7 @@ func (o *OTLPReceiverParser) Ports() ([]corev1.ServicePort, error) { return ports, nil } -// ParserName returns the name of this parser +// ParserName returns the name of this parser. func (o *OTLPReceiverParser) ParserName() string { return parserNameOTLP } diff --git a/pkg/collector/parser/receiver_otlp_test.go b/pkg/collector/parser/receiver_otlp_test.go index 6d2154a8e2..c5132060ec 100644 --- a/pkg/collector/parser/receiver_otlp_test.go +++ b/pkg/collector/parser/receiver_otlp_test.go @@ -1,3 +1,17 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package parser import ( diff --git a/pkg/collector/parser/receiver_sapm.go b/pkg/collector/parser/receiver_sapm.go index ba1cef23f2..a9b8b574c5 100644 --- a/pkg/collector/parser/receiver_sapm.go +++ b/pkg/collector/parser/receiver_sapm.go @@ -1,10 +1,24 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package parser import "github.com/go-logr/logr" const parserNameSAPM = "__sapm" -// NewSAPMReceiverParser builds a new parser for SAPM receivers, from the contrib repository +// NewSAPMReceiverParser builds a new parser for SAPM receivers, from the contrib repository. func NewSAPMReceiverParser(logger logr.Logger, name string, config map[interface{}]interface{}) ReceiverParser { return &GenericReceiver{ logger: logger, diff --git a/pkg/collector/parser/receiver_sapm_test.go b/pkg/collector/parser/receiver_sapm_test.go index b8b8c31f01..6a0c3de594 100644 --- a/pkg/collector/parser/receiver_sapm_test.go +++ b/pkg/collector/parser/receiver_sapm_test.go @@ -1,3 +1,17 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package parser // all tests for the SAPM parser are currently part of the test TestDownstreamParsers diff --git a/pkg/collector/parser/receiver_signalfx.go b/pkg/collector/parser/receiver_signalfx.go index 9676aa871f..f4140c4701 100644 --- a/pkg/collector/parser/receiver_signalfx.go +++ b/pkg/collector/parser/receiver_signalfx.go @@ -1,10 +1,24 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package parser import "github.com/go-logr/logr" const parserNameSignalFx = "__signalfx" -// NewSignalFxReceiverParser builds a new parser for SignalFx receivers, from the contrib repository +// NewSignalFxReceiverParser builds a new parser for SignalFx receivers, from the contrib repository. func NewSignalFxReceiverParser(logger logr.Logger, name string, config map[interface{}]interface{}) ReceiverParser { return &GenericReceiver{ logger: logger, diff --git a/pkg/collector/parser/receiver_signalfx_test.go b/pkg/collector/parser/receiver_signalfx_test.go index 1ca3809f50..cd196ee5d0 100644 --- a/pkg/collector/parser/receiver_signalfx_test.go +++ b/pkg/collector/parser/receiver_signalfx_test.go @@ -1,3 +1,17 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package parser // all tests for the SignalFx parser are currently part of the test TestDownstreamParsers diff --git a/pkg/collector/parser/receiver_test.go b/pkg/collector/parser/receiver_test.go index fa6030f3ef..10252e801b 100644 --- a/pkg/collector/parser/receiver_test.go +++ b/pkg/collector/parser/receiver_test.go @@ -1,3 +1,17 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package parser import ( diff --git a/pkg/collector/parser/receiver_wavefront.go b/pkg/collector/parser/receiver_wavefront.go index 1b123dcf96..00c3f17e10 100644 --- a/pkg/collector/parser/receiver_wavefront.go +++ b/pkg/collector/parser/receiver_wavefront.go @@ -1,10 +1,24 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package parser import "github.com/go-logr/logr" const parserNameWavefront = "__wavefront" -// NewWavefrontReceiverParser builds a new parser for Wavefront receivers, from the contrib repository +// NewWavefrontReceiverParser builds a new parser for Wavefront receivers, from the contrib repository. func NewWavefrontReceiverParser(logger logr.Logger, name string, config map[interface{}]interface{}) ReceiverParser { return &GenericReceiver{ logger: logger, diff --git a/pkg/collector/parser/receiver_wavefront_test.go b/pkg/collector/parser/receiver_wavefront_test.go index 92b777d00b..6bea4d91e7 100644 --- a/pkg/collector/parser/receiver_wavefront_test.go +++ b/pkg/collector/parser/receiver_wavefront_test.go @@ -1,3 +1,17 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package parser // all tests for the Wavefront parser are currently part of the test TestDownstreamParsers diff --git a/pkg/collector/parser/receiver_zipkin-scribe.go b/pkg/collector/parser/receiver_zipkin-scribe.go index 075e1196b8..1c6fa3631c 100644 --- a/pkg/collector/parser/receiver_zipkin-scribe.go +++ b/pkg/collector/parser/receiver_zipkin-scribe.go @@ -1,10 +1,24 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package parser import "github.com/go-logr/logr" const parserNameZipkinScribe = "__zipkinscribe" -// NewZipkinScribeReceiverParser builds a new parser for ZipkinScribe receivers +// NewZipkinScribeReceiverParser builds a new parser for ZipkinScribe receivers. func NewZipkinScribeReceiverParser(logger logr.Logger, name string, config map[interface{}]interface{}) ReceiverParser { return &GenericReceiver{ logger: logger, diff --git a/pkg/collector/parser/receiver_zipkin-scribe_test.go b/pkg/collector/parser/receiver_zipkin-scribe_test.go index 714dac7733..dc057612b5 100644 --- a/pkg/collector/parser/receiver_zipkin-scribe_test.go +++ b/pkg/collector/parser/receiver_zipkin-scribe_test.go @@ -1,3 +1,17 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package parser // all tests for the ZipkinScribe parser are currently part of the test TestDownstreamParsers diff --git a/pkg/collector/parser/receiver_zipkin.go b/pkg/collector/parser/receiver_zipkin.go index 18e1ac6609..0aa9eb7ed0 100644 --- a/pkg/collector/parser/receiver_zipkin.go +++ b/pkg/collector/parser/receiver_zipkin.go @@ -1,10 +1,24 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package parser import "github.com/go-logr/logr" const parserNameZipkin = "__zipkin" -// NewZipkinReceiverParser builds a new parser for Zipkin receivers +// NewZipkinReceiverParser builds a new parser for Zipkin receivers. func NewZipkinReceiverParser(logger logr.Logger, name string, config map[interface{}]interface{}) ReceiverParser { return &GenericReceiver{ logger: logger, diff --git a/pkg/collector/parser/receiver_zipkin_test.go b/pkg/collector/parser/receiver_zipkin_test.go index c532a2575e..87bfecc082 100644 --- a/pkg/collector/parser/receiver_zipkin_test.go +++ b/pkg/collector/parser/receiver_zipkin_test.go @@ -1,3 +1,17 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package parser // all tests for the Zipkin parser are currently part of the test TestDownstreamParsers diff --git a/pkg/collector/reconcile/configmap.go b/pkg/collector/reconcile/configmap.go index c8093c152a..dcb33ed155 100644 --- a/pkg/collector/reconcile/configmap.go +++ b/pkg/collector/reconcile/configmap.go @@ -31,7 +31,7 @@ import ( // +kubebuilder:rbac:groups="",resources=configmaps,verbs=get;list;watch;create;update;patch;delete -// ConfigMaps reconciles the config map(s) required for the instance in the current context +// ConfigMaps reconciles the config map(s) required for the instance in the current context. func ConfigMaps(ctx context.Context, params Params) error { desired := []corev1.ConfigMap{ desiredConfigMap(ctx, params), @@ -50,7 +50,7 @@ func ConfigMaps(ctx context.Context, params Params) error { return nil } -func desiredConfigMap(ctx context.Context, params Params) corev1.ConfigMap { +func desiredConfigMap(_ context.Context, params Params) corev1.ConfigMap { name := naming.ConfigMap(params.Instance) labels := collector.Labels(params.Instance) labels["app.kubernetes.io/name"] = name diff --git a/pkg/collector/reconcile/daemonset.go b/pkg/collector/reconcile/daemonset.go index e99b995e1d..8b01af432d 100644 --- a/pkg/collector/reconcile/daemonset.go +++ b/pkg/collector/reconcile/daemonset.go @@ -29,7 +29,7 @@ import ( // +kubebuilder:rbac:groups="apps",resources=daemonsets,verbs=get;list;watch;create;update;patch;delete -// DaemonSets reconciles the daemon set(s) required for the instance in the current context +// DaemonSets reconciles the daemon set(s) required for the instance in the current context. func DaemonSets(ctx context.Context, params Params) error { desired := []appsv1.DaemonSet{} if params.Instance.Spec.Mode == "daemonset" { diff --git a/pkg/collector/reconcile/deployment.go b/pkg/collector/reconcile/deployment.go index 59802267ee..399b74e800 100644 --- a/pkg/collector/reconcile/deployment.go +++ b/pkg/collector/reconcile/deployment.go @@ -29,7 +29,7 @@ import ( // +kubebuilder:rbac:groups="apps",resources=deployments,verbs=get;list;watch;create;update;patch;delete -// Deployments reconciles the deployment(s) required for the instance in the current context +// Deployments reconciles the deployment(s) required for the instance in the current context. func Deployments(ctx context.Context, params Params) error { desired := []appsv1.Deployment{} if params.Instance.Spec.Mode == "deployment" { diff --git a/pkg/collector/reconcile/opentelemetry.go b/pkg/collector/reconcile/opentelemetry.go index 163500dbc9..9e9f3eaa93 100644 --- a/pkg/collector/reconcile/opentelemetry.go +++ b/pkg/collector/reconcile/opentelemetry.go @@ -1,3 +1,17 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + // Package reconcile contains reconciliation logic for OpenTelemetry Collector components. package reconcile @@ -5,8 +19,9 @@ import ( "context" "fmt" - "github.com/open-telemetry/opentelemetry-operator/internal/version" "sigs.k8s.io/controller-runtime/pkg/client" + + "github.com/open-telemetry/opentelemetry-operator/internal/version" ) // Self updates this instance's self data. This should be the last item in the reconciliation, as it causes changes diff --git a/pkg/collector/reconcile/params.go b/pkg/collector/reconcile/params.go index fea53fcc14..e9e6fa3dbf 100644 --- a/pkg/collector/reconcile/params.go +++ b/pkg/collector/reconcile/params.go @@ -23,7 +23,7 @@ import ( "github.com/open-telemetry/opentelemetry-operator/internal/config" ) -// Params holds the reconciliation-specific parameters +// Params holds the reconciliation-specific parameters. type Params struct { Config config.Config Client client.Client diff --git a/pkg/collector/reconcile/service.go b/pkg/collector/reconcile/service.go index 1ad41e44d6..c7004e5bae 100644 --- a/pkg/collector/reconcile/service.go +++ b/pkg/collector/reconcile/service.go @@ -34,7 +34,7 @@ import ( // +kubebuilder:rbac:groups="",resources=services,verbs=get;list;watch;create;update;patch;delete -// Services reconciles the service(s) required for the instance in the current context +// Services reconciles the service(s) required for the instance in the current context. func Services(ctx context.Context, params Params) error { desired := []corev1.Service{} if params.Instance.Spec.Mode != v1alpha1.ModeSidecar { diff --git a/pkg/collector/reconcile/serviceaccount.go b/pkg/collector/reconcile/serviceaccount.go index 4a22519721..570f80e285 100644 --- a/pkg/collector/reconcile/serviceaccount.go +++ b/pkg/collector/reconcile/serviceaccount.go @@ -30,7 +30,7 @@ import ( // +kubebuilder:rbac:groups="",resources=serviceaccounts,verbs=get;list;watch;create;update;patch;delete -// ServiceAccounts reconciles the service account(s) required for the instance in the current context +// ServiceAccounts reconciles the service account(s) required for the instance in the current context. func ServiceAccounts(ctx context.Context, params Params) error { desired := []corev1.ServiceAccount{} if params.Instance.Spec.Mode != v1alpha1.ModeSidecar { diff --git a/pkg/collector/serviceaccount.go b/pkg/collector/serviceaccount.go index 50511bd2f1..17ba39a7c7 100644 --- a/pkg/collector/serviceaccount.go +++ b/pkg/collector/serviceaccount.go @@ -1,3 +1,17 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package collector import ( @@ -8,7 +22,7 @@ import ( "github.com/open-telemetry/opentelemetry-operator/pkg/naming" ) -// ServiceAccountName returns the name of the existing or self-provisioned service account to use for the given instance +// ServiceAccountName returns the name of the existing or self-provisioned service account to use for the given instance. func ServiceAccountName(instance v1alpha1.OpenTelemetryCollector) string { if len(instance.Spec.ServiceAccount) == 0 { return naming.ServiceAccount(instance) @@ -17,7 +31,7 @@ func ServiceAccountName(instance v1alpha1.OpenTelemetryCollector) string { return instance.Spec.ServiceAccount } -//ServiceAccount returns the service account for the given instance +//ServiceAccount returns the service account for the given instance. func ServiceAccount(otelcol v1alpha1.OpenTelemetryCollector) corev1.ServiceAccount { labels := Labels(otelcol) labels["app.kubernetes.io/name"] = naming.ServiceAccount(otelcol) diff --git a/pkg/collector/serviceaccount_test.go b/pkg/collector/serviceaccount_test.go index 5c8c7249e2..1430811a4a 100644 --- a/pkg/collector/serviceaccount_test.go +++ b/pkg/collector/serviceaccount_test.go @@ -1,3 +1,17 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package collector_test import ( diff --git a/pkg/collector/upgrade/noop.go b/pkg/collector/upgrade/noop.go index e13fbe2c1b..bf0598cf32 100644 --- a/pkg/collector/upgrade/noop.go +++ b/pkg/collector/upgrade/noop.go @@ -1,3 +1,17 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package upgrade import ( diff --git a/pkg/collector/upgrade/suite_test.go b/pkg/collector/upgrade/suite_test.go index c8bf1e4ed0..47ca3150c1 100644 --- a/pkg/collector/upgrade/suite_test.go +++ b/pkg/collector/upgrade/suite_test.go @@ -1,3 +1,17 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package upgrade_test import ( diff --git a/pkg/collector/upgrade/upgrade.go b/pkg/collector/upgrade/upgrade.go index f4c78aa8c7..fd4495b162 100644 --- a/pkg/collector/upgrade/upgrade.go +++ b/pkg/collector/upgrade/upgrade.go @@ -1,3 +1,17 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + // Package upgrade handles the upgrade routine from one OpenTelemetry Collector to the next. package upgrade @@ -14,7 +28,7 @@ import ( "github.com/open-telemetry/opentelemetry-operator/internal/version" ) -// ManagedInstances finds all the otelcol instances for the current operator and upgrades them, if necessary +// ManagedInstances finds all the otelcol instances for the current operator and upgrades them, if necessary. func ManagedInstances(ctx context.Context, logger logr.Logger, ver version.Version, cl client.Client) error { logger.Info("looking for managed instances to upgrade") @@ -63,7 +77,7 @@ func ManagedInstances(ctx context.Context, logger logr.Logger, ver version.Versi return nil } -// ManagedInstance performs the necessary changes to bring the given otelcol instance to the current version +// ManagedInstance performs the necessary changes to bring the given otelcol instance to the current version. func ManagedInstance(ctx context.Context, logger logr.Logger, currentV version.Version, cl client.Client, otelcol v1alpha1.OpenTelemetryCollector) (v1alpha1.OpenTelemetryCollector, error) { // this is likely a new instance, assume it's already up to date if otelcol.Status.Version == "" { diff --git a/pkg/collector/upgrade/upgrade_test.go b/pkg/collector/upgrade/upgrade_test.go index e2aac56391..449246b678 100644 --- a/pkg/collector/upgrade/upgrade_test.go +++ b/pkg/collector/upgrade/upgrade_test.go @@ -1,3 +1,17 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package upgrade_test import ( diff --git a/pkg/collector/upgrade/v0_15_0.go b/pkg/collector/upgrade/v0_15_0.go index 188888b9e2..4fbac3ea2b 100644 --- a/pkg/collector/upgrade/v0_15_0.go +++ b/pkg/collector/upgrade/v0_15_0.go @@ -1,3 +1,17 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package upgrade import ( diff --git a/pkg/collector/upgrade/v0_15_0_test.go b/pkg/collector/upgrade/v0_15_0_test.go index 90e0218359..dd4c4bea06 100644 --- a/pkg/collector/upgrade/v0_15_0_test.go +++ b/pkg/collector/upgrade/v0_15_0_test.go @@ -1,3 +1,17 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package upgrade_test import ( diff --git a/pkg/collector/upgrade/v0_2_10.go b/pkg/collector/upgrade/v0_2_10.go index a6752509c2..c4e7c5c6b6 100644 --- a/pkg/collector/upgrade/v0_2_10.go +++ b/pkg/collector/upgrade/v0_2_10.go @@ -1,3 +1,17 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package upgrade import ( @@ -6,7 +20,7 @@ import ( "github.com/open-telemetry/opentelemetry-operator/api/v1alpha1" ) -// this is our first version under otel/opentelemetry-collector +// this is our first version under otel/opentelemetry-collector. func upgrade0_2_10(cl client.Client, otelcol *v1alpha1.OpenTelemetryCollector) (*v1alpha1.OpenTelemetryCollector, error) { // this is a no-op, but serves to keep the skeleton here for the future versions return otelcol, nil diff --git a/pkg/collector/upgrade/v0_9_0.go b/pkg/collector/upgrade/v0_9_0.go index 379fb4eb61..5747282c14 100644 --- a/pkg/collector/upgrade/v0_9_0.go +++ b/pkg/collector/upgrade/v0_9_0.go @@ -1,3 +1,17 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package upgrade import ( diff --git a/pkg/collector/upgrade/v0_9_0_test.go b/pkg/collector/upgrade/v0_9_0_test.go index bd70b66328..9d71715e8c 100644 --- a/pkg/collector/upgrade/v0_9_0_test.go +++ b/pkg/collector/upgrade/v0_9_0_test.go @@ -1,3 +1,17 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package upgrade_test import ( diff --git a/pkg/collector/upgrade/versions.go b/pkg/collector/upgrade/versions.go index da3feedcec..25df1a8ecf 100644 --- a/pkg/collector/upgrade/versions.go +++ b/pkg/collector/upgrade/versions.go @@ -1,3 +1,17 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package upgrade import ( diff --git a/pkg/collector/volume.go b/pkg/collector/volume.go index b77cd8359c..292326e7ce 100644 --- a/pkg/collector/volume.go +++ b/pkg/collector/volume.go @@ -23,7 +23,7 @@ import ( "github.com/open-telemetry/opentelemetry-operator/pkg/naming" ) -// Volumes builds the volumes for the given instance, including the config map volume +// Volumes builds the volumes for the given instance, including the config map volume. func Volumes(cfg config.Config, otelcol v1alpha1.OpenTelemetryCollector) []corev1.Volume { volumes := []corev1.Volume{{ Name: naming.ConfigMapVolume(), diff --git a/pkg/collector/volume_test.go b/pkg/collector/volume_test.go index 36b7dcc90b..ecc3aa808a 100644 --- a/pkg/collector/volume_test.go +++ b/pkg/collector/volume_test.go @@ -1,3 +1,17 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package collector_test import ( diff --git a/pkg/naming/main.go b/pkg/naming/main.go index 4fe1505eb8..cf18051a48 100644 --- a/pkg/naming/main.go +++ b/pkg/naming/main.go @@ -1,3 +1,17 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + // Package naming is for determining the names for components (containers, services, ...). package naming @@ -7,42 +21,42 @@ import ( "github.com/open-telemetry/opentelemetry-operator/api/v1alpha1" ) -// ConfigMap builds the name for the config map used in the OpenTelemetryCollector containers +// ConfigMap builds the name for the config map used in the OpenTelemetryCollector containers. func ConfigMap(otelcol v1alpha1.OpenTelemetryCollector) string { return fmt.Sprintf("%s-collector", otelcol.Name) } -// ConfigMapVolume returns the name to use for the config map's volume in the pod +// ConfigMapVolume returns the name to use for the config map's volume in the pod. func ConfigMapVolume() string { return "otc-internal" } -// Container returns the name to use for the container in the pod +// Container returns the name to use for the container in the pod. func Container() string { return "otc-container" } -// Collector builds the collector (deployment/daemonset) name based on the instance +// Collector builds the collector (deployment/daemonset) name based on the instance. func Collector(otelcol v1alpha1.OpenTelemetryCollector) string { return fmt.Sprintf("%s-collector", otelcol.Name) } -// HeadlessService builds the name for the headless service based on the instance +// HeadlessService builds the name for the headless service based on the instance. func HeadlessService(otelcol v1alpha1.OpenTelemetryCollector) string { return fmt.Sprintf("%s-headless", Service(otelcol)) } -// MonitoringService builds the name for the monitoring service based on the instance +// MonitoringService builds the name for the monitoring service based on the instance. func MonitoringService(otelcol v1alpha1.OpenTelemetryCollector) string { return fmt.Sprintf("%s-monitoring", Service(otelcol)) } -// Service builds the service name based on the instance +// Service builds the service name based on the instance. func Service(otelcol v1alpha1.OpenTelemetryCollector) string { return fmt.Sprintf("%s-collector", otelcol.Name) } -// ServiceAccount builds the service account name based on the instance +// ServiceAccount builds the service account name based on the instance. func ServiceAccount(otelcol v1alpha1.OpenTelemetryCollector) string { return fmt.Sprintf("%s-collector", otelcol.Name) } diff --git a/pkg/platform/main.go b/pkg/platform/main.go index 9c47337983..e4791a28eb 100644 --- a/pkg/platform/main.go +++ b/pkg/platform/main.go @@ -15,17 +15,17 @@ // Package platform contains target platforms this operator might run on. package platform -// Platform holds the auto-detected platform type +// Platform holds the auto-detected platform type. type Platform int const ( - // Unknown is used when the current platform can't be determined + // Unknown is used when the current platform can't be determined. Unknown Platform = iota - // OpenShift represents a platform of type OpenShift + // OpenShift represents a platform of type OpenShift. OpenShift Platform = iota - // Kubernetes represents a platform of type Kubernetes + // Kubernetes represents a platform of type Kubernetes. Kubernetes ) diff --git a/pkg/sidecar/annotation.go b/pkg/sidecar/annotation.go index 34a76b7473..8225976c22 100644 --- a/pkg/sidecar/annotation.go +++ b/pkg/sidecar/annotation.go @@ -21,11 +21,11 @@ import ( ) const ( - // Annotation contains the annotation name that pods contain, indicating whether a sidecar is desired + // Annotation contains the annotation name that pods contain, indicating whether a sidecar is desired. Annotation = "sidecar.opentelemetry.io/inject" ) -// AnnotationValue returns the effective annotation value, based on the annotations from the pod and namespace +// AnnotationValue returns the effective annotation value, based on the annotations from the pod and namespace. func AnnotationValue(ns corev1.Namespace, pod corev1.Pod) string { // is the pod annotated with instructions to inject sidecars? is the namespace annotated? // if any of those is true, a sidecar might be desired. diff --git a/pkg/sidecar/pod.go b/pkg/sidecar/pod.go index ea4dc05ae3..0dd4a79bf3 100644 --- a/pkg/sidecar/pod.go +++ b/pkg/sidecar/pod.go @@ -31,7 +31,7 @@ const ( label = "sidecar.opentelemetry.io/injected" ) -// Add a new sidecar container to the given pod, based on the given OpenTelemetryCollector +// Add a new sidecar container to the given pod, based on the given OpenTelemetryCollector. func Add(cfg config.Config, logger logr.Logger, otelcol v1alpha1.OpenTelemetryCollector, pod corev1.Pod) (corev1.Pod, error) { // add the container volumes := collector.Volumes(cfg, otelcol) @@ -47,7 +47,7 @@ func Add(cfg config.Config, logger logr.Logger, otelcol v1alpha1.OpenTelemetryCo return pod, nil } -// Remove the sidecar container from the given pod +// Remove the sidecar container from the given pod. func Remove(pod corev1.Pod) (corev1.Pod, error) { if !ExistsIn(pod) { return pod, nil @@ -63,7 +63,7 @@ func Remove(pod corev1.Pod) (corev1.Pod, error) { return pod, nil } -// ExistsIn checks whether a sidecar container exists in the given pod +// ExistsIn checks whether a sidecar container exists in the given pod. func ExistsIn(pod corev1.Pod) bool { for _, container := range pod.Spec.Containers { if container.Name == naming.Container() {