-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Conversation
git/operations.go
Outdated
func commit(ctx context.Context, workingDir, commitMessage string) error { | ||
func commit(ctx context.Context, workingDir string, commitAction *CommitAction) error { | ||
commitAuthor := commitAction.Author | ||
// The user in the update.Cause.User must be a valid github user, otherwise the commit fails |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
git/operations.go
Outdated
// then this is just about ok. Otherwise there could be config file with stored users to ignore etc. | ||
// Currently the committer is hardcoded to flux-bot for user requested actions. | ||
// TODO (potentially): allow the users to set the committer, ie have an additional | ||
// update.Cause.Committer field. |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
git/operations.go
Outdated
// Currently the committer is hardcoded to flux-bot for user requested actions. | ||
// TODO (potentially): allow the users to set the committer, ie have an additional | ||
// update.Cause.Committer field. | ||
if commitAuthor != "" && commitAuthor != "test@test" { |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
git/operations.go
Outdated
return errors.Wrap(err, "git commit config") | ||
} | ||
if err := execGitCmd(ctx, | ||
workingDir, nil, nil, |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
daemon/daemon.go
Outdated
@@ -96,7 +97,7 @@ func (d *Daemon) ListServices(namespace string) ([]flux.ServiceStatus, error) { | |||
return res, nil | |||
} | |||
|
|||
// List the images available for set of services | |||
// ListImages - List the images available for set of services |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks pretty good. I've suggested some tidies. I'm going to try it out now :)
cmd/fluxctl/args.go
Outdated
cmd.Flags().StringVarP(&opts.Message, "message", "m", "", "attach a message to the update") | ||
cmd.Flags().StringVar(&opts.User, "user", username, "override the user reported as initating the update") | ||
cmd.Flags().StringVar(&opts.User, "user", username, "override the user reported as initiating the update") |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
cmd/fluxctl/args.go
Outdated
authorInfo := getUserGitconfig() | ||
userName := authorInfo["user.name"] | ||
|
||
switch userName { |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
cmd/fluxctl/args.go
Outdated
userGitconfig["user.email"] = "" | ||
return userGitconfig | ||
} | ||
res := out.String() |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
cmd/fluxctl/args.go
Outdated
func userGitconfigMap(s string) map[string]string { | ||
c := make(map[string]string) | ||
lines := splitList(s) | ||
if len(lines) == 0 { |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
cmd/fluxctl/args.go
Outdated
} | ||
userGitconfig["user.name"] = username | ||
userGitconfig["user.email"] = "" | ||
return userGitconfig |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
cmd/fluxd/main.go
Outdated
gitPath = fs.String("git-path", "", "path within git repo to locate Kubernetes manifests (relative path)") | ||
gitUser = fs.String("git-user", "Weave Flux", "username to use as git committer") | ||
gitEmail = fs.String("git-email", "support@weave.works", "email to use as git committer") | ||
gitSetAuthor = fs.Bool("git-set-author", false, "boolean to set a git author different to git committer") |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
daemon/daemon.go
Outdated
@@ -511,3 +525,10 @@ func policyEventTypes(u policy.Update) []string { | |||
sort.Strings(result) | |||
return result | |||
} | |||
|
|||
func getCommitAuthor(setAuthor bool, author string) string { |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
cmd/fluxctl/args.go
Outdated
userName := authorInfo["user.name"] | ||
userEmail := authorInfo["user.email"] | ||
|
||
switch userName { |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
cmd/fluxctl/args_test.go
Outdated
|
||
userGitconfigInfo := userGitconfigMap(d) | ||
if len(userGitconfigInfo) != 6 { | ||
t.Fatal("expected no content") |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
gitPath = fs.String("git-path", "", "path within git repo to locate Kubernetes manifests (relative path)") | ||
gitUser = fs.String("git-user", "Weave Flux", "username to use as git committer") | ||
gitEmail = fs.String("git-email", "support@weave.works", "email to use as git committer") | ||
gitSetAuthor = fs.Bool("git-set-author", false, "If set, the author of git commits will reflect the user who initiated the commit and will differ from the git committer.") |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good to go 🏅
Thanks for sticking at it!
(Please |
Refactored with fluxd set-author-flag
54b81f2
to
366fd04
Compare
No description provided.