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

Improved config handling and bugfixes #2716

Merged
merged 6 commits into from
Nov 24, 2023
Merged

Conversation

AnomalRoil
Copy link
Member

This PR is doing a few changes to the way we handle the Config action, its logging and also improves a few comments.

This is notably fixing #2673 by properly handling all the different cases for a local vs global config change not necessarily leading to a git add and git commit in the store.
Sadly, there is no way when using the gitconfig Set command to know if the option was written to the global vs local config, and so to do this really nicely we would need to change the signature of the func (c *Config) Set(mount, key, value string) error function to include a more explicit return value.
But we can fix the problem by properly handling the different errors than can arise during the Add and Commit phases of the config, which is what this PR does.

This PR also prevents us from setting the global config while reporting a misleading "No existing configuration found" error.
Previously, upon using gopass config some.name true on an uninitialized store, we would get the following:

🌟 Welcome to gopass!
⚠ No existing configuration found.
☝ Please run 'gopass setup'
true

Now we get just the expected true, since we do support changing the global config without having a store. When trying to do it on a local config, tho, it will now fail:

  • for the root store with:
     $ gopass config --store "<root>" some.name true
     
     Error: Store <root> seems uninitialized or cannot be initialized
    
  • on a substore, with:
     $ gopass config --store "test" some.name true
     Error: Error setting config value: failed to set config value "some.name": substore 'test' is not initialized or doesn't exist
    

pkg/gitconfig/configs.go Outdated Show resolved Hide resolved
internal/action/config.go Outdated Show resolved Hide resolved
@AnomalRoil
Copy link
Member Author

While doing this, I realized we are not properly supporting worktree level configs in gopass:
a worktree level config will take precedence over a local config or a global config, but we cannot alter or set its values from within gopass.

Is that expected @dominikschulz ?

@dominikschulz
Copy link
Member

My goal was to support worktree configs, but it was rather low priority and at this point I don't remember if I finished that part or not.

But the documentation claims that I didn't complete it: https://pkg.go.dev/github.com/gopasspw/gopass/pkg/gitconfig#hdr-Known_limitations

Copy link
Member

@dominikschulz dominikschulz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice! A few more remarks and questions, but I think we're almost there.

internal/action/config.go Outdated Show resolved Hide resolved
internal/action/config.go Outdated Show resolved Hide resolved
internal/action/config.go Outdated Show resolved Hide resolved
internal/action/config.go Show resolved Hide resolved
internal/backend/storage/fs/store.go Show resolved Hide resolved
pkg/gitconfig/configs.go Show resolved Hide resolved
Signed-off-by: Yolan Romailler <[email protected]>
Signed-off-by: Yolan Romailler <[email protected]>
Copy link
Member

@dominikschulz dominikschulz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks!

@dominikschulz dominikschulz merged commit d168602 into master Nov 24, 2023
8 checks passed
@dominikschulz dominikschulz deleted the config/fixcommits branch November 24, 2023 17:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Defects storage Storage / FS Backends
Projects
None yet
2 participants