feat: clear cache

This commit is contained in:
Kevin Franklin Kim 2025-04-04 16:45:12 +02:00
parent adceff3e4d
commit 2ac4f35ff5
No known key found for this signature in database
5 changed files with 17 additions and 8 deletions

View File

@ -73,7 +73,7 @@ func (c *Command) Validate(ctx context.Context, r *readline.Readline) error {
func (c *Command) Execute(ctx context.Context, r *readline.Readline) error {
dir, args := r.Args().Shift()
if _, err := os.Stat(dir); errors.Is(err, os.ErrNotExist) {
c.cache.Delete("")
c.cache.Delete()
c.l.Info("bootstrapping a new zeus:", dir)
return shell.New(ctx, c.l, "zeus", "bootstrap").
Args(args...).

View File

@ -1,6 +1,6 @@
package beam
type Database struct {
Port int `yaml:"port"`
Hostname string `yaml:"hostname"`
Port int `json:"port" yaml:"port"`
Hostname string `json:"hostname" yaml:"hostname"`
}

View File

@ -5,6 +5,7 @@ import (
"fmt"
"github.com/foomo/posh-providers/kubernets/kubectl"
"github.com/foomo/posh/pkg/cache"
"github.com/foomo/posh/pkg/command/tree"
"github.com/foomo/posh/pkg/env"
"github.com/foomo/posh/pkg/log"
@ -20,6 +21,7 @@ type (
l log.Logger
k3d *K3d
name string
cache cache.Cache
kubectl *kubectl.Kubectl
commandTree tree.Root
}
@ -41,10 +43,11 @@ func CommandWithName(v string) CommandOption {
// ~ Constructor
// ------------------------------------------------------------------------------------------------
func NewCommand(l log.Logger, k3d *K3d, kubectl *kubectl.Kubectl, opts ...CommandOption) (*Command, error) {
func NewCommand(l log.Logger, k3d *K3d, cache cache.Cache, kubectl *kubectl.Kubectl, opts ...CommandOption) (*Command, error) {
inst := &Command{
l: l.Named("k3d"),
k3d: k3d,
cache: cache,
kubectl: kubectl,
name: "k3d",
}
@ -347,12 +350,18 @@ func (c *Command) kubeconfig(ctx context.Context, r *readline.Readline) error {
}
// delete cluster
return shell.New(ctx, c.l, "k3d", "kubeconfig", "get", clusterCfg.AliasName()).
if err := shell.New(ctx, c.l, "k3d", "kubeconfig", "get", clusterCfg.AliasName()).
Args(">", c.kubectl.Cluster(name).Config("")).
Args(r.Flags()...).
Args(r.AdditionalArgs()...).
Args(r.AdditionalFlags()...).
Run()
Run(); err != nil {
return err
}
c.cache.Clear()
return nil
}
/*

View File

@ -8,7 +8,7 @@ import (
)
type Workspace struct {
Packages []string `yaml:"packages"`
Packages []string `json:"packages" yaml:"packages"`
}
func LoadWorkspace(filename string) (*Workspace, error) {

View File

@ -8,7 +8,7 @@ import (
)
type Workspace struct {
Packages []string `yaml:"packages"`
Packages []string `json:"packages" yaml:"packages"`
}
func LoadWorkspace(filename string) (*Workspace, error) {