diff --git a/go.mod b/go.mod index 04452253..8d157249 100644 --- a/go.mod +++ b/go.mod @@ -17,7 +17,7 @@ require ( github.com/onsi/ginkgo/v2 v2.32.1 github.com/onsi/gomega v1.42.1 github.com/spf13/cobra v1.10.2 - github.com/testcontainers/testcontainers-go v0.43.0 + github.com/testcontainers/testcontainers-go v0.44.0 ) require ( @@ -138,7 +138,7 @@ require ( github.com/go-critic/go-critic v0.14.4 // indirect github.com/go-logr/logr v1.4.4 // indirect github.com/go-logr/stdr v1.2.2 // indirect - github.com/go-ole/go-ole v1.2.6 // indirect + github.com/go-ole/go-ole v1.3.0 // indirect github.com/go-task/slim-sprig/v3 v3.0.0 // indirect github.com/go-toolsmith/astcast v1.1.0 // indirect github.com/go-toolsmith/astcopy v1.1.0 // indirect @@ -200,7 +200,7 @@ require ( github.com/ldez/usetesting v0.5.0 // indirect github.com/leonklingele/grouper v1.1.2 // indirect github.com/lucasb-eyer/go-colorful v1.4.1 // indirect - github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect + github.com/lufia/plan9stats v0.0.0-20260330125221-c963978e514e // indirect github.com/macabu/inamedparam v0.2.0 // indirect github.com/magiconair/properties v1.8.10 // indirect github.com/manuelarte/embeddedstructfieldcheck v0.4.0 // indirect @@ -220,7 +220,7 @@ require ( github.com/moby/go-archive v0.2.0 // indirect github.com/moby/moby/client v0.5.1 // indirect github.com/moby/patternmatcher v0.6.1 // indirect - github.com/moby/sys/sequential v0.6.0 // indirect + github.com/moby/sys/sequential v0.7.0 // indirect github.com/moby/sys/user v0.4.0 // indirect github.com/moby/sys/userns v0.1.0 // indirect github.com/moby/term v0.5.2 // indirect @@ -277,8 +277,8 @@ require ( github.com/tetafro/godot v1.5.6 // indirect github.com/timakin/bodyclose v0.0.0-20260129054331-73d1f95b84b4 // indirect github.com/timonwong/loggercheck v0.11.0 // indirect - github.com/tklauser/go-sysconf v0.3.16 // indirect - github.com/tklauser/numcpus v0.11.0 // indirect + github.com/tklauser/go-sysconf v0.4.0 // indirect + github.com/tklauser/numcpus v0.12.0 // indirect github.com/tomarrell/wrapcheck/v2 v2.12.0 // indirect github.com/tommy-muehle/go-mnd/v2 v2.5.1 // indirect github.com/tonistiigi/go-csvvalue v0.0.0-20240814133006-030d3b2625d0 // indirect diff --git a/go.sum b/go.sum index 27b02dc5..ca069744 100644 --- a/go.sum +++ b/go.sum @@ -322,8 +322,9 @@ github.com/go-logr/logr v1.4.4 h1:tG4xh9yMsRCAiodLVTxyrkzSZ9+o0L1Kg/+cPVcbP/8= github.com/go-logr/logr v1.4.4/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= -github.com/go-ole/go-ole v1.2.6 h1:/Fpf6oFPoeFik9ty7siob0G6Ke8QvQEuVcuChpwXzpY= github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0= +github.com/go-ole/go-ole v1.3.0 h1:Dt6ye7+vXGIKZ7Xtk4s6/xVdGDQynvom7xCFEdWr6uE= +github.com/go-ole/go-ole v1.3.0/go.mod h1:5LS6F96DhAwUc7C+1HLexzMXY1xGRSryjyPPKW6zv78= github.com/go-quicktest/qt v1.102.0 h1:HSQxCeh5YZH3EL3W39ixjtyaEhcWSXQHtHnMBzSs474= github.com/go-quicktest/qt v1.102.0/go.mod h1:p4lGIVX+8Wa6ZPNDvqcxq36XpUDLh42FLetFU7odllI= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= @@ -402,7 +403,6 @@ github.com/golangci/unconvert v0.0.0-20250410112200-a129a6e6413e/go.mod h1:h+wZw github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= @@ -514,8 +514,8 @@ github.com/leonklingele/grouper v1.1.2 h1:o1ARBDLOmmasUaNDesWqWCIFH3u7hoFlM84Yrj github.com/leonklingele/grouper v1.1.2/go.mod h1:6D0M/HVkhs2yRKRFZUoGjeDy7EZTfFBE9gl4kjmIGkA= github.com/lucasb-eyer/go-colorful v1.4.1 h1:1EO+WB73+EH8EVbzlrG3KLAfEypQWVHIBqlTf+2hNss= github.com/lucasb-eyer/go-colorful v1.4.1/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0= -github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 h1:6E+4a0GO5zZEnZ81pIr0yLvtUWk2if982qA3F3QD6H4= -github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0/go.mod h1:zJYVVT2jmtg6P3p1VtQj7WsuWi/y4VnjVBn7F8KPB3I= +github.com/lufia/plan9stats v0.0.0-20260330125221-c963978e514e h1:Q6MvJtQK/iRcRtzAscm/zF23XxJlbECiGPyRicsX+Ak= +github.com/lufia/plan9stats v0.0.0-20260330125221-c963978e514e/go.mod h1:autxFIvghDt3jPTLoqZ9OZ7s9qTGNAWmYCjVFWPX/zg= github.com/macabu/inamedparam v0.2.0 h1:VyPYpOc10nkhI2qeNUdh3Zket4fcZjEWe35poddBCpE= github.com/macabu/inamedparam v0.2.0/go.mod h1:+Pee9/YfGe5LJ62pYXqB89lJ+0k5bsR8Wgz/C0Zlq3U= github.com/magiconair/properties v1.8.10 h1:s31yESBquKXCV9a/ScB3ESkOjUYYv+X0rg8SYxI99mE= @@ -570,8 +570,8 @@ github.com/moby/moby/client v0.5.1 h1:tYNaJno4c0HXz12y5BiqEDy0rVTYkWzI26lGvnTMiJ github.com/moby/moby/client v0.5.1/go.mod h1:odLstlZ6uSnfvAgVxMpvgmb8SUdd+siH2T0GBuxVAlM= github.com/moby/patternmatcher v0.6.1 h1:qlhtafmr6kgMIJjKJMDmMWq7WLkKIo23hsrpR3x084U= github.com/moby/patternmatcher v0.6.1/go.mod h1:hDPoyOpDY7OrrMDLaYoY3hf52gNCR/YOUYxkhApJIxc= -github.com/moby/sys/sequential v0.6.0 h1:qrx7XFUd/5DxtqcoH1h438hF5TmOvzC/lspjy7zgvCU= -github.com/moby/sys/sequential v0.6.0/go.mod h1:uyv8EUTrca5PnDsdMGXhZe6CCe8U/UiTWd+lL+7b/Ko= +github.com/moby/sys/sequential v0.7.0 h1:ASQNGNROJSuOO6LL6bPHbKvuZu6NU8P4ldPWk31zj/8= +github.com/moby/sys/sequential v0.7.0/go.mod h1:NfSTAp6V3fw4tmkD62PEcOKeZKquXT8VKCkf7aVR79o= github.com/moby/sys/user v0.4.0 h1:jhcMKit7SA80hivmFJcbB1vqmw//wU61Zdui2eQXuMs= github.com/moby/sys/user v0.4.0/go.mod h1:bG+tYYYJgaMtRKgEmuueC0hJEAZWwtIbZTB+85uoHjs= github.com/moby/sys/userns v0.1.0 h1:tVLXkFOxVu9A64/yh59slHVv9ahO9UIev4JZusOLG/g= @@ -755,8 +755,8 @@ github.com/tenntenn/modver v1.0.1 h1:2klLppGhDgzJrScMpkj9Ujy3rXPUspSjAcev9tSEBgA github.com/tenntenn/modver v1.0.1/go.mod h1:bePIyQPb7UeioSRkw3Q0XeMhYZSMx9B8ePqg6SAMGH0= github.com/tenntenn/text/transform v0.0.0-20200319021203-7eef512accb3 h1:f+jULpRQGxTSkNYKJ51yaw6ChIqO+Je8UqsTKN/cDag= github.com/tenntenn/text/transform v0.0.0-20200319021203-7eef512accb3/go.mod h1:ON8b8w4BN/kE1EOhwT0o+d62W65a6aPw1nouo9LMgyY= -github.com/testcontainers/testcontainers-go v0.43.0 h1:oEQx5MW2DGd9z3AeEQfB2lPM0eLs7ztyaGRu75bFo5A= -github.com/testcontainers/testcontainers-go v0.43.0/go.mod h1:+VxkT2NQnKOZPKi6praMuMKYHYyOGXr0XSBSlSMCzFo= +github.com/testcontainers/testcontainers-go v0.44.0 h1:/Fwh6HY1mIikhnm9e7HwoxGycx0lzRAE0f5VQpjFxzI= +github.com/testcontainers/testcontainers-go v0.44.0/go.mod h1:IcnwQrYTO86xHXu5bvMaBH7ATlbS3Qn1M1QWW3c66rE= github.com/tetafro/godot v1.5.6 h1:IEkrFCwXaYHlOn4mGzGS3F3dkP6m9t0jpwqBFPIkKiA= github.com/tetafro/godot v1.5.6/go.mod h1:eOkMrVQurDui411nBY2FA05EYH01r14LuWY/NrVDVcU= github.com/tidwall/gjson v1.19.0 h1:xwxm7n691Uf3u5OFjzngavjGTh55KX5q/9w9xHW88JU= @@ -778,10 +778,10 @@ github.com/tj/go-buffer v1.1.0/go.mod h1:iyiJpfFcR2B9sXu7KvjbT9fpM4mOelRSDTbntVj github.com/tj/go-elastic v0.0.0-20171221160941-36157cbbebc2/go.mod h1:WjeM0Oo1eNAjXGDx2yma7uG2XoyRZTq1uv3M/o7imD0= github.com/tj/go-kinesis v0.0.0-20171128231115-08b17f58cb1b/go.mod h1:/yhzCV0xPfx6jb1bBgRFjl5lytqVqZXEaeqWP8lTEao= github.com/tj/go-spin v1.1.0/go.mod h1:Mg1mzmePZm4dva8Qz60H2lHwmJ2loum4VIrLgVnKwh4= -github.com/tklauser/go-sysconf v0.3.16 h1:frioLaCQSsF5Cy1jgRBrzr6t502KIIwQ0MArYICU0nA= -github.com/tklauser/go-sysconf v0.3.16/go.mod h1:/qNL9xxDhc7tx3HSRsLWNnuzbVfh3e7gh/BmM179nYI= -github.com/tklauser/numcpus v0.11.0 h1:nSTwhKH5e1dMNsCdVBukSZrURJRoHbSEQjdEbY+9RXw= -github.com/tklauser/numcpus v0.11.0/go.mod h1:z+LwcLq54uWZTX0u/bGobaV34u6V7KNlTZejzM6/3MQ= +github.com/tklauser/go-sysconf v0.4.0 h1:7H0uAN+7RkwWRaxhYXDLqa5V3LPrJeV8wmD9dRUgPQU= +github.com/tklauser/go-sysconf v0.4.0/go.mod h1:8mTNWyog7H+MpKijp4VmKJAd2bbYQ2zuUwkYRbUArPI= +github.com/tklauser/numcpus v0.12.0 h1:NR85qdvHA9pFse3x3weVZ0r0ST8R6l5RHbZrlRaqob4= +github.com/tklauser/numcpus v0.12.0/go.mod h1:ABHeXzJnr/qqwguhClkZKT1/8VABcYrsyUiUGobwWJg= github.com/tomarrell/wrapcheck/v2 v2.12.0 h1:H/qQ1aNWz/eeIhxKAFvkfIA+N7YDvq6TWVFL27Of9is= github.com/tomarrell/wrapcheck/v2 v2.12.0/go.mod h1:AQhQuZd0p7b6rfW+vUwHm5OMCGgp63moQ9Qr/0BpIWo= github.com/tommy-muehle/go-mnd/v2 v2.5.1 h1:NowYhSdyE/1zwK9QCLeRb6USWdoif80Ie+v+yU8u1Zw= @@ -931,6 +931,7 @@ golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20211105183446-c75c47738b0c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= diff --git a/vendor/github.com/go-ole/go-ole/SECURITY.md b/vendor/github.com/go-ole/go-ole/SECURITY.md new file mode 100644 index 00000000..dac28152 --- /dev/null +++ b/vendor/github.com/go-ole/go-ole/SECURITY.md @@ -0,0 +1,13 @@ +# Security Policy + +## Supported Versions + +Security updates are applied only to the latest release. + +## Reporting a Vulnerability + +If you have discovered a security vulnerability in this project, please report it privately. **Do not disclose it as a public issue.** This gives us time to work with you to fix the issue before public exposure, reducing the chance that the exploit will be used before a patch is released. + +Please disclose it at [security advisory](https://github.com/go-ole/go-ole/security/advisories/new). + +This project is maintained by a team of volunteers on a reasonable-effort basis. As such, please give us at least 90 days to work on a fix before public exposure. diff --git a/vendor/github.com/go-ole/go-ole/appveyor.yml b/vendor/github.com/go-ole/go-ole/appveyor.yml index 0d557ac2..8df7fa26 100644 --- a/vendor/github.com/go-ole/go-ole/appveyor.yml +++ b/vendor/github.com/go-ole/go-ole/appveyor.yml @@ -6,14 +6,9 @@ version: "1.3.0.{build}-alpha-{branch}" -os: Windows Server 2012 R2 +os: Visual Studio 2019 -branches: - only: - - master - - v1.2 - - v1.1 - - v1.0 +build: off skip_tags: true @@ -21,20 +16,40 @@ clone_folder: c:\gopath\src\github.com\go-ole\go-ole environment: GOPATH: c:\gopath - matrix: - - GOARCH: amd64 - GOVERSION: 1.5 - GOROOT: c:\go - DOWNLOADPLATFORM: "x64" + GOROOT: c:\go + DOWNLOADPLATFORM: "x64" -install: - - choco install mingw - - SET PATH=c:\tools\mingw64\bin;%PATH% +before_test: # - Download COM Server - ps: Start-FileDownload "https://github.com/go-ole/test-com-server/releases/download/v1.0.2/test-com-server-${env:DOWNLOADPLATFORM}.zip" - 7z e test-com-server-%DOWNLOADPLATFORM%.zip -oc:\gopath\src\github.com\go-ole\go-ole > NUL - c:\gopath\src\github.com\go-ole\go-ole\build\register-assembly.bat - # - set + +test_script: + - go test -v -cover ./... + # go vet has false positives on unsafe.Pointer with windows/sys. Disabling since it is recommended to use go test instead. + # - go vet ./... + +branches: + only: + - master + - v1.2 + - v1.1 + - v1.0 + +matrix: + allow_failures: + - environment: + GOROOT: C:\go-x86 + DOWNLOADPLATFORM: "x86" + - environment: + GOROOT: C:\go118 + DOWNLOADPLATFORM: "x64" + - environment: + GOROOT: C:\go118-x86 + DOWNLOADPLATFORM: "x86" + +install: - go version - go env - go get -u golang.org/x/tools/cmd/cover @@ -45,10 +60,9 @@ build_script: - cd c:\gopath\src\github.com\go-ole\go-ole - go get -v -t ./... - go build - - go test -v -cover ./... # disable automatic tests -test: off +test: on # disable deployment deploy: off diff --git a/vendor/github.com/go-ole/go-ole/com.go b/vendor/github.com/go-ole/go-ole/com.go index a9bef150..cabbac01 100644 --- a/vendor/github.com/go-ole/go-ole/com.go +++ b/vendor/github.com/go-ole/go-ole/com.go @@ -11,6 +11,7 @@ import ( var ( procCoInitialize = modole32.NewProc("CoInitialize") procCoInitializeEx = modole32.NewProc("CoInitializeEx") + procCoInitializeSecurity = modole32.NewProc("CoInitializeSecurity") procCoUninitialize = modole32.NewProc("CoUninitialize") procCoCreateInstance = modole32.NewProc("CoCreateInstance") procCoTaskMemFree = modole32.NewProc("CoTaskMemFree") @@ -37,6 +38,9 @@ var ( procDispatchMessageW = moduser32.NewProc("DispatchMessageW") ) +// This is to enable calling COM Security initialization multiple times +var bSecurityInit bool = false + // coInitialize initializes COM library on current thread. // // MSDN documentation suggests that this function should not be called. Call @@ -68,6 +72,35 @@ func coInitializeEx(coinit uint32) (err error) { return } +// coInitializeSecurity: Registers security and sets the default security values +// for the process. +func coInitializeSecurity(cAuthSvc int32, + dwAuthnLevel uint32, + dwImpLevel uint32, + dwCapabilities uint32) (err error) { + // Check COM Security initialization has done previously + if !bSecurityInit { + // https://learn.microsoft.com/en-us/windows/win32/api/combaseapi/nf-combaseapi-coinitializesecurity + hr, _, _ := procCoInitializeSecurity.Call( + uintptr(0), // Allow *all* VSS writers to communicate back! + uintptr(cAuthSvc), // Default COM authentication service + uintptr(0), // Default COM authorization service + uintptr(0), // Reserved parameter + uintptr(dwAuthnLevel), // Strongest COM authentication level + uintptr(dwImpLevel), // Minimal impersonation abilities + uintptr(0), // Default COM authentication settings + uintptr(dwCapabilities), // Cloaking + uintptr(0)) // eserved parameter + if hr != 0 { + err = NewError(hr) + } else { + // COM Security initialization done make global flag true. + bSecurityInit = true + } + } + return +} + // CoInitialize initializes COM library on current thread. // // MSDN documentation suggests that this function should not be called. Call @@ -96,6 +129,15 @@ func CoUninitialize() { procCoUninitialize.Call() } +// CoInitializeSecurity: Registers security and sets the default security values +// for the process. +func CoInitializeSecurity(cAuthSvc int32, + dwAuthnLevel uint32, + dwImpLevel uint32, + dwCapabilities uint32) (err error) { + return coInitializeSecurity(cAuthSvc, dwAuthnLevel, dwImpLevel, dwCapabilities) +} + // CoTaskMemFree frees memory pointer. func CoTaskMemFree(memptr uintptr) { procCoTaskMemFree.Call(memptr) diff --git a/vendor/github.com/go-ole/go-ole/idispatch_windows.go b/vendor/github.com/go-ole/go-ole/idispatch_windows.go index b399f047..649c0734 100644 --- a/vendor/github.com/go-ole/go-ole/idispatch_windows.go +++ b/vendor/github.com/go-ole/go-ole/idispatch_windows.go @@ -1,3 +1,4 @@ +//go:build windows // +build windows package ole @@ -92,7 +93,7 @@ func invoke(disp *IDispatch, dispid int32, dispatch int16, params ...interface{} case int8: vargs[n] = NewVariant(VT_I1, int64(v.(int8))) case *int8: - vargs[n] = NewVariant(VT_I1|VT_BYREF, int64(uintptr(unsafe.Pointer(v.(*uint8))))) + vargs[n] = NewVariant(VT_I1|VT_BYREF, int64(uintptr(unsafe.Pointer(v.(*int8))))) case int16: vargs[n] = NewVariant(VT_I2, int64(v.(int16))) case *int16: diff --git a/vendor/github.com/go-ole/go-ole/variant.go b/vendor/github.com/go-ole/go-ole/variant.go index 967a23fe..a2c8402f 100644 --- a/vendor/github.com/go-ole/go-ole/variant.go +++ b/vendor/github.com/go-ole/go-ole/variant.go @@ -99,7 +99,7 @@ func (v *VARIANT) Value() interface{} { case VT_DISPATCH: return v.ToIDispatch() case VT_BOOL: - return v.Val != 0 + return (v.Val & 0xffff) != 0 } return nil } diff --git a/vendor/github.com/lufia/plan9stats/README.md b/vendor/github.com/lufia/plan9stats/README.md index a21700c0..70e5386c 100644 --- a/vendor/github.com/lufia/plan9stats/README.md +++ b/vendor/github.com/lufia/plan9stats/README.md @@ -1,2 +1,10 @@ # plan9stats A module for retrieving statistics of Plan 9 + +[![GoDev][godev-image]][godev-url] +[![Actions Status][actions-image]][actions-url] + +[godev-image]: https://pkg.go.dev/badge/github.com/lufia/plan9stats +[godev-url]: https://pkg.go.dev/github.com/lufia/plan9stats +[actions-image]: https://github.com/lufia/plan9stats/workflows/Test/badge.svg?branch=main +[actions-url]: https://github.com/lufia/plan9stats/actions?workflow=Test diff --git a/vendor/github.com/lufia/plan9stats/cpu.go b/vendor/github.com/lufia/plan9stats/cpu.go index a101b911..eaff362c 100644 --- a/vendor/github.com/lufia/plan9stats/cpu.go +++ b/vendor/github.com/lufia/plan9stats/cpu.go @@ -178,9 +178,12 @@ func ReadCPUStats(ctx context.Context, opts ...Option) (*CPUStats, error) { var up uint32parser pids := make([]uint32, len(names)) for i, s := range names { + if s == "trace" { + continue + } pids[i] = up.Parse(s) } - if up.err != nil { + if err := up.err; err != nil { return nil, err } sort.Slice(pids, func(i, j int) bool { diff --git a/vendor/github.com/lufia/plan9stats/disk.go b/vendor/github.com/lufia/plan9stats/disk.go new file mode 100644 index 00000000..4a4fa0cd --- /dev/null +++ b/vendor/github.com/lufia/plan9stats/disk.go @@ -0,0 +1,116 @@ +package stats + +import ( + "bufio" + "bytes" + "context" + "os" + "path/filepath" + "strings" +) + +// Storage represents /dev/sdXX/ctl. +type Storage struct { + Name string + Model string + Capacity int64 + Partitions []*Partition +} + +// Partition represents a part of /dev/sdXX/ctl. +type Partition struct { + Name string + Start uint64 + End uint64 +} + +func ReadStorages(ctx context.Context, opts ...Option) ([]*Storage, error) { + cfg := newConfig(opts...) + sdctl := filepath.Join(cfg.rootdir, "/dev/sdctl") + f, err := os.Open(sdctl) + if err != nil { + return nil, err + } + defer f.Close() + + var a []*Storage + scanner := bufio.NewScanner(f) + for scanner.Scan() { + fields := bytes.Split(scanner.Bytes(), delim) + if len(fields) == 0 { + continue + } + exp := string(fields[0]) + "*" + if !strings.HasPrefix(exp, "sd") { + continue + } + dir := filepath.Join(cfg.rootdir, "/dev", exp) + m, err := filepath.Glob(dir) + if err != nil { + return nil, err + } + for _, dir := range m { + s, err := readStorage(dir) + if err != nil { + return nil, err + } + a = append(a, s) + } + } + if err := scanner.Err(); err != nil { + return nil, err + } + return a, nil +} + +func readStorage(dir string) (*Storage, error) { + ctl := filepath.Join(dir, "ctl") + f, err := os.Open(ctl) + if err != nil { + return nil, err + } + defer f.Close() + + var s Storage + s.Name = filepath.Base(dir) + scanner := bufio.NewScanner(f) + for scanner.Scan() { + line := scanner.Bytes() + switch { + case bytes.HasPrefix(line, []byte("inquiry ")): + s.Model = string(bytes.TrimSpace(line[7:])) + case bytes.HasPrefix(line, []byte("geometry ")): + fields := bytes.Split(line, delim) + if len(fields) < 3 { + continue + } + var p intParser + sec := p.ParseInt64(string(fields[1]), 10) + size := p.ParseInt64(string(fields[2]), 10) + if err := p.Err(); err != nil { + return nil, err + } + s.Capacity = sec * size + case bytes.HasPrefix(line, []byte("part ")): + fields := bytes.Split(line, delim) + if len(fields) < 4 { + continue + } + var p intParser + start := p.ParseUint64(string(fields[2]), 10) + end := p.ParseUint64(string(fields[3]), 10) + if err := p.Err(); err != nil { + return nil, err + } + s.Partitions = append(s.Partitions, &Partition{ + Name: string(fields[1]), + Start: start, + End: end, + }) + } + } + if err := scanner.Err(); err != nil { + return nil, err + } + return &s, nil +} diff --git a/vendor/github.com/lufia/plan9stats/host.go b/vendor/github.com/lufia/plan9stats/host.go index 957e9034..a3921c0e 100644 --- a/vendor/github.com/lufia/plan9stats/host.go +++ b/vendor/github.com/lufia/plan9stats/host.go @@ -109,12 +109,6 @@ func parseGauge(s string, r *Gauge) error { return nil } -type Storage struct { - Name string - Model string - Capacity int64 -} - type Interface struct { Name string Addr string @@ -177,7 +171,7 @@ func ReadHost(ctx context.Context, opts ...Option) (*Host, error) { } h.Sysname = name - a, err := readStorages(cfg.rootdir) + a, err := ReadStorages(ctx, opts...) if err != nil { return nil, err } @@ -203,80 +197,6 @@ func readSysname(rootdir string) (string, error) { return string(bytes.TrimSpace(b)), nil } -func readStorages(rootdir string) ([]*Storage, error) { - sdctl := filepath.Join(rootdir, "/dev/sdctl") - f, err := os.Open(sdctl) - if err != nil { - return nil, err - } - defer f.Close() - - var a []*Storage - scanner := bufio.NewScanner(f) - for scanner.Scan() { - fields := bytes.Split(scanner.Bytes(), delim) - if len(fields) == 0 { - continue - } - exp := string(fields[0]) + "*" - if !strings.HasPrefix(exp, "sd") { - continue - } - dir := filepath.Join(rootdir, "/dev", exp) - m, err := filepath.Glob(dir) - if err != nil { - return nil, err - } - for _, dir := range m { - s, err := readStorage(dir) - if err != nil { - return nil, err - } - a = append(a, s) - } - } - if err := scanner.Err(); err != nil { - return nil, err - } - return a, nil -} - -func readStorage(dir string) (*Storage, error) { - ctl := filepath.Join(dir, "ctl") - f, err := os.Open(ctl) - if err != nil { - return nil, err - } - defer f.Close() - - var s Storage - s.Name = filepath.Base(dir) - scanner := bufio.NewScanner(f) - for scanner.Scan() { - line := scanner.Bytes() - switch { - case bytes.HasPrefix(line, []byte("inquiry")): - s.Model = string(bytes.TrimSpace(line[7:])) - case bytes.HasPrefix(line, []byte("geometry")): - fields := bytes.Split(line, delim) - if len(fields) < 3 { - continue - } - var p intParser - sec := p.ParseInt64(string(fields[1]), 10) - size := p.ParseInt64(string(fields[2]), 10) - if err := p.Err(); err != nil { - return nil, err - } - s.Capacity = sec * size - } - } - if err := scanner.Err(); err != nil { - return nil, err - } - return &s, nil -} - type IPStats struct { ID int // number of interface in ipifc dir Device string // associated physical device diff --git a/vendor/github.com/lufia/plan9stats/int.go b/vendor/github.com/lufia/plan9stats/int.go index db133c43..e3c9dc83 100644 --- a/vendor/github.com/lufia/plan9stats/int.go +++ b/vendor/github.com/lufia/plan9stats/int.go @@ -26,6 +26,15 @@ func (p *intParser) ParseInt64(s string, base int) int64 { return n } +func (p *intParser) ParseUint64(s string, base int) uint64 { + if p.err != nil { + return 0 + } + var n uint64 + n, p.err = strconv.ParseUint(s, base, 64) + return n +} + func (p *intParser) Err() error { return p.err } diff --git a/vendor/github.com/moby/sys/sequential/sequential_unix.go b/vendor/github.com/moby/sys/sequential/sequential_unix.go index 278cdfb0..24c7c4be 100644 --- a/vendor/github.com/moby/sys/sequential/sequential_unix.go +++ b/vendor/github.com/moby/sys/sequential/sequential_unix.go @@ -1,5 +1,4 @@ //go:build !windows -// +build !windows package sequential diff --git a/vendor/github.com/moby/sys/sequential/sequential_windows.go b/vendor/github.com/moby/sys/sequential/sequential_windows.go index 3500ecc6..a8bfc326 100644 --- a/vendor/github.com/moby/sys/sequential/sequential_windows.go +++ b/vendor/github.com/moby/sys/sequential/sequential_windows.go @@ -1,3 +1,5 @@ +//go:build windows + package sequential import ( @@ -6,108 +8,36 @@ import ( "strconv" "sync" "time" - "unsafe" - - "golang.org/x/sys/windows" ) // Create is a copy of [os.Create], modified to use sequential file access. // -// It uses [windows.FILE_FLAG_SEQUENTIAL_SCAN] rather than [windows.FILE_ATTRIBUTE_NORMAL] -// as implemented in golang. Refer to the [Win32 API documentation] for details -// on sequential file access. +// It uses the Windows sequential scan file flag. Refer to the [Win32 API +// documentation] for details on sequential file access. // // [Win32 API documentation]: https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-createfilea#FILE_FLAG_SEQUENTIAL_SCAN func Create(name string) (*os.File, error) { - return openFileSequential(name, windows.O_RDWR|windows.O_CREAT|windows.O_TRUNC) + return openFileSequential(name, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0o666) } // Open is a copy of [os.Open], modified to use sequential file access. // -// It uses [windows.FILE_FLAG_SEQUENTIAL_SCAN] rather than [windows.FILE_ATTRIBUTE_NORMAL] -// as implemented in golang. Refer to the [Win32 API documentation] for details -// on sequential file access. +// It uses the Windows sequential scan file flag. Refer to the [Win32 API +// documentation] for details on sequential file access. // // [Win32 API documentation]: https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-createfilea#FILE_FLAG_SEQUENTIAL_SCAN func Open(name string) (*os.File, error) { - return openFileSequential(name, windows.O_RDONLY) + return openFileSequential(name, os.O_RDONLY, 0) } // OpenFile is a copy of [os.OpenFile], modified to use sequential file access. // -// It uses [windows.FILE_FLAG_SEQUENTIAL_SCAN] rather than [windows.FILE_ATTRIBUTE_NORMAL] -// as implemented in golang. Refer to the [Win32 API documentation] for details -// on sequential file access. +// It uses the Windows sequential scan file flag. Refer to the [Win32 API +// documentation] for details on sequential file access. // // [Win32 API documentation]: https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-createfilea#FILE_FLAG_SEQUENTIAL_SCAN -func OpenFile(name string, flag int, _ os.FileMode) (*os.File, error) { - return openFileSequential(name, flag) -} - -func openFileSequential(name string, flag int) (file *os.File, err error) { - if name == "" { - return nil, &os.PathError{Op: "open", Path: name, Err: windows.ERROR_FILE_NOT_FOUND} - } - r, e := openSequential(name, flag|windows.O_CLOEXEC) - if e != nil { - return nil, &os.PathError{Op: "open", Path: name, Err: e} - } - return os.NewFile(uintptr(r), name), nil -} - -func makeInheritSa() *windows.SecurityAttributes { - var sa windows.SecurityAttributes - sa.Length = uint32(unsafe.Sizeof(sa)) - sa.InheritHandle = 1 - return &sa -} - -func openSequential(path string, mode int) (fd windows.Handle, err error) { - if len(path) == 0 { - return windows.InvalidHandle, windows.ERROR_FILE_NOT_FOUND - } - pathp, err := windows.UTF16PtrFromString(path) - if err != nil { - return windows.InvalidHandle, err - } - var access uint32 - switch mode & (windows.O_RDONLY | windows.O_WRONLY | windows.O_RDWR) { - case windows.O_RDONLY: - access = windows.GENERIC_READ - case windows.O_WRONLY: - access = windows.GENERIC_WRITE - case windows.O_RDWR: - access = windows.GENERIC_READ | windows.GENERIC_WRITE - } - if mode&windows.O_CREAT != 0 { - access |= windows.GENERIC_WRITE - } - if mode&windows.O_APPEND != 0 { - access &^= windows.GENERIC_WRITE - access |= windows.FILE_APPEND_DATA - } - sharemode := uint32(windows.FILE_SHARE_READ | windows.FILE_SHARE_WRITE) - var sa *windows.SecurityAttributes - if mode&windows.O_CLOEXEC == 0 { - sa = makeInheritSa() - } - var createmode uint32 - switch { - case mode&(windows.O_CREAT|windows.O_EXCL) == (windows.O_CREAT | windows.O_EXCL): - createmode = windows.CREATE_NEW - case mode&(windows.O_CREAT|windows.O_TRUNC) == (windows.O_CREAT | windows.O_TRUNC): - createmode = windows.CREATE_ALWAYS - case mode&windows.O_CREAT == windows.O_CREAT: - createmode = windows.OPEN_ALWAYS - case mode&windows.O_TRUNC == windows.O_TRUNC: - createmode = windows.TRUNCATE_EXISTING - default: - createmode = windows.OPEN_EXISTING - } - // Use FILE_FLAG_SEQUENTIAL_SCAN rather than FILE_ATTRIBUTE_NORMAL as implemented in golang. - // https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-createfilea#FILE_FLAG_SEQUENTIAL_SCAN - h, e := windows.CreateFile(pathp, access, sharemode, sa, createmode, windows.FILE_FLAG_SEQUENTIAL_SCAN, 0) - return h, e +func OpenFile(name string, flag int, perm os.FileMode) (*os.File, error) { + return openFileSequential(name, flag, perm) } // Helpers for CreateTemp @@ -134,9 +64,8 @@ func nextSuffix() string { // CreateTemp is a copy of [os.CreateTemp], modified to use sequential file access. // -// It uses [windows.FILE_FLAG_SEQUENTIAL_SCAN] rather than [windows.FILE_ATTRIBUTE_NORMAL] -// as implemented in golang. Refer to the [Win32 API documentation] for details -// on sequential file access. +// It uses the Windows sequential scan file flag. Refer to the [Win32 API +// documentation] for details on sequential file access. // // [Win32 API documentation]: https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-createfilea#FILE_FLAG_SEQUENTIAL_SCAN func CreateTemp(dir, prefix string) (f *os.File, err error) { @@ -145,9 +74,9 @@ func CreateTemp(dir, prefix string) (f *os.File, err error) { } nconflict := 0 - for i := 0; i < 10000; i++ { + for range 10000 { name := filepath.Join(dir, prefix+nextSuffix()) - f, err = openFileSequential(name, windows.O_RDWR|windows.O_CREAT|windows.O_EXCL) + f, err = openFileSequential(name, os.O_RDWR|os.O_CREATE|os.O_EXCL, 0o600) if os.IsExist(err) { if nconflict++; nconflict > 10 { randmu.Lock() diff --git a/vendor/github.com/moby/sys/sequential/sequential_windows_go126.go b/vendor/github.com/moby/sys/sequential/sequential_windows_go126.go new file mode 100644 index 00000000..926c4201 --- /dev/null +++ b/vendor/github.com/moby/sys/sequential/sequential_windows_go126.go @@ -0,0 +1,13 @@ +//go:build windows && go1.26 + +package sequential + +import ( + "os" + + "golang.org/x/sys/windows" +) + +func openFileSequential(name string, flag int, perm os.FileMode) (*os.File, error) { + return os.OpenFile(name, flag|windows.O_FILE_FLAG_SEQUENTIAL_SCAN, perm) +} diff --git a/vendor/github.com/moby/sys/sequential/sequential_windows_pre126.go b/vendor/github.com/moby/sys/sequential/sequential_windows_pre126.go new file mode 100644 index 00000000..fa8129cf --- /dev/null +++ b/vendor/github.com/moby/sys/sequential/sequential_windows_pre126.go @@ -0,0 +1,76 @@ +//go:build windows && !go1.26 + +package sequential + +import ( + "os" + "unsafe" + + "golang.org/x/sys/windows" +) + +func openFileSequential(name string, flag int, _ os.FileMode) (file *os.File, err error) { + if name == "" { + return nil, &os.PathError{Op: "open", Path: name, Err: windows.ERROR_FILE_NOT_FOUND} + } + r, e := openSequential(name, flag|windows.O_CLOEXEC) + if e != nil { + return nil, &os.PathError{Op: "open", Path: name, Err: e} + } + return os.NewFile(uintptr(r), name), nil +} + +func makeInheritSa() *windows.SecurityAttributes { + var sa windows.SecurityAttributes + sa.Length = uint32(unsafe.Sizeof(sa)) + sa.InheritHandle = 1 + return &sa +} + +func openSequential(path string, mode int) (fd windows.Handle, err error) { + if len(path) == 0 { + return windows.InvalidHandle, windows.ERROR_FILE_NOT_FOUND + } + pathp, err := windows.UTF16PtrFromString(path) + if err != nil { + return windows.InvalidHandle, err + } + var access uint32 + switch mode & (windows.O_RDONLY | windows.O_WRONLY | windows.O_RDWR) { + case windows.O_RDONLY: + access = windows.GENERIC_READ + case windows.O_WRONLY: + access = windows.GENERIC_WRITE + case windows.O_RDWR: + access = windows.GENERIC_READ | windows.GENERIC_WRITE + } + if mode&windows.O_CREAT != 0 { + access |= windows.GENERIC_WRITE + } + if mode&windows.O_APPEND != 0 { + access &^= windows.GENERIC_WRITE + access |= windows.FILE_APPEND_DATA + } + sharemode := uint32(windows.FILE_SHARE_READ | windows.FILE_SHARE_WRITE) + var sa *windows.SecurityAttributes + if mode&windows.O_CLOEXEC == 0 { + sa = makeInheritSa() + } + var createmode uint32 + switch { + case mode&(windows.O_CREAT|windows.O_EXCL) == (windows.O_CREAT | windows.O_EXCL): + createmode = windows.CREATE_NEW + case mode&(windows.O_CREAT|windows.O_TRUNC) == (windows.O_CREAT | windows.O_TRUNC): + createmode = windows.CREATE_ALWAYS + case mode&windows.O_CREAT == windows.O_CREAT: + createmode = windows.OPEN_ALWAYS + case mode&windows.O_TRUNC == windows.O_TRUNC: + createmode = windows.TRUNCATE_EXISTING + default: + createmode = windows.OPEN_EXISTING + } + // Use FILE_FLAG_SEQUENTIAL_SCAN rather than FILE_ATTRIBUTE_NORMAL as implemented in golang. + // https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-createfilea#FILE_FLAG_SEQUENTIAL_SCAN + h, e := windows.CreateFile(pathp, access, sharemode, sa, createmode, windows.FILE_FLAG_SEQUENTIAL_SCAN, 0) + return h, e +} diff --git a/vendor/github.com/testcontainers/testcontainers-go/.golangci.yml b/vendor/github.com/testcontainers/testcontainers-go/.golangci.yml index bd3e9de7..7f866b6e 100644 --- a/vendor/github.com/testcontainers/testcontainers-go/.golangci.yml +++ b/vendor/github.com/testcontainers/testcontainers-go/.golangci.yml @@ -25,6 +25,10 @@ linters: - usestdlibvars exclusions: rules: + - linters: + - misspell + path: "^modules/mosquitto" + text: "(?i)mosquitto" - linters: - revive path: "^exec/" diff --git a/vendor/github.com/testcontainers/testcontainers-go/Pipfile.lock b/vendor/github.com/testcontainers/testcontainers-go/Pipfile.lock index 2a6138cc..3fac5c65 100644 --- a/vendor/github.com/testcontainers/testcontainers-go/Pipfile.lock +++ b/vendor/github.com/testcontainers/testcontainers-go/Pipfile.lock @@ -428,12 +428,12 @@ }, "pymdown-extensions": { "hashes": [ - "sha256:aace82bcccba3efc03e25d584e6a22d27a8e17caa3f4dd9f207e49b787aa9a91", - "sha256:d6ba157a6c03146a7fb122b2b9a121300056384eafeec9c9f9e584adfdb2a32d" + "sha256:72cfcf55f07aea0d4af2c4f11dd4e52466ddfb1bb819673146398e0bd3a77354", + "sha256:d7a5d08014fc571e80ca21dd6f854e31f94c489800350564d55d15b3c41e76b6" ], "index": "pypi", "markers": "python_version >= '3.9'", - "version": "==10.16.1" + "version": "==10.21.3" }, "python-dateutil": { "hashes": [ diff --git a/vendor/github.com/testcontainers/testcontainers-go/container.go b/vendor/github.com/testcontainers/testcontainers-go/container.go index b7f0b653..b2a1706b 100644 --- a/vendor/github.com/testcontainers/testcontainers-go/container.go +++ b/vendor/github.com/testcontainers/testcontainers-go/container.go @@ -22,6 +22,7 @@ import ( "github.com/moby/patternmatcher/ignorefile" tcexec "github.com/testcontainers/testcontainers-go/exec" + "github.com/testcontainers/testcontainers-go/internal/config" "github.com/testcontainers/testcontainers-go/internal/core" "github.com/testcontainers/testcontainers-go/log" "github.com/testcontainers/testcontainers-go/wait" @@ -176,7 +177,7 @@ func (c *ContainerRequest) sessionID() string { return sessionID } - return core.SessionID() + return config.Read().SessionID } // containerOptions functional options for a container diff --git a/vendor/github.com/testcontainers/testcontainers-go/docker.go b/vendor/github.com/testcontainers/testcontainers-go/docker.go index 4346531b..ab243e2c 100644 --- a/vendor/github.com/testcontainers/testcontainers-go/docker.go +++ b/vendor/github.com/testcontainers/testcontainers-go/docker.go @@ -3,6 +3,7 @@ package testcontainers import ( "archive/tar" "bufio" + "bytes" "context" "encoding/binary" "errors" @@ -586,8 +587,29 @@ func (c *DockerContainer) Exec(ctx context.Context, cmd []string, options ...tce if err != nil { return 0, nil, fmt.Errorf("container exec attach: %w", err) } + defer hijack.Close() - processOptions.Reader = hijack.Reader + // A not-yet-started exec inspects as {Running:false, ExitCode:null->0}, which + // is indistinguishable from "exited 0". The daemon closes the stream only once + // the process ends, so drain to EOF before inspecting; buffer it so callers + // can still read the output from the returned reader. + var buf bytes.Buffer + drained := make(chan error, 1) // buffered so the goroutine can finish after we return on ctx cancel + go func() { + _, copyErr := io.Copy(&buf, hijack.Reader) + drained <- copyErr + }() + + select { + case copyErr := <-drained: + if copyErr != nil { + return 0, nil, fmt.Errorf("container exec read: %w", copyErr) + } + case <-ctx.Done(): + return 0, nil, ctx.Err() + } + + processOptions.Reader = bytes.NewReader(buf.Bytes()) // second loop to process the multiplexed option, as now we have a reader // from the created exec response. @@ -595,6 +617,9 @@ func (c *DockerContainer) Exec(ctx context.Context, cmd []string, options ...tce o.Apply(processOptions) } + // The daemon marks the exec stopped asynchronously after closing the stream, + // so a single immediate inspect can still observe Running:true; poll until it + // reports terminal. var exitCode int for { execResp, err := cli.ExecInspect(ctx, response.ID, client.ExecInspectOptions{}) @@ -607,7 +632,11 @@ func (c *DockerContainer) Exec(ctx context.Context, cmd []string, options ...tce break } - time.Sleep(100 * time.Millisecond) + select { + case <-ctx.Done(): + return 0, nil, ctx.Err() + case <-time.After(100 * time.Millisecond): + } } return exitCode, processOptions.Reader, nil @@ -981,7 +1010,7 @@ func (c *DockerContainer) connectReaper(ctx context.Context) error { return nil } - reaper, err := spawner.reaper(context.WithValue(ctx, core.DockerHostContextKey, c.provider.host), core.SessionID(), c.provider) + reaper, err := spawner.reaper(context.WithValue(ctx, core.DockerHostContextKey, c.provider.host), c.provider.config.SessionID, c.provider) if err != nil { return fmt.Errorf("reaper: %w", err) } @@ -1353,7 +1382,7 @@ func (p *DockerProvider) findContainerByName(ctx context.Context, name string) ( // Note that, 'name' filter will use regex to find the containers containers, err := p.client.ContainerList(ctx, client.ContainerListOptions{ All: true, - Filters: make(client.Filters).Add("name", fmt.Sprintf("^%s$", name)), + Filters: make(client.Filters).Add("name", fmt.Sprintf("^%s$", regexp.QuoteMeta(name))), }) if err != nil { return nil, fmt.Errorf("container list: %w", err) diff --git a/vendor/github.com/testcontainers/testcontainers-go/docker_client.go b/vendor/github.com/testcontainers/testcontainers-go/docker_client.go index ae4ff511..53c7da03 100644 --- a/vendor/github.com/testcontainers/testcontainers-go/docker_client.go +++ b/vendor/github.com/testcontainers/testcontainers-go/docker_client.go @@ -9,7 +9,9 @@ import ( "github.com/moby/moby/client" "github.com/testcontainers/testcontainers-go/internal" + "github.com/testcontainers/testcontainers-go/internal/config" "github.com/testcontainers/testcontainers-go/internal/core" + "github.com/testcontainers/testcontainers-go/internal/core/bootstrap" "github.com/testcontainers/testcontainers-go/log" ) @@ -17,6 +19,8 @@ import ( // It implements the SystemAPIClient interface in order to cache the docker info and reuse it. type DockerClient struct { *client.Client // client is embedded into our own client + + config config.Config } var ( @@ -85,8 +89,8 @@ func (c *DockerClient) Info(ctx context.Context, options client.InfoOptions) (cl internal.Version, host, core.MustExtractDockerSocket(ctx), - core.SessionID(), - core.ProcessID(), + c.config.SessionID, + bootstrap.ProcessID(), ) return dockerInfo, nil @@ -125,6 +129,7 @@ func NewDockerClientWithOpts(ctx context.Context, opt ...client.Opt) (*DockerCli tcClient := DockerClient{ Client: dockerClient, + config: config.Read(), } if _, err = tcClient.Info(ctx, client.InfoOptions{}); err != nil { diff --git a/vendor/github.com/testcontainers/testcontainers-go/generic.go b/vendor/github.com/testcontainers/testcontainers-go/generic.go index 57dbe760..e4933177 100644 --- a/vendor/github.com/testcontainers/testcontainers-go/generic.go +++ b/vendor/github.com/testcontainers/testcontainers-go/generic.go @@ -7,6 +7,7 @@ import ( "maps" "sync" + "github.com/testcontainers/testcontainers-go/internal/config" "github.com/testcontainers/testcontainers-go/internal/core" "github.com/testcontainers/testcontainers-go/log" ) @@ -100,7 +101,7 @@ type GenericProvider interface { // reaper is enabled, otherwise this is excluded to prevent resources being // incorrectly reaped. func GenericLabels() map[string]string { - return core.DefaultLabels(core.SessionID()) + return core.DefaultLabels(config.Read().SessionID) } // AddGenericLabels adds the generic labels to target. diff --git a/vendor/github.com/testcontainers/testcontainers-go/internal/config/config.go b/vendor/github.com/testcontainers/testcontainers-go/internal/config/config.go index 262f40d6..d2b762eb 100644 --- a/vendor/github.com/testcontainers/testcontainers-go/internal/config/config.go +++ b/vendor/github.com/testcontainers/testcontainers-go/internal/config/config.go @@ -9,6 +9,8 @@ import ( "time" "github.com/magiconair/properties" + + "github.com/testcontainers/testcontainers-go/internal/core/bootstrap" ) const ReaperDefaultImage = "testcontainers/ryuk:0.14.0" @@ -52,6 +54,13 @@ type Config struct { // Environment variable: TESTCONTAINERS_HUB_IMAGE_NAME_PREFIX HubImageNamePrefix string `properties:"hub.image.name.prefix,default="` + // SessionID is the ID of the testing session. + // Setting this value will preclude runs from creating more than one reaper. Therefore, + // changes to ryuk settings past its creation will be ignored. + // + // Environment variable: TESTCONTAINERS_SESSION_ID + SessionID string `properties:"session.id,default="` + // RyukDisabled is a flag to enable or disable the Garbage Collector. // Setting this to true will prevent testcontainers from automatically cleaning up // resources, which is particularly important in tests which timeout as they @@ -121,6 +130,13 @@ func read() Config { config.HubImageNamePrefix = hubImageNamePrefix } + sessionID := os.Getenv("TESTCONTAINERS_SESSION_ID") + if sessionID != "" { + config.SessionID = sessionID + } else if config.SessionID == "" { + config.SessionID = bootstrap.SessionID() + } + ryukPrivilegedEnv := os.Getenv("TESTCONTAINERS_RYUK_CONTAINER_PRIVILEGED") if parseBool(ryukPrivilegedEnv) { config.RyukPrivileged = ryukPrivilegedEnv == "true" diff --git a/vendor/github.com/testcontainers/testcontainers-go/internal/core/bootstrap.go b/vendor/github.com/testcontainers/testcontainers-go/internal/core/bootstrap/bootstrap.go similarity index 99% rename from vendor/github.com/testcontainers/testcontainers-go/internal/core/bootstrap.go rename to vendor/github.com/testcontainers/testcontainers-go/internal/core/bootstrap/bootstrap.go index d249d9be..18758c7e 100644 --- a/vendor/github.com/testcontainers/testcontainers-go/internal/core/bootstrap.go +++ b/vendor/github.com/testcontainers/testcontainers-go/internal/core/bootstrap/bootstrap.go @@ -1,4 +1,4 @@ -package core +package bootstrap import ( "crypto/sha256" diff --git a/vendor/github.com/testcontainers/testcontainers-go/internal/core/client.go b/vendor/github.com/testcontainers/testcontainers-go/internal/core/client.go index 795e6640..dd3263d2 100644 --- a/vendor/github.com/testcontainers/testcontainers-go/internal/core/client.go +++ b/vendor/github.com/testcontainers/testcontainers-go/internal/core/client.go @@ -8,6 +8,7 @@ import ( "github.com/testcontainers/testcontainers-go/internal" "github.com/testcontainers/testcontainers-go/internal/config" + "github.com/testcontainers/testcontainers-go/internal/core/bootstrap" ) // NewClient returns a new docker client extracting the docker host from the different alternatives @@ -35,8 +36,8 @@ func NewClient(ctx context.Context, ops ...client.Opt) (*client.Client, error) { opts = append(opts, client.WithHTTPHeaders( map[string]string{ - "x-tc-pp": ProjectPath(), - "x-tc-sid": SessionID(), + "x-tc-pp": bootstrap.ProjectPath(), + "x-tc-sid": tcConfig.SessionID, "User-Agent": "tc-go/" + internal.Version, }), ) diff --git a/vendor/github.com/testcontainers/testcontainers-go/internal/version.go b/vendor/github.com/testcontainers/testcontainers-go/internal/version.go index d18d432b..6236de0b 100644 --- a/vendor/github.com/testcontainers/testcontainers-go/internal/version.go +++ b/vendor/github.com/testcontainers/testcontainers-go/internal/version.go @@ -1,4 +1,4 @@ package internal // Version is the next development version of the application -const Version = "0.43.0" +const Version = "0.44.0" diff --git a/vendor/github.com/testcontainers/testcontainers-go/log/logger.go b/vendor/github.com/testcontainers/testcontainers-go/log/logger.go index d20e90a0..b86f568a 100644 --- a/vendor/github.com/testcontainers/testcontainers-go/log/logger.go +++ b/vendor/github.com/testcontainers/testcontainers-go/log/logger.go @@ -19,16 +19,21 @@ type Logger interface { Printf(format string, v ...any) } -// defaultLogger is the default Logger instance. -var defaultLogger Logger = &noopLogger{} +// defaultLogger would print available information to stderr +var defaultLogger Logger = log.New(os.Stderr, "", log.LstdFlags) + +func NewNoopLogger() Logger { + return &noopLogger{} +} func init() { - // Enable default logger in the testing with a verbose flag. + // Disable default logger in testing mode if explicitly disabled via -test.v=false. if testing.Testing() { - // Parse manually because testing.Verbose() panics unless flag.Parse() has done. + // Disable logging if explicitly disabled via -test.v=false for _, arg := range os.Args { - if strings.EqualFold(arg, "-test.v=true") || strings.EqualFold(arg, "-v") { - defaultLogger = log.New(os.Stderr, "", log.LstdFlags) + if strings.EqualFold(arg, "-test.v=false") { + defaultLogger = NewNoopLogger() + break } } } diff --git a/vendor/github.com/testcontainers/testcontainers-go/mkdocs.yml b/vendor/github.com/testcontainers/testcontainers-go/mkdocs.yml index 123271cf..679328e0 100644 --- a/vendor/github.com/testcontainers/testcontainers-go/mkdocs.yml +++ b/vendor/github.com/testcontainers/testcontainers-go/mkdocs.yml @@ -25,6 +25,7 @@ extra_javascript: - https://cdn.jsdelivr.net/npm/chartjs-adapter-date-fns@3.0.0/dist/chartjs-adapter-date-fns.bundle.min.js - https://cdn.jsdelivr.net/npm/papaparse@5.4.1/papaparse.min.js - js/usage-metrics.js + - js/modules-usage-metrics.js repo_name: testcontainers-go repo_url: https://github.com/testcontainers/testcontainers-go markdown_extensions: @@ -74,6 +75,8 @@ nav: - features/tls.md - Modules: - modules/index.md + - modules/fakegcsserver.md + - modules/activemq.md - modules/aerospike.md - modules/arangodb.md - modules/artemis.md @@ -85,6 +88,8 @@ nav: - modules/cockroachdb.md - modules/consul.md - modules/couchbase.md + - modules/couchdb.md + - modules/cratedb.md - modules/databend.md - modules/dex.md - modules/dind.md @@ -94,6 +99,7 @@ nav: - modules/dynamodb.md - modules/elasticsearch.md - modules/etcd.md + - modules/firebird.md - modules/forgejo.md - modules/gcloud.md - modules/grafana-lgtm.md @@ -102,7 +108,9 @@ nav: - modules/k3s.md - modules/k6.md - modules/kafka.md + - modules/kurrentdb.md - modules/localstack.md + - modules/mailpit.md - modules/mariadb.md - modules/meilisearch.md - modules/memcached.md @@ -111,29 +119,42 @@ nav: - modules/mockserver.md - modules/mongodb-atlaslocal.md - modules/mongodb.md + - modules/mosquitto.md - modules/mssql.md - modules/mysql.md - modules/nats.md - modules/nebulagraph.md - modules/neo4j.md + - modules/nginx.md - modules/ollama.md - modules/openfga.md - modules/openldap.md - modules/opensearch.md + - modules/orientdb.md + - modules/papercutsmtp.md - modules/pinecone.md - modules/postgres.md + - modules/presto.md - modules/pulsar.md - modules/qdrant.md + - modules/questdb.md - modules/rabbitmq.md + - modules/ravendb.md - modules/redis.md - modules/redpanda.md - modules/registry.md + - modules/s3mock.md - modules/scylladb.md + - modules/sftp.md - modules/socat.md - modules/solace.md + - modules/solr.md - modules/surrealdb.md - modules/tidb.md + - modules/timeplus.md - modules/toxiproxy.md + - modules/trino.md + - modules/typesense.md - modules/valkey.md - modules/vault.md - modules/vearch.md @@ -158,10 +179,12 @@ nav: - system_requirements/using_colima.md - system_requirements/using_podman.md - system_requirements/rancher.md - - Usage Metrics: usage-metrics.md + - Usage Metrics: + - Core Library: usage-metrics/index.md + - Modules: usage-metrics/modules.md - Dependabot: dependabot.md - Contributing: contributing.md - Getting help: getting_help.md edit_uri: edit/main/docs/ extra: - latest_version: v0.43.0 + latest_version: v0.44.0 diff --git a/vendor/github.com/testcontainers/testcontainers-go/network.go b/vendor/github.com/testcontainers/testcontainers-go/network.go index c5fa4eb5..a305c7b2 100644 --- a/vendor/github.com/testcontainers/testcontainers-go/network.go +++ b/vendor/github.com/testcontainers/testcontainers-go/network.go @@ -5,6 +5,7 @@ import ( "github.com/moby/moby/api/types/network" + "github.com/testcontainers/testcontainers-go/internal/config" "github.com/testcontainers/testcontainers-go/internal/core" ) @@ -56,5 +57,5 @@ func (r NetworkRequest) sessionID() string { return sessionID } - return core.SessionID() + return config.Read().SessionID } diff --git a/vendor/github.com/testcontainers/testcontainers-go/options.go b/vendor/github.com/testcontainers/testcontainers-go/options.go index 4a629cbe..c1e9ac3f 100644 --- a/vendor/github.com/testcontainers/testcontainers-go/options.go +++ b/vendor/github.com/testcontainers/testcontainers-go/options.go @@ -53,19 +53,38 @@ func WithDockerfile(df FromDockerfile) CustomizeRequestOption { } // WithConfigModifier allows to override the default container config +// New in v0.43.1: The method can be called multiple times and the method will run sequentially with the last call +// being called last. func WithConfigModifier(modifier func(config *container.Config)) CustomizeRequestOption { return func(req *GenericContainerRequest) error { - req.ConfigModifier = modifier + if req.ConfigModifier == nil { + req.ConfigModifier = modifier + } else { + fn := req.ConfigModifier + req.ConfigModifier = func(config *container.Config) { + fn(config) + modifier(config) + } + } return nil } } // WithEndpointSettingsModifier allows to override the default endpoint settings +// New in v0.43.1: The method can be called multiple times and the method will run sequentially with the last call +// being called last. func WithEndpointSettingsModifier(modifier func(settings map[string]*network.EndpointSettings)) CustomizeRequestOption { return func(req *GenericContainerRequest) error { - req.EndpointSettingsModifier = modifier - + if req.EndpointSettingsModifier == nil { + req.EndpointSettingsModifier = modifier + } else { + fn := req.EndpointSettingsModifier + req.EndpointSettingsModifier = func(settings map[string]*network.EndpointSettings) { + fn(settings) + modifier(settings) + } + } return nil } } @@ -85,9 +104,19 @@ func WithEnv(envs map[string]string) CustomizeRequestOption { } // WithHostConfigModifier allows to override the default host config +// New in v0.43.1: The method can be called multiple times and the method will run sequentially with the last call +// being called last. func WithHostConfigModifier(modifier func(hostConfig *container.HostConfig)) CustomizeRequestOption { return func(req *GenericContainerRequest) error { - req.HostConfigModifier = modifier + if req.HostConfigModifier == nil { + req.HostConfigModifier = modifier + } else { + fn := req.HostConfigModifier + req.HostConfigModifier = func(hostConfig *container.HostConfig) { + fn(hostConfig) + modifier(hostConfig) + } + } return nil } diff --git a/vendor/github.com/testcontainers/testcontainers-go/reaper.go b/vendor/github.com/testcontainers/testcontainers-go/reaper.go index 776529d0..b4bde903 100644 --- a/vendor/github.com/testcontainers/testcontainers-go/reaper.go +++ b/vendor/github.com/testcontainers/testcontainers-go/reaper.go @@ -345,10 +345,12 @@ func (r *reaperSpawner) fromContainer(ctx context.Context, sessionID string, pro log.Printf("⏳ Waiting for Reaper %q to be ready", dockerContainer.ID[:8]) // Reusing an existing container so we determine the port from the container's exposed ports. - if err := wait.ForExposedPort(). - WithPollInterval(100*time.Millisecond). - SkipInternalCheck(). - WaitUntilReady(ctx, dockerContainer); err != nil { + if err := wait.ForAll( + wait.ForLog("Started"), + wait.ForExposedPort(). + WithPollInterval(100*time.Millisecond). + SkipInternalCheck(), + ).WaitUntilReady(ctx, dockerContainer); err != nil { return nil, fmt.Errorf("wait for reaper %s: %w", dockerContainer.ID[:8], err) } diff --git a/vendor/github.com/testcontainers/testcontainers-go/requirements.txt b/vendor/github.com/testcontainers/testcontainers-go/requirements.txt index a2970c67..69aeed52 100644 --- a/vendor/github.com/testcontainers/testcontainers-go/requirements.txt +++ b/vendor/github.com/testcontainers/testcontainers-go/requirements.txt @@ -1,5 +1,5 @@ mkdocs==1.5.3 mkdocs-codeinclude-plugin==0.3.1 -mkdocs-include-markdown-plugin==7.2.2 +mkdocs-include-markdown-plugin==7.3.0 mkdocs-material==9.5.18 mkdocs-markdownextradata-plugin==0.2.6 diff --git a/vendor/github.com/testcontainers/testcontainers-go/testcontainers.go b/vendor/github.com/testcontainers/testcontainers-go/testcontainers.go index 77ba722c..d3e18907 100644 --- a/vendor/github.com/testcontainers/testcontainers-go/testcontainers.go +++ b/vendor/github.com/testcontainers/testcontainers-go/testcontainers.go @@ -3,6 +3,7 @@ package testcontainers import ( "context" + "github.com/testcontainers/testcontainers-go/internal/config" "github.com/testcontainers/testcontainers-go/internal/core" ) @@ -50,5 +51,5 @@ func MustExtractDockerSocket(ctx context.Context) string { // - identify the test session, aggregating the test execution of multiple packages in the same test session. // - tag the containers created by testcontainers-go, adding a label to the container with the session ID. func SessionID() string { - return core.SessionID() + return config.Read().SessionID } diff --git a/vendor/github.com/testcontainers/testcontainers-go/testing.go b/vendor/github.com/testcontainers/testcontainers-go/testing.go index 47b36092..32a7909d 100644 --- a/vendor/github.com/testcontainers/testcontainers-go/testing.go +++ b/vendor/github.com/testcontainers/testcontainers-go/testing.go @@ -21,7 +21,7 @@ var errAlreadyInProgress = regexp.MustCompile(`removal of container .* is alread // SkipIfProviderIsNotHealthy is a utility function capable of skipping tests // if the provider is not healthy, or running at all. // This is a function designed to be used in your test, when Docker is not mandatory for CI/CD. -// In this way tests that depend on Testcontainers won't run if the provider is provisioned correctly. +// In this way tests that depend on Testcontainers won't run if the provider is not provisioned correctly. func SkipIfProviderIsNotHealthy(t *testing.T) { t.Helper() defer func() { @@ -94,12 +94,8 @@ func (lc *StdoutLogConsumer) Accept(l Log) { // CleanupContainer is a helper function that schedules the container // to be stopped / terminated when the test ends. -// -// This should be called as a defer directly after (before any error check) -// of [GenericContainer](...) or a modules Run(...) in a test to ensure the -// container is stopped when the function ends. -// -// before any error check. If container is nil, it's a no-op. +// This should be the first call after [GenericContainer](...) or a module's +// Run(...) in a test before any error check. If container is nil, it's a no-op. func CleanupContainer(tb testing.TB, ctr Container, options ...TerminateOption) { tb.Helper() diff --git a/vendor/github.com/tklauser/go-sysconf/.cirrus.yml b/vendor/github.com/tklauser/go-sysconf/.cirrus.yml index 61724abe..b6c025a0 100644 --- a/vendor/github.com/tklauser/go-sysconf/.cirrus.yml +++ b/vendor/github.com/tklauser/go-sysconf/.cirrus.yml @@ -1,10 +1,10 @@ env: CIRRUS_CLONE_DEPTH: 1 - GO_VERSION: go1.25.0 + GO_VERSION: go1.26.1 -freebsd_13_task: +freebsd_14_task: freebsd_instance: - image_family: freebsd-13-5 + image_family: freebsd-14-3 install_script: | pkg install -y go GOBIN=$PWD/bin go install golang.org/dl/${GO_VERSION}@latest @@ -12,9 +12,9 @@ freebsd_13_task: build_script: bin/${GO_VERSION} build -v ./... test_script: bin/${GO_VERSION} test -race ./... -freebsd_14_task: +freebsd_15_task: freebsd_instance: - image_family: freebsd-14-2 + image_family: freebsd-15-0-amd64-zfs install_script: | pkg install -y go GOBIN=$PWD/bin go install golang.org/dl/${GO_VERSION}@latest diff --git a/vendor/github.com/tklauser/go-sysconf/sysconf_darwin.go b/vendor/github.com/tklauser/go-sysconf/sysconf_darwin.go index b471ec10..c6aaff77 100644 --- a/vendor/github.com/tklauser/go-sysconf/sysconf_darwin.go +++ b/vendor/github.com/tklauser/go-sysconf/sysconf_darwin.go @@ -86,7 +86,7 @@ func sysconf(name int) (int64, error) { if err := unix.Getrlimit(unix.RLIMIT_NOFILE, &rlim); err != nil { return -1, nil } - if rlim.Cur > unix.RLIM_INFINITY { + if rlim.Cur == unix.RLIM_INFINITY { return -1, nil } if rlim.Cur > _LONG_MAX { @@ -296,7 +296,10 @@ func sysconf(name int) (int64, error) { return _XOPEN_XCU_VERSION, nil case SC_PHYS_PAGES: - return sysctl64("hw.memsize") / int64(unix.Getpagesize()), nil + if mem := sysctl64("hw.memsize"); mem >= 0 { + return mem / int64(unix.Getpagesize()), nil + } + return -1, nil case SC_NPROCESSORS_CONF: fallthrough case SC_NPROCESSORS_ONLN: diff --git a/vendor/github.com/tklauser/go-sysconf/sysconf_linux.go b/vendor/github.com/tklauser/go-sysconf/sysconf_linux.go index 9af70070..15b80395 100644 --- a/vendor/github.com/tklauser/go-sysconf/sysconf_linux.go +++ b/vendor/github.com/tklauser/go-sysconf/sysconf_linux.go @@ -29,7 +29,7 @@ func readProcFsInt64(path string, fallback int64) int64 { if err != nil { return fallback } - i, err := strconv.ParseInt(string(data[:len(data)-1]), 0, 64) + i, err := strconv.ParseInt(strings.TrimRight(string(data), "\n"), 0, 64) if err != nil { return fallback } @@ -55,7 +55,7 @@ func getPhysPages() int64 { var si unix.Sysinfo_t err := unix.Sysinfo(&si) if err != nil { - return int64(0) + return -1 } return getMemPages(uint64(si.Totalram), si.Unit) } @@ -64,7 +64,7 @@ func getAvPhysPages() int64 { var si unix.Sysinfo_t err := unix.Sysinfo(&si) if err != nil { - return int64(0) + return -1 } return getMemPages(uint64(si.Freeram), si.Unit) } @@ -144,13 +144,6 @@ func hasClock(clockid int32) bool { return true } -func max(a, b int64) int64 { - if a > b { - return a - } - return b -} - func sysconf(name int) (int64, error) { switch name { case SC_AIO_LISTIO_MAX: diff --git a/vendor/github.com/tklauser/go-sysconf/sysconf_netbsd.go b/vendor/github.com/tklauser/go-sysconf/sysconf_netbsd.go index 87cf6a10..288d13c7 100644 --- a/vendor/github.com/tklauser/go-sysconf/sysconf_netbsd.go +++ b/vendor/github.com/tklauser/go-sysconf/sysconf_netbsd.go @@ -195,7 +195,10 @@ func sysconf(name int) (int64, error) { // Linux/Solaris case SC_PHYS_PAGES: - return sysctl64("hw.physmem64") / int64(unix.Getpagesize()), nil + if mem := sysctl64("hw.physmem64"); mem >= 0 { + return mem / int64(unix.Getpagesize()), nil + } + return -1, nil // Native case SC_SCHED_RT_TS: diff --git a/vendor/github.com/tklauser/go-sysconf/sysconf_openbsd.go b/vendor/github.com/tklauser/go-sysconf/sysconf_openbsd.go index c0c394ab..937e5a00 100644 --- a/vendor/github.com/tklauser/go-sysconf/sysconf_openbsd.go +++ b/vendor/github.com/tklauser/go-sysconf/sysconf_openbsd.go @@ -257,7 +257,10 @@ func sysconf(name int) (int64, error) { } return -1, nil case SC_PHYS_PAGES: - return sysctl64("hw.physmem") / int64(unix.Getpagesize()), nil + if mem := sysctl64("hw.physmem"); mem >= 0 { + return mem / int64(unix.Getpagesize()), nil + } + return -1, nil case SC_NPROCESSORS_CONF: return sysctl32("hw.ncpu"), nil case SC_NPROCESSORS_ONLN: diff --git a/vendor/github.com/tklauser/numcpus/.cirrus.yml b/vendor/github.com/tklauser/numcpus/.cirrus.yml index 61724abe..b6c025a0 100644 --- a/vendor/github.com/tklauser/numcpus/.cirrus.yml +++ b/vendor/github.com/tklauser/numcpus/.cirrus.yml @@ -1,10 +1,10 @@ env: CIRRUS_CLONE_DEPTH: 1 - GO_VERSION: go1.25.0 + GO_VERSION: go1.26.1 -freebsd_13_task: +freebsd_14_task: freebsd_instance: - image_family: freebsd-13-5 + image_family: freebsd-14-3 install_script: | pkg install -y go GOBIN=$PWD/bin go install golang.org/dl/${GO_VERSION}@latest @@ -12,9 +12,9 @@ freebsd_13_task: build_script: bin/${GO_VERSION} build -v ./... test_script: bin/${GO_VERSION} test -race ./... -freebsd_14_task: +freebsd_15_task: freebsd_instance: - image_family: freebsd-14-2 + image_family: freebsd-15-0-amd64-zfs install_script: | pkg install -y go GOBIN=$PWD/bin go install golang.org/dl/${GO_VERSION}@latest diff --git a/vendor/github.com/tklauser/numcpus/numcpus_linux.go b/vendor/github.com/tklauser/numcpus/numcpus_linux.go index d05ee982..5e8f4152 100644 --- a/vendor/github.com/tklauser/numcpus/numcpus_linux.go +++ b/vendor/github.com/tklauser/numcpus/numcpus_linux.go @@ -51,49 +51,20 @@ func readCPURangeWith[T any](file string, f func(cpus string) (T, error)) (T, er } func countCPURange(cpus string) (int, error) { - cpus = strings.Trim(cpus, "\n ") - - // Treat empty file as valid. This might be the case if there are no offline CPUs in which - // case /sys/devices/system/cpu/offline is empty. - if cpus == "" { - return 0, nil - } - - n := int(0) - for cpuRange := range strings.SplitSeq(cpus, ",") { - if cpuRange == "" { - return 0, fmt.Errorf("empty CPU range in CPU string %q", cpus) - } - from, to, found := strings.Cut(cpuRange, "-") - first, err := strconv.ParseUint(from, 10, 32) - if err != nil { - return 0, err - } - if !found { - n++ - continue - } - last, err := strconv.ParseUint(to, 10, 32) - if err != nil { - return 0, err - } - if last < first { - return 0, fmt.Errorf("last CPU in range (%d) less than first (%d)", last, first) - } - n += int(last - first + 1) - } - return n, nil + list, err := listCPURange(cpus) + return len(list), err } func listCPURange(cpus string) ([]int, error) { cpus = strings.Trim(cpus, "\n ") - // See comment in countCPURange. + // Treat empty file as valid. This might be the case if there are no offline CPUs in which + // case /sys/devices/system/cpu/offline is empty. if cpus == "" { return []int{}, nil } - list := []int{} + var list []int for cpuRange := range strings.SplitSeq(cpus, ",") { if cpuRange == "" { return nil, fmt.Errorf("empty CPU range in CPU string %q", cpus) @@ -123,18 +94,13 @@ func listCPURange(cpus string) ([]int, error) { } func getConfigured() (int, error) { - d, err := os.Open(sysfsCPUBasePath) - if err != nil { - return 0, err - } - defer d.Close() - fis, err := d.Readdir(-1) + entries, err := os.ReadDir(sysfsCPUBasePath) if err != nil { return 0, err } count := 0 - for _, fi := range fis { - if name := fi.Name(); fi.IsDir() && strings.HasPrefix(name, "cpu") { + for _, entry := range entries { + if name := entry.Name(); entry.IsDir() && strings.HasPrefix(name, "cpu") { _, err := strconv.ParseInt(name[3:], 10, 64) if err == nil { count++ @@ -149,7 +115,7 @@ func getKernelMax() (int, error) { if err != nil { return 0, err } - n, err := strconv.ParseInt(strings.Trim(string(buf), "\n "), 10, 32) + n, err := strconv.ParseInt(strings.Trim(string(buf), "\n "), 10, 64) if err != nil { return 0, err } diff --git a/vendor/modules.txt b/vendor/modules.txt index e1d64bc2..e8e40abe 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -586,7 +586,7 @@ github.com/go-logr/logr/funcr # github.com/go-logr/stdr v1.2.2 ## explicit; go 1.16 github.com/go-logr/stdr -# github.com/go-ole/go-ole v1.2.6 +# github.com/go-ole/go-ole v1.3.0 ## explicit; go 1.12 github.com/go-ole/go-ole github.com/go-ole/go-ole/oleutil @@ -1038,8 +1038,8 @@ github.com/leonklingele/grouper/pkg/analyzer/vars # github.com/lucasb-eyer/go-colorful v1.4.1 ## explicit; go 1.12 github.com/lucasb-eyer/go-colorful -# github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 -## explicit; go 1.16 +# github.com/lufia/plan9stats v0.0.0-20260330125221-c963978e514e +## explicit; go 1.21 github.com/lufia/plan9stats # github.com/macabu/inamedparam v0.2.0 ## explicit; go 1.23.0 @@ -1144,8 +1144,8 @@ github.com/moby/moby/client/pkg/versions ## explicit; go 1.19 github.com/moby/patternmatcher github.com/moby/patternmatcher/ignorefile -# github.com/moby/sys/sequential v0.6.0 -## explicit; go 1.17 +# github.com/moby/sys/sequential v0.7.0 +## explicit; go 1.24.0 github.com/moby/sys/sequential # github.com/moby/sys/user v0.4.0 ## explicit; go 1.17 @@ -1435,13 +1435,14 @@ github.com/stretchr/testify/require # github.com/subosito/gotenv v1.6.0 ## explicit; go 1.18 github.com/subosito/gotenv -# github.com/testcontainers/testcontainers-go v0.43.0 +# github.com/testcontainers/testcontainers-go v0.44.0 ## explicit; go 1.25.0 github.com/testcontainers/testcontainers-go github.com/testcontainers/testcontainers-go/exec github.com/testcontainers/testcontainers-go/internal github.com/testcontainers/testcontainers-go/internal/config github.com/testcontainers/testcontainers-go/internal/core +github.com/testcontainers/testcontainers-go/internal/core/bootstrap github.com/testcontainers/testcontainers-go/internal/core/network github.com/testcontainers/testcontainers-go/log github.com/testcontainers/testcontainers-go/wait @@ -1459,11 +1460,11 @@ github.com/timonwong/loggercheck/internal/checkers/printf github.com/timonwong/loggercheck/internal/rules github.com/timonwong/loggercheck/internal/sets github.com/timonwong/loggercheck/internal/stringutil -# github.com/tklauser/go-sysconf v0.3.16 -## explicit; go 1.24.0 +# github.com/tklauser/go-sysconf v0.4.0 +## explicit; go 1.25.0 github.com/tklauser/go-sysconf -# github.com/tklauser/numcpus v0.11.0 -## explicit; go 1.24.0 +# github.com/tklauser/numcpus v0.12.0 +## explicit; go 1.25.0 github.com/tklauser/numcpus # github.com/tomarrell/wrapcheck/v2 v2.12.0 ## explicit; go 1.24.0