Add whoami command to peach-config #128

Merged
notplants merged 4 commits from who-am-i into main 2022-07-05 13:10:37 +00:00
Owner

This command can be used during the yunohost install to check if the sbot is running (and wait for it to start running).

I copied over init_sbot from peach-web/src/utils/sbot.rs.

It might make sense for init_sbot to only be defined in peach-lib, and for peach-web to import it from there, but perhaps that could be done as a separate PR.

The reason to define a whoami command here in peach-config, instead of make calls to go-sbot directly, is so that we can use the same configuration in peach-config (which really could be renamed peach-cli, as thats what it effectively is) that is used in peach-web, and so that we can use golgi functions.

This command can be used during the yunohost install to check if the sbot is running (and wait for it to start running). I copied over init_sbot from peach-web/src/utils/sbot.rs. It might make sense for init_sbot to only be defined in peach-lib, and for peach-web to import it from there, but perhaps that could be done as a separate PR. The reason to define a whoami command here in peach-config, instead of make calls to go-sbot directly, is so that we can use the same configuration in peach-config (which really could be renamed peach-cli, as thats what it effectively is) that is used in peach-web, and so that we can use golgi functions.
notplants added 2 commits 2022-07-04 12:51:39 +00:00
continuous-integration/drone/pr Build is failing Details
7e94135839
Whoami
Author
Owner

Alternatively, we could add HTTP endpoints to peach-web which are specifically meant to be called from the command line such as
/whoami
/setdomain?domainvalue

but then we need to either let these endpoints be unauthenticated,
or in yunohost figure out how to authenticate via the command line, and then make calls to these endpoints (which also sounds complicated to me)

Alternatively, we could add HTTP endpoints to peach-web which are specifically meant to be called from the command line such as /whoami /setdomain?domainvalue but then we need to either let these endpoints be unauthenticated, or in yunohost figure out how to authenticate via the command line, and then make calls to these endpoints (which also sounds complicated to me)
notplants added 1 commit 2022-07-04 12:54:09 +00:00
continuous-integration/drone/pr Build is passing Details
1258a3697d
Cargo fmt
notplants requested review from glyph 2022-07-04 12:59:06 +00:00
Owner

As mentioned in #127, I think there are better ways to check if the sbot is running. However, I do think it's useful to have a whoami command as part of peach-config (it provides a nice way to query the public key of the local instance).

It might make sense for init_sbot to only be defined in peach-lib, and for peach-web to import it from there, but perhaps that could be done as a separate PR.

I think I'm fine with either option; would need to spend a bit of time looking at the code. I tend to lose clarity of the map after a while.

The reason to define a whoami command here in peach-config, instead of make calls to go-sbot directly, is so that we can use the same configuration in peach-config (which really could be renamed peach-cli, as thats what it effectively is) that is used in peach-web, and so that we can use golgi functions.

👍 (+1 peach-cli)

but then we need to either let these endpoints be unauthenticated,
or in yunohost figure out how to authenticate via the command line, and then make calls to these endpoints (which also sounds complicated to me)

Agreed. Too complicated.

As mentioned in https://git.coopcloud.tech/PeachCloud/peach-workspace/issues/127, I think there are better ways to check if the `sbot` is running. However, I do think it's useful to have a `whoami` command as part of `peach-config` (it provides a nice way to query the public key of the local instance). > It might make sense for init_sbot to only be defined in peach-lib, and for peach-web to import it from there, but perhaps that could be done as a separate PR. I think I'm fine with either option; would need to spend a bit of time looking at the code. I tend to lose clarity of the map after a while. > The reason to define a whoami command here in peach-config, instead of make calls to go-sbot directly, is so that we can use the same configuration in peach-config (which really could be renamed peach-cli, as thats what it effectively is) that is used in peach-web, and so that we can use golgi functions. 👍 (+1 `peach-cli`) > but then we need to either let these endpoints be unauthenticated, or in yunohost figure out how to authenticate via the command line, and then make calls to these endpoints (which also sounds complicated to me) Agreed. Too complicated.
glyph approved these changes 2022-07-05 08:07:06 +00:00
glyph left a comment
Owner

