diff --git a/README.md b/README.md index 0f71edc..4cef4cd 100644 --- a/README.md +++ b/README.md @@ -89,17 +89,48 @@ some methods. ```terminal ❯ nix run .# -- invoke org.freedesktop.systemd1 /org/freedesktop/systemd1 GetDefaultTarget +NKey: UAMLBE4LIDYXH6FO5LW6CPLEBZJ23I2OT3TPZYIJPQY5HJ46X3BU7UJK + +[default.target] + NKey: UBQUIKYGFC7CH5XMF52P2NN4ESI4XTXGAKT3WTG3XGU3352DMHGZQAX7 -["default.target"] +[default.target] NKey: UAILZJS66U24VALTH2D6OWVD5JTS3IDFMKOICJSOX7CHNAF3AXFVWIFX -["default.target"] +[default.target] -NKey: UAMLBE4LIDYXH6FO5LW6CPLEBZJ23I2OT3TPZYIJPQY5HJ46X3BU7UJK +``` -["default.target"] +JSON output with `-J` flag: + +```terminal +❯ nix run .# -- invoke org.freedesktop.systemd1 /org/freedesktop/systemd1 GetDefaultTarget -J | jq +{ + "destination": "org.freedesktop.systemd1", + "path": "/org/freedesktop/systemd1", + "responses": [ + { + "nkey": "UBQUIKYGFC7CH5XMF52P2NN4ESI4XTXGAKT3WTG3XGU3352DMHGZQAX7", + "value": [ + "default.target" + ] + }, + { + "nkey": "UAMLBE4LIDYXH6FO5LW6CPLEBZJ23I2OT3TPZYIJPQY5HJ46X3BU7UJK", + "value": [ + "default.target" + ] + }, + { + "nkey": "UAILZJS66U24VALTH2D6OWVD5JTS3IDFMKOICJSOX7CHNAF3AXFVWIFX", + "value": [ + "default.target" + ] + } + ] +} ``` #### Get a property on all machines @@ -109,17 +140,42 @@ NKey: UAMLBE4LIDYXH6FO5LW6CPLEBZJ23I2OT3TPZYIJPQY5HJ46X3BU7UJK NKey: UBQUIKYGFC7CH5XMF52P2NN4ESI4XTXGAKT3WTG3XGU3352DMHGZQAX7 Signature: s -"active" +active -NKey: UAMLBE4LIDYXH6FO5LW6CPLEBZJ23I2OT3TPZYIJPQY5HJ46X3BU7UJK +NKey: UAILZJS66U24VALTH2D6OWVD5JTS3IDFMKOICJSOX7CHNAF3AXFVWIFX Signature: s -"active" +active -NKey: UAILZJS66U24VALTH2D6OWVD5JTS3IDFMKOICJSOX7CHNAF3AXFVWIFX +NKey: UAMLBE4LIDYXH6FO5LW6CPLEBZJ23I2OT3TPZYIJPQY5HJ46X3BU7UJK Signature: s -"active" +active + +``` + +JSON output with `-J` flag: + +```terminal +❯ nix run .# -- get org.freedesktop.systemd1 /org/freedesktop/systemd1/unit/basic_2etarget ActiveState -J | jq +{ + "destination": "org.freedesktop.systemd1", + "path": "/org/freedesktop/systemd1/unit/basic_2etarget", + "responses": [ + { + "nkey": "UAILZJS66U24VALTH2D6OWVD5JTS3IDFMKOICJSOX7CHNAF3AXFVWIFX", + "value": "active" + }, + { + "nkey": "UBQUIKYGFC7CH5XMF52P2NN4ESI4XTXGAKT3WTG3XGU3352DMHGZQAX7", + "value": "active" + }, + { + "nkey": "UAMLBE4LIDYXH6FO5LW6CPLEBZJ23I2OT3TPZYIJPQY5HJ46X3BU7UJK", + "value": "active" + } + ] +} ``` #### Get a property on a list of machines by NATS NKey @@ -129,12 +185,32 @@ Signature: s Signature: s NKey: UAMLBE4LIDYXH6FO5LW6CPLEBZJ23I2OT3TPZYIJPQY5HJ46X3BU7UJK -"active" +active NKey: UBQUIKYGFC7CH5XMF52P2NN4ESI4XTXGAKT3WTG3XGU3352DMHGZQAX7 Signature: s -"active" +active +``` + +JSON output with `-J` flag: + +```terminal +❯ nix run .# -- get org.freedesktop.systemd1 /org/freedesktop/systemd1/unit/basic_2etarget ActiveState --nkeys UBQUIKYGFC7CH5XMF52P2NN4ESI4XTXGAKT3WTG3XGU3352DMHGZQAX7,UAMLBE4LIDYXH6FO5LW6CPLEBZJ23I2OT3TPZYIJPQY5HJ46X3BU7UJK -J | jq +{ + "destination": "org.freedesktop.systemd1", + "path": "/org/freedesktop/systemd1/unit/basic_2etarget", + "responses": [ + { + "nkey": "UBQUIKYGFC7CH5XMF52P2NN4ESI4XTXGAKT3WTG3XGU3352DMHGZQAX7", + "value": "active" + }, + { + "nkey": "UAMLBE4LIDYXH6FO5LW6CPLEBZJ23I2OT3TPZYIJPQY5HJ46X3BU7UJK", + "value": "active" + } + ] +} ``` #### Listen for all signals from each machine diff --git a/go.mod b/go.mod index 3f0f78d..b3514f4 100644 --- a/go.mod +++ b/go.mod @@ -7,11 +7,11 @@ require ( github.com/charmbracelet/log v0.4.0 github.com/godbus/dbus/v5 v5.1.0 github.com/juju/errors v1.0.0 - github.com/nats-io/nats.go v1.33.1 + github.com/nats-io/nats.go v1.34.1 github.com/numtide/nits v0.0.0-20240315145428-585ec33b9d48 github.com/ztrue/shutdown v0.1.1 - golang.org/x/crypto v0.21.0 - golang.org/x/sync v0.6.0 + golang.org/x/crypto v0.22.0 + golang.org/x/sync v0.7.0 ) require ( @@ -20,18 +20,21 @@ require ( github.com/blang/semver v3.5.1+incompatible // indirect github.com/briandowns/spinner v1.23.0 // indirect github.com/charmbracelet/lipgloss v0.10.0 // indirect - github.com/cpuguy83/go-md2man/v2 v2.0.3 // indirect + github.com/cpuguy83/go-md2man/v2 v2.0.4 // indirect github.com/dustin/go-humanize v1.0.1 // indirect + github.com/ettle/strcase v0.2.0 // indirect github.com/fatih/color v1.16.0 // indirect github.com/go-logfmt/logfmt v0.6.0 // indirect + github.com/go-ole/go-ole v1.3.0 // indirect github.com/golang/protobuf v1.5.4 // indirect github.com/google/go-github/v30 v30.1.0 // indirect github.com/google/go-querystring v1.1.0 // indirect github.com/inconshreveable/go-update v0.0.0-20160112193335-8152e7eb6ccf // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect - github.com/klauspost/compress v1.17.7 // indirect + github.com/klauspost/compress v1.17.8 // indirect github.com/lucasb-eyer/go-colorful v1.2.0 // indirect + github.com/lufia/plan9stats v0.0.0-20240408141607-282e7b5d6b74 // indirect github.com/mattn/go-colorable v0.1.13 // indirect github.com/mattn/go-isatty v0.0.20 // indirect github.com/mattn/go-runewidth v0.0.15 // indirect @@ -46,20 +49,27 @@ require ( github.com/nats-io/nkeys v0.4.7 // indirect github.com/nats-io/nsc/v2 v2.8.6 // indirect github.com/nats-io/nuid v1.0.1 // indirect + github.com/nix-community/go-nix v0.0.0-20231219074122-93cb24a86856 // indirect + github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55 // indirect github.com/rhysd/go-github-selfupdate v1.2.3 // indirect github.com/rivo/uniseg v0.4.7 // indirect github.com/rogpeppe/go-internal v1.12.0 // indirect github.com/russross/blackfriday/v2 v2.1.0 // indirect + github.com/shirou/gopsutil/v3 v3.24.3 // indirect + github.com/shoenig/go-m1cpu v0.1.6 // indirect github.com/spf13/cobra v1.8.0 // indirect github.com/spf13/pflag v1.0.5 // indirect github.com/tcnksm/go-gitconfig v0.1.2 // indirect - github.com/ulikunitz/xz v0.5.11 // indirect + github.com/tklauser/go-sysconf v0.3.13 // indirect + github.com/tklauser/numcpus v0.7.0 // indirect + github.com/ulikunitz/xz v0.5.12 // indirect github.com/xlab/tablewriter v0.0.0-20160610135559-80b567a11ad5 // indirect - golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 // indirect - golang.org/x/net v0.22.0 // indirect - golang.org/x/oauth2 v0.18.0 // indirect - golang.org/x/sys v0.18.0 // indirect - golang.org/x/term v0.18.0 // indirect + github.com/yusufpapurcu/wmi v1.2.4 // indirect + golang.org/x/exp v0.0.0-20240409090435-93d18d7e34b8 // indirect + golang.org/x/net v0.24.0 // indirect + golang.org/x/oauth2 v0.19.0 // indirect + golang.org/x/sys v0.19.0 // indirect + golang.org/x/term v0.19.0 // indirect golang.org/x/text v0.14.0 // indirect google.golang.org/appengine v1.6.8 // indirect google.golang.org/protobuf v1.33.0 // indirect diff --git a/go.sum b/go.sum index 8c160ff..2ce25b6 100644 --- a/go.sum +++ b/go.sum @@ -22,6 +22,8 @@ github.com/charmbracelet/log v0.4.0 h1:G9bQAcx8rWA2T3pWvx7YtPTPwgqpk7D68BX21IRW8 github.com/charmbracelet/log v0.4.0/go.mod h1:63bXt/djrizTec0l11H20t8FDSvA4CRZJ1KH22MdptM= github.com/cpuguy83/go-md2man/v2 v2.0.3 h1:qMCsGGgs+MAzDFyp9LpAe1Lqy/fY/qCovCm0qnXZOBM= github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= +github.com/cpuguy83/go-md2man/v2 v2.0.4 h1:wfIWP927BUkWJb2NmU/kNDYIBTh/ziUX91+lVfRxZq4= +github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/creack/pty v1.1.17 h1:QeVUsEDNrLBW4tMgZHvxy18sKtr6VI492kBhUfhDJNI= github.com/creack/pty v1.1.17/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -29,11 +31,16 @@ 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/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY= github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto= +github.com/ettle/strcase v0.2.0 h1:fGNiVF21fHXpX1niBgk0aROov1LagYsOwV/xqKDKR/Q= +github.com/ettle/strcase v0.2.0/go.mod h1:DajmHElDSaX76ITe3/VHVyMin4LWSJN5Z909Wp+ED1A= github.com/fatih/color v1.16.0 h1:zmkK9Ngbjj+K0yRhTVONQh1p/HknKYSlNT+vZCzyokM= github.com/fatih/color v1.16.0/go.mod h1:fL2Sau1YI5c0pdGEVCbKQbLXB6edEj1ZgiY4NijnWvE= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/go-logfmt/logfmt v0.6.0 h1:wGYYu3uicYdqXVgoYbvnkrPVXkuLM1p1ifugDMEdRi4= github.com/go-logfmt/logfmt v0.6.0/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs= +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/godbus/dbus/v5 v5.1.0 h1:4KLkAxT3aOY8Li4FRJe/KvhoNFFxo0m6fNuFUO8QJUk= github.com/godbus/dbus/v5 v5.1.0/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= @@ -44,6 +51,8 @@ github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5/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.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-github/v30 v30.1.0 h1:VLDx+UolQICEOKu2m4uAoMti1SxuEBAl7RSEG16L+Oo= @@ -67,6 +76,8 @@ github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 h1:Z9n2FFNU github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51/go.mod h1:CzGEWj7cYgsdH8dAjBGEr58BoE7ScuLd+fwFZ44+/x8= github.com/klauspost/compress v1.17.7 h1:ehO88t2UGzQK66LMdE8tibEd1ErmzZjNEqWkjLAKQQg= github.com/klauspost/compress v1.17.7/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw= +github.com/klauspost/compress v1.17.8 h1:YcnTYrq7MikUT7k0Yb5eceMmALQPYBW/Xltxn0NAMnU= +github.com/klauspost/compress v1.17.8/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= @@ -77,6 +88,9 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69Aj6K7nkY= github.com/lucasb-eyer/go-colorful v1.2.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0= +github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0/go.mod h1:zJYVVT2jmtg6P3p1VtQj7WsuWi/y4VnjVBn7F8KPB3I= +github.com/lufia/plan9stats v0.0.0-20240408141607-282e7b5d6b74 h1:1KuuSOy4ZNgW0KA2oYIngXVFhQcXxhLqCVK7cBcldkk= +github.com/lufia/plan9stats v0.0.0-20240408141607-282e7b5d6b74/go.mod h1:ilwx/Dta8jXAgpFYFvSWEMwxmbWXyiUHkd5FwyKhb5k= github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= @@ -111,12 +125,16 @@ github.com/nats-io/nats-server/v2 v2.10.12 h1:G6u+RDrHkw4bkwn7I911O5jqys7jJVRY6M github.com/nats-io/nats-server/v2 v2.10.12/go.mod h1:H1n6zXtYLFCgXcf/SF8QNTSIFuS8tyZQMN9NguUHdEs= github.com/nats-io/nats.go v1.33.1 h1:8TxLZZ/seeEfR97qV0/Bl939tpDnt2Z2fK3HkPypj70= github.com/nats-io/nats.go v1.33.1/go.mod h1:Ubdu4Nh9exXdSz0RVWRFBbRfrbSxOYd26oF0wkWclB8= +github.com/nats-io/nats.go v1.34.1 h1:syWey5xaNHZgicYBemv0nohUPPmaLteiBEUT6Q5+F/4= +github.com/nats-io/nats.go v1.34.1/go.mod h1:Ubdu4Nh9exXdSz0RVWRFBbRfrbSxOYd26oF0wkWclB8= github.com/nats-io/nkeys v0.4.7 h1:RwNJbbIdYCoClSDNY7QVKZlyb/wfT6ugvFCiKy6vDvI= github.com/nats-io/nkeys v0.4.7/go.mod h1:kqXRgRDPlGy7nGaEDMuYzmiJCIAAWDK0IMBtDmGD0nc= github.com/nats-io/nsc/v2 v2.8.6 h1:ytf5F2mb+BXx8DjXImPyqOZrFFozt9umQGuQ+6m9eXs= github.com/nats-io/nsc/v2 v2.8.6/go.mod h1:jHj6s7VspjVwl0NRoWjVN+gqVvhA+NdkTpAk/WZg5yk= github.com/nats-io/nuid v1.0.1 h1:5iA8DT8V7q8WK2EScv2padNa/rTESc1KdnPw4TC2paw= github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c= +github.com/nix-community/go-nix v0.0.0-20231219074122-93cb24a86856 h1:CHnKW7ZH43KDkO9vDazQefi82Z0l1smKhSOpMsV1A9I= +github.com/nix-community/go-nix v0.0.0-20231219074122-93cb24a86856/go.mod h1:0FdXufC8BrrWsr65fGYC0fI6hlk4ku+JHGUiYhX/6g4= github.com/numtide/nits v0.0.0-20240315145428-585ec33b9d48 h1:G5HnXGpaWMTuYi2Burn+1xDYH/HsMI8CPguA3cTC5kU= github.com/numtide/nits v0.0.0-20240315145428-585ec33b9d48/go.mod h1:pjyRiQxz5gTUqquWZQoJXyPkXb+h3ux5g2br0klWaPI= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= @@ -125,6 +143,9 @@ github.com/onsi/gomega v1.4.3 h1:RE1xgDvH7imwFD45h+u2SgIfERHlS2yNG4DObb5BSKU= github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= 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/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c/go.mod h1:OmDBASR4679mdNQnz2pUhc2G8CO2JrUAVFDRBDP/hJE= +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/rhysd/go-github-selfupdate v1.2.3 h1:iaa+J202f+Nc+A8zi75uccC8Wg3omaM7HDeimXA22Ag= github.com/rhysd/go-github-selfupdate v1.2.3/go.mod h1:mp/N8zj6jFfBQy/XMYoWsmfzxazpPAODuqarmPDe2Rg= github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= @@ -135,23 +156,44 @@ github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4= github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= +github.com/shirou/gopsutil/v3 v3.24.3 h1:eoUGJSmdfLzJ3mxIhmOAhgKEKgQkeOwKpz1NbhVnuPE= +github.com/shirou/gopsutil/v3 v3.24.3/go.mod h1:JpND7O217xa72ewWz9zN2eIIkPWsDN/3pl0H8Qt0uwg= +github.com/shoenig/go-m1cpu v0.1.6 h1:nxdKQNcEB6vzgA2E2bvzKIYRuNj7XNJ4S/aRSwKzFtM= +github.com/shoenig/go-m1cpu v0.1.6/go.mod h1:1JJMcUBvfNwpq05QDQVAnx3gUHr9IYF7GNg9SUEw2VQ= +github.com/shoenig/test v0.6.4/go.mod h1:byHiCGXqrVaflBLAMq/srcZIHynQPQgeyvkvXnjqq0k= github.com/spf13/cobra v1.8.0 h1:7aJaZx1B85qltLMc546zn58BxxfZdR/W22ej9CFoEf0= github.com/spf13/cobra v1.8.0/go.mod h1:WXLWApfZ71AjXPya3WOlMsY9yMs7YeiHhFVlvLyhcho= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= +github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= +github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= github.com/stretchr/testify v1.2.1/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= +github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/tcnksm/go-gitconfig v0.1.2 h1:iiDhRitByXAEyjgBqsKi9QU4o2TNtv9kPP3RgPgXBPw= github.com/tcnksm/go-gitconfig v0.1.2/go.mod h1:/8EhP4H7oJZdIPyT+/UIsG87kTzrzM4UsLGSItWYCpE= +github.com/tklauser/go-sysconf v0.3.12/go.mod h1:Ho14jnntGE1fpdOqQEEaiKRpvIavV0hSfmBq8nJbHYI= +github.com/tklauser/go-sysconf v0.3.13 h1:GBUpcahXSpR2xN01jhkNAbTLRk2Yzgggk8IM08lq3r4= +github.com/tklauser/go-sysconf v0.3.13/go.mod h1:zwleP4Q4OehZHGn4CYZDipCgg9usW5IJePewFCGVEa0= +github.com/tklauser/numcpus v0.6.1/go.mod h1:1XfjsgE2zo8GVw7POkMbHENHzVg3GzmoZ9fESEdAacY= +github.com/tklauser/numcpus v0.7.0 h1:yjuerZP127QG9m5Zh/mSO4wqurYil27tHrqwRoRjpr4= +github.com/tklauser/numcpus v0.7.0/go.mod h1:bb6dMVcj8A42tSE7i32fsIUCbQNllK5iDguyOZRUzAY= github.com/ulikunitz/xz v0.5.9/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14= github.com/ulikunitz/xz v0.5.11 h1:kpFauv27b6ynzBNT/Xy+1k+fK4WswhN/6PN5WhFAGw8= github.com/ulikunitz/xz v0.5.11/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14= +github.com/ulikunitz/xz v0.5.12 h1:37Nm15o69RwBkXM0J6A5OlE67RZTfzUxTj8fB3dfcsc= +github.com/ulikunitz/xz v0.5.12/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14= github.com/xlab/tablewriter v0.0.0-20160610135559-80b567a11ad5 h1:gmD7q6cCJfBbcuobWQe/KzLsd9Cd3amS1Mq5f3uU1qo= github.com/xlab/tablewriter v0.0.0-20160610135559-80b567a11ad5/go.mod h1:fVwOndYN3s5IaGlMucfgxwMhqwcaJtlGejBU6zX6Yxw= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= +github.com/yusufpapurcu/wmi v1.2.4 h1:zFUKzehAFReQwLys1b/iSMl+JQGSCSjtVqQn9bBrPo0= +github.com/yusufpapurcu/wmi v1.2.4/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0= github.com/ztrue/shutdown v0.1.1 h1:GKR2ye2OSQlq1GNVE/s2NbrIMsFdmL+NdR6z6t1k+Tg= github.com/ztrue/shutdown v0.1.1/go.mod h1:hcMWcM2SwIsQk7Wb49aYme4tX66x6iLzs07w1OYAQLw= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= @@ -160,8 +202,12 @@ golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad/go.mod h1:jdWPYTVW3xRLrWP golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA= golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs= +golang.org/x/crypto v0.22.0 h1:g1v0xeRhjcugydODzvb3mEM9SQ0HGp9s/nh3COQ/C30= +golang.org/x/crypto v0.22.0/go.mod h1:vr6Su+7cTlO45qkww3VDJlzDn0ctJvRgYbC2NvXHt+M= golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 h1:LfspQV/FYTatPTr/3HzIcmiUFH7PGP+OQ6mgDYo3yuQ= golang.org/x/exp v0.0.0-20240222234643-814bf88cf225/go.mod h1:CxmFvTBINI24O/j8iY7H1xHzx2i4OsyguNBmN/uPtqc= +golang.org/x/exp v0.0.0-20240409090435-93d18d7e34b8 h1:ESSUROHIBHg7USnszlcdmjBEwdMj9VUvU+OPk4yl2mc= +golang.org/x/exp v0.0.0-20240409090435-93d18d7e34b8/go.mod h1:/lliqkxwWAhPjf5oSOIJup2XcqJaw8RGS6k3TGEc7GI= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -172,34 +218,49 @@ golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.22.0 h1:9sGLhx7iRIHEiX0oAJ3MRZMUCElJgy7Br1nO+AMN3Tc= golang.org/x/net v0.22.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= +golang.org/x/net v0.24.0 h1:1PcaxkF854Fu3+lvBIx5SYn9wRlBzzcnHZSiaFFAb0w= +golang.org/x/net v0.24.0/go.mod h1:2Q7sJY5mzlzWjKtYUEXSlBWCdyaioyXzRB2RtU8KVE8= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20181106182150-f42d05182288/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.18.0 h1:09qnuIAgzdx1XplqJvW6CQqMCtGZykZWcXzPMPUusvI= golang.org/x/oauth2 v0.18.0/go.mod h1:Wf7knwG0MPoWIMMBgFlEaSUDaKskp0dCfrlJRJXbBi8= +golang.org/x/oauth2 v0.19.0 h1:9+E/EZBCbTLNrbN35fHv/a/d/mOBatymz1zbtQrXpIg= +golang.org/x/oauth2 v0.19.0/go.mod h1:vYi7skDa1x015PmRRYZ7+s1cWyPgrPiSYRe4rnsexc8= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ= golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M= +golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190530182044-ad28b68e88f1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201204225414-ed752295db88/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/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.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.19.0 h1:q5f1RH2jigJ1MoAWp2KTp3gm5zAGFUTarQZ5U386+4o= +golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.18.0 h1:FcHjZXDMxI8mM3nwhX9HlKop4C0YQvCVCdwYl2wOtE8= golang.org/x/term v0.18.0/go.mod h1:ILwASektA3OnRv7amZ1xhE/KTR+u50pbXfZ03+6Nx58= +golang.org/x/term v0.19.0 h1:+ThwsDv+tYfnJFhF4L8jITxu1tdTWRTZpdsWgEgjL6Q= +golang.org/x/term v0.19.0/go.mod h1:2CuTdWZ7KHSQwUzKva0cbMg6q2DMI3Mmxp+gKJbskEk= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= diff --git a/gomod2nix.toml b/gomod2nix.toml index e6e3c49..67b44b1 100644 --- a/gomod2nix.toml +++ b/gomod2nix.toml @@ -23,17 +23,23 @@ schema = 3 version = "v0.4.0" hash = "sha256-VQerB44vC646n3fe3haJ3DHa9L5+GRhCfDfm1p3QnZk=" [mod."github.com/cpuguy83/go-md2man/v2"] - version = "v2.0.3" - hash = "sha256-FAMxR5eBO9LQp6ev1b7zaPUS5aoNz1GtsPpoArjiJVw=" + version = "v2.0.4" + hash = "sha256-pQ+H8Psh92KWTang8hK0cHFLomH+4X0rMMilIJUQ4Qc=" [mod."github.com/dustin/go-humanize"] version = "v1.0.1" hash = "sha256-yuvxYYngpfVkUg9yAmG99IUVmADTQA0tMbBXe0Fq0Mc=" + [mod."github.com/ettle/strcase"] + version = "v0.2.0" + hash = "sha256-FSoHfW0jeHUQ1PeKcPeVcWDtJLDV+EzCvpyzk3y7su4=" [mod."github.com/fatih/color"] version = "v1.16.0" hash = "sha256-Aq/SM28aPJVzvapllQ64R/DM4aZ5CHPewcm/AUJPyJQ=" [mod."github.com/go-logfmt/logfmt"] version = "v0.6.0" hash = "sha256-RtIG2qARd5sT10WQ7F3LR8YJhS8exs+KiuUiVf75bWg=" + [mod."github.com/go-ole/go-ole"] + version = "v1.3.0" + hash = "sha256-tF8t3VcV71jQ4jbPL91BwR59AKDpUAFV1waIKzkXJu8=" [mod."github.com/godbus/dbus/v5"] version = "v5.1.0" hash = "sha256-xOCMJpQK3KTmHTPn/CdqI4j0eENCtMmJDgAIoYqYOEY=" @@ -59,11 +65,14 @@ schema = 3 version = "v0.0.0-20180428030007-95032a82bc51" hash = "sha256-AOEdKETBMUC39ln6jBJ9NYdJWp++jV5lSbjNqG3dV+c=" [mod."github.com/klauspost/compress"] - version = "v1.17.7" - hash = "sha256-UkW+tAFEZYj067z9gXDQjQx0dCF8noCn5OSw/APh4oo=" + version = "v1.17.8" + hash = "sha256-8rgCCfHX29le8m6fyVn6gwFde5TPUHjwQqZqv9JIubs=" [mod."github.com/lucasb-eyer/go-colorful"] version = "v1.2.0" hash = "sha256-Gg9dDJFCTaHrKHRR1SrJgZ8fWieJkybljybkI9x0gyE=" + [mod."github.com/lufia/plan9stats"] + version = "v0.0.0-20240408141607-282e7b5d6b74" + hash = "sha256-mP87o1VlEDpDdEgRrBsAWs79J4AIN8/vyqa2E0FLCvM=" [mod."github.com/mattn/go-colorable"] version = "v0.1.13" hash = "sha256-qb3Qbo0CELGRIzvw7NVM1g/aayaz4Tguppk9MD2/OI8=" @@ -98,8 +107,8 @@ schema = 3 version = "v2.5.5" hash = "sha256-p5CxpfAcUpbjePxFeZM5+7HnJpxWBfm6vV/1OISME5U=" [mod."github.com/nats-io/nats.go"] - version = "v1.33.1" - hash = "sha256-c7Ttinyz8XQU9iVbzRemo8alx+/l9uLi2YizGO/sNpo=" + version = "v1.34.1" + hash = "sha256-vQo2j9yTfUaC/6PwLv77xHzeWgQCn3h1FgtAzZ6KjMc=" [mod."github.com/nats-io/nkeys"] version = "v0.4.7" hash = "sha256-ui/vSa2TGe6Pe2aAzitBa1Pd2vKgTMuHoBhYYy2p6Rw=" @@ -109,9 +118,15 @@ schema = 3 [mod."github.com/nats-io/nuid"] version = "v1.0.1" hash = "sha256-7wddxVz3hnFg/Pf+61+MtQJJL/l8EaC8brHoNsmD64c=" + [mod."github.com/nix-community/go-nix"] + version = "v0.0.0-20231219074122-93cb24a86856" + hash = "sha256-gCRU9d4tuGP70i2IA2pl+ZcowHrWfN4mdOnQQR7AnH4=" [mod."github.com/numtide/nits"] version = "v0.0.0-20240315145428-585ec33b9d48" hash = "sha256-VqS30X5Ttp+Oqv+lfKcfcGQ6FiW8nqY66OHJMFqCEdE=" + [mod."github.com/power-devops/perfstat"] + version = "v0.0.0-20240221224432-82ca36839d55" + hash = "sha256-ujzuJ1ttQgjHQJEij4O/2+I8DZaUVZQCQgA4ysfqulI=" [mod."github.com/rhysd/go-github-selfupdate"] version = "v1.2.3" hash = "sha256-LxN1JfZFgGJu5cURbwwEIgPLuniuyGAubkVJ//H92oY=" @@ -124,6 +139,12 @@ schema = 3 [mod."github.com/russross/blackfriday/v2"] version = "v2.1.0" hash = "sha256-R+84l1si8az5yDqd5CYcFrTyNZ1eSYlpXKq6nFt4OTQ=" + [mod."github.com/shirou/gopsutil/v3"] + version = "v3.24.3" + hash = "sha256-p4NRcl0Zi49bzs+pkc164Q71Kc190vi/AdvNIzSNJqA=" + [mod."github.com/shoenig/go-m1cpu"] + version = "v0.1.6" + hash = "sha256-hT+JP30BBllsXosK/lo89HV/uxxPLsUyO3dRaDiLnCg=" [mod."github.com/spf13/cobra"] version = "v1.8.0" hash = "sha256-oAE+fEaRfZPE541IPWE0GMeBBYgH2DMhtZNxzp7DFlY=" @@ -133,36 +154,45 @@ schema = 3 [mod."github.com/tcnksm/go-gitconfig"] version = "v0.1.2" hash = "sha256-qSpRWf6MX2UX0teqSd4Bk8Lt5hksljEnzs8eONCA52s=" + [mod."github.com/tklauser/go-sysconf"] + version = "v0.3.13" + hash = "sha256-qU5jDtQWJO4icuDs7KVR/CUuYEolEW3ASQhWy2yNcx8=" + [mod."github.com/tklauser/numcpus"] + version = "v0.7.0" + hash = "sha256-yLlJ1flprZ1FrsQEUXnNIeAN/bKpNTz3Fweb/AWZnPU=" [mod."github.com/ulikunitz/xz"] - version = "v0.5.11" - hash = "sha256-SUyrjc2wyN3cTGKe5JdBEXjtZC1rJySRxJHVUZ59row=" + version = "v0.5.12" + hash = "sha256-i8IGHLdPZkKsmgHNB2cHHI4/493tJh7uiBzoKXXXgOA=" [mod."github.com/xlab/tablewriter"] version = "v0.0.0-20160610135559-80b567a11ad5" hash = "sha256-TiC96KSeXP3eCTelzgU0LndtM602zc5dHNYwJhLH6SQ=" + [mod."github.com/yusufpapurcu/wmi"] + version = "v1.2.4" + hash = "sha256-N+YDBjOW59YOsZ2lRBVtFsEEi48KhNQRb63/0ZSU3bA=" [mod."github.com/ztrue/shutdown"] version = "v0.1.1" hash = "sha256-+ygx5THHu9g+vBAn6b63tV35bvQGdRyto4pLhkontJI=" [mod."golang.org/x/crypto"] - version = "v0.21.0" - hash = "sha256-Z4k1LvFh4Jai7HUe6TTuXSG3VnuiRpMwdARIdZZqSYk=" + version = "v0.22.0" + hash = "sha256-2+u9nd32+Bi7EEv7QFc12CRTbfV7DApNv+yKIr7+lTw=" [mod."golang.org/x/exp"] - version = "v0.0.0-20240222234643-814bf88cf225" - hash = "sha256-DM6/KUjyqyuqXai7UH1vMsoKXQAlYfcHTwK1dHqjRAc=" + version = "v0.0.0-20240409090435-93d18d7e34b8" + hash = "sha256-yJ9KBMmck/gGGTwPx26kZzqBHlh3sn3kKVjwBI1OB0w=" [mod."golang.org/x/net"] - version = "v0.22.0" - hash = "sha256-pcefO4noO9I6mATKBWF6shgIjZvFg0kDsV1Jo/NsFns=" + version = "v0.24.0" + hash = "sha256-w1c21ljta5wNIyel9CSIn/crPzwOCRofNKhqmfs4aEQ=" [mod."golang.org/x/oauth2"] - version = "v0.18.0" - hash = "sha256-TX4CvtvHU+SGSmqlxaQqlgJjlJiOtLGYAZa0zeBfZak=" + version = "v0.19.0" + hash = "sha256-IYdkq8R8BXnwoBt/ZLAMJr0DkLZDMVkjeBJNQ/Z9Bes=" [mod."golang.org/x/sync"] - version = "v0.6.0" - hash = "sha256-LLims/wjDZtIqlYCVHREewcUOX4hwRwplEuZKPOJ/HI=" + version = "v0.7.0" + hash = "sha256-2ETllEu2GDWoOd/yMkOkLC2hWBpKzbVZ8LhjLu0d2A8=" [mod."golang.org/x/sys"] - version = "v0.18.0" - hash = "sha256-bIFhfFp7Sj0E1gcE3X3l/jecCfSRLgrkb8f0Yr6tVR0=" + version = "v0.19.0" + hash = "sha256-cmuL31TYLJmDm/fDnI2Sn0wB88cpdOHV1+urorsJWx4=" [mod."golang.org/x/term"] - version = "v0.18.0" - hash = "sha256-lpze9arFZIhBV8Ht3VZyoiUwqPkeH2IwfXt8M3xljiM=" + version = "v0.19.0" + hash = "sha256-wFwEMwhtsr0C4mqjxukjMM7lxJLYPvb7gAPO95xyhyg=" [mod."golang.org/x/text"] version = "v0.14.0" hash = "sha256-yh3B0tom1RfzQBf1RNmfdNWF1PtiqxV41jW1GVS6JAg=" diff --git a/internal/cmd/cli/Invoke.go b/internal/cmd/cli/Invoke.go index 6909613..0161975 100644 --- a/internal/cmd/cli/Invoke.go +++ b/internal/cmd/cli/Invoke.go @@ -6,7 +6,6 @@ import ( "strings" "time" - "github.com/nats-io/nats.go" "golang.org/x/sync/errgroup" "github.com/brianmcgee/cbus/pkg/rpc" @@ -30,19 +29,33 @@ func (i *Invoke) Run() (err error) { ctx, cancel := context.WithTimeout(context.Background(), time.Second) defer cancel() - respCh := make(chan *nats.Msg, 16) + respCh := make(chan *rpc.Response, 16) eg, ctx := errgroup.WithContext(ctx) eg.Go(func() error { return rpc.InvokeMethod(ctx, i.Destination, i.Path, i.Property, respCh, i.Nkeys...) }) - for msg := range respCh { - for k, v := range msg.Header { + var responses responseList + for resp := range respCh { + responses = append(responses, resp) + } + + for resp := range respCh { + for k, v := range resp.Msg.Header { fmt.Printf("%s: %s\n", k, strings.Join(v, ",")) } - fmt.Println("\n" + string(msg.Data) + "\n") + fmt.Println("\n" + string(resp.Value) + "\n") + } + + if err = eg.Wait(); err != nil { + return err } - return eg.Wait() + if CLI.Json { + return printResponsesAsJson(i.Destination, i.Path, responses) + } else { + responses.Print() + return nil + } } diff --git a/internal/cmd/cli/get.go b/internal/cmd/cli/get.go index 4ac5ddf..a7e1d49 100644 --- a/internal/cmd/cli/get.go +++ b/internal/cmd/cli/get.go @@ -2,17 +2,40 @@ package cli import ( "context" + "encoding/json" "fmt" "strings" "time" - "github.com/nats-io/nats.go" "golang.org/x/sync/errgroup" "github.com/brianmcgee/cbus/pkg/rpc" nutil "github.com/numtide/nits/pkg/nats" ) +type responseList []*rpc.Response + +func (rl responseList) Print() { + for _, resp := range rl { + for k, v := range resp.Msg.Header { + fmt.Printf("%s: %s\n", k, strings.Join(v, ",")) + } + var value interface{} + if resp.Value != nil { + if err := json.Unmarshal(resp.Value, &value); err != nil { + value = err.Error() + } + } + fmt.Printf("\n%v\n\n", value) + } +} + +type result struct { + Destination string `json:"destination"` + Path string `json:"path"` + Responses responseList `json:"responses"` +} + type Get struct { Nats nutil.CliOptions `embed:"" prefix:"nats-"` Destination string `arg:"" help:"The bus to target"` @@ -30,19 +53,40 @@ func (g *Get) Run() (err error) { ctx, cancel := context.WithTimeout(context.Background(), time.Second) defer cancel() - respCh := make(chan *nats.Msg, 16) + respCh := make(chan *rpc.Response, 16) eg, ctx := errgroup.WithContext(ctx) eg.Go(func() error { return rpc.GetProperty(ctx, g.Destination, g.Path, g.Property, respCh, g.Nkeys...) }) - for msg := range respCh { - for k, v := range msg.Header { - fmt.Printf("%s: %s\n", k, strings.Join(v, ",")) - } - fmt.Println("\n" + string(msg.Data) + "\n") + var responses responseList + for resp := range respCh { + responses = append(responses, resp) + } + + if err = eg.Wait(); err != nil { + return err + } + + if CLI.Json { + return printResponsesAsJson(g.Destination, g.Path, responses) + } else { + responses.Print() + return nil } +} + +func printResponsesAsJson(dest string, path string, responses responseList) error { + result := result{} + result.Destination = dest + result.Path = path + result.Responses = responses - return eg.Wait() + bytes, err := json.Marshal(result) + if err != nil { + return err + } + fmt.Printf("%s\n", string(bytes)) + return nil } diff --git a/pkg/agent/proxy.go b/pkg/agent/proxy.go index 57ed6dd..73cb72f 100644 --- a/pkg/agent/proxy.go +++ b/pkg/agent/proxy.go @@ -143,6 +143,10 @@ func removeDestination(dest string) error { } func busHandler(req micro.Request) { + // response headers to include whether there is an error or not + respHeaders := micro.Headers{"NKey": []string{nkey}} + respOpts := []micro.RespondOpt{micro.WithHeaders(respHeaders)} + inv, err := parseInvocation(req.Subject()) if err != nil { _ = req.Error("100", err.Error(), nil) @@ -154,7 +158,7 @@ func busHandler(req micro.Request) { // todo cache these lookups? node, err := introspect.Call(obj) if err != nil { - _ = req.Error("100", "failed to introspect object", []byte(err.Error())) + _ = req.Error("100", "failed to introspect object", []byte(err.Error()), respOpts...) return } @@ -173,23 +177,18 @@ func busHandler(req micro.Request) { } if name == "" { - _ = req.Error("100", fmt.Sprintf("invalid property: %v", inv.target), nil) + _ = req.Error("100", fmt.Sprintf("invalid property: %v", inv.target), nil, respOpts...) return } prop, err := obj.GetProperty(name) if err != nil { - _ = req.Error("100", err.Error(), nil) + _ = req.Error("100", err.Error(), nil, respOpts...) return } - headers := micro.WithHeaders( - micro.Headers{ - "NKey": []string{nkey}, - "Signature": []string{prop.Signature().String()}, - }, - ) - _ = req.Respond([]byte(prop.String()), headers) + respHeaders["Signature"] = []string{prop.Signature().String()} + _ = req.Respond([]byte(prop.String()), respOpts...) case "method": @@ -204,7 +203,7 @@ func busHandler(req micro.Request) { } if method == "" { - _ = req.Error("100", fmt.Sprintf("invalid method: %v", inv.target), nil) + _ = req.Error("100", fmt.Sprintf("invalid method: %v", inv.target), nil, respOpts...) return } @@ -215,7 +214,7 @@ func busHandler(req micro.Request) { flag, err := strconv.Atoi(flagHeader) if err != nil { - _ = req.Error("100", "invalid 'Method-Flag' header", nil) + _ = req.Error("100", "invalid 'Method-Flag' header", nil, respOpts...) return } @@ -224,29 +223,24 @@ func busHandler(req micro.Request) { var invokeArgs []interface{} if len(req.Data()) > 0 { if err = json.Unmarshal(req.Data(), &invokeArgs); err != nil { - _ = req.Error("100", "failed to unmarshal req.Data", nil) + _ = req.Error("100", "failed to unmarshal req.Data", nil, respOpts...) return } } call := obj.Call(method, dbus.Flags(flag), invokeArgs...) if call.Err != nil { - _ = req.Error("100", "failed to invoke method: "+err.Error(), nil) + _ = req.Error("100", "failed to invoke method: "+err.Error(), nil, respOpts...) return } bytes, err := json.Marshal(call.Body) if err != nil { - _ = req.Error("100", "failed to marshal result to JSON", nil) + _ = req.Error("100", "failed to marshal result to JSON", nil, respOpts...) return } - headers := micro.WithHeaders( - micro.Headers{ - "NKey": []string{nkey}, - }, - ) - _ = req.Respond(bytes, headers) + _ = req.Respond(bytes, respOpts...) default: log.Error("unexpected invocation variant", "subject", req.Subject(), "variant", inv.variant) diff --git a/pkg/rpc/response.go b/pkg/rpc/response.go new file mode 100644 index 0000000..bab5602 --- /dev/null +++ b/pkg/rpc/response.go @@ -0,0 +1,52 @@ +package rpc + +import ( + "encoding/json" + + "github.com/juju/errors" + "github.com/nats-io/nats.go" + "github.com/nats-io/nats.go/micro" +) + +type Response struct { + Msg *nats.Msg + NKey string + Error error + Value json.RawMessage +} + +func (r Response) MarshalJSON() ([]byte, error) { + var errorMsg string + if r.Error != nil { + errorMsg = r.Error.Error() + } + + anon := struct { + NKey string `json:"nkey"` + Error string `json:"error,omitempty"` + Value json.RawMessage `json:"value,omitempty"` + }{NKey: r.NKey, Error: errorMsg, Value: r.Value} + + return json.Marshal(anon) +} + +func parseResponse(msg *nats.Msg, resp *Response) { + resp.Msg = msg + + // todo use a constant + resp.NKey = msg.Header.Get("NKey") + if resp.NKey == "" { + // todo make a const error + resp.Error = errors.New("nkey header not found") + return + } + + err := msg.Header.Get(micro.ErrorHeader) + errCode := msg.Header.Get(micro.ErrorCodeHeader) + + if !(err == "" || errCode == "") { + resp.Error = errors.Errorf("%s: %s", errCode, err) + } else { + resp.Error = json.Unmarshal(msg.Data, &resp.Value) + } +} diff --git a/pkg/rpc/rpc.go b/pkg/rpc/rpc.go index c26e4de..93691a2 100644 --- a/pkg/rpc/rpc.go +++ b/pkg/rpc/rpc.go @@ -24,7 +24,7 @@ func request( path string, variant string, name string, - respCh chan *nats.Msg, + respCh chan *Response, nkeys ...string, ) error { defer close(respCh) @@ -89,7 +89,10 @@ func request( } else if err != nil { return err } - respCh <- msg + + resp := Response{} + parseResponse(msg, &resp) + respCh <- &resp } } @@ -98,7 +101,7 @@ func GetProperty( dest string, path string, name string, - respCh chan *nats.Msg, + respCh chan *Response, nkeys ...string, ) error { return request(ctx, dest, path, "prop", name, respCh, nkeys...) @@ -109,7 +112,7 @@ func InvokeMethod( dest string, path string, name string, - respCh chan *nats.Msg, + respCh chan *Response, nkeys ...string, ) error { return request(ctx, dest, path, "method", name, respCh, nkeys...)