Skip to content

Commit

Permalink
chore: Remove gopass version check
Browse files Browse the repository at this point in the history
  • Loading branch information
twpayne committed Nov 9, 2023
1 parent c7f7b4e commit b58ac65
Showing 1 changed file with 3 additions and 42 deletions.
45 changes: 3 additions & 42 deletions internal/cmd/gopasstemplatefuncs.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,12 @@ var (
)

type gopassConfig struct {
Command string `json:"command" mapstructure:"command" yaml:"command"`
versionOK bool
cache map[string]string
rawCache map[string][]byte
Command string `json:"command" mapstructure:"command" yaml:"command"`
cache map[string]string
rawCache map[string][]byte
}

func (c *Config) gopassTemplateFunc(id string) string {
if !c.Gopass.versionOK {
if err := c.gopassVersionCheck(); err != nil {
panic(err)
}
c.Gopass.versionOK = true
}

if password, ok := c.Gopass.cache[id]; ok {
return password
}
Expand All @@ -57,13 +49,6 @@ func (c *Config) gopassTemplateFunc(id string) string {
}

func (c *Config) gopassRawTemplateFunc(id string) string {
if !c.Gopass.versionOK {
if err := c.gopassVersionCheck(); err != nil {
panic(err)
}
c.Gopass.versionOK = true
}

if output, ok := c.Gopass.rawCache[id]; ok {
return string(output)
}
Expand Down Expand Up @@ -93,27 +78,3 @@ func (c *Config) gopassOutput(args ...string) ([]byte, error) {
}
return output, nil
}

func (c *Config) gopassVersionCheck() error {
output, err := c.gopassOutput("--version")
if err != nil {
return err
}
m := gopassVersionRx.FindSubmatch(output)
if m == nil {
return &extractVersionError{
output: output,
}
}
version, err := semver.NewVersion(string(m[1]))
if err != nil {
return err
}
if version.LessThan(gopassMinVersion) {
return &versionTooOldError{
have: version,
need: &gopassMinVersion,
}
}
return nil
}

0 comments on commit b58ac65

Please sign in to comment.