-
Notifications
You must be signed in to change notification settings - Fork 158
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
set default SPLUNK_LISTEN_INTERFACE to 127.0.0.1 for agent configs
- Loading branch information
1 parent
bfa8a8e
commit 8470072
Showing
5 changed files
with
200 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// Copyright Splunk, Inc. | ||
// | ||
// 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. | ||
|
||
// go:build windows | ||
|
||
package settings | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"path/filepath" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestSetDefaultEnvVarsSetsInterfaceFromConfigOptionWithProgramData(t *testing.T) { | ||
pd := os.Getenv("ProgramData") | ||
for _, tc := range []struct{ config, expectedIP string }{ | ||
{filepath.Join(pd, "Splunk", "OpenTelemetry Collector", "agent_config.yaml"), "127.0.0.1"}, | ||
{fmt.Sprintf("file:%s", filepath.Join(pd, "Splunk", "OpenTelemetry Collector", "agent_config.yaml")), "127.0.0.1"}, | ||
{"\\some-other-config.yaml", "0.0.0.0"}, | ||
{"file:\\some-other-config.yaml", "0.0.0.0"}, | ||
} { | ||
tc := tc | ||
t.Run(fmt.Sprintf("%v->%v", tc.config, tc.expectedIP), func(t *testing.T) { | ||
t.Cleanup(clearEnv(t)) | ||
os.Setenv("SPLUNK_REALM", "noop") | ||
os.Setenv("SPLUNK_ACCESS_TOKEN", "noop") | ||
s, err := parseArgs([]string{"--config", tc.config}) | ||
require.NoError(t, err) | ||
require.NoError(t, setDefaultEnvVars(s)) | ||
|
||
val, ok := os.LookupEnv("SPLUNK_LISTEN_INTERFACE") | ||
assert.True(t, ok) | ||
assert.Equal(t, tc.expectedIP, val) | ||
}) | ||
} | ||
} |
Oops, something went wrong.