Skip to content

Commit 4834f59

Browse files
author
Scott Schulthess
committed
add github app docs to readme
restore oauth basic remove private key file reference typo punctuation Update Golang from 1.22.10 to 1.23.7 and its dependencies
1 parent 8dc473a commit 4834f59

File tree

4 files changed

+26
-17
lines changed

4 files changed

+26
-17
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@ automated tests.
5656
| `labels` | No | `["bug", "enhancement"]` | The labels on the PR. The pipeline will only trigger on pull requests having at least one of the specified labels. |
5757
| `disable_git_lfs` | No | `true` | Disable Git LFS, skipping an attempt to convert pointers of files tracked into their corresponding objects when checked out into a working copy. |
5858
| `states` | No | `["OPEN", "MERGED"]` | The PR states to select (`OPEN`, `MERGED` or `CLOSED`). The pipeline will only trigger on pull requests matching one of the specified states. Default is ["OPEN"]. |
59+
| `use_github_app` | No | `false` | Whether to authenticate using a github app or not.
60+
| `github_organization` | No | `Vault-tec` | Which Github organization your github app is in.
61+
| `private_key` | No | `-----BEGIN RSA...` | Private key for your github app.
62+
| `installation_id` | No | `12356` | Installation id for your github app.
63+
| `application_id` | No | `12356` | Application id for your github app.
5964

6065
**Notes:**
6166

git.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ func NewGitClient(source *Source, dir string, output io.Writer) (*GitClient, err
4040
PrivateKey: source.PrivateKey,
4141
UseGithubApp: source.UseGitHubApp,
4242
ApplicationID: source.ApplicationID,
43-
GithubOrganziation: source.GithubOrganziation,
43+
GithubOrganziation: source.GithubOrganization,
4444
Directory: dir,
4545
Output: output,
4646
}, nil
@@ -102,6 +102,10 @@ func (g *GitClient) Init(branch string) error {
102102
if err := g.command("git", "config", "credential.https://github.com.helper", helperStr).Run(); err != nil {
103103
return fmt.Errorf("failed to configure github url: %s", err)
104104
}
105+
} else {
106+
if err := g.command("git", "config", "url.https://[email protected]/.insteadOf", "[email protected]:").Run(); err != nil {
107+
return fmt.Errorf("failed to configure github url: %s", err)
108+
}
105109
}
106110
if err := g.command("git", "config", "--global", "url.https://.insteadOf", "git://").Run(); err != nil {
107111
return fmt.Errorf("failed to configure github url: %s", err)

models.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ type Source struct {
3030
TrustedTeams []string `json:"trusted_teams"`
3131
TrustedUsers []string `json:"trusted_users"`
3232
UseGitHubApp bool `json:"use_github_app"`
33-
GithubOrganziation string `json:"github_organization"`
33+
GithubOrganization string `json:"github_organization"`
3434
PrivateKey string `json:"private_key"`
3535
ApplicationID int64 `json:"application_id"`
3636
InstallationID int64 `json:"installation_id"`
@@ -43,12 +43,12 @@ func (s *Source) Validate() error {
4343
}
4444
if s.UseGitHubApp {
4545
if s.PrivateKey == "" {
46-
return errors.New("Either private_key or private_key_file should be supplied if using GitHub App authentication")
46+
return errors.New("private_key is required for GitHub App authentication")
4747
}
4848
if s.ApplicationID == 0 || s.InstallationID == 0 {
4949
return errors.New("application_id and installation_id must be set if using GitHub App authentication")
5050
}
51-
if len(s.GithubOrganziation) == 0 {
51+
if len(s.GithubOrganization) == 0 {
5252
return errors.New("github_organization must be set if using GitHub App authentication")
5353
}
5454
if s.AccessToken != "" {

models_test.go

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -38,23 +38,23 @@ func TestSource(t *testing.T) {
3838
{
3939
description: "should support GitHub App authentication",
4040
source: resource.Source{
41-
Repository: "test/test",
41+
Repository: "test/test",
4242
GithubOrganziation: "test",
43-
UseGitHubApp: true,
44-
PrivateKey: "key.pem",
45-
ApplicationID: 123456,
46-
InstallationID: 1,
43+
UseGitHubApp: true,
44+
PrivateKey: "key.pem",
45+
ApplicationID: 123456,
46+
InstallationID: 1,
4747
},
4848
},
4949
{
50-
description: "requires a private_key or private_key_file GitHub App configuration values",
50+
description: "private_key App configuration values",
5151
source: resource.Source{
5252
Repository: "test/test",
5353
UseGitHubApp: true,
5454
ApplicationID: 123456,
5555
InstallationID: 1,
5656
},
57-
wantErr: "Either private_key or private_key_file should be supplied if using GitHub App authentication",
57+
wantErr: "private_key is required for GitHub App authentication",
5858
},
5959
{
6060
description: "requires an application_id and installation_id GitHub App configuration values",
@@ -69,13 +69,13 @@ func TestSource(t *testing.T) {
6969
{
7070
description: "should not have an access_token when using GitHub App authentication",
7171
source: resource.Source{
72-
Repository: "test/test",
73-
UseGitHubApp: true,
72+
Repository: "test/test",
73+
UseGitHubApp: true,
7474
GithubOrganziation: "test",
75-
PrivateKey: "key.pem",
76-
ApplicationID: 123456,
77-
InstallationID: 1,
78-
AccessToken: "123456",
75+
PrivateKey: "key.pem",
76+
ApplicationID: 123456,
77+
InstallationID: 1,
78+
AccessToken: "123456",
7979
},
8080
wantErr: "access_token is not required when using GitHub App authentication",
8181
},

0 commit comments

Comments
 (0)