From b90fb552a69d2bd64d0d68bbd6af7d53ace4bb60 Mon Sep 17 00:00:00 2001 From: Alex Freska Date: Tue, 26 Nov 2024 11:17:33 -0500 Subject: [PATCH] refactor(renterd-libs): move autopilot routes --- .changeset/selfish-queens-fold.md | 7 ++++ .changeset/ten-lies-draw.md | 7 ++++ .changeset/violet-peas-press.md | 7 ++++ apps/hostd-e2e/project.json | 2 +- apps/renterd-e2e/project.json | 2 +- apps/renterd/contexts/hosts/dataset.ts | 7 +--- apps/renterd/contexts/hosts/index.tsx | 1 - apps/walletd-e2e/project.json | 2 +- internal/cluster/go.mod | 27 ++++++------ internal/cluster/go.sum | 58 +++++++++++++------------- libs/clusterd/src/index.ts | 1 - libs/renterd-js/README.md | 1 - libs/renterd-js/src/autopilot.ts | 20 +-------- libs/renterd-js/src/bus.ts | 17 ++++++++ libs/renterd-js/src/example.ts | 1 - libs/renterd-react/src/autopilot.ts | 42 +------------------ libs/renterd-react/src/bus.ts | 37 ++++++++++++++++ libs/renterd-types/src/autopilot.ts | 3 +- libs/renterd-types/src/bus.ts | 1 - libs/renterd-types/src/types.ts | 2 +- 20 files changed, 127 insertions(+), 118 deletions(-) create mode 100644 .changeset/selfish-queens-fold.md create mode 100644 .changeset/ten-lies-draw.md create mode 100644 .changeset/violet-peas-press.md diff --git a/.changeset/selfish-queens-fold.md b/.changeset/selfish-queens-fold.md new file mode 100644 index 000000000..47c9b85c1 --- /dev/null +++ b/.changeset/selfish-queens-fold.md @@ -0,0 +1,7 @@ +--- +'@siafoundation/renterd-js': minor +'@siafoundation/renterd-react': minor +'@siafoundation/renterd-types': minor +--- + +The host checks field is now just HostAutopilotChecks. diff --git a/.changeset/ten-lies-draw.md b/.changeset/ten-lies-draw.md new file mode 100644 index 000000000..e105a2397 --- /dev/null +++ b/.changeset/ten-lies-draw.md @@ -0,0 +1,7 @@ +--- +'@siafoundation/renterd-js': minor +'@siafoundation/renterd-react': minor +'@siafoundation/renterd-types': minor +--- + +Autopilot config routes moved to the bus. diff --git a/.changeset/violet-peas-press.md b/.changeset/violet-peas-press.md new file mode 100644 index 000000000..ef7bdea0e --- /dev/null +++ b/.changeset/violet-peas-press.md @@ -0,0 +1,7 @@ +--- +'@siafoundation/renterd-js': minor +'@siafoundation/renterd-react': minor +'@siafoundation/renterd-types': minor +--- + +Removed the autopilotID parameter from the hosts API. diff --git a/apps/hostd-e2e/project.json b/apps/hostd-e2e/project.json index 79a970f9a..02c094dd2 100644 --- a/apps/hostd-e2e/project.json +++ b/apps/hostd-e2e/project.json @@ -9,7 +9,7 @@ "executor": "nx:run-commands", "options": { "commands": [ - // "cd internal/cluster && go get -u go.sia.tech/hostd@master", + "cd internal/cluster && go get -u go.sia.tech/hostd@master", "cd internal/cluster && go get -u go.sia.tech/renterd@dev", "cd internal/cluster && go get -u go.sia.tech/walletd@master", "cd internal/cluster && go mod tidy", diff --git a/apps/renterd-e2e/project.json b/apps/renterd-e2e/project.json index 38345cd17..84ec6abd9 100644 --- a/apps/renterd-e2e/project.json +++ b/apps/renterd-e2e/project.json @@ -9,7 +9,7 @@ "executor": "nx:run-commands", "options": { "commands": [ - // "cd internal/cluster && go get -u go.sia.tech/hostd@master", + "cd internal/cluster && go get -u go.sia.tech/hostd@master", "cd internal/cluster && go get -u go.sia.tech/renterd@dev", "cd internal/cluster && go get -u go.sia.tech/walletd@master", "cd internal/cluster && go mod tidy", diff --git a/apps/renterd/contexts/hosts/dataset.ts b/apps/renterd/contexts/hosts/dataset.ts index a56da4705..d57aaa37f 100644 --- a/apps/renterd/contexts/hosts/dataset.ts +++ b/apps/renterd/contexts/hosts/dataset.ts @@ -14,7 +14,6 @@ import { objectEntries } from '@siafoundation/design-system' export function useDataset({ response, allContracts, - autopilotID, allowlist, blocklist, isAllowlistActive, @@ -22,7 +21,6 @@ export function useDataset({ onHostSelect, }: { response: ReturnType - autopilotID?: string allContracts: ContractData[] allowlist: ReturnType blocklist: ReturnType @@ -47,16 +45,13 @@ export function useDataset({ blocklist: block, isAllowlistActive, }), - ...getAutopilotFields( - autopilotID ? host.checks?.[autopilotID] : undefined - ), + ...getAutopilotFields(host.checks), location: sch?.location, countryCode: sch?.country_code, } }) }, [ onHostSelect, - autopilotID, response.data, allContracts, allowlist.data, diff --git a/apps/renterd/contexts/hosts/index.tsx b/apps/renterd/contexts/hosts/index.tsx index 841152e50..924662a3f 100644 --- a/apps/renterd/contexts/hosts/index.tsx +++ b/apps/renterd/contexts/hosts/index.tsx @@ -179,7 +179,6 @@ function useHostsMain() { const dataset = useDataset({ response, allContracts, - autopilotID: autopilotState.data?.id, allowlist, blocklist, isAllowlistActive, diff --git a/apps/walletd-e2e/project.json b/apps/walletd-e2e/project.json index 38f9de8b2..4d751725f 100644 --- a/apps/walletd-e2e/project.json +++ b/apps/walletd-e2e/project.json @@ -9,7 +9,7 @@ "executor": "nx:run-commands", "options": { "commands": [ - // "cd internal/cluster && go get -u go.sia.tech/hostd@master", + "cd internal/cluster && go get -u go.sia.tech/hostd@master", "cd internal/cluster && go get -u go.sia.tech/renterd@dev", "cd internal/cluster && go get -u go.sia.tech/walletd@master", "cd internal/cluster && go mod tidy", diff --git a/internal/cluster/go.mod b/internal/cluster/go.mod index b1f6ad6e7..d30fe3031 100644 --- a/internal/cluster/go.mod +++ b/internal/cluster/go.mod @@ -5,16 +5,16 @@ go 1.23.1 toolchain go1.23.2 require ( - go.sia.tech/cluster v0.1.3-0.20241108192158-4ddce3247904 - go.sia.tech/core v0.6.1 - go.sia.tech/coreutils v0.6.0 + go.sia.tech/cluster v0.1.3-0.20241203203049-cb265a6a0e92 + go.sia.tech/core v0.6.2 + go.sia.tech/coreutils v0.7.0 go.uber.org/zap v1.27.0 ) require ( github.com/aws/aws-sdk-go v1.55.5 // indirect - github.com/cloudflare/cloudflare-go v0.107.0 // indirect - github.com/gabriel-vasile/mimetype v1.4.6 // indirect + github.com/cloudflare/cloudflare-go v0.110.0 // indirect + github.com/gabriel-vasile/mimetype v1.4.7 // indirect github.com/goccy/go-json v0.10.3 // indirect github.com/google/go-querystring v1.1.0 // indirect github.com/gotd/contrib v0.20.0 // indirect @@ -30,18 +30,17 @@ require ( github.com/shopspring/decimal v1.4.0 // indirect go.etcd.io/bbolt v1.3.11 // indirect go.sia.tech/gofakes3 v0.0.5 // indirect - go.sia.tech/hostd v1.1.3-0.20241101150257-8319b75af8b2 // indirect + go.sia.tech/hostd v1.1.3-0.20241126153600-d590d9259987 // indirect go.sia.tech/jape v0.12.1 // indirect go.sia.tech/mux v1.3.0 // indirect - go.sia.tech/renterd v1.1.0-beta.5.0.20241108111642-4b0f42a3d24f // indirect - go.sia.tech/walletd v0.8.1-0.20241101091153-465e9da22d82 // indirect + go.sia.tech/renterd v1.1.0-beta.5.0.20241203123141-50c650a896c2 // indirect + go.sia.tech/walletd v0.8.1-0.20241120185708-2f26e9b843f1 // indirect go.uber.org/multierr v1.11.0 // indirect - golang.org/x/crypto v0.28.0 // indirect - golang.org/x/net v0.30.0 // indirect - golang.org/x/sys v0.26.0 // indirect - golang.org/x/text v0.19.0 // indirect - golang.org/x/time v0.7.0 // indirect + golang.org/x/crypto v0.29.0 // indirect + golang.org/x/net v0.31.0 // indirect + golang.org/x/sys v0.27.0 // indirect + golang.org/x/text v0.20.0 // indirect + golang.org/x/time v0.8.0 // indirect golang.org/x/tools v0.23.0 // indirect lukechampine.com/frand v1.5.1 // indirect - nhooyr.io/websocket v1.8.17 // indirect ) diff --git a/internal/cluster/go.sum b/internal/cluster/go.sum index 05dae4e1a..39f520f16 100644 --- a/internal/cluster/go.sum +++ b/internal/cluster/go.sum @@ -2,13 +2,13 @@ filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA= filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4= github.com/aws/aws-sdk-go v1.55.5 h1:KKUZBfBoyqy5d3swXyiC7Q76ic40rYcbqH7qjh59kzU= github.com/aws/aws-sdk-go v1.55.5/go.mod h1:eRwEWoyTWFMVYVQzKMNHWP5/RV4xIUGMQfXQHfHkpNU= -github.com/cloudflare/cloudflare-go v0.107.0 h1:cMDIw2tzt6TXCJyMFVyP+BPOVkIfMvcKjhMNSNvuEPc= -github.com/cloudflare/cloudflare-go v0.107.0/go.mod h1:5cYGzVBqNTLxMYSLdVjuSs5LJL517wJDSvMPWUrzHzc= +github.com/cloudflare/cloudflare-go v0.110.0 h1:aBKKUXwRWqErd4rITsnCLESOacxxset/BcpdXn23900= +github.com/cloudflare/cloudflare-go v0.110.0/go.mod h1:2ZZ+EkmThmd6pkZ56UKGXWpz2wsjeqoTg93P4+VSmMg= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 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/gabriel-vasile/mimetype v1.4.6 h1:3+PzJTKLkvgjeTbts6msPJt4DixhT4YtFNf1gtGe3zc= -github.com/gabriel-vasile/mimetype v1.4.6/go.mod h1:JX1qVKqZd40hUPpAfiNTe0Sne7hdfKSbOqqmkq8GCXc= +github.com/gabriel-vasile/mimetype v1.4.7 h1:SKFKl7kD0RiPdbht0s7hFtjl489WcQ1VyPW8ZzUMYCA= +github.com/gabriel-vasile/mimetype v1.4.7/go.mod h1:GDlAgAyIRT27BhFl53XNAFtfjzOkLaF35JdEG0P7LtU= github.com/go-sql-driver/mysql v1.8.1 h1:LedoTUt/eveggdHS9qUFC1EFSa8bU2+1pZjSRpvNJ1Y= github.com/go-sql-driver/mysql v1.8.1/go.mod h1:wEBSXgmK//2ZFJyE+qWnIsVGmvmEKlqwuVSjsCm7DZg= github.com/goccy/go-json v0.10.3 h1:KZ5WoDbxAIgm2HNbYckL0se1fHD6rz5j4ywS6ebzDqA= @@ -49,24 +49,24 @@ github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsT github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= go.etcd.io/bbolt v1.3.11 h1:yGEzV1wPz2yVCLsD8ZAiGHhHVlczyC9d1rP43/VCRJ0= go.etcd.io/bbolt v1.3.11/go.mod h1:dksAq7YMXoljX0xu6VF5DMZGbhYYoLUalEiSySYAS4I= -go.sia.tech/cluster v0.1.3-0.20241108192158-4ddce3247904 h1:NXbmfgBU4sPOF0lczIGECDR6cPNXata4g17HKt+Sy8U= -go.sia.tech/cluster v0.1.3-0.20241108192158-4ddce3247904/go.mod h1:HcpoIxTf1TXUccc0YIwyxD/3WBNRXLs6SpwG7WHdBK4= -go.sia.tech/core v0.6.1 h1:eaExM2E2eNr43su2XDkY5J24E3F54YGS7hcC3WtVjVk= -go.sia.tech/core v0.6.1/go.mod h1:P3C1BWa/7J4XgdzWuaYHBvLo2RzZ0UBaJM4TG1GWB2g= -go.sia.tech/coreutils v0.6.0 h1:r0IZt+aVdGG2uIHl7OtaWRYdVx4NQ7ezRoSGa0Ej8GY= -go.sia.tech/coreutils v0.6.0/go.mod h1:XlsnogeYU/Tdjzp/HUNAj5T7tZCdmeBHIBjymbPC+uQ= +go.sia.tech/cluster v0.1.3-0.20241203203049-cb265a6a0e92 h1:3sYU7m4E1W1NbKBrIWlanDMPZz6iPa+TcThgLmDbo2g= +go.sia.tech/cluster v0.1.3-0.20241203203049-cb265a6a0e92/go.mod h1:MhFF2XgK4XaoPJ9Gm7rJaKPhulYM+BhrBztQoOV94hc= +go.sia.tech/core v0.6.2 h1:8NEjxyD93A+EhZopsBy/LvuHH+zUSjRNKnf9rXgtIwU= +go.sia.tech/core v0.6.2/go.mod h1:4v+aT/33857tMfqa5j5OYlAoLsoIrd4d7qMlgeP+VGk= +go.sia.tech/coreutils v0.7.0 h1:YpgOUD4vrpDz0KC7FJz+UCOaKaqV5EkX3gMUUmJoz5s= +go.sia.tech/coreutils v0.7.0/go.mod h1:eMoqzqO4opKQ6n9tTTxHQmccfNlj+8RFOYuDSL/Qd4g= go.sia.tech/gofakes3 v0.0.5 h1:vFhVBUFbKE9ZplvLE2w4TQxFMQyF8qvgxV4TaTph+Vw= go.sia.tech/gofakes3 v0.0.5/go.mod h1:LXEzwGw+OHysWLmagleCttX93cJZlT9rBu/icOZjQ54= -go.sia.tech/hostd v1.1.3-0.20241101150257-8319b75af8b2 h1:6fogOsOr7efjeDHCO0mqIibEa5cOagSSo3JXe1fuifM= -go.sia.tech/hostd v1.1.3-0.20241101150257-8319b75af8b2/go.mod h1:096sIYupHRUGkVyAe6i511la7wQo5LfRHGNUSMIKcT4= +go.sia.tech/hostd v1.1.3-0.20241126153600-d590d9259987 h1:PBPbQ6SyZu9CEMgKo1Vou7PLDIJH4/X1Yoxqf1hPfE8= +go.sia.tech/hostd v1.1.3-0.20241126153600-d590d9259987/go.mod h1:mlX0X3KpJd/YcOSFZdY1HdEma9UHkN1W5OgHYqyVhbU= go.sia.tech/jape v0.12.1 h1:xr+o9V8FO8ScRqbSaqYf9bjj1UJ2eipZuNcI1nYousU= go.sia.tech/jape v0.12.1/go.mod h1:wU+h6Wh5olDjkPXjF0tbZ1GDgoZ6VTi4naFw91yyWC4= go.sia.tech/mux v1.3.0 h1:hgR34IEkqvfBKUJkAzGi31OADeW2y7D6Bmy/Jcbop9c= go.sia.tech/mux v1.3.0/go.mod h1:I46++RD4beqA3cW9Xm9SwXbezwPqLvHhVs9HLpDtt58= -go.sia.tech/renterd v1.1.0-beta.5.0.20241108111642-4b0f42a3d24f h1:xLuQwVkhpxNltC7BmDqgdOCVIC5Ja9LDD+jvXgs4UeY= -go.sia.tech/renterd v1.1.0-beta.5.0.20241108111642-4b0f42a3d24f/go.mod h1:RF1WAXIjAevzbW6NSAkPX5XFYP1xPSiVQTMGPL24h3o= -go.sia.tech/walletd v0.8.1-0.20241101091153-465e9da22d82 h1:b48uOxKkBhexR8/1bYLNscYyD8weMYWltj46wsNVhkY= -go.sia.tech/walletd v0.8.1-0.20241101091153-465e9da22d82/go.mod h1:eowElIUuv8MVsyFBbOtLytJgm0ztzQBJ9QF7ZAiIK6g= +go.sia.tech/renterd v1.1.0-beta.5.0.20241203123141-50c650a896c2 h1:NOuw/yVzBKn3hhOK/RJIIsKsLoOI2tzgogu6mjLSfIw= +go.sia.tech/renterd v1.1.0-beta.5.0.20241203123141-50c650a896c2/go.mod h1:TBO18j+T36sPlOdnIndHdLcKiojpXHtyqNYm+CvI0ew= +go.sia.tech/walletd v0.8.1-0.20241120185708-2f26e9b843f1 h1:YWyRj37ZhPsHtLKgJq3gAo0zCWYl3fM24WVIBTS//yA= +go.sia.tech/walletd v0.8.1-0.20241120185708-2f26e9b843f1/go.mod h1:IMK3pD/UVpTHrExrOJLvaNSuE6lJ0pxcAvwpQ977aCM= go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= @@ -74,25 +74,25 @@ go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN8 go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8= go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.28.0 h1:GBDwsMXVQi34v5CCYUm2jkJvu4cbtru2U4TN2PSyQnw= -golang.org/x/crypto v0.28.0/go.mod h1:rmgy+3RHxRZMyY0jjAJShp2zgEdOqj2AO7U0pYmeQ7U= +golang.org/x/crypto v0.29.0 h1:L5SG1JTTXupVV3n6sUqMTeWbjAyfPwoda2DLX8J8FrQ= +golang.org/x/crypto v0.29.0/go.mod h1:+F4F4N5hv6v38hfeYwTdx20oUvLLc+QfrE9Ax9HtgRg= golang.org/x/mod v0.19.0 h1:fEdghXQSo20giMthA7cd28ZC+jts4amQ3YMXiP5oMQ8= golang.org/x/mod v0.19.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.30.0 h1:AcW1SDZMkb8IpzCdQUaIq2sP4sZ4zw+55h6ynffypl4= -golang.org/x/net v0.30.0/go.mod h1:2wGyMJ5iFasEhkwi13ChkO/t1ECNC4X4eBKkVFyYFlU= +golang.org/x/net v0.31.0 h1:68CPQngjLL0r2AlUKiSxtQFKvzRVbnzLwMUn5SzcLHo= +golang.org/x/net v0.31.0/go.mod h1:P4fl1q7dY2hnZFxEk4pPSkDHF+QqjitcnDjUQyMM+pM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ= -golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sync v0.9.0 h1:fEo0HyrW1GIgZdpbhCRO0PkJajUS5H9IFUztCgEo2jQ= +golang.org/x/sync v0.9.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo= -golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.27.0 h1:wBqf8DvsY9Y/2P8gAfPDEYNuS30J4lPHJxXSb/nJZ+s= +golang.org/x/sys v0.27.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.19.0 h1:kTxAhCbGbxhK0IwgSKiMO5awPoDQ0RpfiVYBfK860YM= -golang.org/x/text v0.19.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= -golang.org/x/time v0.7.0 h1:ntUhktv3OPE6TgYxXWv9vKvUSJyIFJlyohwbkEwPrKQ= -golang.org/x/time v0.7.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= +golang.org/x/text v0.20.0 h1:gK/Kv2otX8gz+wn7Rmb3vT96ZwuoxnQlY+HlJVj7Qug= +golang.org/x/text v0.20.0/go.mod h1:D4IsuqiFMhST5bX19pQ9ikHC2GsaKyk/oF+pn3ducp4= +golang.org/x/time v0.8.0 h1:9i3RxcPv3PZnitoVGMPDKZSq1xW1gK1Xy3ArNOGZfEg= +golang.org/x/time v0.8.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= golang.org/x/tools v0.0.0-20190829051458-42f498d34c4d/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.23.0 h1:SGsXPZ+2l4JsgaCKkx+FQ9YZ5XEtA1GZYuoDjenLjvg= golang.org/x/tools v0.23.0/go.mod h1:pnu6ufv6vQkll6szChhK3C3L/ruaIv5eBeztNG8wtsI= @@ -106,5 +106,3 @@ gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= lukechampine.com/frand v1.5.1 h1:fg0eRtdmGFIxhP5zQJzM1lFDbD6CUfu/f+7WgAZd5/w= lukechampine.com/frand v1.5.1/go.mod h1:4VstaWc2plN4Mjr10chUD46RAVGWhpkZ5Nja8+Azp0Q= -nhooyr.io/websocket v1.8.17 h1:KEVeLJkUywCKVsnLIDlD/5gtayKp8VoCkksHCGGfT9Y= -nhooyr.io/websocket v1.8.17/go.mod h1:rN9OFWIUwuxg4fR5tELlYC04bXYowCP9GX47ivo2l+c= diff --git a/libs/clusterd/src/index.ts b/libs/clusterd/src/index.ts index fadb59aee..af1e0dad3 100644 --- a/libs/clusterd/src/index.ts +++ b/libs/clusterd/src/index.ts @@ -104,7 +104,6 @@ export async function waitForContracts({ await mine(1) const hosts = await bus.hosts({ data: { - autopilotID: 'autopilot', filterMode: 'allowed', usabilityMode: 'usable', limit: 50, diff --git a/libs/renterd-js/README.md b/libs/renterd-js/README.md index 5bd2e8983..13feb95e7 100644 --- a/libs/renterd-js/README.md +++ b/libs/renterd-js/README.md @@ -53,7 +53,6 @@ export async function example() { const hosts = await bus.hosts({ data: { - autopilotID: 'autopilot', filterMode: 'allowed', usabilityMode: 'usable', addressContains: 'example.com', diff --git a/libs/renterd-js/src/autopilot.ts b/libs/renterd-js/src/autopilot.ts index 49f4077d9..74c42612d 100644 --- a/libs/renterd-js/src/autopilot.ts +++ b/libs/renterd-js/src/autopilot.ts @@ -2,21 +2,15 @@ import { AutopilotConfigEvaluateParams, AutopilotConfigEvaluatePayload, AutopilotConfigEvaluateResponse, - AutopilotConfigParams, - AutopilotConfigPayload, - AutopilotConfigResponse, - AutopilotConfigUpdateParams, - AutopilotConfigUpdatePayload, - AutopilotConfigUpdateResponse, AutopilotStateParams, AutopilotStatePayload, AutopilotStateResponse, AutopilotTriggerParams, AutopilotTriggerPayload, AutopilotTriggerResponse, - autopilotConfigRoute, autopilotStateRoute, autopilotTriggerRoute, + autopilotConfigEvaluateRoute, } from '@siafoundation/renterd-types' import { buildRequestHandler, initAxios } from '@siafoundation/request' @@ -35,21 +29,11 @@ export function Autopilot({ AutopilotStatePayload, AutopilotStateResponse >(axios, 'get', autopilotStateRoute), - config: buildRequestHandler< - AutopilotConfigParams, - AutopilotConfigPayload, - AutopilotConfigResponse - >(axios, 'get', autopilotConfigRoute), - configUpdate: buildRequestHandler< - AutopilotConfigUpdateParams, - AutopilotConfigUpdatePayload, - AutopilotConfigUpdateResponse - >(axios, 'put', autopilotConfigRoute), configEvaluate: buildRequestHandler< AutopilotConfigEvaluateParams, AutopilotConfigEvaluatePayload, AutopilotConfigEvaluateResponse - >(axios, 'post', autopilotConfigRoute), + >(axios, 'post', autopilotConfigEvaluateRoute), trigger: buildRequestHandler< AutopilotTriggerParams, AutopilotTriggerPayload, diff --git a/libs/renterd-js/src/bus.ts b/libs/renterd-js/src/bus.ts index 0f5a65406..e78a5e1a1 100644 --- a/libs/renterd-js/src/bus.ts +++ b/libs/renterd-js/src/bus.ts @@ -256,6 +256,13 @@ import { HostScanPayload, HostScanResponse, busHostHostKeyScanRoute, + AutopilotConfigParams, + AutopilotConfigPayload, + AutopilotConfigResponse, + AutopilotConfigUpdateParams, + AutopilotConfigUpdatePayload, + AutopilotConfigUpdateResponse, + busAutopilotRoute, } from '@siafoundation/renterd-types' import { buildRequestHandler, initAxios } from '@siafoundation/request' @@ -598,5 +605,15 @@ export function Bus({ api, password }: { api: string; password?: string }) { MultipartUploadAddPartPayload, MultipartUploadAddPartResponse >(axios, 'post', busMultipartPartRoute), + autopilotConfig: buildRequestHandler< + AutopilotConfigParams, + AutopilotConfigPayload, + AutopilotConfigResponse + >(axios, 'get', busAutopilotRoute), + autopilotConfigUpdate: buildRequestHandler< + AutopilotConfigUpdateParams, + AutopilotConfigUpdatePayload, + AutopilotConfigUpdateResponse + >(axios, 'put', busAutopilotRoute), } } diff --git a/libs/renterd-js/src/example.ts b/libs/renterd-js/src/example.ts index 019bc3cbc..9b3339138 100644 --- a/libs/renterd-js/src/example.ts +++ b/libs/renterd-js/src/example.ts @@ -42,7 +42,6 @@ export async function example() { const hosts = await bus.hosts({ data: { - autopilotID: 'autopilot-id', filterMode: 'allowed', usabilityMode: 'usable', addressContains: 'example.com', diff --git a/libs/renterd-react/src/autopilot.ts b/libs/renterd-react/src/autopilot.ts index bdccf73e7..eaab9c51b 100644 --- a/libs/renterd-react/src/autopilot.ts +++ b/libs/renterd-react/src/autopilot.ts @@ -1,19 +1,12 @@ import { useGetSwr, usePostSwr, - usePutFunc, HookArgsSwr, HookArgsCallback, HookArgsWithPayloadSwr, - delay, usePostFunc, } from '@siafoundation/react-core' import { - AutopilotConfigParams, - AutopilotConfigResponse, - AutopilotConfigUpdateParams, - AutopilotConfigUpdatePayload, - AutopilotConfigUpdateResponse, AutopilotConfigEvaluateParams, AutopilotConfigEvaluatePayload, AutopilotConfigEvaluateResponse, @@ -22,9 +15,9 @@ import { AutopilotTriggerParams, AutopilotTriggerPayload, AutopilotTriggerResponse, - autopilotConfigRoute, autopilotStateRoute, autopilotTriggerRoute, + autopilotConfigEvaluateRoute, } from '@siafoundation/renterd-types' export function useAutopilotState( @@ -36,37 +29,6 @@ export function useAutopilotState( }) } -export function useAutopilotConfig( - args?: HookArgsSwr -) { - return useGetSwr({ - ...args, - route: autopilotConfigRoute, - }) -} - -export function useAutopilotConfigUpdate( - args?: HookArgsCallback< - AutopilotConfigUpdateParams, - AutopilotConfigUpdatePayload, - AutopilotConfigUpdateResponse - > -) { - return usePutFunc( - { ...args, route: autopilotConfigRoute }, - async (mutate) => { - mutate((key) => key === autopilotConfigRoute) - // Might need a delay before revalidating status which returns whether - // or not autopilot is configured. - const func = async () => { - await delay(1000) - mutate((key) => key === autopilotStateRoute) - } - func() - } - ) -} - export function useAutopilotConfigEvaluate( args: HookArgsWithPayloadSwr< AutopilotConfigEvaluateParams, @@ -74,7 +36,7 @@ export function useAutopilotConfigEvaluate( AutopilotConfigEvaluateResponse > ) { - return usePostSwr({ ...args, route: autopilotConfigRoute }) + return usePostSwr({ ...args, route: autopilotConfigEvaluateRoute }) } export function useAutopilotTrigger( diff --git a/libs/renterd-react/src/bus.ts b/libs/renterd-react/src/bus.ts index bf1bdcff5..cac7b3e73 100644 --- a/libs/renterd-react/src/bus.ts +++ b/libs/renterd-react/src/bus.ts @@ -21,6 +21,12 @@ import { AlertsDismissResponse, AlertsParams, AlertsResponse, + AutopilotConfigParams, + AutopilotConfigResponse, + AutopilotConfigUpdateParams, + AutopilotConfigUpdatePayload, + AutopilotConfigUpdateResponse, + busAutopilotRoute, BucketCreateParams, BucketCreatePayload, BucketCreateResponse, @@ -247,6 +253,7 @@ import { HostScanResponse, busHostHostKeyScanRoute, Host, + autopilotStateRoute, } from '@siafoundation/renterd-types' // state @@ -1024,3 +1031,33 @@ export function useMultipartUploadAddPart( } ) } + +// autopilot + +export function useAutopilotConfig( + args?: HookArgsSwr +) { + return useGetSwr({ + ...args, + route: busAutopilotRoute, + }) +} + +export function useAutopilotConfigUpdate( + args?: HookArgsCallback< + AutopilotConfigUpdateParams, + AutopilotConfigUpdatePayload, + AutopilotConfigUpdateResponse + > +) { + return usePutFunc({ ...args, route: busAutopilotRoute }, async (mutate) => { + mutate((key) => key === busAutopilotRoute) + // Might need a delay before revalidating status which returns whether + // or not autopilot is configured. + const func = async () => { + await delay(1000) + mutate((key) => key === autopilotStateRoute) + } + func() + }) +} diff --git a/libs/renterd-types/src/autopilot.ts b/libs/renterd-types/src/autopilot.ts index 1c2672be2..a21570766 100644 --- a/libs/renterd-types/src/autopilot.ts +++ b/libs/renterd-types/src/autopilot.ts @@ -2,8 +2,9 @@ import { BuildState } from './bus' import { AutopilotConfig, SettingsGouging, SettingsRedundancy } from './types' export const autopilotStateRoute = '/autopilot/state' -export const autopilotConfigRoute = '/autopilot/config' +export const autopilotConfigEvaluateRoute = '/autopilot/config/evaluate' export const autopilotTriggerRoute = '/autopilot/trigger' +export const busAutopilotRoute = '/bus/autopilot' type AutopilotStatus = { id: string diff --git a/libs/renterd-types/src/bus.ts b/libs/renterd-types/src/bus.ts index d888f5b88..e23f92493 100644 --- a/libs/renterd-types/src/bus.ts +++ b/libs/renterd-types/src/bus.ts @@ -225,7 +225,6 @@ export type HostsParams = void export type HostsFilterMode = 'all' | 'allowed' | 'blocked' export type HostsUsabilityMode = 'all' | 'usable' | 'unusable' export type HostsPayload = { - autopilotID?: string filterMode: HostsFilterMode usabilityMode?: HostsUsabilityMode addressContains?: string diff --git a/libs/renterd-types/src/types.ts b/libs/renterd-types/src/types.ts index 1b6c32ee7..1d98895b5 100644 --- a/libs/renterd-types/src/types.ts +++ b/libs/renterd-types/src/types.ts @@ -186,7 +186,7 @@ export type Host = { storedData: number resolvedAddresses?: string[] subnets?: string[] - checks?: Record + checks?: HostAutopilotChecks } export type HostAutopilotChecks = {