Implementation looks good to me. I left comments in the discussion thread.

🟢

Implementation looks good to me. I left comments in the discussion thread. 🟢
Author
Owner

👍 (+1 peach-cli)

Now that we are using Rouille for peach-web, I think we could quite easily move the contents of the main() function in peach-web/src/main into a run() funciton in peach-web/src/main.rs,

then import peach-web into peach-cli as a dependency,

and then use peach-web/src/main::run() as a "web" subcommand within peach-cli (as described here: #57)

this would allow us to have peach-cli and peach-web as one binary, with minimal work, which I think would be pretty cool (right now both peach-config and peach-web and go-sbot all get installed as binaries in a yunohost install)

As mentioned in #127, I think there are better ways to check if the sbot is running. However, I do think it's useful to have a whoami command as part of peach-config (it provides a nice way to query the public key of the local instance).

I like testing via whoami because its a "full end-to-end test" -- its theoretically possibly go-sbot service could be running, but hanging for some reason, or not accepting connections, or not able to return results, for whatever reason, but if whoami returns a value, I feel pretty confident that it can also do the other stuff its supposed to do (I recall Lorentz mentioning that running whoami is also what planetary does as a health check for go-sbot to know when to restart it)

> 👍 (+1 `peach-cli`) Now that we are using Rouille for peach-web, I think we could quite easily move the contents of the main() function in peach-web/src/main into a run() funciton in peach-web/src/main.rs, then import peach-web into peach-cli as a dependency, and then use peach-web/src/main::run() as a "web" subcommand within peach-cli (as described here: https://git.coopcloud.tech/PeachCloud/peach-workspace/issues/57) this would allow us to have peach-cli and peach-web as one binary, with minimal work, which I think would be pretty cool (right now both peach-config and peach-web and go-sbot all get installed as binaries in a yunohost install) > As mentioned in https://git.coopcloud.tech/PeachCloud/peach-workspace/issues/127, I think there are better ways to check if the `sbot` is running. However, I do think it's useful to have a `whoami` command as part of `peach-config` (it provides a nice way to query the public key of the local instance). I like testing via whoami because its a "full end-to-end test" -- its theoretically possibly go-sbot service could be running, but hanging for some reason, or not accepting connections, or not able to return results, for whatever reason, but if whoami returns a value, I feel pretty confident that it can also do the other stuff its supposed to do (I recall Lorentz mentioning that running whoami is also what planetary does as a health check for go-sbot to know when to restart it)
notplants added 1 commit 2022-07-05 12:52:24 +00:00
continuous-integration/drone/pr Build is passing Details
c6fc5c2992
Merge branch 'main' into who-am-i
notplants merged commit fcaa9e29c4 into main 2022-07-05 13:10:37 +00:00
notplants deleted branch who-am-i 2022-07-05 13:10:39 +00:00
Owner

I've copied your comments about peach-web -> peach-cli into the relevant issue so we can keep track of it (#57 (comment)).

I like testing via whoami because its a "full end-to-end test"

Ah, OK, that makes sense. I didn't realise you wanted a health check.

if whoami returns a value, I feel pretty confident that it can also do the other stuff its supposed to do

👍

I've copied your comments about `peach-web` -> `peach-cli` into the relevant issue so we can keep track of it (https://git.coopcloud.tech/PeachCloud/peach-workspace/issues/57#issuecomment-13558). > I like testing via whoami because its a "full end-to-end test" Ah, OK, that makes sense. I didn't realise you wanted a health check. > if whoami returns a value, I feel pretty confident that it can also do the other stuff its supposed to do 👍
Sign in to join this conversation.
No description provided.