Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion internal/components/component.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ func PortFromEndpoint(endpoint string) (int32, error) {
portStr := r.FindString(endpoint)
cleanedPortStr := strings.ReplaceAll(portStr, ":", "")
port, err = strconv.ParseInt(cleanedPortStr, 10, 32)

if err != nil {
return UnsetPort, err
}
Expand Down
2 changes: 1 addition & 1 deletion internal/components/processors/k8sattribute.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ type K8sAttributeConfig struct {

func GenerateK8SAttrRbacRules(_ logr.Logger, config K8sAttributeConfig) ([]rbacv1.PolicyRule, error) {
// These policies need to be added always
var prs = []rbacv1.PolicyRule{
prs := []rbacv1.PolicyRule{
{
APIGroups: []string{""},
Resources: []string{"pods", "namespaces"},
Expand Down
4 changes: 1 addition & 3 deletions internal/controllers/targetallocator_reconciler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@ import (

var testLogger = logf.Log.WithName("opamp-bridge-controller-unit-tests")

var (
testScheme *runtime.Scheme = scheme.Scheme
)
var testScheme *runtime.Scheme = scheme.Scheme

func init() {
utilruntime.Must(monitoringv1.AddToScheme(testScheme))
Expand Down
2 changes: 1 addition & 1 deletion internal/instrumentation/annotation.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const (
)

// annotationValue returns the effective annotationInjectJava value, based on the annotations from the pod and namespace.
func annotationValue(ns metav1.ObjectMeta, pod metav1.ObjectMeta, annotation string) string {
func annotationValue(ns, pod metav1.ObjectMeta, annotation string) 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.
podAnnValue := pod.Annotations[annotation]
Expand Down
2 changes: 1 addition & 1 deletion internal/instrumentation/dotnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ func injectDefaultDotNetEnvVars(container *corev1.Container, runtime string) {
// setDotNetEnvVar function sets env var to the container if not exist already.
// value of concatValues should be set to true if the env var supports multiple values separated by :.
// If it is set to false, the original container's env var value has priority.
func setDotNetEnvVar(container *corev1.Container, envVarName string, envVarValue string, concatValues bool) {
func setDotNetEnvVar(container *corev1.Container, envVarName, envVarValue string, concatValues bool) {
idx := getIndexOfEnv(container.Env, envVarName)
if idx < 0 {
container.Env = append(container.Env, corev1.EnvVar{
Expand Down
2 changes: 1 addition & 1 deletion internal/instrumentation/podmutator.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ func (langInsts *languageInstrumentations) setCommonInstrumentedContainers(ns co
return nil
}

func (langInsts *languageInstrumentations) setLanguageSpecificContainers(ns metav1.ObjectMeta, pod metav1.ObjectMeta) error {
func (langInsts *languageInstrumentations) setLanguageSpecificContainers(ns, pod metav1.ObjectMeta) error {
inst := []struct {
iwc *instrumentationWithContainers
annotation string
Expand Down
6 changes: 4 additions & 2 deletions internal/instrumentation/podmutator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2958,7 +2958,8 @@ func TestMutatePod(t *testing.T) {
Image: "otel/apache-httpd:1",
Command: []string{"/bin/sh", "-c"},
Args: []string{
"cp -r /opt/opentelemetry/* /opt/opentelemetry-webserver/agent && export agentLogDir=$(echo \"/opt/opentelemetry-webserver/agent/logs\" | sed 's,/,\\\\/,g') && cat /opt/opentelemetry-webserver/agent/conf/opentelemetry_sdk_log4cxx.xml.template | sed 's/__agent_log_dir__/'${agentLogDir}'/g' > /opt/opentelemetry-webserver/agent/conf/opentelemetry_sdk_log4cxx.xml &&echo \"$OTEL_APACHE_AGENT_CONF\" > /opt/opentelemetry-webserver/source-conf/opentemetry_agent.conf && sed -i 's/<<SID-PLACEHOLDER>>/'${APACHE_SERVICE_INSTANCE_ID}'/g' /opt/opentelemetry-webserver/source-conf/opentemetry_agent.conf && echo -e '\nInclude /usr/local/apache2/conf/opentemetry_agent.conf' >> /opt/opentelemetry-webserver/source-conf/httpd.conf"},
"cp -r /opt/opentelemetry/* /opt/opentelemetry-webserver/agent && export agentLogDir=$(echo \"/opt/opentelemetry-webserver/agent/logs\" | sed 's,/,\\\\/,g') && cat /opt/opentelemetry-webserver/agent/conf/opentelemetry_sdk_log4cxx.xml.template | sed 's/__agent_log_dir__/'${agentLogDir}'/g' > /opt/opentelemetry-webserver/agent/conf/opentelemetry_sdk_log4cxx.xml &&echo \"$OTEL_APACHE_AGENT_CONF\" > /opt/opentelemetry-webserver/source-conf/opentemetry_agent.conf && sed -i 's/<<SID-PLACEHOLDER>>/'${APACHE_SERVICE_INSTANCE_ID}'/g' /opt/opentelemetry-webserver/source-conf/opentemetry_agent.conf && echo -e '\nInclude /usr/local/apache2/conf/opentemetry_agent.conf' >> /opt/opentelemetry-webserver/source-conf/httpd.conf",
},
Env: []corev1.EnvVar{
{
Name: apacheAttributesEnvVar,
Expand Down Expand Up @@ -3217,7 +3218,8 @@ func TestMutatePod(t *testing.T) {
{
Name: "OTEL_NGINX_I13N_SCRIPT",
Value: nginxSdkInitContainerI13nScript,
}, {
},
{
Name: nginxServiceInstanceIdEnvVar,
ValueFrom: &corev1.EnvVarSource{
FieldRef: &corev1.ObjectFieldSelector{
Expand Down
2 changes: 1 addition & 1 deletion internal/instrumentation/python.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func injectPythonSDKToContainer(pythonSpec v1alpha1.Python, container *corev1.Co
return nil
}

func injectPythonSDKToPod(pythonSpec v1alpha1.Python, pod corev1.Pod, firstContainerName string, platform string, instSpec v1alpha1.InstrumentationSpec) corev1.Pod {
func injectPythonSDKToPod(pythonSpec v1alpha1.Python, pod corev1.Pod, firstContainerName, platform string, instSpec v1alpha1.InstrumentationSpec) corev1.Pod {
volume := instrVolume(pythonSpec.VolumeClaimTemplate, pythonVolumeName, pythonSpec.VolumeSizeLimit)

// This has been validated already
Expand Down
1 change: 0 additions & 1 deletion internal/manifests/collector/configmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ func ConfigMap(params manifests.Params) (*corev1.ConfigMap, error) {
}

replacedConf, err := ReplaceConfig(*otelCol, params.TargetAllocator, replaceCfgOpts...)

if err != nil {
params.Log.V(2).Info("failed to update prometheus config to use sharded targets: ", "err", err)
return nil, err
Expand Down
3 changes: 1 addition & 2 deletions internal/manifests/collector/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ func paramsWithMode(mode v1beta1.Mode) manifests.Params {
},
Spec: v1beta1.OpenTelemetryCollectorSpec{
OpenTelemetryCommonFields: v1beta1.OpenTelemetryCommonFields{

Image: "ghcr.io/open-telemetry/opentelemetry-operator/opentelemetry-operator:0.47.0",
Ports: []v1beta1.PortsSpec{
{
Expand All @@ -93,7 +92,7 @@ func paramsWithMode(mode v1beta1.Mode) manifests.Params {
}
}

func newParams(taContainerImage string, file string, cfg *config.Config) (manifests.Params, error) {
func newParams(taContainerImage, file string, cfg *config.Config) (manifests.Params, error) {
replicas := int32(1)
var configYAML []byte
var err error
Expand Down
7 changes: 4 additions & 3 deletions internal/manifests/manifestutils/annotations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,10 @@ func TestUserAnnotations(t *testing.T) {
ObjectMeta: metav1.ObjectMeta{
Name: "my-instance",
Namespace: "my-ns",
Annotations: map[string]string{"prometheus.io/scrape": "false",
"prometheus.io/port": "1234",
"prometheus.io/path": "/test",
Annotations: map[string]string{
"prometheus.io/scrape": "false",
"prometheus.io/port": "1234",
"prometheus.io/path": "/test",
},
},
Spec: v1beta1.OpenTelemetryCollectorSpec{
Expand Down
2 changes: 2 additions & 0 deletions internal/manifests/manifestutils/labels_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ func TestLabelsCommonSet(t *testing.T) {
assert.Equal(t, "opentelemetry", labels["app.kubernetes.io/part-of"])
assert.Equal(t, "opentelemetry-collector", labels["app.kubernetes.io/component"])
}

func TestLabelsSha256Set(t *testing.T) {
// prepare
otelcol := v1alpha1.OpenTelemetryCollector{
Expand Down Expand Up @@ -79,6 +80,7 @@ func TestLabelsSha256Set(t *testing.T) {
assert.Equal(t, "opentelemetry", labelsTag["app.kubernetes.io/part-of"])
assert.Equal(t, "opentelemetry-collector", labelsTag["app.kubernetes.io/component"])
}

func TestLabelsTagUnset(t *testing.T) {
// prepare
otelcol := v1alpha1.OpenTelemetryCollector{
Expand Down
3 changes: 2 additions & 1 deletion internal/manifests/opampbridge/configmap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ description:
endpoint: ws://opamp-server:4320/v1/opamp
headers:
authorization: access-12345-token
`}
`,
}
tests := []struct {
description string
image string
Expand Down
2 changes: 1 addition & 1 deletion internal/manifests/opampbridge/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func Container(cfg config.Config, _ logr.Logger, opampBridge v1alpha1.OpAMPBridg
volumeMounts = append(volumeMounts, opampBridge.Spec.VolumeMounts...)
}

var envVars = opampBridge.Spec.Env
envVars := opampBridge.Spec.Env
if opampBridge.Spec.Env == nil {
envVars = []corev1.EnvVar{}
}
Expand Down
2 changes: 1 addition & 1 deletion internal/manifests/targetallocator/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func Container(cfg config.Config, _ logr.Logger, instance v1alpha1.TargetAllocat
}}
volumeMounts = append(volumeMounts, instance.Spec.VolumeMounts...)

var envVars = instance.Spec.Env
envVars := instance.Spec.Env
if envVars == nil {
envVars = []corev1.EnvVar{}
}
Expand Down
2 changes: 2 additions & 0 deletions internal/manifests/targetallocator/container_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,7 @@ func TestContainerDoesNotOverrideEnvVars(t *testing.T) {
// verify
assert.Equal(t, expected, c)
}

func TestReadinessProbe(t *testing.T) {
targetAllocator := v1alpha1.TargetAllocator{}
cfg := config.New()
Expand All @@ -372,6 +373,7 @@ func TestReadinessProbe(t *testing.T) {
// verify
assert.Equal(t, expected, c.ReadinessProbe)
}

func TestLivenessProbe(t *testing.T) {
// prepare
targetAllocator := v1alpha1.TargetAllocator{}
Expand Down
6 changes: 4 additions & 2 deletions internal/manifests/targetallocator/deployment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,10 @@ var testAffinityValue = &v1.Affinity{
},
}

var runAsUser int64 = 1000
var runAsGroup int64 = 1000
var (
runAsUser int64 = 1000
runAsGroup int64 = 1000
)

var testSecurityContextValue = &v1.PodSecurityContext{
RunAsUser: &runAsUser,
Expand Down
3 changes: 2 additions & 1 deletion internal/manifests/targetallocator/volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ func Volumes(cfg config.Config, instance v1alpha1.TargetAllocator) []corev1.Volu
{
Key: cfg.TargetAllocatorConfigMapEntry,
Path: cfg.TargetAllocatorConfigMapEntry,
}},
},
},
},
},
}}
Expand Down
2 changes: 1 addition & 1 deletion internal/naming/dns_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
)

func TestDnsName(t *testing.T) {
var tests = []struct {
tests := []struct {
in string
out string
}{
Expand Down
2 changes: 1 addition & 1 deletion internal/operator-metrics/metrics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func TestOperatorMetrics_Start(t *testing.T) {
defer cancelTimeout()

// Wait until one service monitor is being created
var serviceMonitor = &monitoringv1.ServiceMonitor{}
serviceMonitor := &monitoringv1.ServiceMonitor{}
err = wait.PollUntilContextTimeout(
ctxTimeout,
time.Millisecond*100,
Expand Down
Loading