in custom-targets/git-ops/git-deployer/deploy.go [285:316]
func copyToLocalGitRepo(srcPath, repo, gitPath string) (string, error) {
srcFile, err := os.Open(srcPath)
if err != nil {
return "", err
}
defer srcFile.Close()
var gitManifestPath string
// If git path is not provided then use the name of the local file.
if len(gitPath) == 0 {
_, file := filepath.Split(srcPath)
gitManifestPath = filepath.Join(repo, file)
} else {
gitManifestPath = filepath.Join(repo, gitPath)
}
// Create any directories in the local git repo path if necessary.
if err := os.MkdirAll(filepath.Dir(gitManifestPath), os.ModePerm); err != nil {
return "", err
}
dstFile, err := os.Create(gitManifestPath)
if err != nil {
return "", err
}
defer dstFile.Close()
if _, err := io.Copy(dstFile, srcFile); err != nil {
return "", err
}
return gitManifestPath, nil
}