Skip to content

Commit

Permalink
Merge pull request #2248 from rsteube/cache-key
Browse files Browse the repository at this point in the history
updated carapace
  • Loading branch information
rsteube authored Feb 17, 2024
2 parents 0829bdc + 202e1a9 commit 3ee6a55
Show file tree
Hide file tree
Showing 11 changed files with 26 additions and 24 deletions.
4 changes: 2 additions & 2 deletions completers/code_completer/cmd/action/extension.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"time"

"github.com/rsteube/carapace"
"github.com/rsteube/carapace/pkg/cache"
"github.com/rsteube/carapace/pkg/cache/key"
"github.com/spf13/cobra"
)

Expand Down Expand Up @@ -87,5 +87,5 @@ func ActionMicrosoftExtensions(category string) carapace.Action {
return carapace.ActionCallback(func(c carapace.Context) carapace.Action {
// Microsoft extensions are aliased and only found by the 'Microsoft' publisher (though the actual name differs)
return ActionExtensionSearch(category).Invoke(carapace.Context{Value: "Microsoft"}).ToA()
}).Cache(24*time.Hour, cache.String(category))
}).Cache(24*time.Hour, key.String(category))
}
4 changes: 2 additions & 2 deletions completers/gradle_completer/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"strings"

"github.com/rsteube/carapace"
"github.com/rsteube/carapace/pkg/cache"
"github.com/rsteube/carapace/pkg/cache/key"
"github.com/rsteube/carapace/pkg/style"
"github.com/rsteube/carapace/pkg/util"
"github.com/spf13/cobra"
Expand Down Expand Up @@ -126,7 +126,7 @@ func ActionTasks() carapace.Action {
if buildConfig, err := locateBuildConfig(); err != nil {
return "", err
} else {
return cache.FileChecksum(buildConfig)()
return key.FileChecksum(buildConfig)()
}
})
}
Expand Down
4 changes: 2 additions & 2 deletions completers/pulumi_completer/cmd/action/urn.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"time"

"github.com/rsteube/carapace"
"github.com/rsteube/carapace/pkg/cache"
"github.com/rsteube/carapace/pkg/cache/key"
"github.com/spf13/cobra"
)

Expand Down Expand Up @@ -47,7 +47,7 @@ func ActionUrns(cmd *cobra.Command) carapace.Action {
return "", err
}

return cache.String(absWd, stack)()
return key.String(absWd, stack)()
},
).Invoke(c).ToA()
})
Expand Down
4 changes: 2 additions & 2 deletions completers/sdkmanager_completer/cmd/action/action.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"time"

"github.com/rsteube/carapace"
"github.com/rsteube/carapace/pkg/cache"
"github.com/rsteube/carapace/pkg/cache/key"
"github.com/spf13/cobra"
)

Expand Down Expand Up @@ -36,7 +36,7 @@ func ActionAvailablePackages(cmd *cobra.Command) carapace.Action {
}
}
return carapace.ActionValuesDescribed(vals...)
}).Cache(1*time.Hour, cache.String(sdk_root, channel))
}).Cache(1*time.Hour, key.String(sdk_root, channel))
})
}

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.21

require (
github.com/pelletier/go-toml v1.9.5
github.com/rsteube/carapace v0.49.2
github.com/rsteube/carapace v0.50.0
github.com/rsteube/carapace-bridge v0.2.12
github.com/rsteube/carapace-shlex v0.1.2
github.com/rsteube/carapace-spec v0.15.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ github.com/pelletier/go-toml v1.9.5 h1:4yBQzkHv+7BHq2PQUZF3Mx0IYxG7LsP222s7Agd3v
github.com/pelletier/go-toml v1.9.5/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/rsteube/carapace v0.49.2 h1:BMtZK/iGeGFF2cAIn+x0zM46ZbNt7OM+p18sHHXpXm4=
github.com/rsteube/carapace v0.49.2/go.mod h1:syVOvI8e2rEEK/9aMZxfWuHvcnQK/EcnTV4roClEnLE=
github.com/rsteube/carapace v0.50.0 h1:LO3ehEjcdbIx9owiyCiVfgL5A0cJPGq4X7c8V5DsA20=
github.com/rsteube/carapace v0.50.0/go.mod h1:syVOvI8e2rEEK/9aMZxfWuHvcnQK/EcnTV4roClEnLE=
github.com/rsteube/carapace-bridge v0.2.12 h1:d1kgjgqrmgOa7lHLj/b/esJv692kHSQvTXhmzdx8dwQ=
github.com/rsteube/carapace-bridge v0.2.12/go.mod h1:dT8ZptEIYd4zyg5CnPPr+hiLDukPu+lZLcNeyU2Wy2w=
github.com/rsteube/carapace-pflag v0.2.0 h1:EYqFO9Haib3NDCPqKu0VxOGi9YQBkXk1IzlHdT0M0vw=
Expand Down
4 changes: 2 additions & 2 deletions pkg/actions/fs/tar.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"time"

"github.com/rsteube/carapace"
"github.com/rsteube/carapace/pkg/cache"
"github.com/rsteube/carapace/pkg/cache/key"
"github.com/rsteube/carapace/pkg/style"
)

