passbolt / go-passbolt-cli

A CLI tool to interact with Passbolt, a Open source Password Manager for Teams
https://passbolt.com
MIT License
60 stars 14 forks source link

[feature] self upgrading release binary #50

Open kskarthik opened 5 months ago

kskarthik commented 5 months ago

The idea is to have similar feature to deno upgrade & bun upgrade in which the user can upgrade the existing binary using a cli flag.

This will be a useful feature for many users whose distributions which always do not ship with latest versions of the cli

I wish to work on this patch if we can agree on implementing such feature.

speatzle commented 5 months ago

I do not know of any distributions that ships go-passbolt-cli in their repositories, which is why i always planned to provide my own deb and rpm repositories for easy updates but got stalled due to my limited time and low demand.

Would having generic deb and rpm repositories solve your Issue? I think building an Updater from Scratch would be quite complex since it would also need to handle things like man pages and shell completions. The security implications would also have to be considered.

kskarthik commented 5 months ago

i have initially found this lib which can do the heavy lifing (also includes security aspects like checksum verification) https://github.com/creativeprojects/go-selfupdate

Would having generic deb and rpm repositories solve your Issue?

yes, it would. But it also implies user should add custom repos to their system

speatzle commented 5 months ago

I don't see how that library can update additional files like man pages or shell completions (maybe i missed it?). Also if anything goes wrong and can't start it anymore there is no possibility to downgrade again. I generally dislike the Windows Style Self updating.

I don't see adding custom repositories as such a big deal (you also have to do that if you are installing the passbolt server). go-passbolt-cli Simply is not big enough to be included in distros.

I tried to avoid having to add custom repos by looking into packaging the CLI as a Flatpak instead but their CLI Support has "Issues" we would have to work around https://github.com/flatpak/flatpak/issues/1188 .

kskarthik commented 5 months ago

I don't see how that library can update additional files like man pages or shell completions (maybe i missed it?). Also if anything goes wrong and can't start it anymore there is no possibility to downgrade again. I generally dislike the Windows Style Self updating.

Yes, The lib i shared does not handle man pages & shell completions.

I tried to avoid having to add custom repos by looking into packaging the CLI as a Flatpak instead but their CLI Support has "Issues" we would have to work around https://github.com/flatpak/flatpak/issues/1188 .

yes, flatpaks are not ideal for CLIs. We have to add an alias & no support for man pages AFAIK

speatzle commented 3 months ago

In the meantime, go-passbolt-cli has been added as a nixpkg https://search.nixos.org/packages?channel=24.05&show=go-passbolt-cli&from=0&size=50&sort=relevance&type=packages&query=go-passbolt-cli

kskarthik commented 2 months ago

I have also packaged for opensuse tumbleweed https://build.opensuse.org/request/show/1181068

It takes a few days to land in the main repositories!

speatzle commented 2 months ago

I have also packaged for opensuse tumbleweed https://build.opensuse.org/request/show/1181068

Cool, i will add that to the Readme once it has been released

kskarthik commented 2 months ago

Sure, i will let you know

kskarthik commented 2 months ago

@speatzle Now accepted to opensuse tumbleweed! https://build.opensuse.org/package/show/openSUSE:Factory/go-passbolt-cli

url: https://software.opensuse.org/package/go-passbolt-cli

kskarthik commented 2 months ago

It might also reflect here https://repology.org/project/go:passbolt-cli/versions shortly

speatzle commented 2 months ago

Cool, i will give it a spin this weekend.

kskarthik commented 2 months ago

btw is this project still community driven or made official ? since i set the disclaimer in pkg info as well


❯ zypper info go-passbolt-cli
Loading repository data...
Reading installed packages...

Information for package go-passbolt-cli:
----------------------------------------
Repository     : Main Repository (OSS)
Name           : go-passbolt-cli
Version        : 0.3.1-1.1
Arch           : x86_64
Vendor         : openSUSE
Installed Size : 18.5 MiB
Installed      : No
Status         : not installed
Source package : go-passbolt-cli-0.3.1-1.1.src
Upstream URL   : https://github.com/passbolt/go-passbolt-cli
Summary        : A CLI tool to interact with Passbolt
Description    :
    This package provides a CLI tool to interact with Passbolt, An Open
    Source Password Manager for Teams

    Passbolt Website: https://www.passbolt.com/

    This project is community driven and not associated with Passbolt
    SA
