Skip to content

Commit

Permalink
Username and email must be set
Browse files Browse the repository at this point in the history
The values aren't super important, as we're only using them to support
merging branches in git and never pushing code.
  • Loading branch information
djeebus committed Jan 8, 2024
1 parent 3794ae9 commit c80e375
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 5 deletions.
5 changes: 5 additions & 0 deletions pkg/vcs/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ import (
"github.com/zapier/kubechecks/pkg/repo"
)

const (
DefaultVcsUsername = "kubechecks"
DefaultVcsEmail = "[email protected]"
)

var (
// ErrInvalidType is a sentinel error for use in client implementations
ErrInvalidType = errors.New("invalid event type")
Expand Down
22 changes: 18 additions & 4 deletions pkg/vcs/github_client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,26 @@ func CreateGithubClient() (*Client, error) {
return nil, errors.Wrap(err, "failed to get user")
}

return &Client{
client := &Client{
Client: googleClient,
v4Client: shurcoolClient,
username: *user.Login,
email: *user.Email,
}, nil
}
if user != nil {
if user.Login != nil {
client.username = *user.Login
}
if user.Email != nil {
client.email = *user.Email
}
}

if client.username == "" {
client.username = vcs.DefaultVcsUsername
}
if client.email == "" {
client.email = vcs.DefaultVcsEmail
}
return client, nil
}

func (c *Client) Username() string { return c.username }
Expand Down
9 changes: 8 additions & 1 deletion pkg/vcs/gitlab_client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,14 @@ func CreateGitlabClient() (*Client, error) {
return nil, errors.Wrap(err, "failed to get current user")
}

return &Client{Client: c, username: user.Username, email: user.Email}, nil
client := &Client{Client: c, username: user.Username, email: user.Email}
if client.username == "" {
client.username = vcs.DefaultVcsUsername
}
if client.email == "" {
client.email = vcs.DefaultVcsEmail
}
return client, nil
}

func (c *Client) Email() string { return c.email }
Expand Down

0 comments on commit c80e375

Please sign in to comment.