Expand All @@ -18,6 +18,6 @@ func ActionTarFileContents(file string) carapace.Action {
return carapace.ActionExecCommand("tar", "--list", "--file", file)(func(output []byte) carapace.Action {
lines := strings.Split(string(output), "\n")
return carapace.ActionValues(lines[:len(lines)-1]...)
}).Cache(24*time.Hour, cache.FileStats(file)).Invoke(c).ToMultiPartsA("/").StyleF(style.ForPathExt)
}).Cache(24*time.Hour, key.FileStats(file)).Invoke(c).ToMultiPartsA("/").StyleF(style.ForPathExt)
})
}
8 changes: 4 additions & 4 deletions pkg/actions/tools/dbt/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"time"

"github.com/rsteube/carapace"
"github.com/rsteube/carapace/pkg/cache"
"github.com/rsteube/carapace/pkg/cache/key"
"github.com/rsteube/carapace/pkg/style"
"github.com/rsteube/carapace/pkg/util"
)
Expand Down Expand Up @@ -36,8 +36,8 @@ func (o ResourceOpts) Default() ResourceOpts {
return o
}

func (o ResourceOpts) key() cache.Key {
return cache.String(
func (o ResourceOpts) key() key.Key {
return key.String(
strconv.FormatBool(o.Analysis),
strconv.FormatBool(o.Exposure),
strconv.FormatBool(o.Metric),
Expand Down Expand Up @@ -118,6 +118,6 @@ func ActionResources(opts ResourceOpts) carapace.Action {
}
}
return carapace.ActionStyledValuesDescribed(vals...)
}).Cache(24*time.Hour, opts.key(), cache.FileStats(path)) // TODO opts , manifest.json constantly gets new modification time??
}).Cache(24*time.Hour, opts.key(), key.FileStats(path)) // TODO opts , manifest.json constantly gets new modification time??
}).Tag("resources")
}
6 changes: 4 additions & 2 deletions pkg/actions/tools/gh/gh.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
// package gh contains github related actions
package gh

import "github.com/rsteube/carapace/pkg/cache"
import (
"github.com/rsteube/carapace/pkg/cache/key"
)

type HostOpts struct {
Host string
Expand All @@ -27,4 +29,4 @@ type RepoOpts struct {
Name string
}

func (o RepoOpts) cacheKey() cache.Key { return cache.String(o.Host, o.Owner, o.Name) }
func (o RepoOpts) cacheKey() key.Key { return key.String(o.Host, o.Owner, o.Name) }
4 changes: 2 additions & 2 deletions pkg/actions/tools/mvn/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"strings"

"github.com/rsteube/carapace"
"github.com/rsteube/carapace/pkg/cache"
"github.com/rsteube/carapace/pkg/cache/key"
"github.com/rsteube/carapace/pkg/util"
)

Expand All @@ -26,6 +26,6 @@ func ActionProjects(file string) carapace.Action {
return carapace.ActionExecCommand("mvn", args...)(func(output []byte) carapace.Action {
lines := strings.Split(string(output), "\n")
return carapace.ActionValues(lines[:len(lines)-1]...)
}).Cache(-1, cache.FileStats(file))
}).Cache(-1, key.FileStats(file))
})
}
6 changes: 3 additions & 3 deletions pkg/actions/tools/youtubedl/youtubedl.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"time"

"github.com/rsteube/carapace"
"github.com/rsteube/carapace/pkg/cache"
"github.com/rsteube/carapace/pkg/cache/key"
)

// ActionFormats completes formats
Expand Down Expand Up @@ -35,7 +35,7 @@ func ActionFormats(url string) carapace.Action {
}
}
return carapace.ActionValuesDescribed(vals...)
}).Cache(1*time.Hour, cache.String(c.Args[0]))
}).Cache(1*time.Hour, key.String(c.Args[0]))
})
}

Expand Down Expand Up @@ -64,6 +64,6 @@ func ActionSubLangs(url string) carapace.Action {
}
}
return carapace.ActionValuesDescribed(vals...)
}).Cache(1*time.Hour, cache.String(c.Args[0]))
}).Cache(1*time.Hour, key.String(c.Args[0]))
})
}

0 comments on commit 3ee6a55

Please sign in to comment.