forked from fluxcd/flux
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Provide read-only modes of using git
For the helm operator (and in some places in fluxd) we need only read-only access to the git repo. Indeed in some deployments, the helm operator will be given a read-only SSH key. So: give the git mirroring (git.Repo) a read-only option, which means it will - consider itself ready when it's been cloned, without checking whether it can write to the upstream repo; - not let you make a working clone (because it's assumed you won't be able to push commits from it) We still need a way to get a copy of the repo, so the helm operator can look at the files. For that purpose, add a bare-bones type `git.Export`, with which all you can do is get the directory it's been cloned to.
- Loading branch information
Showing
3 changed files
with
63 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package git | ||
|
||
import ( | ||
"context" | ||
"os" | ||
) | ||
|
||
type Export struct { | ||
dir string | ||
} | ||
|
||
func (e *Export) Dir() string { | ||
return e.dir | ||
} | ||
|
||
func (e *Export) Clean() { | ||
if e.dir != "" { | ||
os.RemoveAll(e.dir) | ||
} | ||
} | ||
|
||
// Export creates a minimal clone of the repo, at the ref given. | ||
func (r *Repo) Export(ctx context.Context, ref string) (*Export, error) { | ||
dir, err := r.workingClone(ctx, ref) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return &Export{dir}, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters