-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: project-scoped repository credential improvements (#18388)
* feat: project-scoped repo cred improvements Implementation of #18290 Signed-off-by: Blake Pettersson <[email protected]> * fix: missed a test Signed-off-by: Blake Pettersson <[email protected]> * wip project key changes Signed-off-by: Blake Pettersson <[email protected]> * test: update mocks Signed-off-by: Blake Pettersson <[email protected]> * test: fix tests Signed-off-by: Blake Pettersson <[email protected]> * fix: equivalence even if project is empty Signed-off-by: Blake Pettersson <[email protected]> * fix: wip delete Signed-off-by: Blake Pettersson <[email protected]> * refactor: remove repositorydb Signed-off-by: Blake Pettersson <[email protected]> * chore: improve logging Signed-off-by: Blake Pettersson <[email protected]> * fix: pass project to getrepository Signed-off-by: Blake Pettersson <[email protected]> * test: fix failing test Signed-off-by: Blake Pettersson <[email protected]> * fix: compare with project secret instead of app secret Signed-off-by: Blake Pettersson <[email protected]> * fix: get repository needs same logic as delete Need to update the spec accordingly. Signed-off-by: Blake Pettersson <[email protected]> * feat: add project flag to repo rm command Signed-off-by: Blake Pettersson <[email protected]> * docs: make codegen Signed-off-by: Blake Pettersson <[email protected]> * test: fix failing test Signed-off-by: Blake Pettersson <[email protected]> * test: more failing tests Signed-off-by: Blake Pettersson <[email protected]> * chore: minor cleanups Signed-off-by: Blake Pettersson <[email protected]> * chore: propagate project from ui Signed-off-by: Blake Pettersson <[email protected]> * test: add new test cases Signed-off-by: Blake Pettersson <[email protected]> * chore: code review, improve formulation Signed-off-by: Blake Pettersson <[email protected]> * refactor: address cr feedback Signed-off-by: Blake Pettersson <[email protected]> --------- Signed-off-by: Blake Pettersson <[email protected]> Co-authored-by: Alexander Matyushentsev <[email protected]>
- Loading branch information
1 parent
44b8dc1
commit 4fd478b
Showing
41 changed files
with
992 additions
and
500 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,21 +6,12 @@ import ( | |
|
||
"github.com/argoproj/argo-cd/v2/pkg/apis/application/v1alpha1" | ||
"github.com/argoproj/argo-cd/v2/reposerver/apiclient" | ||
"github.com/argoproj/argo-cd/v2/util/db" | ||
"github.com/argoproj/argo-cd/v2/util/git" | ||
"github.com/argoproj/argo-cd/v2/util/io" | ||
) | ||
|
||
//go:generate go run github.com/vektra/mockery/[email protected] --name=RepositoryDB | ||
|
||
// RepositoryDB Is a lean facade for ArgoDB, | ||
// Using a lean interface makes it easier to test the functionality of the git generator | ||
type RepositoryDB interface { | ||
GetRepository(ctx context.Context, url string) (*v1alpha1.Repository, error) | ||
} | ||
|
||
type argoCDService struct { | ||
repositoriesDB RepositoryDB | ||
getRepository func(ctx context.Context, url, project string) (*v1alpha1.Repository, error) | ||
storecreds git.CredsStore | ||
submoduleEnabled bool | ||
repoServerClientSet apiclient.Clientset | ||
|
@@ -38,17 +29,17 @@ type Repos interface { | |
GetDirectories(ctx context.Context, repoURL string, revision string, noRevisionCache bool) ([]string, error) | ||
} | ||
|
||
func NewArgoCDService(db db.ArgoDB, submoduleEnabled bool, repoClientset apiclient.Clientset, newFileGlobbingEnabled bool) (Repos, error) { | ||
func NewArgoCDService(getRepository func(ctx context.Context, url, project string) (*v1alpha1.Repository, error), submoduleEnabled bool, repoClientset apiclient.Clientset, newFileGlobbingEnabled bool) (Repos, error) { | ||
return &argoCDService{ | ||
repositoriesDB: db.(RepositoryDB), | ||
getRepository: getRepository, | ||
submoduleEnabled: submoduleEnabled, | ||
repoServerClientSet: repoClientset, | ||
newFileGlobbingEnabled: newFileGlobbingEnabled, | ||
}, nil | ||
} | ||
|
||
func (a *argoCDService) GetFiles(ctx context.Context, repoURL string, revision string, pattern string, noRevisionCache bool) (map[string][]byte, error) { | ||
repo, err := a.repositoriesDB.GetRepository(ctx, repoURL) | ||
repo, err := a.getRepository(ctx, repoURL, "") | ||
if err != nil { | ||
return nil, fmt.Errorf("error in GetRepository: %w", err) | ||
} | ||
|
@@ -75,7 +66,7 @@ func (a *argoCDService) GetFiles(ctx context.Context, repoURL string, revision s | |
} | ||
|
||
func (a *argoCDService) GetDirectories(ctx context.Context, repoURL string, revision string, noRevisionCache bool) ([]string, error) { | ||
repo, err := a.repositoriesDB.GetRepository(ctx, repoURL) | ||
repo, err := a.getRepository(ctx, repoURL, "") | ||
if err != nil { | ||
return nil, fmt.Errorf("error in GetRepository: %w", err) | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.