Files
yaho/internal/downloader/types.go
Nikolai Rodionov 7c2294d9df
Some checks failed
Lint / Run on Ubuntu (push) Has been cancelled
E2E Tests / Run on Ubuntu (push) Has been cancelled
Tests / Run on Ubuntu (push) Has been cancelled
Init project
2025-07-15 17:58:36 +02:00

36 lines
842 B
Go

package downloader
import (
"context"
"fmt"
"strings"
"github.com/allanger/yaho/internal/tools/git"
"github.com/allanger/yaho/internal/tools/helm"
)
type PullOptions struct {}
// A very stupid check
func isGitRepo(repository string) bool {
return strings.HasPrefix(repository, "git@") || strings.HasSuffix(repository, ".git")
}
// Pull chart into a temporary directory
func PullChart(ctx context.Context, repository, chart, version string, opts *PullOptions) (string, error) {
if isGitRepo(repository) {
git := git.GitLib{}
path, err := git.CloneRepo(ctx, repository, version)
if err != nil {
return "", err
}
return fmt.Sprintf("%s/%s", path, chart), nil
} else {
helm := helm.HelmLib{}
path, err := helm.PullChart(ctx, repository, chart, version)
if err != nil {
return "", err
}
return path, nil
}
}