feat: extend env helper

This commit is contained in:
franklin 2023-05-16 09:57:24 +02:00
parent f59e381301
commit 0b423e6d5b
4 changed files with 4 additions and 7 deletions

View File

@ -347,7 +347,7 @@ func (c *Command) completePaths(ctx context.Context, filename string, dir bool)
//nolint:forcetypeassert
func (c *Command) paths(ctx context.Context, filename string, dir bool) []string {
return c.cache.Get("paths-"+filename, func() any {
if value, err := files.Find(ctx, ".", filename); err != nil {
if value, err := files.Find(ctx, ".", filename, files.FindWithIgnore(`^(node_modules|\.\w*)$`)); err != nil {
c.l.Debug("failed to walk files", err.Error())
return []string{}
} else if dir {

View File

@ -4,7 +4,6 @@ import (
"context"
"fmt"
"os"
"path"
"github.com/foomo/posh-providers/kubernets/kubectl"
"github.com/foomo/posh-providers/onepassword"
@ -161,8 +160,7 @@ func (c *Command) authLogin(ctx context.Context, r *readline.Readline) error {
}
// resolve or retrieve service account access token
keyFilename := path.Join(
os.Getenv(env.ProjectRoot),
keyFilename := env.Path(
c.gcloud.ServiceAccountKeysPath(),
fmt.Sprintf("%s.json", accountName),
)

View File

@ -78,7 +78,7 @@ func New(l log.Logger, cache cache.Cache, opts ...Option) (*GCloud, error) {
return nil, errors.Wrapf(err, "failed to create directory %q", inst.cfg.ConfigPath)
}
if err := os.Setenv("CLOUDSDK_CONFIG", path.Join(os.Getenv(env.ProjectRoot), inst.cfg.ConfigPath)); err != nil {
if err := os.Setenv("CLOUDSDK_CONFIG", env.Path(inst.cfg.ConfigPath)); err != nil {
return nil, err
}

View File

@ -4,7 +4,6 @@ import (
"context"
"fmt"
"os"
"path"
"strings"
"github.com/foomo/posh/pkg/env"
@ -47,7 +46,7 @@ func (c *Cluster) Env() string {
}
func (c *Cluster) Config() string {
return path.Join(os.Getenv(env.ProjectRoot), c.kubectl.cfg.ConfigPath, c.Name()+".yaml")
return env.Path(c.kubectl.cfg.ConfigPath, c.Name()+".yaml")
}
func (c *Cluster) ConfigExists() bool {