Add repository credential management API and CLI (addresses #2136)#2207
Add repository credential management API and CLI (addresses #2136)#2207alexec merged 55 commits intoargoproj:masterfrom
Conversation
|
looking good so far - I've some polish comments - but I'll wait until this is |
|
I think this PR is complete now. Sorry for it being so large again, I owe you guys a beer or two for all the review work I generate. |
alexec
left a comment
There was a problem hiding this comment.
Another great PR. I've just added some comments as I'm on vacation for a few days now.
|
Regarding the removal of |
alexec
left a comment
There was a problem hiding this comment.
The Helm work is now merged. You'll need to git merge master
|
Don't forget to let us know when it is ready for review. |
|
I'm still working on moving the credentials part out of |
|
I've introduced Final steps are now to adapt the UI to the new semantics, and also to merge the conflicts from master (I hope for the last time). |
|
@alexec I think this is now finally ready for review. Please note that the change is now more invasive than initially was planned, but should be non breaking in terms of configuration - except when someone had The UI still needs a little love, it's a little hackish implementation. I was thinking about moving the credentials part to its own settings page in the future, but for now, the current implementation in the repositories section seems good enough. |
alexec
left a comment
There was a problem hiding this comment.
This looks good me. I'd like to target if for v1.4 rather than v1.3 as we're going to branch v1.3 today (hopefully). @alexmt @jessesuen do you want to review the API changes please?
| if sshPrivateKeyPath != "" { | ||
| if ok, _ := git.IsSSHURL(repo.URL); ok { | ||
| keyData, err := ioutil.ReadFile(sshPrivateKeyPath) | ||
| if err != nil { |
There was a problem hiding this comment.
minor - could use error.Check(..)
| // Print the repository credentials as table | ||
| func printRepoCredsTable(repos []appsv1.RepoCreds) { | ||
| w := tabwriter.NewWriter(os.Stdout, 0, 0, 2, ' ', 0) | ||
| fmt.Fprintf(w, "URL_PATTERN\tUSERNAME\tSSH_CREDS\tTLS_CREDS\n") |
There was a problem hiding this comment.
minor - if you want to provide parseable output, you could add a -o yaml option
| // RepoCreds holds a repository credentials definition | ||
| type RepoCreds struct { | ||
| // URL is the URL that this credentials matches to | ||
| URL string `json:"url" protobuf:"bytes,1,opt,name=url"` |
There was a problem hiding this comment.
minor - do we want document how these are matched?
| want: true, | ||
| }, | ||
| } | ||
| for _, tt := range tests { |
There was a problem hiding this comment.
I think you could simply this test to two lines, as any field other than EnableLFSshould not matter
| r := q.Creds | ||
|
|
||
| if r.URL == "" { | ||
| return nil, status.Errorf(codes.InvalidArgument, "must specify URL") |
| // repo and evaluate the results. Unless forceRefresh is set to true, the | ||
| // result may be retrieved out of the cache. | ||
| func (s *Server) getConnectionState(ctx context.Context, url string, forceRefresh bool) appsv1.ConnectionState { | ||
| if !forceRefresh { |
There was a problem hiding this comment.
Why do we need force refresh? I'm worried that we're using the wrong key for the correction state.
There was a problem hiding this comment.
I think it'd be useful when you change repository credentials, you can see whether the change was successful or not instantly. Credentials aren't (can't be) checked for validity.
The other possibility would be to invalidate the cache on connection state for every repository that matches the credentials' URL prefix, when the credentials change.
| if err != nil { | ||
| return nil, err | ||
| } | ||
| if repoCreds != nil { |
There was a problem hiding this comment.
I think this func accepts nil? So no need to guard.
|
This has been approved but needs to be sync'd with master. @jannfis do you want to do this? |
This PR adds repository credential management to ArgoCD, as discussed in #2136. It changes the following:
Add the following CRUD operations for repository credentials inIntroduces newRepositoryServiceAPIRepoCredsServiceAPI which implements the following CRUD operations for managing repository credentials:ListRepositoryCredentials()CreateRepositoryCredentials()UpdateRepositoryCredentials()DeleteRepositoryCredentials()Deprecation of the following CRUD operations for repository management in
RepositoryServiceAPI. The deprecated methods still available for backwards compatibility, but I think should be safe to remove with the release of v2.0:List()deprecated in favour ofListRepositories()Create()deprecated in favour ofCreateRepository()Update()deprecated in favour ofUpdateRepository()Delete()deprecated in favour ofDeleteRepository()Changes the semantics ofargocd reposub-commands by introducing the--credsswitch to sub-commandslist,addandrmto perform operations on repository credentials instead of repositories.Introduces the
repocredssub-command to CLI, which can be used to manage repository credential templates. It mimicsreposub-command to some extent and supports theadd,rmandlistoperations, with--upsertsupport.Introduces
--force-refresh--refresh <mode>switch toargocd repo listcommand and accompanyingrefreshfield inRepoQuerymessage ofRepositoryServiceAPI to force a cache refresh of the listed repository's connection statusUpdate 08/26/19: Changes behaviour of credential lookup from "first match" to "best match", i.e. given the following two cred URLs
https://reposerver/reposandhttps://reposerver/repos/private, credential lookup for repositoryhttps://reposerver/repos/private/myprivatewould return credentials configured forhttps://reposerver/repos/private, nothttps://reposerver/reposUpdate 08/26/19 2: Adds initial functionality to the web UI for listing, adding and removing repository credential templates - all built into the 'Repositories' settings page. Also added ability to force a cache reload of repositories with a new button on top of the page. See screenshots.
Update 08/27/19: Added documentation for Operator Manual (declarative) and User Manual (Web UI and CLI)
Update 09/28/19: Introduce new
repocredssub-command to CLI and removes--credsswitch (and accompanying functionality) fromreposub-command (docs still need updating).CLI examples: