This repository has been archived by the owner on Nov 1, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use git repo config to identify SyncSet
Using a constant for identifying sync sets means that if more than one fluxd is running in a cluster, they will garbage collect each other's resources. We want to be able to delimit which resources are _this_ fluxd's responsibility. Using the git config, including the branch and paths, means fluxd will only garbage collect files that are in the bit of the repo it is applying. That assumes no other fluxd is looking at (exactly) the same directories in the same git URL -- which is a fair assumption, since that would obviously be a bad config and cause problems, even without considering garbage collection.
- Loading branch information
Showing
5 changed files
with
71 additions
and
6 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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,24 @@ | ||
package git | ||
|
||
import ( | ||
"fmt" | ||
"net/url" | ||
|
||
"github.com/whilp/git-urls" | ||
) | ||
|
||
// Remote points at a git repo somewhere. | ||
type Remote struct { | ||
URL string // clone from here | ||
} | ||
|
||
func (r Remote) SafeURL() string { | ||
u, err := giturls.Parse(r.URL) | ||
if err != nil { | ||
return fmt.Sprintf("<unparseable: %s>", r.URL) | ||
} | ||
if u.User != nil { | ||
u.User = url.User(u.User.Username()) | ||
} | ||
return u.String() | ||
} |
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,20 @@ | ||
package git | ||
|
||
import ( | ||
"strings" | ||
"testing" | ||
) | ||
|
||
func TestSafeURL(t *testing.T) { | ||
const password = "abc123" | ||
for _, url := range []string{ | ||
"git@github.com:weaveworks/flux", | ||
"https://user@example.com:5050/repo.git", | ||
"https://user:" + password + "@example.com:5050/repo.git", | ||
} { | ||
u := Remote{url} | ||
if strings.Contains(u.SafeURL(), password) { | ||
t.Errorf("Safe URL for %s contains password %q", url, password) | ||
} | ||
} | ||
} |