speatzle commented 2 months ago

Yes, this Project is still Community Driven.

speatzle commented 1 month ago

Hey @kskarthik Sorry for the delay. I finally managed to setup a tumbleweed VM (the first few attempts ended in emergency mode due to broken virtio drivers...) and Test the Package.

It Seems to work well but both shell completions and man pages seem to be missing making it hard to use, could you add those to the package?

You can see how to generate them here: https://github.com/passbolt/go-passbolt-cli/blob/main/.github/workflows/.release.yml

kskarthik commented 1 month ago

Sure, I will

kskarthik commented 1 month ago

just added shell completions & man page support https://build.opensuse.org/package/rdiff/security:privacy/go-passbolt-cli?opackage=go-passbolt-cli&oproject=openSUSE%3AFactory&rev=4

Will reflect in tumbleweed in a few days

speatzle commented 1 month ago

I upgraded the package and the man pages work now, it also installed go-passbolt-cli-bash-completions during the upgrade but i can't get the completions to work. Do i need to enable them manually? image

kskarthik commented 1 month ago

do you have the bash-completion package installed ?

zypper info bash-completion ?

speatzle commented 1 month ago

Yes, it was installed automatically:

slt@localhost:~> zypper search passbolt
Loading repository data...
Reading installed packages...

S  | Name                            | Summary                              | Type
---+---------------------------------+--------------------------------------+--------
i+ | go-passbolt-cli                 | A CLI tool to interact with Passbolt | package
i  | go-passbolt-cli-bash-completion | Bash Completion for go-passbolt-cli  | package
   | go-passbolt-cli-fish-completion | Fish Completion for go-passbolt-cli  | package
   | go-passbolt-cli-zsh-completion  | ZSH Completion for go-passbolt-cli   | package
slt@localhost:~> zypper info bash-completion
Loading repository data...
Reading installed packages...

Information for package bash-completion:
----------------------------------------
Repository     : Main Repository (OSS)
Name           : bash-completion
Version        : 2.12.0-2.2
Arch           : noarch
Vendor         : openSUSE
Installed Size : 1003.5 KiB
Installed      : Yes (automatically)
Status         : up-to-date
Source package : bash-completion-2.12.0-2.2.src
Upstream URL   : https://github.com/scop/bash-completion/
Summary        : Programmable Completion for Bash
Description    : 

    bash-completion is a collection of shell functions that take advantage
    of the programmable completion feature of Bash 2.04 and later.

slt@localhost:~> zypper info go-passbolt-cli-bash-completion
Loading repository data...
Reading installed packages...

Information for package go-passbolt-cli-bash-completion:
--------------------------------------------------------
Repository     : Main Repository (OSS)
Name           : go-passbolt-cli-bash-completion
Version        : 0.3.1-2.1
Arch           : noarch
Vendor         : openSUSE
Installed Size : 69.1 KiB
Installed      : Yes (automatically)
Status         : up-to-date
Source package : go-passbolt-cli-0.3.1-2.1.src
Upstream URL   : https://github.com/passbolt/go-passbolt-cli
Summary        : Bash Completion for go-passbolt-cli
Description    : 
    The official bash completion script for go-passbolt-cli, generated during the build.
kskarthik commented 1 month ago

ok, https://build.opensuse.org/projects/openSUSE:Factory/packages/go-passbolt-cli/files/go-passbolt-cli.spec?expand=1 L94 is where the bash completions go

kskarthik commented 1 month ago

i can see the bash completions listed. do you find any anomaly?


usr/share/man/man1/passbolt.1.gz
/usr/share/bash-completion/completions/go-passbolt-cli
kskarthik commented 1 month ago

should the completions match the binary name ?

speatzle commented 1 month ago

Moving to file to match the binary name and restarting bash fixed it for me

slt@localhost:~> sudo mv /usr/share/bash-completion/completions/go-passbolt-cli  /usr/share/bash-completion/completions/passbolt
[sudo] password for root: 
slt@localhost:~> bash
slt@localhost:~> passbolt 
configure  create     delete     export     get        help       list       move       share      update     verify     
slt@localhost:~> passbolt list 
folder    group     resource  user      
slt@localhost:~> passbolt list resource 
kskarthik commented 1 month ago

ok, i will correct it upstream too