Skip to content

Commit

Permalink
[chore] remove setenv function, unused (open-telemetry#30280)
Browse files Browse the repository at this point in the history
This function is no longer used as we set gopsutil variable via context
instead of env vars.
  • Loading branch information
atoulme authored Jan 4, 2024
1 parent 05f9ff4 commit a05ba71
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@ type nodeCapacity struct {
logger *zap.Logger

// osLstat returns a FileInfo describing the named file.
osLstat func(name string) (os.FileInfo, error)
// osSetenv sets the value of the environment variable named by the key
osSetenv func(key string, value string) error
osLstat func(name string) (os.FileInfo, error)
virtualMemory func(ctx context.Context) (*mem.VirtualMemoryStat, error)
cpuInfo func(ctx context.Context) ([]cpu.InfoStat, error)
}
Expand All @@ -37,7 +35,6 @@ func newNodeCapacity(logger *zap.Logger, options ...nodeCapacityOption) (nodeCap
nc := &nodeCapacity{
logger: logger,
osLstat: os.Lstat,
osSetenv: os.Setenv,
virtualMemory: mem.VirtualMemoryWithContext,
cpuInfo: cpu.InfoWithContext,
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,6 @@ func TestNodeCapacity(t *testing.T) {
}
}

// can't parse cpu and mem info
setEnvOption := func(nc *nodeCapacity) {
nc.osSetenv = func(key, value string) error {
return nil
}
}
virtualMemOption := func(nc *nodeCapacity) {
nc.virtualMemory = func(ctx context.Context) (*mem.VirtualMemoryStat, error) {
return nil, errors.New("error")
Expand All @@ -49,7 +43,7 @@ func TestNodeCapacity(t *testing.T) {
return nil, errors.New("error")
}
}
nc, err = newNodeCapacity(zap.NewNop(), lstatOption, setEnvOption, virtualMemOption, cpuInfoOption)
nc, err = newNodeCapacity(zap.NewNop(), lstatOption, virtualMemOption, cpuInfoOption)
assert.NotNil(t, nc)
assert.Nil(t, err)
assert.Equal(t, int64(0), nc.getMemoryCapacity())
Expand All @@ -71,7 +65,7 @@ func TestNodeCapacity(t *testing.T) {
}, nil
}
}
nc, err = newNodeCapacity(zap.NewNop(), lstatOption, setEnvOption, virtualMemOption, cpuInfoOption)
nc, err = newNodeCapacity(zap.NewNop(), lstatOption, virtualMemOption, cpuInfoOption)
assert.NotNil(t, nc)
assert.Nil(t, err)
assert.Equal(t, int64(1024), nc.getMemoryCapacity())
Expand Down

0 comments on commit a05ba71

Please sign in to comment.