Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SSB_CONFIG_FILE for ./sbotcli #151

Closed
mhfowler opened this issue May 26, 2022 · 13 comments
Closed

SSB_CONFIG_FILE for ./sbotcli #151

mhfowler opened this issue May 26, 2022 · 13 comments
Labels
enhancement New feature or request

Comments

@mhfowler
Copy link

The configurations documented here work great for ./go-sbot

but I'm wondering if maybe they are not currently hooked up to work with ./sbotcli as well?

I'm currently working on a peachpub package for yunohost, which requires the go-sbot datadir being installed in a non-standard location (in /home/yunohost.app/peachpub/.ssb-go) instead of in the home folder of the user who is running go-sbot. I've been able to get this working great for ./go-sbot using the SSB_CONFIG_FILE env variable which is documented in config.md

but when I run ./sbotcli commands, I'm running into an error because it can't find .ssb-go in the correct place.

For example:
SSB_CONFIG_FILE=/home/yunohost.app/peachpub/.ssb-go/config.toml ./sbotcli call whoami

yields the error:

level=warn client="unix-path based init failed" err="ssbClient: failed to open unix path \"/root/.ssb-go/socket\""

I think using ./sbotcli is not strictly necessary for my usecase, but it would be helpful for debugging, and in an ideal world probably helpful to have parity between how ./sbotcli and ./go-sbot are configured (or I might also be missing something)

@decentral1se
Copy link
Member

but I'm wondering if maybe they are not currently hooked up to work with ./sbotcli as well?

afaiu sbotcli does not have config special powers, so that would need to be implemented. A similar approach to #138 could be taken but I guess @cblgh would have more information on that.

Some potential work-arounds for now might be:

@mhfowler
Copy link
Author

aw thanks @decentral1se , creating a symlink was a great workaround, all good atleast for debugging :-)
ln -s /home/yunohost.app/peachpub/.ssb-go /root/.ssb-go

@decentral1se
Copy link
Member

decentral1se commented Jul 22, 2022

Hey @mhfowler dove into this briefly and I came to the conclusion that I should better ask you first ☺️

So, sbotcli has different config options than go-sbot in:

Flags: []cli.Flag{
&cli.StringFlag{Name: "shscap", Value: "1KHLiKZvAvjbY1ziZEHMXawbCEIM6qwjCDm3VYRan/s=", Usage: "shs key"},
&cli.StringFlag{Name: "addr", Value: "localhost:8008", Usage: "tcp address of the sbot to connect to (or listen on)"},
&cli.StringFlag{Name: "remoteKey", Value: "", Usage: "the remote pubkey you are connecting to (by default the local key)"},
&keyFileFlag,
&unixSockFlag,
&cli.BoolFlag{Name: "verbose,vv", Usage: "print muxrpc packets"},
&cli.StringFlag{Name: "timeout", Value: "45s", Usage: "pass a duration (like 3s or 5m) after which it times out, empty string to disable"},
},

That means that we might want to make some changes to the config.toml to allow each CLI tool (go-sbot, sbotcli, etc.) to understand which config options are related to itself. This could mean using a TOML table like so:

[go-sbot]
stuff = 1

[sbotcli]
other_stuff = 0

Then I could abstract the config logic out of go-sbot and apply it to sbotcli while re-using the same config file. This change would break existing configs though! It would be a small config migration though. Whatcha think?

/cc @cblgh

@mhfowler
Copy link
Author

mhfowler commented Jul 23, 2022

thanks for looking into this @decentral1se

I've actually been using your symlink suggestion quite effectively since you mentioned it, so this hasn't been much of an obstacle for me personally

doing the config migration sounds not so hard, if you think thats the best format
also cc @mycognosist

@mhfowler
Copy link
Author

the one annoying thing is I have already made a yunohost package including go-sbot that some people might have downloaded,
so I might need to figure out how to include the migration in a yunohost package upgrade, which I haven't done before yet...

@decentral1se
Copy link
Member

Ah ok, maybe this isn't so urgent then but perhaps worth trying anyway. It seems like a small enough thing to dip my toes in on.

For the YunoHost stuff, I'd guess an approach like 1. back up the config file (there should be a YunoHost helper for this 2. template out new config file with contents of a single line: [go-sbot] into the right directory 3. cat the backed up file into the new templated config file (e.g. cat $backed_up_file > $templated_new_config, because all options will naturally be for go-sbot and not for sbotcli since it was not supportes yet 🙃

@decentral1se
Copy link
Member

@KyleMaas @mycognosist whatcha think?

@mycognosist
Copy link
Member

@decentral1se

I like your suggested approach to combine the configs using TOML tables. Based on the experience of @mhfowler and @KyleMaas it seems that a single shared config that works out of the box will be most intuitive and frictionless.

Ideally we follow the order of precedence already established by @cblgh for the go-sbot config: https://github.com/ssbc/go-ssb/blob/master/docs/config.md

We'll just need to be mindful of keeping @mhfowler in the loop before merging, so we can coordinate on the migration script.

@KyleMaas
Copy link
Contributor

@decentral1se Yeah, I like the shared config with the TOML tables. That would make a lot more intuitive sense for me and be a lot more inline with how other packages have configuration for multiple binaries within the same package.

@KyleMaas
Copy link
Contributor

KyleMaas commented Feb 5, 2023

@decentral1se Are you still working on this?

@decentral1se
Copy link
Member

@KyleMaas nah, I bailed on this a while back in favour of the test suite fixing effort.

@KyleMaas
Copy link
Contributor

Wow...this is much more difficult than expected. The fact that sbotcli uses urfave/cli means this is tough to patch in with TOML tables.

@decentral1se
Copy link
Member

@mhfowler this is now supported on latest! Watch out though, you'd need to migrate your configs to the new format in https://github.com/ssbc/go-ssb/blob/master/docs/config.md#example-config (TLDR; add [go-sbot] to existing configs). Thanks @KyleMaas for taking time to make this happen 👏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Development

No branches or pull requests

4 participants