Skip to content

Commit 2dd7600

Browse files
authored
[cmd/opampsupervisor] remove common package (open-telemetry#43885)
The code in this package was used in a single location. Moving the code where it is needed and removing unused func. --------- Signed-off-by: alex boten <[email protected]>
1 parent 4f03e60 commit 2dd7600

File tree

3 files changed

+41
-41
lines changed

3 files changed

+41
-41
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Use this changelog template to create an entry for release notes.
2+
3+
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
4+
change_type: breaking
5+
6+
# The name of the component, or a single word describing the area of concern, (e.g. receiver/filelog)
7+
component: cmd/opampsupervisor
8+
9+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10+
note: Remove common package, moving code where it is used instead.
11+
12+
# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
13+
issues: [43885]
14+
15+
# (Optional) One or more lines of additional information to render under the primary note.
16+
# These lines will be padded with 2 spaces and then inserted directly into the document.
17+
# Use pipe (|) for multiline entries.
18+
subtext:
19+
20+
# If your change doesn't affect end users or the exported elements of any package,
21+
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
22+
# Optional: The change log or logs in which this entry should be included.
23+
# e.g. '[user]' or '[user, api]'
24+
# Include 'user' if the change is relevant to end users.
25+
# Include 'api' if there is a change to a library API.
26+
# Default: '[user]'
27+
change_logs: [api]

cmd/opampsupervisor/supervisor/commander/commander.go

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import (
1818

1919
"go.uber.org/zap"
2020

21-
"github.com/open-telemetry/opentelemetry-collector-contrib/cmd/opampsupervisor/supervisor/common"
2221
"github.com/open-telemetry/opentelemetry-collector-contrib/cmd/opampsupervisor/supervisor/config"
2322
)
2423

@@ -77,7 +76,7 @@ func (c *Commander) Start(ctx context.Context) error {
7776
args := slices.Concat(c.args, c.cfg.Arguments)
7877

7978
c.cmd = exec.CommandContext(ctx, c.cfg.Executable, args...) // #nosec G204
80-
c.cmd.Env = common.EnvVarMapToEnvMapSlice(c.cfg.Env)
79+
c.cmd.Env = envVarMapToEnvMapSlice(c.cfg.Env)
8180
c.cmd.SysProcAttr = sysProcAttrs()
8281

8382
// PassthroughLogging changes how collector start up happens
@@ -209,7 +208,7 @@ func (c *Commander) StartOneShot() ([]byte, []byte, error) {
209208
ctx := context.Background()
210209

211210
cmd := exec.CommandContext(ctx, c.cfg.Executable, c.args...) // #nosec G204
212-
cmd.Env = common.EnvVarMapToEnvMapSlice(c.cfg.Env)
211+
cmd.Env = envVarMapToEnvMapSlice(c.cfg.Env)
213212
cmd.SysProcAttr = sysProcAttrs()
214213
// grab cmd pipes
215214
stdoutPipe, err := cmd.StdoutPipe()
@@ -376,3 +375,15 @@ func (c *Commander) Stop(ctx context.Context) error {
376375

377376
return innerErr
378377
}
378+
379+
func envVarMapToEnvMapSlice(m map[string]string) []string {
380+
// let the command initialize the env itself
381+
if m == nil {
382+
return nil
383+
}
384+
result := os.Environ()
385+
for key, value := range m {
386+
result = append(result, key+"="+value)
387+
}
388+
return result
389+
}

cmd/opampsupervisor/supervisor/common/common.go

Lines changed: 0 additions & 38 deletions
This file was deleted.

0 commit comments

Comments
 (0)