Init project
This commit is contained in:
3
internal/downloader/git.go
Normal file
3
internal/downloader/git.go
Normal file
@@ -0,0 +1,3 @@
|
||||
package downloader
|
||||
|
||||
// It should download a helm chart from git
|
3
internal/downloader/helm.go
Normal file
3
internal/downloader/helm.go
Normal file
@@ -0,0 +1,3 @@
|
||||
package downloader
|
||||
|
||||
// It should download a helm chart
|
35
internal/downloader/types.go
Normal file
35
internal/downloader/types.go
Normal file
@@ -0,0 +1,35 @@
|
||||
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
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user