-
Notifications
You must be signed in to change notification settings - Fork 284
/
git.go
47 lines (42 loc) · 1.24 KB
/
git.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package framework
import (
"context"
_ "embed"
"fmt"
"path/filepath"
"github.com/aws/eks-anywhere/pkg/api/v1alpha1"
"github.com/aws/eks-anywhere/pkg/filewriter"
gitFactory "github.com/aws/eks-anywhere/pkg/git/factory"
)
func (e *ClusterE2ETest) NewGitTools(ctx context.Context, cluster *v1alpha1.Cluster, fluxConfig *v1alpha1.FluxConfig, writer filewriter.FileWriter, repoPath string) (*gitFactory.GitTools, error) {
if fluxConfig == nil {
return nil, nil
}
var localGitWriterPath string
var localGitRepoPath string
if repoPath == "" {
r := e.gitRepoName()
localGitWriterPath = filepath.Join("git", r)
localGitRepoPath = filepath.Join(cluster.Name, "git", r)
} else {
localGitWriterPath = repoPath
localGitRepoPath = repoPath
}
tools, err := gitFactory.Build(ctx, cluster, fluxConfig, writer, gitFactory.WithRepositoryDirectory(localGitRepoPath))
if err != nil {
return nil, fmt.Errorf("creating Git provider: %v", err)
}
if tools.Provider != nil {
err = tools.Provider.Validate(ctx)
if err != nil {
return nil, err
}
}
gitwriter, err := writer.WithDir(localGitWriterPath)
if err != nil {
return nil, fmt.Errorf("creating file writer: %v", err)
}
gitwriter.CleanUpTemp()
tools.Writer = gitwriter
return tools, nil
}