Skip to content

Commit

Permalink
Add support for setting git user.name and user.email on gitops
Browse files Browse the repository at this point in the history
  • Loading branch information
mumoshu committed Jan 26, 2024
1 parent 74f9a02 commit 4df04d3
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 3 deletions.
26 changes: 26 additions & 0 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import (

const (
EnvVarPullRequestAssigneeIDs = "KANVAS_PULLREQUEST_ASSIGNEE_IDS"
EnvVarGitUserName = "KANVAS_GIT_USER_NAME"
EnvVarGitUserEmail = "KANVAS_GIT_USER_EMAIL"
EnvVarPullRequestHead = "KANVAS_PULLREQUEST_HEAD"
)

Expand All @@ -17,6 +19,10 @@ type ApplyOptions struct {
// PullRequestAssigneeIDs is the list of GitHub user IDs to assign to the pull request that will be created by the apply command.
// Each ID can be either an integer or a string.
PullRequestAssigneeIDs []string `json:"pullRequestAssigneeIDs"`
// GitUserName is the name of the user to use for the git commit.
GitUserName string `json:"gitUserName"`
// GitUserEmail is the email of the user to use for the git commit.
GitUserEmail string `json:"gitUserEmail"`
// PullRequestHead is the branch to create the pull request from.
PullRequestHead string `json:"pullRequestHead"`
// EnvVars is the list of environment variables to set for the apply command.
Expand Down Expand Up @@ -45,6 +51,14 @@ func (o *ApplyOptions) GetEnvVars() map[string]string {
m[EnvVarPullRequestAssigneeIDs] = strings.Join(o.PullRequestAssigneeIDs, ",")
}

if o.GitUserName != "" {
m[EnvVarGitUserName] = o.GitUserName
}

if o.GitUserEmail != "" {
m[EnvVarGitUserEmail] = o.GitUserEmail
}

if o.PullRequestHead != "" {
m[EnvVarPullRequestHead] = o.PullRequestHead
}
Expand All @@ -59,6 +73,10 @@ type DiffOptions struct {
// PullRequestAssigneeIDs is the list of GitHub user IDs to assign to the pull request that will be created by the apply command.
// Each ID can be either an integer or a string.
PullRequestAssigneeIDs []string `json:"pullRequestAssigneeIDs"`
// GitUserName is the name of the user to use for the git commit.
GitUserName string `json:"gitUserName"`
// GitUserEmail is the email of the user to use for the git commit.
GitUserEmail string `json:"gitUserEmail"`
// PullRequestHead is the branch to create the pull request from.
PullRequestHead string `json:"pullRequestHead"`
// EnvVars is the list of environment variables to set for the apply command.
Expand Down Expand Up @@ -87,6 +105,14 @@ func (o *DiffOptions) GetEnvVars() map[string]string {
m[EnvVarPullRequestAssigneeIDs] = strings.Join(o.PullRequestAssigneeIDs, ",")
}

if o.GitUserName != "" {
m[EnvVarGitUserName] = o.GitUserName
}

if o.GitUserEmail != "" {
m[EnvVarGitUserEmail] = o.GitUserEmail
}

if o.PullRequestHead != "" {
m[EnvVarPullRequestHead] = o.PullRequestHead
}
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ require (
github.com/hashicorp/go-multierror v1.1.1
github.com/hashicorp/hcl/v2 v2.16.2
github.com/helmfile/vals v0.25.0
github.com/mumoshu/kargo v0.10.1
github.com/mumoshu/kargo v0.11.0
github.com/projectdiscovery/yamldoc-go v1.0.4
github.com/r3labs/sse/v2 v2.10.0
github.com/spf13/cobra v1.6.1
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -425,8 +425,8 @@ github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJ
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
github.com/mumoshu/kargo v0.10.1 h1:aelhntD9Xkbg9TXff94jE0cVjbA0iK8NuTWu1LiWQvk=
github.com/mumoshu/kargo v0.10.1/go.mod h1:xeUe7h+GQA4EhrhmDMzLsmhS6yqeM8bbxlxRlnuJ0ZU=
github.com/mumoshu/kargo v0.11.0 h1:ezD5Ib/d1IvBGJEknbTTr6ncZFqh73nPGoYq+LWVNOU=
github.com/mumoshu/kargo v0.11.0/go.mod h1:xeUe7h+GQA4EhrhmDMzLsmhS6yqeM8bbxlxRlnuJ0ZU=
github.com/munisystem/sse/v2 v2.0.0-20230216080640-b0476d180764 h1:WuMYP/vrtwrulIDsH7PS5A2O5S2Muf+zgo2pooqGzGA=
github.com/munisystem/sse/v2 v2.0.0-20230216080640-b0476d180764/go.mod h1:Igau6Whc+F17QUgML1fYe1VPZzTV6EMCnYktEmkNJ7I=
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
Expand Down

0 comments on commit 4df04d3

Please sign in to comment.