Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1bd6e1256c
|
@@ -22,9 +22,18 @@ for f in $(find . -type f -iname "README.adoc"); do
|
|||||||
if command -v pandoc &> /dev/null;
|
if command -v pandoc &> /dev/null;
|
||||||
then
|
then
|
||||||
newf="${pfx}.md"
|
newf="${pfx}.md"
|
||||||
|
|
||||||
|
set +e
|
||||||
asciidoctor -a ROOTDIR="${orig}/" -b docbook -o - "${f}" | pandoc -f docbook -t markdown_strict -o "${newf}"
|
asciidoctor -a ROOTDIR="${orig}/" -b docbook -o - "${f}" | pandoc -f docbook -t markdown_strict -o "${newf}"
|
||||||
|
if [ $? -eq 0 ];
|
||||||
|
then
|
||||||
echo "Generated ${newf} from ${f}"
|
echo "Generated ${newf} from ${f}"
|
||||||
git add "${newf}"
|
git add "${newf}"
|
||||||
|
else
|
||||||
|
echo "Failed to generate ${newf} from ${f}"
|
||||||
|
git rm "${newf}"
|
||||||
|
fi
|
||||||
|
set -e
|
||||||
fi
|
fi
|
||||||
cd ${orig}
|
cd ${orig}
|
||||||
done
|
done
|
||||||
|
|||||||
22
go.mod
22
go.mod
@@ -4,24 +4,32 @@ go 1.25
|
|||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/Masterminds/sprig/v3 v3.3.0
|
github.com/Masterminds/sprig/v3 v3.3.0
|
||||||
github.com/coreos/go-systemd/v22 v22.6.0
|
github.com/coreos/go-systemd/v22 v22.7.0
|
||||||
github.com/davecgh/go-spew v1.1.1
|
github.com/davecgh/go-spew v1.1.1
|
||||||
github.com/google/uuid v1.6.0
|
github.com/google/uuid v1.6.0
|
||||||
|
github.com/shirou/gopsutil/v4 v4.25.12
|
||||||
go4.org/netipx v0.0.0-20231129151722-fdeea329fbba
|
go4.org/netipx v0.0.0-20231129151722-fdeea329fbba
|
||||||
golang.org/x/sys v0.39.0
|
golang.org/x/sys v0.40.0
|
||||||
r00t2.io/sysutils v1.15.1
|
r00t2.io/sysutils v1.16.0
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
dario.cat/mergo v1.0.1 // indirect
|
dario.cat/mergo v1.0.2 // indirect
|
||||||
github.com/Masterminds/goutils v1.1.1 // indirect
|
github.com/Masterminds/goutils v1.1.1 // indirect
|
||||||
github.com/Masterminds/semver/v3 v3.3.0 // indirect
|
github.com/Masterminds/semver/v3 v3.4.0 // indirect
|
||||||
github.com/djherbis/times v1.6.0 // indirect
|
github.com/djherbis/times v1.6.0 // indirect
|
||||||
|
github.com/ebitengine/purego v0.9.1 // indirect
|
||||||
|
github.com/go-ole/go-ole v1.3.0 // indirect
|
||||||
github.com/huandu/xstrings v1.5.0 // indirect
|
github.com/huandu/xstrings v1.5.0 // indirect
|
||||||
|
github.com/lufia/plan9stats v0.0.0-20251013123823-9fd1530e3ec3 // indirect
|
||||||
github.com/mitchellh/copystructure v1.2.0 // indirect
|
github.com/mitchellh/copystructure v1.2.0 // indirect
|
||||||
github.com/mitchellh/reflectwalk v1.0.2 // indirect
|
github.com/mitchellh/reflectwalk v1.0.2 // indirect
|
||||||
|
github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55 // indirect
|
||||||
github.com/shopspring/decimal v1.4.0 // indirect
|
github.com/shopspring/decimal v1.4.0 // indirect
|
||||||
github.com/spf13/cast v1.7.0 // indirect
|
github.com/spf13/cast v1.10.0 // indirect
|
||||||
golang.org/x/crypto v0.26.0 // indirect
|
github.com/tklauser/go-sysconf v0.3.16 // indirect
|
||||||
|
github.com/tklauser/numcpus v0.11.0 // indirect
|
||||||
|
github.com/yusufpapurcu/wmi v1.2.4 // indirect
|
||||||
|
golang.org/x/crypto v0.47.0 // indirect
|
||||||
golang.org/x/sync v0.19.0 // indirect
|
golang.org/x/sync v0.19.0 // indirect
|
||||||
)
|
)
|
||||||
|
|||||||
57
go.sum
57
go.sum
@@ -1,21 +1,26 @@
|
|||||||
dario.cat/mergo v1.0.1 h1:Ra4+bf83h2ztPIQYNP99R6m+Y7KfnARDfID+a+vLl4s=
|
dario.cat/mergo v1.0.2 h1:85+piFYR1tMbRrLcDwR18y4UKJ3aH1Tbzi24VRW1TK8=
|
||||||
dario.cat/mergo v1.0.1/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk=
|
dario.cat/mergo v1.0.2/go.mod h1:E/hbnu0NxMFBjpMIE34DRGLWqDy0g5FuKDhCb31ngxA=
|
||||||
github.com/Masterminds/goutils v1.1.1 h1:5nUrii3FMTL5diU80unEVvNevw1nH4+ZV4DSLVJLSYI=
|
github.com/Masterminds/goutils v1.1.1 h1:5nUrii3FMTL5diU80unEVvNevw1nH4+ZV4DSLVJLSYI=
|
||||||
github.com/Masterminds/goutils v1.1.1/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU=
|
github.com/Masterminds/goutils v1.1.1/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU=
|
||||||
github.com/Masterminds/semver/v3 v3.3.0 h1:B8LGeaivUe71a5qox1ICM/JLl0NqZSW5CHyL+hmvYS0=
|
github.com/Masterminds/semver/v3 v3.4.0 h1:Zog+i5UMtVoCU8oKka5P7i9q9HgrJeGzI9SA1Xbatp0=
|
||||||
github.com/Masterminds/semver/v3 v3.3.0/go.mod h1:4V+yj/TJE1HU9XfppCwVMZq3I84lprf4nC11bSS5beM=
|
github.com/Masterminds/semver/v3 v3.4.0/go.mod h1:4V+yj/TJE1HU9XfppCwVMZq3I84lprf4nC11bSS5beM=
|
||||||
github.com/Masterminds/sprig/v3 v3.3.0 h1:mQh0Yrg1XPo6vjYXgtf5OtijNAKJRNcTdOOGZe3tPhs=
|
github.com/Masterminds/sprig/v3 v3.3.0 h1:mQh0Yrg1XPo6vjYXgtf5OtijNAKJRNcTdOOGZe3tPhs=
|
||||||
github.com/Masterminds/sprig/v3 v3.3.0/go.mod h1:Zy1iXRYNqNLUolqCpL4uhk6SHUMAOSCzdgBfDb35Lz0=
|
github.com/Masterminds/sprig/v3 v3.3.0/go.mod h1:Zy1iXRYNqNLUolqCpL4uhk6SHUMAOSCzdgBfDb35Lz0=
|
||||||
github.com/coreos/go-systemd/v22 v22.6.0 h1:aGVa/v8B7hpb0TKl0MWoAavPDmHvobFe5R5zn0bCJWo=
|
github.com/coreos/go-systemd/v22 v22.7.0 h1:LAEzFkke61DFROc7zNLX/WA2i5J8gYqe0rSj9KI28KA=
|
||||||
github.com/coreos/go-systemd/v22 v22.6.0/go.mod h1:iG+pp635Fo7ZmV/j14KUcmEyWF+0X7Lua8rrTWzYgWU=
|
github.com/coreos/go-systemd/v22 v22.7.0/go.mod h1:xNUYtjHu2EDXbsxz1i41wouACIwT7Ybq9o0BQhMwD0w=
|
||||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/djherbis/times v1.6.0 h1:w2ctJ92J8fBvWPxugmXIv7Nz7Q3iDMKNx9v5ocVH20c=
|
github.com/djherbis/times v1.6.0 h1:w2ctJ92J8fBvWPxugmXIv7Nz7Q3iDMKNx9v5ocVH20c=
|
||||||
github.com/djherbis/times v1.6.0/go.mod h1:gOHeRAz2h+VJNZ5Gmc/o7iD9k4wW7NMVqieYCY99oc0=
|
github.com/djherbis/times v1.6.0/go.mod h1:gOHeRAz2h+VJNZ5Gmc/o7iD9k4wW7NMVqieYCY99oc0=
|
||||||
|
github.com/ebitengine/purego v0.9.1 h1:a/k2f2HQU3Pi399RPW1MOaZyhKJL9w/xFpKAg4q1s0A=
|
||||||
|
github.com/ebitengine/purego v0.9.1/go.mod h1:iIjxzd6CiRiOG0UyXP+V1+jWqUXVjPKLAI0mRfJZTmQ=
|
||||||
github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8=
|
github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8=
|
||||||
github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0=
|
github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0=
|
||||||
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
|
github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0=
|
||||||
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
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/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
|
||||||
|
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
|
||||||
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
|
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
|
||||||
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||||
github.com/huandu/xstrings v1.5.0 h1:2ag3IFq9ZDANvthTwTiqSSZLjDc+BedvHPAp5tJy2TI=
|
github.com/huandu/xstrings v1.5.0 h1:2ag3IFq9ZDANvthTwTiqSSZLjDc+BedvHPAp5tJy2TI=
|
||||||
@@ -24,33 +29,43 @@ github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
|
|||||||
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
|
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
|
||||||
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
||||||
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
||||||
|
github.com/lufia/plan9stats v0.0.0-20251013123823-9fd1530e3ec3 h1:PwQumkgq4/acIiZhtifTV5OUqqiP82UAl0h87xj/l9k=
|
||||||
|
github.com/lufia/plan9stats v0.0.0-20251013123823-9fd1530e3ec3/go.mod h1:autxFIvghDt3jPTLoqZ9OZ7s9qTGNAWmYCjVFWPX/zg=
|
||||||
github.com/mitchellh/copystructure v1.2.0 h1:vpKXTN4ewci03Vljg/q9QvCGUDttBOGBIa15WveJJGw=
|
github.com/mitchellh/copystructure v1.2.0 h1:vpKXTN4ewci03Vljg/q9QvCGUDttBOGBIa15WveJJGw=
|
||||||
github.com/mitchellh/copystructure v1.2.0/go.mod h1:qLl+cE2AmVv+CoeAwDPye/v+N2HKCj9FbZEVFJRxO9s=
|
github.com/mitchellh/copystructure v1.2.0/go.mod h1:qLl+cE2AmVv+CoeAwDPye/v+N2HKCj9FbZEVFJRxO9s=
|
||||||
github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zxSIeXaQ=
|
github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zxSIeXaQ=
|
||||||
github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw=
|
github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw=
|
||||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||||
|
github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55 h1:o4JXh1EVt9k/+g42oCprj/FisM4qX9L3sZB3upGN2ZU=
|
||||||
|
github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55/go.mod h1:OmDBASR4679mdNQnz2pUhc2G8CO2JrUAVFDRBDP/hJE=
|
||||||
github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8=
|
github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8=
|
||||||
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
|
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
|
||||||
|
github.com/shirou/gopsutil/v4 v4.25.12 h1:e7PvW/0RmJ8p8vPGJH4jvNkOyLmbkXgXW4m6ZPic6CY=
|
||||||
|
github.com/shirou/gopsutil/v4 v4.25.12/go.mod h1:EivAfP5x2EhLp2ovdpKSozecVXn1TmuG7SMzs/Wh4PU=
|
||||||
github.com/shopspring/decimal v1.4.0 h1:bxl37RwXBklmTi0C79JfXCEBD1cqqHt0bbgBAGFp81k=
|
github.com/shopspring/decimal v1.4.0 h1:bxl37RwXBklmTi0C79JfXCEBD1cqqHt0bbgBAGFp81k=
|
||||||
github.com/shopspring/decimal v1.4.0/go.mod h1:gawqmDU56v4yIKSwfBSFip1HdCCXN8/+DMd9qYNcwME=
|
github.com/shopspring/decimal v1.4.0/go.mod h1:gawqmDU56v4yIKSwfBSFip1HdCCXN8/+DMd9qYNcwME=
|
||||||
github.com/spf13/cast v1.7.0 h1:ntdiHjuueXFgm5nzDRdOS4yfT43P5Fnud6DH50rz/7w=
|
github.com/spf13/cast v1.10.0 h1:h2x0u2shc1QuLHfxi+cTJvs30+ZAHOGRic8uyGTDWxY=
|
||||||
github.com/spf13/cast v1.7.0/go.mod h1:ancEpBxwJDODSW/UG4rDrAqiKolqNNh2DX3mk86cAdo=
|
github.com/spf13/cast v1.10.0/go.mod h1:jNfB8QC9IA6ZuY2ZjDp0KtFO2LZZlg4S/7bzP6qqeHo=
|
||||||
github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4=
|
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
|
||||||
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
|
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
|
||||||
|
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/yusufpapurcu/wmi v1.2.4 h1:zFUKzehAFReQwLys1b/iSMl+JQGSCSjtVqQn9bBrPo0=
|
||||||
|
github.com/yusufpapurcu/wmi v1.2.4/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0=
|
||||||
go4.org/netipx v0.0.0-20231129151722-fdeea329fbba h1:0b9z3AuHCjxk0x/opv64kcgZLBseWJUpBw5I82+2U4M=
|
go4.org/netipx v0.0.0-20231129151722-fdeea329fbba h1:0b9z3AuHCjxk0x/opv64kcgZLBseWJUpBw5I82+2U4M=
|
||||||
go4.org/netipx v0.0.0-20231129151722-fdeea329fbba/go.mod h1:PLyyIXexvUFg3Owu6p/WfdlivPbZJsZdgWZlrGope/Y=
|
go4.org/netipx v0.0.0-20231129151722-fdeea329fbba/go.mod h1:PLyyIXexvUFg3Owu6p/WfdlivPbZJsZdgWZlrGope/Y=
|
||||||
golang.org/x/crypto v0.26.0 h1:RrRspgV4mU+YwB4FYnuBoKsUapNIL5cohGAmSH3azsw=
|
golang.org/x/crypto v0.47.0 h1:V6e3FRj+n4dbpw86FJ8Fv7XVOql7TEwpHapKoMJ/GO8=
|
||||||
golang.org/x/crypto v0.26.0/go.mod h1:GY7jblb9wI+FOo5y8/S2oY4zWP07AkOJ4+jxCqdqn54=
|
golang.org/x/crypto v0.47.0/go.mod h1:ff3Y9VzzKbwSSEzWqJsJVBnWmRwRSHt/6Op5n9bQc4A=
|
||||||
golang.org/x/sync v0.19.0 h1:vV+1eWNmZ5geRlYjzm2adRgW2/mcpevXNg50YZtPCE4=
|
golang.org/x/sync v0.19.0 h1:vV+1eWNmZ5geRlYjzm2adRgW2/mcpevXNg50YZtPCE4=
|
||||||
golang.org/x/sync v0.19.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI=
|
golang.org/x/sync v0.19.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI=
|
||||||
|
golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20201204225414-ed752295db88/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20220615213510-4f61da869c0c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20220615213510-4f61da869c0c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.39.0 h1:CvCKL8MeisomCi6qNZ+wbb0DN9E5AATixKsvNtMoMFk=
|
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.39.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
|
golang.org/x/sys v0.40.0 h1:DBZZqJ2Rkml6QMQsZywtnjnnGvHza6BTfYFWY9kjEWQ=
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
golang.org/x/sys v0.40.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
|
||||||
gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU=
|
|
||||||
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
|
||||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
r00t2.io/sysutils v1.15.1 h1:0EVZZAxTFqQN6jjfjqUKkXye0LMshUA5MO7l3Wd6wH8=
|
|
||||||
r00t2.io/sysutils v1.15.1/go.mod h1:T0iOnaZaSG5NE1hbXTqojRZc0ia/u8TB73lV7zhMz58=
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,699 +0,0 @@
|
|||||||
# What is SprigX?
|
|
||||||
|
|
||||||
SprigX are extensions to [the `sprig`
|
|
||||||
library](https://masterminds.github.io/sprig/) ([Go
|
|
||||||
docs](https://pkg.go.dev/github.com/Masterminds/sprig/v3)).
|
|
||||||
|
|
||||||
They provide functions that offer more enriched use cases and
|
|
||||||
domain-specific data.
|
|
||||||
|
|
||||||
If you are reading this README on the Go Module Directory documentation
|
|
||||||
(<https://pkg.go.dev/r00t2.io/goutils/tplx/sprigx>) or the directory
|
|
||||||
landing page
|
|
||||||
(<https://git.r00t2.io/r00t2/go_goutils/src/branch/master/tplx/sprigx>),
|
|
||||||
it may not render correctly.
|
|
||||||
|
|
||||||
Be sure to view it at properly via [the AsciiDoc
|
|
||||||
rendering](https://git.r00t2.io/r00t2/go_goutils/src/branch/master/tplx/sprigx/README.adoc)
|
|
||||||
or by downloading and viewing the [HTML
|
|
||||||
version](https://git.r00t2.io/r00t2/go_goutils/raw/branch/master/tplx/sprigx/README.html).
|
|
||||||
|
|
||||||
# How do I Use SprigX?
|
|
||||||
|
|
||||||
The same way you would `sprig`!
|
|
||||||
|
|
||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
htmlTplLib "html/template"
|
|
||||||
txtTplLib "text/template"
|
|
||||||
|
|
||||||
"r00t2.io/goutils/tplx/sprigx"
|
|
||||||
)
|
|
||||||
|
|
||||||
var (
|
|
||||||
txtTpl *txtTplLib.Template = txtTplLib.
|
|
||||||
New("").
|
|
||||||
Funcs(
|
|
||||||
sprigx.TxtFuncMap(),
|
|
||||||
)
|
|
||||||
htmlTpl *htmlTplLib.Template = htmlTplLib.
|
|
||||||
New("").
|
|
||||||
Funcs(
|
|
||||||
sprigx.HtmlFuncMap(),
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
They can even be combined/used together.
|
|
||||||
|
|
||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"text/template"
|
|
||||||
|
|
||||||
"github.com/Masterminds/sprig/v3"
|
|
||||||
"r00t2.io/goutils/tplx/sprigx"
|
|
||||||
)
|
|
||||||
|
|
||||||
var txtTpl *template.Template = template.
|
|
||||||
New("").
|
|
||||||
Funcs(
|
|
||||||
sprigx.TxtFuncMap(),
|
|
||||||
).
|
|
||||||
Funcs(
|
|
||||||
sprig.TxtFuncMap(),
|
|
||||||
)
|
|
||||||
// Or:
|
|
||||||
/*
|
|
||||||
var txtTpl *template.Template = template.
|
|
||||||
New("").
|
|
||||||
Funcs(
|
|
||||||
sprig.TxtFuncMap(),
|
|
||||||
).
|
|
||||||
Funcs(
|
|
||||||
sprigx.TxtFuncMap(),
|
|
||||||
)
|
|
||||||
*/
|
|
||||||
|
|
||||||
If a `<template>.FuncMap` is added via `.Funcs()` **after** template
|
|
||||||
parsing, it will override any functions of the same name of a
|
|
||||||
`<template>.FuncMap` **before** parsing.
|
|
||||||
|
|
||||||
For example, if both `sprig` and `sprigx` provide a function `foo`:
|
|
||||||
|
|
||||||
this will use `foo` from `sprigx`
|
|
||||||
|
|
||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"text/template"
|
|
||||||
|
|
||||||
"github.com/Masterminds/sprig/v3"
|
|
||||||
"r00t2.io/goutils/tplx/sprigx"
|
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
|
||||||
myTpl string = `{{ "This is an example template string." | foo }}`
|
|
||||||
)
|
|
||||||
|
|
||||||
var (
|
|
||||||
tpl *template.Template = template.Must(
|
|
||||||
template.
|
|
||||||
New("").
|
|
||||||
Funcs(sprig.TxtFuncMap()).
|
|
||||||
Parse(myTpl),
|
|
||||||
).
|
|
||||||
Funcs(sprigx.TxtFuncMap())
|
|
||||||
)
|
|
||||||
|
|
||||||
whereas this will use `foo` from `sprig`
|
|
||||||
|
|
||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"text/template"
|
|
||||||
|
|
||||||
"github.com/Masterminds/sprig/v3"
|
|
||||||
"r00t2.io/goutils/tplx/sprigx"
|
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
|
||||||
myTpl string = `{{ "This is an example template string." | foo }}`
|
|
||||||
)
|
|
||||||
|
|
||||||
var (
|
|
||||||
tpl *template.Template = template.Must(
|
|
||||||
template.
|
|
||||||
New("").
|
|
||||||
Funcs(sprigx.TxtFuncMap()).
|
|
||||||
Parse(myTpl),
|
|
||||||
).
|
|
||||||
Funcs(sprig.TxtFuncMap())
|
|
||||||
)
|
|
||||||
|
|
||||||
and a function can even be explicitly overridden.
|
|
||||||
|
|
||||||
This would override a function `foo` and `foo2` in `sprigx` from `foo`
|
|
||||||
and `foo2` from `sprig`, but leave all other `sprig` functions
|
|
||||||
untouched.
|
|
||||||
|
|
||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"text/template"
|
|
||||||
|
|
||||||
"github.com/Masterminds/sprig/v3"
|
|
||||||
"r00t2.io/goutils/tplx/sprigx"
|
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
|
||||||
myTpl string = `{{ "This is an example template string." | foo }}`
|
|
||||||
)
|
|
||||||
|
|
||||||
var (
|
|
||||||
overrideFuncs template.FuncMap = sprig.TxtFuncMap()
|
|
||||||
tpl *template.Template = template.Must(
|
|
||||||
template.
|
|
||||||
New("").
|
|
||||||
Funcs(sprigx.TxtFuncMap()).
|
|
||||||
Parse(myTpl),
|
|
||||||
).
|
|
||||||
Funcs(
|
|
||||||
template.FuncMap(
|
|
||||||
map[string]any{
|
|
||||||
"foo": overrideFuncs["foo"],
|
|
||||||
"foo2": overrideFuncs["foo2"],
|
|
||||||
},
|
|
||||||
),
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
# Functions
|
|
||||||
|
|
||||||
Expect this list to grow over time, and potentially more frequently than
|
|
||||||
the `sprigx` functions.
|
|
||||||
|
|
||||||
## Operating System
|
|
||||||
|
|
||||||
### `osHostname`
|
|
||||||
|
|
||||||
`osHostname` simply wraps and returns the result of calling
|
|
||||||
[`os.Hostname`](https://pkg.go.dev/os#Hostname).
|
|
||||||
|
|
||||||
As such, it comes with the same caveats - it’s possible for it to error,
|
|
||||||
and it isn’t guaranteed to be an FQDN — it will be precisely/exactly
|
|
||||||
whatever the kernel’s hostname is set as.
|
|
||||||
|
|
||||||
## System/Platform/Architecture
|
|
||||||
|
|
||||||
### `sysArch`
|
|
||||||
|
|
||||||
Returns the [`runtime.GOARCH`](https://pkg.go.dev/runtime#GOARCH)
|
|
||||||
constant.
|
|
||||||
|
|
||||||
### `sysNumCpu`
|
|
||||||
|
|
||||||
Returns the value from
|
|
||||||
[`runtime.NumCPU`](https://pkg.go.dev/runtime#NumCPU).
|
|
||||||
|
|
||||||
### `sysOsName`
|
|
||||||
|
|
||||||
Returns the [`runtime.GOOS`](https://pkg.go.dev/runtime#GOOS) constant.
|
|
||||||
|
|
||||||
### `sysRuntime`
|
|
||||||
|
|
||||||
This function returns a `map[string]string` of various information from
|
|
||||||
the [`runtime` stdlib library](https://pkg.go.dev/runtime).
|
|
||||||
|
|
||||||
Specifically, the following are returned.
|
|
||||||
|
|
||||||
The value type is a direct link to the `runtime` documentation providing
|
|
||||||
more detail about the associated value.
|
|
||||||
|
|
||||||
Because all values are mapped as strings, they can be converted back to
|
|
||||||
their native type via e.g. the [Sprig conversion
|
|
||||||
functions](https://masterminds.github.io/sprig/conversion.html) if
|
|
||||||
necessary.
|
|
||||||
|
|
||||||
<table>
|
|
||||||
<caption><code>sysRuntime</code> Values</caption>
|
|
||||||
<colgroup>
|
|
||||||
<col style="width: 50%" />
|
|
||||||
<col style="width: 50%" />
|
|
||||||
</colgroup>
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th style="text-align: center;">Key</th>
|
|
||||||
<th style="text-align: center;">Value Type</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
<tr>
|
|
||||||
<td style="text-align: center;"><p><code>compiler</code></p></td>
|
|
||||||
<td style="text-align: center;"><p><a
|
|
||||||
href="https://pkg.go.dev/runtime#Compiler">string</a></p></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td style="text-align: center;"><p><code>arch</code></p></td>
|
|
||||||
<td style="text-align: center;"><p><a
|
|
||||||
href="https://pkg.go.dev/runtime#GOARCH">string</a></p></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td style="text-align: center;"><p><code>os</code></p></td>
|
|
||||||
<td style="text-align: center;"><p><a
|
|
||||||
href="https://pkg.go.dev/runtime#GOOS">string</a></p></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td style="text-align: center;"><p><code>maxprocs</code></p></td>
|
|
||||||
<td style="text-align: center;"><p><a
|
|
||||||
href="https://pkg.go.dev/runtime#GOMAXPROCS">int</a> <a href="#fn1"
|
|
||||||
class="footnote-ref" id="fnref1"
|
|
||||||
role="doc-noteref"><sup>1</sup></a></p></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td style="text-align: center;"><p><code>cpu_cnt</code></p></td>
|
|
||||||
<td style="text-align: center;"><p><a
|
|
||||||
href="https://pkg.go.dev/runtime#NumCPU">int</a></p></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td style="text-align: center;"><p><code>num_cgo</code></p></td>
|
|
||||||
<td style="text-align: center;"><p><a
|
|
||||||
href="https://pkg.go.dev/runtime#NumCgoCall">int</a></p></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td style="text-align: center;"><p><code>num_go</code></p></td>
|
|
||||||
<td style="text-align: center;"><p><a
|
|
||||||
href="https://pkg.go.dev/runtime#NumGoroutine">int</a></p></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td style="text-align: center;"><p><code>go_ver</code></p></td>
|
|
||||||
<td style="text-align: center;"><p><a
|
|
||||||
href="https://pkg.go.dev/runtime#Version">string</a></p></td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
<section id="footnotes" class="footnotes footnotes-end-of-document"
|
|
||||||
role="doc-endnotes">
|
|
||||||
<hr />
|
|
||||||
<ol>
|
|
||||||
<li id="fn1"><p>For safety concerns, <code>sprigx</code> does not allow
|
|
||||||
<strong>setting</strong> <code>GOMAXPROCS</code>, this value only
|
|
||||||
contains the <strong>current</strong> <code>GOMAXPROCS</code> value.<a
|
|
||||||
href="#fnref1" class="footnote-back" role="doc-backlink">↩︎</a></p></li>
|
|
||||||
</ol>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
As a convenience, some of these values also have their own dedicated
|
|
||||||
functions as well:
|
|
||||||
|
|
||||||
- [](#fn_sys_arch)
|
|
||||||
|
|
||||||
- [](#fn_sys_numcpu)
|
|
||||||
|
|
||||||
- [](#fn_sys_os)
|
|
||||||
|
|
||||||
## Paths
|
|
||||||
|
|
||||||
### Generic
|
|
||||||
|
|
||||||
These operate similar to [the `path` stdlib
|
|
||||||
library](https://pkg.go.dev/path) and use a fixed `/` path separator.
|
|
||||||
|
|
||||||
#### `pathJoin`
|
|
||||||
|
|
||||||
`pathJoin` operates **exactly** like
|
|
||||||
[`path.Join`](https://pkg.go.dev/path#Join) in stdlib.
|
|
||||||
|
|
||||||
If you are joining paths in a pipeline, you almost assuredly want
|
|
||||||
[](#fn_path_gnrc_ppj) or [](#fn_path_gnrc_pspj) instead unless you are
|
|
||||||
explicitly **appending** a pipeline result to a path.
|
|
||||||
|
|
||||||
{{- pathJoin "a" "b" "c" }}
|
|
||||||
{{- pathJoin "/" "a" "b" "c" }}
|
|
||||||
{{- pathJoin "/a/b" "c" }}
|
|
||||||
|
|
||||||
renders as:
|
|
||||||
|
|
||||||
a/b/c
|
|
||||||
/a/b/c
|
|
||||||
/a/b/c
|
|
||||||
|
|
||||||
#### `pathPipeJoin`
|
|
||||||
|
|
||||||
`pathPipeJoin` operates like [](#fn_path_gnrc_pj) with one deviation:
|
|
||||||
the root/base path is expected to be **last** in the arguments.
|
|
||||||
|
|
||||||
This makes it much more suitable for use in template pipelines, as the
|
|
||||||
previous value in a pipeline is passed in as the last element to the
|
|
||||||
next pipe function.
|
|
||||||
|
|
||||||
{{- $myBase := "/a" -}}
|
|
||||||
{{- pathPipeJoin "b" "c" "a" }}
|
|
||||||
{{- pathPipeJoin "a" "b" "c" "/" }}
|
|
||||||
{{- $myBase | pathPipeJoin "b" "c" }}
|
|
||||||
|
|
||||||
renders as:
|
|
||||||
|
|
||||||
a/b/c
|
|
||||||
/a/b/c
|
|
||||||
/a/b/c
|
|
||||||
|
|
||||||
#### `pathSliceJoin`
|
|
||||||
|
|
||||||
`pathSliceJoin` joins a slice of path segment strings (`[]string`)
|
|
||||||
instead of a variadic sequence of strings.
|
|
||||||
|
|
||||||
The `splitList` function shown below is from the [`sprig` string slice
|
|
||||||
functions](https://masterminds.github.io/sprig/string_slice.html).
|
|
||||||
|
|
||||||
{{- $myList := "a,b,c" | splitList "," -}}
|
|
||||||
{{- $myList | pathSliceJoin }}
|
|
||||||
{{- ("a,b,c" | splitList ",") | pathSliceJoin }}
|
|
||||||
{{- ("/,a,b,c" | splitList ",") | pathSliceJoin }}
|
|
||||||
|
|
||||||
renders as:
|
|
||||||
|
|
||||||
a/b/c
|
|
||||||
a/b/c
|
|
||||||
/a/b/c
|
|
||||||
|
|
||||||
#### `pathSlicePipeJoin`
|
|
||||||
|
|
||||||
`pathSlicePipeJoin` operates like [](#fn_path_gnrc_ppj) in that it is
|
|
||||||
suitable for pipeline use in which the root/base path is passed in from
|
|
||||||
the pipeline, but it is like [](#fn_path_gnrc_psj) in that it then also
|
|
||||||
accepts a slice of path segments (`[]string`) to append to that base
|
|
||||||
path.
|
|
||||||
|
|
||||||
The `splitList` function shown below is from the [`sprig` string slice
|
|
||||||
functions](https://masterminds.github.io/sprig/string_slice.html).
|
|
||||||
|
|
||||||
{{- $myBase := "/a" -}}
|
|
||||||
{{- $myList := "b,c,d" | splitList "." -}}
|
|
||||||
{{- pathSlicePipeJoin $myList $myBase }}
|
|
||||||
{{- $myBase | pathSlicePipeJoin $myList }}
|
|
||||||
|
|
||||||
renders as:
|
|
||||||
|
|
||||||
/a/b/c
|
|
||||||
/a/b/c
|
|
||||||
|
|
||||||
#### `pathSubJoin`
|
|
||||||
|
|
||||||
`pathSubJoin` operates like [](#fn_path_gnrc_pj) but it expects an
|
|
||||||
explicit root/base path.
|
|
||||||
|
|
||||||
The pipeline-friendly equivalent of this is [](#fn_path_gnrc_ppj).
|
|
||||||
|
|
||||||
{{- pathSubJoin "/a/b" "c" }}
|
|
||||||
{{- pathSubJoin "/" "a" "b" "c" }}
|
|
||||||
{{- "c" | pathSubJoin "/" "a" "b" }}
|
|
||||||
|
|
||||||
renders as:
|
|
||||||
|
|
||||||
/a/b/c
|
|
||||||
/a/b/c
|
|
||||||
/a/b/c
|
|
||||||
|
|
||||||
### OS/Platform-Tailored
|
|
||||||
|
|
||||||
These operate similar to [the `path/filepath` stdlib
|
|
||||||
library](https://pkg.go.dev/path/filepath), and use the OS-specific
|
|
||||||
[`os.PathSeparator`](https://pkg.go.dev/os#PathSeparator).
|
|
||||||
|
|
||||||
Take special note of the oddness around specifying Windows paths and
|
|
||||||
drive letters in e.g. [](#fn_path_os_pj)!
|
|
||||||
|
|
||||||
It is recommended to make use of [](#fn_sys_os) to conditionally format
|
|
||||||
path bases/roots if needed.
|
|
||||||
|
|
||||||
#### `osPathJoin`
|
|
||||||
|
|
||||||
`osPathJoin` operates **exactly** like
|
|
||||||
[`path/filepath.Join`](https://pkg.go.dev/path/filepath#Join) in stdlib.
|
|
||||||
|
|
||||||
If you are joining paths in a pipeline, you almost assuredly want
|
|
||||||
[](#fn_path_os_ppj) or [](#fn_path_os_pspj) instead unless you are
|
|
||||||
explicitly **appending** a pipeline result to a path.
|
|
||||||
|
|
||||||
{{- osPathJoin "a" "b" "c" }}
|
|
||||||
{{- osPathJoin "/" "a" "b" "c" }}
|
|
||||||
{{- osPathJoin "C:\\" "a" "b" "c" }}
|
|
||||||
{{- osPathJoin "C:" "a" "b" "c" }}
|
|
||||||
|
|
||||||
renders as:
|
|
||||||
|
|
||||||
<table>
|
|
||||||
<colgroup>
|
|
||||||
<col style="width: 33%" />
|
|
||||||
<col style="width: 66%" />
|
|
||||||
</colgroup>
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th style="text-align: center;">OS</th>
|
|
||||||
<th style="text-align: center;">Result</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
<tr>
|
|
||||||
<td style="text-align: center;"><p>Windows</p></td>
|
|
||||||
<td style="text-align: left;"><pre class="text"><code>a\b\c
|
|
||||||
\a\b\c
|
|
||||||
\a\b\c
|
|
||||||
C:\a\b\c
|
|
||||||
C:a\b\c</code></pre></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td style="text-align: center;"><p>Others (e.g. Linux, macOS)</p></td>
|
|
||||||
<td style="text-align: left;"><pre class="text"><code>a/b/c
|
|
||||||
/a/b/c
|
|
||||||
C:\/a/b/c
|
|
||||||
C:/a/b/c</code></pre></td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
#### `osPathPipeJoin`
|
|
||||||
|
|
||||||
`osPathPipeJoin` operates like [](#fn_path_gnrc_ppj) (except using
|
|
||||||
OS-specific path separators).
|
|
||||||
|
|
||||||
This makes it much more suitable for use in template pipelines, as the
|
|
||||||
previous value in a pipeline is passed in as the last element to the
|
|
||||||
next pipe function.
|
|
||||||
|
|
||||||
{{- $myBase := "/a" -}}
|
|
||||||
{{- osPathPipeJoin "b" "c" "a" }}
|
|
||||||
{{- osPathPipeJoin "a" "b" "c" "/" }}
|
|
||||||
{{- $myBase | osPathPipeJoin "b" "c" }}
|
|
||||||
|
|
||||||
renders as:
|
|
||||||
|
|
||||||
<table>
|
|
||||||
<colgroup>
|
|
||||||
<col style="width: 33%" />
|
|
||||||
<col style="width: 66%" />
|
|
||||||
</colgroup>
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th style="text-align: center;">OS</th>
|
|
||||||
<th style="text-align: center;">Result</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
<tr>
|
|
||||||
<td style="text-align: center;"><p>Windows</p></td>
|
|
||||||
<td style="text-align: left;"><pre class="text"><code>a\b\c
|
|
||||||
\a\b\c
|
|
||||||
\a\b\c</code></pre></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td style="text-align: center;"><p>Others (e.g. Linux, macOS)</p></td>
|
|
||||||
<td style="text-align: left;"><pre class="text"><code>a/b/c
|
|
||||||
/a/b/c
|
|
||||||
/a/b/c</code></pre></td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
#### `osPathSep`
|
|
||||||
|
|
||||||
`osPathSep` returns the
|
|
||||||
[`os.PathSeparator`](https://pkg.go.dev/os#PathSeparator) for this OS.
|
|
||||||
|
|
||||||
{{- osPathSep }}
|
|
||||||
|
|
||||||
renders as:
|
|
||||||
|
|
||||||
<table>
|
|
||||||
<colgroup>
|
|
||||||
<col style="width: 33%" />
|
|
||||||
<col style="width: 66%" />
|
|
||||||
</colgroup>
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th style="text-align: center;">OS</th>
|
|
||||||
<th style="text-align: center;">Result</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
<tr>
|
|
||||||
<td style="text-align: center;"><p>Windows</p></td>
|
|
||||||
<td style="text-align: left;"><pre class="text"><code>\</code></pre></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td style="text-align: center;"><p>Others (e.g. Linux, macOS)</p></td>
|
|
||||||
<td style="text-align: left;"><pre class="text"><code>/</code></pre></td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
#### `osPathSliceJoin`
|
|
||||||
|
|
||||||
`osPathSliceJoin` operates like [](#fn_path_gnrc_psj) but with
|
|
||||||
OS-specific path separators.
|
|
||||||
|
|
||||||
The `splitList` function shown below is from the [`sprig` string slice
|
|
||||||
functions](https://masterminds.github.io/sprig/string_slice.html).
|
|
||||||
|
|
||||||
{{- $myList := "a,b,c" | splitList "," -}}
|
|
||||||
{{- $myList | osPathSliceJoin }}
|
|
||||||
{{- ("a,b,c" | splitList ",") | osPathSliceJoin }}
|
|
||||||
{{- ("/,a,b,c" | splitList ",") | osPathSliceJoin }}
|
|
||||||
|
|
||||||
renders as:
|
|
||||||
|
|
||||||
<table>
|
|
||||||
<colgroup>
|
|
||||||
<col style="width: 33%" />
|
|
||||||
<col style="width: 66%" />
|
|
||||||
</colgroup>
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th style="text-align: center;">OS</th>
|
|
||||||
<th style="text-align: center;">Result</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
<tr>
|
|
||||||
<td style="text-align: center;"><p>Windows</p></td>
|
|
||||||
<td style="text-align: left;"><pre class="text"><code>a\b\c
|
|
||||||
a\b\c
|
|
||||||
\a\b\c</code></pre></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td style="text-align: center;"><p>Others (e.g. Linux, macOS)</p></td>
|
|
||||||
<td style="text-align: left;"><pre class="text"><code>a/b/c
|
|
||||||
a/b/c
|
|
||||||
/a/b/c</code></pre></td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
#### `osPathSlicePipeJoin`
|
|
||||||
|
|
||||||
`osPathSlicePipeJoin` operates like [](#fn_path_gnrc_pspj) but with
|
|
||||||
OS-specific separators.
|
|
||||||
|
|
||||||
The `splitList` function shown below is from the [`sprig` string slice
|
|
||||||
functions](https://masterminds.github.io/sprig/string_slice.html).
|
|
||||||
|
|
||||||
{{- $myBase := "/a" -}}
|
|
||||||
{{- $myList := "b,c,d" | splitList "." -}}
|
|
||||||
{{- osPathSlicePipeJoin $myList $myBase }}
|
|
||||||
{{- $myBase | osPathSlicePipeJoin $myList }}
|
|
||||||
|
|
||||||
renders as:
|
|
||||||
|
|
||||||
<table>
|
|
||||||
<colgroup>
|
|
||||||
<col style="width: 33%" />
|
|
||||||
<col style="width: 66%" />
|
|
||||||
</colgroup>
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th style="text-align: center;">OS</th>
|
|
||||||
<th style="text-align: center;">Result</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
<tr>
|
|
||||||
<td style="text-align: center;"><p>Windows</p></td>
|
|
||||||
<td style="text-align: left;"><pre class="text"><code>\a\b\c\d
|
|
||||||
\a\b\c\d</code></pre></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td style="text-align: center;"><p>Others (e.g. Linux, macOS)</p></td>
|
|
||||||
<td style="text-align: left;"><pre class="text"><code>/a/b/c/d
|
|
||||||
/a/b/c/d</code></pre></td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
#### `osPathSubJoin`
|
|
||||||
|
|
||||||
`osPathSubJoin` operates like [](#fn_path_gnrc_psubj) but with
|
|
||||||
OS-specific separators.
|
|
||||||
|
|
||||||
The pipeline-friendly equivalent of this is [](#fn_path_os_ppj).
|
|
||||||
|
|
||||||
{{- osPathSubJoin "/a/b" "c" }}
|
|
||||||
{{- osPathSubJoin "/" "a" "b" "c" }}
|
|
||||||
{{- "c" | osPathSubJoin "/" "a" "b" }}
|
|
||||||
|
|
||||||
renders as:
|
|
||||||
|
|
||||||
<table>
|
|
||||||
<colgroup>
|
|
||||||
<col style="width: 33%" />
|
|
||||||
<col style="width: 66%" />
|
|
||||||
</colgroup>
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th style="text-align: center;">OS</th>
|
|
||||||
<th style="text-align: center;">Result</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
<tr>
|
|
||||||
<td style="text-align: center;"><p>Windows</p></td>
|
|
||||||
<td style="text-align: left;"><pre class="text"><code>\a\b\c
|
|
||||||
\a\b\c
|
|
||||||
\a\b\c</code></pre></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td style="text-align: center;"><p>Others (e.g. Linux, macOS)</p></td>
|
|
||||||
<td style="text-align: left;"><pre class="text"><code>/a/b/c
|
|
||||||
/a/b/c
|
|
||||||
/a/b/c</code></pre></td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
## Strings
|
|
||||||
|
|
||||||
### `extIndent`
|
|
||||||
|
|
||||||
`extIndent` allows for a MUCH more flexible indenter than the `sprig`
|
|
||||||
`indent` function.
|
|
||||||
|
|
||||||
It works with both Windows (`\r\n`) and POSIX (`\n`) linebreaks.
|
|
||||||
|
|
||||||
If `<indentString>` is set to `\n` and `<levels>` is always set to `1`,
|
|
||||||
this function can even be used to doubelspace text!
|
|
||||||
|
|
||||||
It has quite a few arguments, however:
|
|
||||||
|
|
||||||
{{ extIndent <levels> <skipFirst> <skipEmpty> <skipWhitespace> <indentString> <input> }}
|
|
||||||
|
|
||||||
Where:
|
|
||||||
|
|
||||||
- `<levels>`: The level of indentation for the text. If less than or
|
|
||||||
equal to `0`, `extIndent` just returns `<input>` as-is and NO-OPs
|
|
||||||
otherwise.
|
|
||||||
|
|
||||||
- `<skipFirst>`: If true, skip indenting the first line. This is
|
|
||||||
particularly handy if you like to visually align your function calls
|
|
||||||
in your templates.
|
|
||||||
|
|
||||||
- `<skipEmpty>`: If true, do not add an indent to **empty** lines
|
|
||||||
(where an "empty line" means "only has a linebreak").
|
|
||||||
|
|
||||||
- `<skipWhitespace>`: If true, do not add an indent to lines that
|
|
||||||
**only** consist of whitespace (spaces, tabs, etc.) and a linebreak.
|
|
||||||
|
|
||||||
- `<indentString>`: The string to use as the "indent character". This
|
|
||||||
can be any string, such as `" "`, `"\t"`, `"."`, `"|"`, `"=="` etc.
|
|
||||||
|
|
||||||
- `<input>`: The text to be indented. Because it is the last argument,
|
|
||||||
`extIndent` works with pipelined text as well.
|
|
||||||
|
|
||||||
## Debugging
|
|
||||||
|
|
||||||
### `dump`
|
|
||||||
|
|
||||||
The `dump` function calls [the `Sdump`
|
|
||||||
function](https://pkg.go.dev/github.com/davecgh/go-spew/spew#Sdump) from
|
|
||||||
[`go-spew`](https://github.com/davecgh/go-spew)
|
|
||||||
([`github.com/davecgh/go-spew/spew`](https://pkg.go.dev/github.com/davecgh/go-spew/spew))
|
|
||||||
for whatever object(s) is/are passed to it.
|
|
||||||
@@ -1,22 +1,48 @@
|
|||||||
package sprigx
|
package sprigx
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"path"
|
`os`
|
||||||
"path/filepath"
|
`os/user`
|
||||||
|
`path`
|
||||||
|
`path/filepath`
|
||||||
|
`runtime`
|
||||||
|
|
||||||
|
`github.com/davecgh/go-spew/spew`
|
||||||
|
`github.com/shirou/gopsutil/v4/cpu`
|
||||||
|
`github.com/shirou/gopsutil/v4/disk`
|
||||||
|
`github.com/shirou/gopsutil/v4/host`
|
||||||
|
`github.com/shirou/gopsutil/v4/load`
|
||||||
|
`github.com/shirou/gopsutil/v4/mem`
|
||||||
|
psnet `github.com/shirou/gopsutil/v4/net`
|
||||||
|
`github.com/shirou/gopsutil/v4/process`
|
||||||
|
`github.com/shirou/gopsutil/v4/sensors`
|
||||||
|
`r00t2.io/sysutils`
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
// genericMap holds functions usable/intended for use in either an [html/template.FuncMap] or [text/template.FuncMap].
|
// genericMap holds functions usable/intended for use in either an [html/template.FuncMap] or [text/template.FuncMap].
|
||||||
genericMap map[string]any = map[string]any{
|
genericMap map[string]any = map[string]any{
|
||||||
// Debugging
|
// Debugging
|
||||||
"dump": dump,
|
"dump": spew.Sdump,
|
||||||
// Strings
|
/*
|
||||||
"extIndent": extIndent, // PR in: https://github.com/Masterminds/sprig/pull/468
|
"Meta"/Template-Helpers
|
||||||
// OS/System
|
*/
|
||||||
"sysArch": sysArch,
|
"metaIsNil": metaIsNil,
|
||||||
"sysNumCpu": sysNumCpu,
|
/*
|
||||||
"sysOsName": sysOsNm,
|
OS
|
||||||
"sysRuntime": sysRuntime,
|
*/
|
||||||
|
"osFQDN": osFQDN,
|
||||||
|
"osGroupById": osGroupById,
|
||||||
|
"osGroupByName": user.LookupGroup,
|
||||||
|
"osHost": osHost,
|
||||||
|
"osHostname": os.Hostname,
|
||||||
|
"osIdState": sysutils.GetIDState,
|
||||||
|
"osUser": user.Current,
|
||||||
|
"osUserById": osUserById,
|
||||||
|
"osUserByName": user.Lookup,
|
||||||
|
/*
|
||||||
|
Paths
|
||||||
|
*/
|
||||||
// Paths: Generic
|
// Paths: Generic
|
||||||
"pathJoin": path.Join,
|
"pathJoin": path.Join,
|
||||||
"pathPipeJoin": pathPipeJoin,
|
"pathPipeJoin": pathPipeJoin,
|
||||||
@@ -30,6 +56,70 @@ var (
|
|||||||
"osPathSliceJoin": osPathSliceJoin,
|
"osPathSliceJoin": osPathSliceJoin,
|
||||||
"osPathSlicePipeJoin": osPathSlicePipeJoin,
|
"osPathSlicePipeJoin": osPathSlicePipeJoin,
|
||||||
"osPathSubJoin": osPathSubJoin,
|
"osPathSubJoin": osPathSubJoin,
|
||||||
|
/*
|
||||||
|
PSUtil
|
||||||
|
(https://pkg.go.dev/github.com/shirou/gopsutil/v4)
|
||||||
|
*/
|
||||||
|
// .../cpu
|
||||||
|
"psCpuCnts": cpu.Counts,
|
||||||
|
"psCpuInfo": cpu.Info,
|
||||||
|
"psCpuPct": cpu.Percent,
|
||||||
|
"psCpuTimes": cpu.Times,
|
||||||
|
// .../disk
|
||||||
|
"psDiskIoCnts": disk.IOCounters,
|
||||||
|
"psDiskLabel": disk.Label,
|
||||||
|
"psDiskParts": disk.Partitions,
|
||||||
|
"psDiskSerial": disk.SerialNumber,
|
||||||
|
"psDiskUsage": disk.Usage,
|
||||||
|
// .../host
|
||||||
|
"psHostBoot": host.BootTime,
|
||||||
|
"psHostId": host.HostID,
|
||||||
|
"psHostInfo": host.Info,
|
||||||
|
"psHostKernArch": host.KernelArch,
|
||||||
|
"psHostKernVer": host.KernelVersion,
|
||||||
|
"psHostPlatInfo": psHostPlatInfo,
|
||||||
|
"psHostUptime": host.Uptime,
|
||||||
|
"psHostUsers": host.Users,
|
||||||
|
"psHostVirt": psHostVirt,
|
||||||
|
// .../load
|
||||||
|
"psLoadAvg": load.Avg,
|
||||||
|
"psLoadMisc": load.Misc,
|
||||||
|
// .../mem
|
||||||
|
"psMemSwap": mem.SwapMemory,
|
||||||
|
"psMemSwapDevs": mem.SwapDevices,
|
||||||
|
"psMemVMem": mem.VirtualMemory,
|
||||||
|
// .../net
|
||||||
|
"psNetConns": psnet.Connections,
|
||||||
|
"psNetConnsMax": psnet.ConnectionsMax,
|
||||||
|
"psNetConnsPid": psnet.ConnectionsPid,
|
||||||
|
"psNetConnsPidMax": psnet.ConnectionsPidMax,
|
||||||
|
"psNetCTStats": psnet.ConntrackStats,
|
||||||
|
"psNetCTStatList": psnet.NewConntrackStatList,
|
||||||
|
"psNetFilterCnts": psnet.FilterCounters,
|
||||||
|
"psNetIoCnts": psnet.IOCounters,
|
||||||
|
"psNetIoCntsFile": psnet.IOCountersByFile,
|
||||||
|
"psNetIfaces": psnet.Interfaces,
|
||||||
|
"psNetPids": psnet.Pids,
|
||||||
|
"psNetProtoCnt": psnet.ProtoCounters,
|
||||||
|
// .../process
|
||||||
|
"psProcs": process.Processes,
|
||||||
|
"psProcNew": process.NewProcess,
|
||||||
|
"psProcPids": process.Pids,
|
||||||
|
"psProcPidExists": process.PidExists,
|
||||||
|
// .../sensors
|
||||||
|
"psSensorTemps": sensors.SensorsTemperatures,
|
||||||
|
/*
|
||||||
|
Strings
|
||||||
|
*/
|
||||||
|
"extIndent": extIndent, // PR in: https://github.com/Masterminds/sprig/pull/468
|
||||||
|
/*
|
||||||
|
System/Platform
|
||||||
|
*/
|
||||||
|
"sysArch": sysArch,
|
||||||
|
"sysNumCpu": runtime.NumCPU,
|
||||||
|
"sysOsName": sysOsNm,
|
||||||
|
"sysRuntime": sysRuntime,
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// htmlMap holds functions usable/intended for use in only an [html/template.FuncMap].
|
// htmlMap holds functions usable/intended for use in only an [html/template.FuncMap].
|
||||||
|
|||||||
9
tplx/sprigx/consts_darwin.go
Normal file
9
tplx/sprigx/consts_darwin.go
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
//go:build darwin
|
||||||
|
|
||||||
|
package sprigx
|
||||||
|
|
||||||
|
var (
|
||||||
|
osGenericMap map[string]any = map[string]any{}
|
||||||
|
osHtmlMap map[string]any = map[string]any{}
|
||||||
|
osTxtMap map[string]any = map[string]any{}
|
||||||
|
)
|
||||||
25
tplx/sprigx/consts_linux.go
Normal file
25
tplx/sprigx/consts_linux.go
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
//go:build linux
|
||||||
|
|
||||||
|
package sprigx
|
||||||
|
|
||||||
|
import (
|
||||||
|
`github.com/shirou/gopsutil/v4/mem`
|
||||||
|
psnet `github.com/shirou/gopsutil/v4/net`
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
osGenericMap map[string]any = map[string]any{
|
||||||
|
/*
|
||||||
|
PSUtil
|
||||||
|
(https://pkg.go.dev/github.com/shirou/gopsutil/v4)
|
||||||
|
*/
|
||||||
|
// .../mem
|
||||||
|
"psMemExVMem": mem.NewExLinux().VirtualMemory,
|
||||||
|
// .../net
|
||||||
|
"psNetRev": psnet.Reverse,
|
||||||
|
// .../sensors
|
||||||
|
"psSensorExTemp": psSensorExTemp,
|
||||||
|
}
|
||||||
|
osHtmlMap map[string]any = map[string]any{}
|
||||||
|
osTxtMap map[string]any = map[string]any{}
|
||||||
|
)
|
||||||
9
tplx/sprigx/consts_unknown.go
Normal file
9
tplx/sprigx/consts_unknown.go
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
//go:build !(linux || windows || darwin)
|
||||||
|
|
||||||
|
package sprigx
|
||||||
|
|
||||||
|
var (
|
||||||
|
osGenericMap map[string]any = map[string]any{}
|
||||||
|
osHtmlMap map[string]any = map[string]any{}
|
||||||
|
osTxtMap map[string]any = map[string]any{}
|
||||||
|
)
|
||||||
24
tplx/sprigx/consts_windows.go
Normal file
24
tplx/sprigx/consts_windows.go
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
//go:build windows
|
||||||
|
|
||||||
|
package sprigx
|
||||||
|
|
||||||
|
import (
|
||||||
|
`github.com/shirou/gopsutil/v4/mem`
|
||||||
|
`github.com/shirou/gopsutil/v4/winservices`
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
osGenericMap map[string]any = map[string]any{
|
||||||
|
/*
|
||||||
|
PSUtil
|
||||||
|
(https://pkg.go.dev/github.com/shirou/gopsutil/v4)
|
||||||
|
*/
|
||||||
|
// .../mem
|
||||||
|
"psMemExVMem": mem.NewExWindows().VirtualMemory,
|
||||||
|
// .../winservices
|
||||||
|
"psWinsvcList": winservices.ListServices,
|
||||||
|
"psWinsvcNew": winservices.NewService,
|
||||||
|
}
|
||||||
|
osHtmlMap map[string]any = map[string]any{}
|
||||||
|
osTxtMap map[string]any = map[string]any{}
|
||||||
|
)
|
||||||
@@ -25,6 +25,11 @@ func FuncMap() (fmap map[string]any) {
|
|||||||
for fn, f = range genericMap {
|
for fn, f = range genericMap {
|
||||||
fmap[fn] = f
|
fmap[fn] = f
|
||||||
}
|
}
|
||||||
|
if osGenericMap != nil && len(osGenericMap) > 0 {
|
||||||
|
for fn, f = range osGenericMap {
|
||||||
|
fmap[fn] = f
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -43,6 +48,12 @@ func HtmlFuncMap() (fmap htpl.FuncMap) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if osHtmlMap != nil && len(osHtmlMap) > 0 {
|
||||||
|
for fn, f = range osHtmlMap {
|
||||||
|
fmap[fn] = f
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -60,5 +71,11 @@ func TxtFuncMap() (fmap ttpl.FuncMap) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if osTxtMap != nil && len(osTxtMap) > 0 {
|
||||||
|
for fn, f = range osTxtMap {
|
||||||
|
fmap[fn] = f
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,17 +0,0 @@
|
|||||||
package sprigx
|
|
||||||
|
|
||||||
import (
|
|
||||||
`github.com/davecgh/go-spew/spew`
|
|
||||||
)
|
|
||||||
|
|
||||||
/*
|
|
||||||
dump calls [spew.Sdump] on obj.
|
|
||||||
|
|
||||||
[spew.Sdump]: https://pkg.go.dev/github.com/davecgh/go-spew/spew
|
|
||||||
*/
|
|
||||||
func dump(obj any) (out string) {
|
|
||||||
|
|
||||||
out = spew.Sdump(obj)
|
|
||||||
|
|
||||||
return
|
|
||||||
}
|
|
||||||
14
tplx/sprigx/funcs_tpl_meta.go
Normal file
14
tplx/sprigx/funcs_tpl_meta.go
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
package sprigx
|
||||||
|
|
||||||
|
// Nop explicitly performs a NO-OP and returns an empty string, allowing one to override "unsafe" functions.
|
||||||
|
func Nop(obj ...any) (s string) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// metaIsNil returns true if obj is explicitly nil.
|
||||||
|
func metaIsNil(obj any) (isNil bool) {
|
||||||
|
|
||||||
|
isNil = obj == nil
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
@@ -1,13 +1,73 @@
|
|||||||
package sprigx
|
package sprigx
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"os"
|
`os`
|
||||||
|
`os/user`
|
||||||
|
`strconv`
|
||||||
|
`strings`
|
||||||
)
|
)
|
||||||
|
|
||||||
// osHostname returns os.Hostname()
|
// osGroupById returns os/user.LookupGroupId. Can accept either an integer or a string.
|
||||||
func osHostname() (out string, err error) {
|
func osGroupById[T string | int](gid T) (g *user.Group, err error) {
|
||||||
|
|
||||||
out, err = os.Hostname()
|
var gidStr string
|
||||||
|
|
||||||
|
switch t := any(gid).(type) {
|
||||||
|
case string:
|
||||||
|
gidStr = t
|
||||||
|
case int:
|
||||||
|
gidStr = strconv.Itoa(t)
|
||||||
|
}
|
||||||
|
|
||||||
|
g, err = user.LookupGroupId(gidStr)
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
osFQDN (tries to) return the FQDN of this host.
|
||||||
|
|
||||||
|
Currently it just calls os.Hostname() but may be extended to "try harder" in the future.
|
||||||
|
*/
|
||||||
|
func osFQDN() (fqdn string, err error) {
|
||||||
|
|
||||||
|
fqdn, err = os.Hostname()
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
osHost returns the system's "host shortname".
|
||||||
|
|
||||||
|
Currently it just calls os.Hostname() and takes the first
|
||||||
|
"host label" (as RFCs refer to it), but it may be extended
|
||||||
|
in the future.
|
||||||
|
*/
|
||||||
|
func osHost() (hostNm string, err error) {
|
||||||
|
|
||||||
|
hostNm, err = os.Hostname()
|
||||||
|
|
||||||
|
if hostNm == "" {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
hostNm = strings.Split(hostNm, ".")[0]
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// osUserById returns an os/user.LookupId. Can accept either an integer or a string.
|
||||||
|
func osUserById[T string | int](uid T) (u *user.User, err error) {
|
||||||
|
|
||||||
|
var uidStr string
|
||||||
|
|
||||||
|
switch t := any(uid).(type) {
|
||||||
|
case string:
|
||||||
|
uidStr = t
|
||||||
|
case int:
|
||||||
|
uidStr = strconv.Itoa(t)
|
||||||
|
}
|
||||||
|
|
||||||
|
u, err = user.LookupId(uidStr)
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
43
tplx/sprigx/funcs_tpl_psutils.go
Normal file
43
tplx/sprigx/funcs_tpl_psutils.go
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
package sprigx
|
||||||
|
|
||||||
|
import (
|
||||||
|
`github.com/shirou/gopsutil/v4/host`
|
||||||
|
)
|
||||||
|
|
||||||
|
/*
|
||||||
|
psHostPlatInfo returns a "squashed" github.com/shirou/gopsutil/v4/host.PlatformInformation;
|
||||||
|
normally it returns a (string, string, string, error)
|
||||||
|
but you can only have a (any) or (any, error) return in Golang templates.
|
||||||
|
*/
|
||||||
|
func psHostPlatInfo() (platInfo [3]string, err error) {
|
||||||
|
|
||||||
|
var s1 string
|
||||||
|
var s2 string
|
||||||
|
var s3 string
|
||||||
|
|
||||||
|
if s1, s2, s3, err = host.PlatformInformation(); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
platInfo = [3]string{s1, s2, s3}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
psHostVirt returns a "squared" github.com/shirou/gopsutil/v4/host.Virtualization;
|
||||||
|
normally it returns a (string, string, error) but Go templates etc.
|
||||||
|
*/
|
||||||
|
func psHostVirt() (virtInfo [2]string, err error) {
|
||||||
|
|
||||||
|
var s1 string
|
||||||
|
var s2 string
|
||||||
|
|
||||||
|
if s1, s2, err = host.Virtualization(); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
virtInfo = [2]string{s1, s2}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
15
tplx/sprigx/funcs_tpl_psutils_linux.go
Normal file
15
tplx/sprigx/funcs_tpl_psutils_linux.go
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
package sprigx
|
||||||
|
|
||||||
|
import (
|
||||||
|
`context`
|
||||||
|
|
||||||
|
`github.com/shirou/gopsutil/v4/sensors`
|
||||||
|
)
|
||||||
|
|
||||||
|
// psSensorExTemp wraps github.com/shirou/gopsutil/v4/sensors.NewExLinux().TemperatureWithContext() to not require a context.
|
||||||
|
func psSensorExTemp() (exTemps []sensors.ExTemperature, err error) {
|
||||||
|
|
||||||
|
exTemps, err = sensors.NewExLinux().TemperatureWithContext(context.Background())
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
@@ -5,6 +5,22 @@ import (
|
|||||||
`runtime`
|
`runtime`
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// sysArch returns [runtime.GOARCH].
|
||||||
|
func sysArch() (out string) {
|
||||||
|
|
||||||
|
out = runtime.GOARCH
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// sysOsNm returns [runtime.GOOS].
|
||||||
|
func sysOsNm() (out string) {
|
||||||
|
|
||||||
|
out = runtime.GOOS
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// sysRuntime returns various information from [runtime].
|
// sysRuntime returns various information from [runtime].
|
||||||
func sysRuntime() (out map[string]string) {
|
func sysRuntime() (out map[string]string) {
|
||||||
|
|
||||||
@@ -21,27 +37,3 @@ func sysRuntime() (out map[string]string) {
|
|||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// sysArch returns [runtime.GOARCH].
|
|
||||||
func sysArch() (out string) {
|
|
||||||
|
|
||||||
out = runtime.GOARCH
|
|
||||||
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// sysNumCpu returns the reuslt from [runtime.NumCPU].
|
|
||||||
func sysNumCpu() (out string) {
|
|
||||||
|
|
||||||
out = fmt.Sprintf("%d", runtime.NumCPU())
|
|
||||||
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// sysOsNm returns [runtime.GOOS].
|
|
||||||
func sysOsNm() (out string) {
|
|
||||||
|
|
||||||
out = runtime.GOOS
|
|
||||||
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user