-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
allow to pass context values to override environment variables #1439
Conversation
712bc7b
to
738801a
Compare
@shirou when you get a chance, can you please review this PR ? |
Sorry to late response. I finally had time to review it. As a premise, I agree with the policy about the method of putting values into the So, I have a more implementation-oriented comment. common.Env will become a Therefore, how about to restrict the types in the
GetEnvWithContext retrieve side may became a bit more complicated, but I think this method is clearer and more extensible. More to the point, in the future, I would also like to add options other than How do you think? |
I'm on it. |
Ready for another review @shirou , thanks! |
@shirou code review feedback addressed, thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would like to merge this as I think this is probably the best way to go.
Thank you very much for your patience with my review.
I believe this change will give gopsutil great potential for extensibility in the future. I would like to thank you again!
* fix some comments Signed-off-by: cui fliter <[email protected]> * chore(deps): bump github.com/stretchr/testify from 1.8.2 to 1.8.3 Bumps [github.com/stretchr/testify](https://github.com/stretchr/testify) from 1.8.2 to 1.8.3. - [Release notes](https://github.com/stretchr/testify/releases) - [Commits](stretchr/testify@v1.8.2...v1.8.3) --- updated-dependencies: - dependency-name: github.com/stretchr/testify dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]> * fix(mem): Correct capitalization of linux writeback fixes: shirou#1471 * chore(deps): bump github.com/yusufpapurcu/wmi from 1.2.2 to 1.2.3 Bumps [github.com/yusufpapurcu/wmi](https://github.com/yusufpapurcu/wmi) from 1.2.2 to 1.2.3. - [Release notes](https://github.com/yusufpapurcu/wmi/releases) - [Commits](yusufpapurcu/wmi@v1.2.2...v1.2.3) --- updated-dependencies: - dependency-name: github.com/yusufpapurcu/wmi dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]> * [common]: fix potential leak on Sleep. * chore(deps): bump github.com/stretchr/testify from 1.8.3 to 1.8.4 Bumps [github.com/stretchr/testify](https://github.com/stretchr/testify) from 1.8.3 to 1.8.4. - [Release notes](https://github.com/stretchr/testify/releases) - [Commits](stretchr/testify@v1.8.3...v1.8.4) --- updated-dependencies: - dependency-name: github.com/stretchr/testify dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]> * allow to pass context values to override environment variables * move the Env key out of internal packages * change to use a typed map per code review * lint fixes * remove deprecation comments * add more env keys * apply code review * fix more linting reports * add(README): add passing context value document which is introduced by shirou#1439. * Ref actions by commit SHA in build_test.yml It's important to make sure the SHA's are from the original repositories and not forks. For reference: https://github.com/actions/setup-go/releases/tag/v4.0.1 actions/setup-go@fac708d https://github.com/actions/checkout/releases/tag/v3.5.2 actions/checkout@8e5e7e5 https://github.com/actions/cache/releases/tag/v3.3.1 actions/cache@88522ab Signed-off-by: Gabriela Gutierrez <[email protected]> * Ref actions by commit SHA in labeler.yml It's important to make sure the SHA's are from the original repositories and not forks. For reference: https://github.com/actions/labeler/releases/tag/v4.1.0 actions/labeler@9fcb2c2 Signed-off-by: Gabriela Gutierrez <[email protected]> * Ref actions by commit SHA in lint.yml It's important to make sure the SHA's are from the original repositories and not forks. For reference: https://github.com/actions/setup-go/releases/tag/v4.0.1 actions/setup-go@fac708d https://github.com/actions/checkout/releases/tag/v3.5.2 actions/checkout@8e5e7e5 https://github.com/golangci/golangci-lint-action/releases/tag/v3.5.0 golangci/golangci-lint-action@5f1fec7 Signed-off-by: Gabriela Gutierrez <[email protected]> * Ref actions by commit SHA in release.yml It's important to make sure the SHA's are from the original repositories and not forks. For reference: https://github.com/actions/checkout/releases/tag/v3.5.2 actions/checkout@8e5e7e5 Signed-off-by: Gabriela Gutierrez <[email protected]> * Ref actions by commit SHA in sbom_generator.yml It's important to make sure the SHA's are from the original repositories and not forks. For reference: https://github.com/actions/checkout/releases/tag/v3.5.2 actions/checkout@8e5e7e5 https://github.com/advanced-security/sbom-generator-action/releases/tag/v0.0.1 advanced-security/sbom-generator-action@375dee8 https://github.com/actions/upload-artifact/releases/tag/v3.1.2 actions/upload-artifact@0b7f8ab Signed-off-by: Gabriela Gutierrez <[email protected]> * Ref actions by commit SHA in shellcheck.yml It's important to make sure the SHA's are from the original repositories and not forks. For reference: https://github.com/actions/checkout/releases/tag/v3.5.2 actions/checkout@8e5e7e5 https://github.com/ludeeus/action-shellcheck/releases/tag/2.0.0 ludeeus/action-shellcheck@00cae50 Signed-off-by: Gabriela Gutierrez <[email protected]> * Ref actions by commit SHA in test.yml It's important to make sure the SHA's are from the original repositories and not forks. For reference: https://github.com/actions/setup-go/releases/tag/v4.0.1 actions/setup-go@fac708d https://github.com/actions/checkout/releases/tag/v3.5.2 actions/checkout@8e5e7e5 https://github.com/actions/cache/releases/tag/v3.3.1 actions/cache@88522ab Signed-off-by: Gabriela Gutierrez <[email protected]> * chore(deps): bump actions/checkout from 3.5.2 to 3.5.3 Bumps [actions/checkout](https://github.com/actions/checkout) from 3.5.2 to 3.5.3. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](actions/checkout@8e5e7e5...c85c95e) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]> * chore(deps): bump golangci/golangci-lint-action from 3.5.0 to 3.6.0 Bumps [golangci/golangci-lint-action](https://github.com/golangci/golangci-lint-action) from 3.5.0 to 3.6.0. - [Release notes](https://github.com/golangci/golangci-lint-action/releases) - [Commits](golangci/golangci-lint-action@5f1fec7...639cd34) --- updated-dependencies: - dependency-name: golangci/golangci-lint-action dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> * chore(deps): bump golang.org/x/sys from 0.8.0 to 0.9.0 Bumps [golang.org/x/sys](https://github.com/golang/sys) from 0.8.0 to 0.9.0. - [Commits](golang/sys@v0.8.0...v0.9.0) --- updated-dependencies: - dependency-name: golang.org/x/sys dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> * cpu_percent and memory_percent update * chore(deps): bump actions/labeler from 4.1.0 to 4.2.0 Bumps [actions/labeler](https://github.com/actions/labeler) from 4.1.0 to 4.2.0. - [Release notes](https://github.com/actions/labeler/releases) - [Commits](actions/labeler@9fcb2c2...0967ca8) --- updated-dependencies: - dependency-name: actions/labeler dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> * [process] Remove all noisy and useless Test_AllProcesses_X tests These tests can't fail more than their invidiual counterparts and produce an incredibly verbose output * chore(deps): bump golang.org/x/sys from 0.9.0 to 0.10.0 Bumps [golang.org/x/sys](https://github.com/golang/sys) from 0.9.0 to 0.10.0. - [Commits](golang/sys@v0.9.0...v0.10.0) --- updated-dependencies: - dependency-name: golang.org/x/sys dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> * [process][posix] Realign process.Name() with python psutil to return same value on python3 scripts processes e2c79a1 started to blindly set the process name to the full path (instead of the basename) of the cmdline exectuable if the process name from the process comm was truncated on linux. Python psutil never did that, and this is just wrong for python (or any executable interpreted script) where the process name is not the interpreter binary but the script itself. A new test to check process name value against psutil value is added here, which would hopefully catch any potential future changes in psutil. Reverts shirou#542 Fixes shirou#1485 * chore(deps): bump actions/labeler from 4.2.0 to 4.3.0 Bumps [actions/labeler](https://github.com/actions/labeler) from 4.2.0 to 4.3.0. - [Release notes](https://github.com/actions/labeler/releases) - [Commits](actions/labeler@0967ca8...ac9175f) --- updated-dependencies: - dependency-name: actions/labeler dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> * Enable setting of vendor and related information for all Power versions * chore(deps): bump golang.org/x/sys from 0.10.0 to 0.11.0 Bumps [golang.org/x/sys](https://github.com/golang/sys) from 0.10.0 to 0.11.0. - [Commits](golang/sys@v0.10.0...v0.11.0) --- updated-dependencies: - dependency-name: golang.org/x/sys dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> * mem: linux: fix vmstat field names The field names are read from /proc/vmstat were capitalized as their output fields by mistake * chore(deps): bump github.com/tklauser/go-sysconf from 0.3.11 to 0.3.12 Bumps [github.com/tklauser/go-sysconf](https://github.com/tklauser/go-sysconf) from 0.3.11 to 0.3.12. - [Release notes](https://github.com/tklauser/go-sysconf/releases) - [Commits](tklauser/go-sysconf@v0.3.11...v0.3.12) --- updated-dependencies: - dependency-name: github.com/tklauser/go-sysconf dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]> * chore(deps): bump actions/setup-go from 4.0.1 to 4.1.0 Bumps [actions/setup-go](https://github.com/actions/setup-go) from 4.0.1 to 4.1.0. - [Release notes](https://github.com/actions/setup-go/releases) - [Commits](actions/setup-go@fac708d...93397be) --- updated-dependencies: - dependency-name: actions/setup-go dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> * fix: fixed windows disk package leaks - fixed goroutine leak in PartitionsWithContext - closed registry handle in init * [host][linux]: remove double quote from lsb release info fix: shirou#1502 * chore(deps): bump golangci/golangci-lint-action from 3.6.0 to 3.7.0 Bumps [golangci/golangci-lint-action](https://github.com/golangci/golangci-lint-action) from 3.6.0 to 3.7.0. - [Release notes](https://github.com/golangci/golangci-lint-action/releases) - [Commits](golangci/golangci-lint-action@639cd34...3a91952) --- updated-dependencies: - dependency-name: golangci/golangci-lint-action dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> * fix IOCounters() SerialNumber enumeration * Update disk/disk_linux.go Co-authored-by: shirou <[email protected]> * update comment * comment cleanup * chore(deps): bump actions/checkout from 3.5.3 to 3.6.0 Bumps [actions/checkout](https://github.com/actions/checkout) from 3.5.3 to 3.6.0. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](actions/checkout@c85c95e...f43a0e5) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> --------- Signed-off-by: cui fliter <[email protected]> Signed-off-by: dependabot[bot] <[email protected]> Signed-off-by: Gabriela Gutierrez <[email protected]> Co-authored-by: cui fliter <[email protected]> Co-authored-by: shirou <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Josh Powers <[email protected]> Co-authored-by: Antoine Toulme <[email protected]> Co-authored-by: Gabriela Gutierrez <[email protected]> Co-authored-by: Elfranne <[email protected]> Co-authored-by: Lomanic <[email protected]> Co-authored-by: Kishen V <[email protected]> Co-authored-by: Hugo Beauzée-Luyssen <[email protected]> Co-authored-by: Ozan HACIBEKİROĞLU <[email protected]> Co-authored-by: Greg Dallavalle <[email protected]> Co-authored-by: Greg <[email protected]>
Fixes #1438