Skip to content

Commit 1a49b36

Browse files
authored
[chore] Updates TA to splunk-otel-collector v0.142.0 and marks TA as v1.10.0 (#7054)
* [chore] Updates TA to splunk-otel-collector v0.142.0 and marks TA as v1.10.0 * [chore] fix lint errors Signed-off-by: Dani Louca <dlouca@splunk.com> --------- Signed-off-by: Dani Louca <dlouca@splunk.com>
1 parent 00a3458 commit 1a49b36

File tree

13 files changed

+40
-37
lines changed

13 files changed

+40
-37
lines changed

packaging/technical-addon/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ THIS_MAKEFILE_DIR := $(abspath $(dir $(lastword $(MAKEFILE_LIST))))
33
include $(abspath $(THIS_MAKEFILE_DIR)/../../Makefile.Common)
44

55
# Used for packaging
6-
OTEL_COLLECTOR_VERSION?=0.141.0
6+
OTEL_COLLECTOR_VERSION?=0.142.0
77
SPLUNK_OTELCOL_DOWNLOAD_BASE?=https://github.com/signalfx/splunk-otel-collector/releases/download
88
PLATFORM?=linux
99
ARCH?=amd64

packaging/technical-addon/Splunk_TA_otel/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
## Unreleased
44

5+
## v1.10.0
6+
7+
- Updates addon to use collector version v0.142.0
8+
59
## v1.9.0
610

711
- Updates addon to use collector version v0.141.0

packaging/technical-addon/Splunk_TA_otel/default/app.conf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ label = Splunk Add-on for OpenTelemetry Agent
1818
[launcher]
1919
author = Splunk, Inc.
2020
description = Splunk Add-on for OpenTelemetry is used to easily deploy OpenTelemetry Agent alongside Splunk Universal Forwarder to collect traces and metrics
21-
version = 1.9.0
21+
version = 1.10.0
2222

2323
[package]
2424
id = Splunk_TA_otel
2525

2626
[id]
2727
name = Splunk_TA_otel
28-
version = 1.9.0
28+
version = 1.10.0

packaging/technical-addon/cmd/modinput_config_generator/generator_test.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -90,18 +90,18 @@ func TestRunner(t *testing.T) {
9090

9191
// Check Schema
9292
code, output, err := tc.Exec(ctx, []string{"sudo", "/opt/splunk/bin/splunk", "btool", "check", "--debug"})
93-
assert.NoError(t, err)
93+
require.NoError(t, err)
9494
assert.LessOrEqual(t, code, 1) // Other stanzas may be missing and thus have this be 0 or 1
9595
assert.GreaterOrEqual(t, code, 0) // bound to [0,1]
9696
read, err := io.ReadAll(output)
97-
assert.NoError(t, err)
97+
require.NoError(t, err)
9898
assert.NotContains(t, string(read), "Invalid Key in Stanza")
9999

100100
// check log output
101101
_, output, err = tc.Exec(ctx, []string{"sudo", "cat", "/opt/splunk/var/log/splunk/Sample_Addon.log"})
102102
require.NoError(t, err)
103103
read, err = io.ReadAll(output)
104-
assert.NoError(t, err)
104+
require.NoError(t, err)
105105
expectedJSON := `{"Flags":["--test-flag","/opt/splunk/etc/apps/Sample_Addon/local/access_token","--test-flag"],"EnvVars":["EVERYTHING_SET=/opt/splunk/etc/apps/Sample_Addon/local/access_token","UNARY_FLAG_WITH_EVERYTHING_SET=/opt/splunk/etc/apps/Sample_Addon/local/access_token"], "SplunkHome":"/opt/splunk/etc", "TaHome":"/opt/splunk/etc/apps/Sample_Addon", "PlatformHome":"/opt/splunk/etc/apps/Sample_Addon/linux_x86_64", "EverythingSet":"/opt/splunk/etc/apps/Sample_Addon/local/access_token", "MinimalSet":"", "MinimalSetRequired":"", "UnaryFlagWithEverythingSet":"/opt/splunk/etc/apps/Sample_Addon/local/access_token","Platform":"linux"}`
106106
i := bytes.Index(read, []byte("Sample output:"))
107107
line := read[i+len("Sample output:"):]
@@ -112,7 +112,7 @@ func TestRunner(t *testing.T) {
112112
require.NoError(t, dec.Decode(unmarshalled))
113113
expected := &ExampleOutput{}
114114
require.NoError(t, json.Unmarshal([]byte(expectedJSON), expected))
115-
assert.EqualValues(t, expected, unmarshalled)
115+
assert.Equal(t, expected, unmarshalled)
116116
}
117117

118118
func TestRunnerConfigGeneration(t *testing.T) {
@@ -135,9 +135,9 @@ func TestRunnerConfigGeneration(t *testing.T) {
135135
for _, tc := range tests {
136136
t.Run(tc.testSchemaName, func(tt *testing.T) {
137137
config, err := loadYaml(tc.sampleYamlPath, tc.testSchemaName)
138-
assert.NoError(tt, err)
138+
require.NoError(tt, err)
139139
err = generateModinputConfig(config, tc.outDir)
140-
assert.NoError(tt, err)
140+
require.NoError(tt, err)
141141
assert.FileExists(tt, filepath.Join(filepath.Dir(tc.sampleYamlPath), "modinput_config.go"))
142142
})
143143
}
@@ -166,9 +166,9 @@ func TestInputsConfGeneration(t *testing.T) {
166166
for _, tc := range tests {
167167
t.Run(tc.testSchemaName, func(tt *testing.T) {
168168
config, err := loadYaml(tc.sampleYamlPath, tc.testSchemaName)
169-
assert.NoError(tt, err)
169+
require.NoError(tt, err)
170170
err = generateTaModInputConfs(config, tc.addonSourceDir, tc.outDir)
171-
assert.NoError(tt, err)
171+
require.NoError(tt, err)
172172
testcommon.AssertFilesMatch(tt, filepath.Join("internal", "testdata", "pkg", "sample_addon", "expected", "inputs.conf"), filepath.Join(tc.outDir, tc.testSchemaName, "default", "inputs.conf"))
173173
testcommon.AssertFilesMatch(tt, filepath.Join("internal", "testdata", "pkg", "sample_addon", "expected", "inputs.conf.spec"), filepath.Join(tc.outDir, tc.testSchemaName, "README", "inputs.conf.spec"))
174174
})

packaging/technical-addon/internal/modularinput/inputs_processor.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ func (mip *ModinputProcessor) ProcessXML(modInput *XMLInput) error {
6666
providedInputs := make(map[string]bool)
6767

6868
for _, stanza := range modInput.Configuration.Stanzas {
69-
stanzaPrefix := fmt.Sprintf("%s://", mip.SchemaName)
69+
stanzaPrefix := mip.SchemaName + "://"
7070

7171
if strings.HasPrefix(stanza.Name, stanzaPrefix) {
7272
for _, param := range stanza.Params {
@@ -96,7 +96,7 @@ func (mip *ModinputProcessor) GetFlags() []string {
9696
for _, modinputName := range keys {
9797
modularInput := mip.ModularInputs[modinputName]
9898
if modularInput.Config.Flag.Name != "" {
99-
flags = append(flags, fmt.Sprintf("--%s", modularInput.Config.Flag.Name))
99+
flags = append(flags, "--"+modularInput.Config.Flag.Name)
100100
if !modularInput.Config.Flag.IsUnary {
101101
flags = append(flags, modularInput.Value)
102102
}

packaging/technical-addon/internal/modularinput/spec_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import (
2525
func TestLoadConfig(t *testing.T) {
2626
actual, err := LoadConfig("./testdata/sample-modular-inputs.yaml")
2727
require.NoError(t, err)
28-
require.EqualValues(t,
28+
require.Equal(t,
2929
&TemplateData{
3030
ModularInputs: map[string]ModInputConfig{
3131
"everything_set": {Description: "SET ALL THE THINGS", Default: "$SPLUNK_OTEL_TA_HOME/local/access_token", Flag: Flag{Name: "test-flag", IsUnary: false}, Required: false, PassthroughEnvVar: true, ReplaceableEnvVar: true},

packaging/technical-addon/internal/packaging/paths.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
package packaging
1616

1717
import (
18+
"errors"
1819
"fmt"
1920
"os"
2021
"path/filepath"
@@ -56,7 +57,7 @@ func findGitRoot(startDir string) (string, error) {
5657

5758
parentDir := filepath.Dir(dir)
5859
if parentDir == dir {
59-
return "", fmt.Errorf("no git repository found")
60+
return "", errors.New("no git repository found")
6061
}
6162
dir = parentDir
6263
}
@@ -69,7 +70,7 @@ func GetSourceDir() (string, error) {
6970
fmt.Println("ADDONS_SOURCE_DIR not set, searching for make root")
7071
sourceDir, err = findSourceRoot(".")
7172
if err != nil || sourceDir == "" {
72-
return "", fmt.Errorf("could not makefile to use as ADDONS_SOURCE_DIR and ADDONS_SOURCE_DIR was not specified as an env var")
73+
return "", errors.New("could not makefile to use as ADDONS_SOURCE_DIR and ADDONS_SOURCE_DIR was not specified as an env var")
7374
}
7475
}
7576
return sourceDir, nil
@@ -92,7 +93,7 @@ func findSourceRoot(startDir string) (string, error) {
9293

9394
parentDir := filepath.Dir(dir)
9495
if parentDir == dir {
95-
return "", fmt.Errorf("no Makefile found")
96+
return "", errors.New("no Makefile found")
9697
}
9798
dir = parentDir
9899
}

packaging/technical-addon/internal/packaging/targz_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ func TestPackaging(t *testing.T) {
3939
paths, err := getFilesFromTarGz(actualPath)
4040
require.NoError(t, err)
4141
expectedPaths := mapset.NewSet[string]("Sample_Addon/default/inputs.conf", "Sample_Addon/README/inputs.conf.spec", "Sample_Addon/linux_x86_64/bin/helloworld.sh")
42-
assert.EqualValues(t, expectedPaths, paths, "expected paths to match, missing: %v ; extra: %v", expectedPaths.Difference(paths), paths.Difference(expectedPaths))
42+
assert.Equal(t, expectedPaths, paths, "expected paths to match, missing: %v ; extra: %v", expectedPaths.Difference(paths), paths.Difference(expectedPaths))
4343
}
4444

4545
func getFilesFromTarGz(tarGzPath string) (mapset.Set[string], error) {

packaging/technical-addon/internal/testaddon/splunk.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ package testaddon
1616

1717
import (
1818
"context"
19-
"fmt"
2019
"os"
2120
"path/filepath"
2221
"strings"
@@ -139,7 +138,7 @@ func PackAddon(t *testing.T, defaultModInputs *modularinput.GenericModularInput,
139138
err = repackFunc(t, packedDir)
140139
require.NoError(t, err)
141140

142-
addonPath := filepath.Join(t.TempDir(), fmt.Sprintf("%s.tgz", defaultModInputs.SchemaName))
141+
addonPath := filepath.Join(t.TempDir(), defaultModInputs.SchemaName+".tgz")
143142
err = packaging.PackageAddon(packedDir, addonPath)
144143
require.NoError(t, err)
145144

packaging/technical-addon/internal/testcommon/utils.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,20 @@ import (
2222
"github.com/stretchr/testify/require"
2323
)
2424

25-
func AssertFilesMatch(tt *testing.T, expectedPath, actualPath string) {
26-
require.FileExists(tt, actualPath)
27-
require.FileExists(tt, expectedPath)
25+
func AssertFilesMatch(t *testing.T, expectedPath, actualPath string) {
26+
require.FileExists(t, actualPath)
27+
require.FileExists(t, expectedPath)
2828
expected, err := os.ReadFile(expectedPath)
2929
if err != nil {
30-
tt.Fatalf("Failed to read expected file: %v", err)
30+
t.Fatalf("Failed to read expected file: %v", err)
3131
}
3232

3333
actual, err := os.ReadFile(actualPath)
3434
if err != nil {
35-
tt.Fatalf("Failed to read actual file: %v", err)
35+
t.Fatalf("Failed to read actual file: %v", err)
3636
}
3737

3838
if diff := cmp.Diff(string(expected), string(actual)); diff != "" {
39-
tt.Errorf("File contents mismatch (-expected +actual)\npaths: (%s, %s):\n%s", expectedPath, actualPath, diff)
39+
t.Errorf("File contents mismatch (-expected +actual)\npaths: (%s, %s):\n%s", expectedPath, actualPath, diff)
4040
}
4141
}

0 commit comments

Comments
 (0)