Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion docs/spec/v1/gitrepositories.md
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ The `github` provider can be used to authenticate to Git repositories using
The GitHub App information is specified in `.spec.secretRef` in the format
specified below:

- Get the App ID from the app settings page at `https://github.com/settings/apps/<app-name>`.
- Get the App ID or Client ID from the app settings page at `https://github.com/settings/apps/<app-name>`.
- The private key that was generated in the pre-requisites.
- (Optional) GitHub Enterprise Server users can set the base URL to
`http(s)://HOSTNAME/api/v3`.
Expand All @@ -426,6 +426,7 @@ metadata:
type: Opaque
stringData:
githubAppID: "<app-id>"
githubAppClientID: "<client-id>"
githubAppInstallationOwner: "<github-org-or-user>"
githubAppInstallationID: "<app-installation-id>"
githubAppPrivateKey: |
Expand All @@ -439,6 +440,9 @@ stringData:
-----END CERTIFICATE-----
```

Exactly one of `githubAppID` or `githubAppClientID` must be provided.
If neither or both are provided, the reconciliation will fail with a misconfiguration error.

Exactly one of `githubAppInstallationOwner` or `githubAppInstallationID` must be provided.
If neither or both are provided, the reconciliation will fail with a misconfiguration error.
When `githubAppInstallationOwner` is provided, the controller will look for the installation
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ require (
github.com/fluxcd/pkg/apis/event v0.29.0
github.com/fluxcd/pkg/apis/meta v1.32.0
github.com/fluxcd/pkg/artifact v0.21.0
github.com/fluxcd/pkg/auth v0.57.0
github.com/fluxcd/pkg/auth v0.58.0
github.com/fluxcd/pkg/cache v0.15.0
github.com/fluxcd/pkg/git v0.53.0
github.com/fluxcd/pkg/gittestserver v0.30.0
github.com/fluxcd/pkg/helmtestserver v0.42.0
github.com/fluxcd/pkg/http/transport v0.8.0
github.com/fluxcd/pkg/masktoken v0.9.0
github.com/fluxcd/pkg/oci v0.70.0
github.com/fluxcd/pkg/runtime v0.112.0
github.com/fluxcd/pkg/runtime v0.114.0
github.com/fluxcd/pkg/sourceignore v0.19.0
github.com/fluxcd/pkg/ssh v0.26.0
github.com/fluxcd/pkg/tar v1.2.0
Expand Down
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,8 @@ github.com/fluxcd/pkg/artifact v0.21.0 h1:hUb2JacxhTLMNmFy8G6IvJxJLFvifNpCr7dDuE
github.com/fluxcd/pkg/artifact v0.21.0/go.mod h1:XZkvL7gtJoVTclRBrvwklW6PLazt00tT7TKDPhINZoU=
github.com/fluxcd/pkg/auth v0.57.0 h1:RJu5Sn8sel0/LZ0FyN/FL4juyQyOqIHHhL7nVV4GMAw=
github.com/fluxcd/pkg/auth v0.57.0/go.mod h1:aJYfAWHGN2332txF1EInn/N13A8CjpKPQRc8tCqvKmY=
github.com/fluxcd/pkg/auth v0.58.0 h1:2MUjD8rw1kZY4ULs5HLCAlw/DAdMMUXGvtKFt/wZyjo=
github.com/fluxcd/pkg/auth v0.58.0/go.mod h1:aJYfAWHGN2332txF1EInn/N13A8CjpKPQRc8tCqvKmY=
github.com/fluxcd/pkg/cache v0.15.0 h1:/mb5nEFWKETY3cXdw2nfYuDZp7deFXDw479dBhQHzjc=
github.com/fluxcd/pkg/cache v0.15.0/go.mod h1:Xttm38GeHpQCphCyTTuXSLeLE5psR7+DaSO4Ov28AEw=
github.com/fluxcd/pkg/git v0.53.0 h1:wHtxfJ+qaNSQowaZB8Lr5adZO7psAsaID0E5W5QZREs=
Expand All @@ -382,6 +384,8 @@ github.com/fluxcd/pkg/oci v0.70.0 h1:rylPalOomTmMPR/SYSEcADxo6XM1AUr62FMwLoubd0Y
github.com/fluxcd/pkg/oci v0.70.0/go.mod h1:+mnv4AX8sGeCqFEF3xs9O04on8ByZNtq/ZQIHXJk0qU=
github.com/fluxcd/pkg/runtime v0.112.0 h1:FnE+98Fg2LJYRBxMYGOIuE4C7nwtLMCXxFFJpMizdsA=
github.com/fluxcd/pkg/runtime v0.112.0/go.mod h1:YUljTAXVaeWG+GLnXNZopFFMZstUoTxJs7+vl91OV58=
github.com/fluxcd/pkg/runtime v0.114.0 h1:uLQ92LeZEmxoFZhQoLUox7C13YUQ1WFYU28Bocl71mw=
github.com/fluxcd/pkg/runtime v0.114.0/go.mod h1:+h0Fyn5VfqFklfXxQJ0cuTxdS6RfE0qCwsSJa09vwy0=
github.com/fluxcd/pkg/sourceignore v0.19.0 h1:s3/E03o9JTAvjIE7K8vI257AT2+0zy8cFOFaX+lx0z8=
github.com/fluxcd/pkg/sourceignore v0.19.0/go.mod h1:MYwDEmDdj5GjHg1r1ljgtNkXNGkeV42G8BnCsggqExg=
github.com/fluxcd/pkg/ssh v0.26.0 h1:fKw0gyZ2KgbngyI4zAzIfa0qnB4XjSpxBg1ZP6RySc8=
Expand Down
2 changes: 1 addition & 1 deletion internal/controller/gitrepository_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -794,7 +794,7 @@ func (r *GitRepositoryReconciler) getAuthOpts(ctx context.Context, obj *sourcev1
}
default:
// analyze secret, if it has github app data, perhaps provider should have been github.
if appID := authData[githubapp.KeyAppID]; len(appID) != 0 {
if len(authData[githubapp.KeyAppID]) != 0 || len(authData[githubapp.KeyAppClientID]) != 0 {
e := serror.NewGeneric(
fmt.Errorf("secretRef '%s/%s' has github app data but provider is not set to github", obj.GetNamespace(), obj.Spec.SecretRef.Name),
sourcev1.InvalidProviderConfigurationReason,
Expand Down
19 changes: 19 additions & 0 deletions internal/controller/gitrepository_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1028,6 +1028,25 @@ func TestGitRepositoryReconciler_getAuthOpts_provider(t *testing.T) {
},
wantErr: "secretRef '/githubAppSecret' has github app data but provider is not set to github",
},
{
name: "generic provider with github app client id in secret",
url: "https://example.com/org/repo",
secret: &corev1.Secret{
ObjectMeta: metav1.ObjectMeta{
Name: "githubAppSecret",
},
Data: map[string][]byte{
githubapp.KeyAppClientID: []byte("Iv23liXXXXXXX"),
},
},
beforeFunc: func(obj *sourcev1.GitRepository) {
obj.Spec.Provider = sourcev1.GitProviderGeneric
obj.Spec.SecretRef = &meta.LocalObjectReference{
Name: "githubAppSecret",
}
},
wantErr: "secretRef '/githubAppSecret' has github app data but provider is not set to github",
},
{
name: "github provider with basic auth secret",
url: "https://github.com/org/repo.git",
Expand Down
Loading