This should clean up any old branches and save on disk space, and fix any errors around bad branch names.
Signed-off-by: Daniel Hix <[email protected]>
Signed-off-by: Daniel Hix <[email protected]>
* git: prune any deleted refers before fetching
This commit modifies `nativeGitClient.Fetch()` to call `git remote prune origin` before fetching refs.
In some cases, an old branch may exist that conflicts with the name of a new branch. The old branch will have been deleted from `origin` but still exist locally in the `argocd-repo-server`.
Example: an old branch `feature/foo` conflicts with a new branch `feature/foo/bar`
In these cases, syncing an application results in the error:
```
rpc error: code = Internal desc = Failed to fetch default: `git fetch origin --tags --force` failed exit status 1: error: cannot lock ref 'refs/remotes/origin/feature/foo/bar': 'refs/remotes/origin/feature/foo' exists; cannot create 'refs/remotes/origin/feature/foo/bar' From https://github.com/org/repo ! [new branch] feature/foo/bar -> origin/feature/foo/bar (unable to update local ref) error: some local refs could not be updated; try running 'git remote prune origin' to remove any old, conflicting branches
```
Adding `git remote prune origin` before fetching, as recommended by the error message, should fix this issue.
The current workaround is to restart the `argocd-repo-server` which should flush the local repository folder. This works when Argo CD is installed using the Helm chart.
Signed-off-by: Kevin Snyder <[email protected]>
* fix: added extra protection to syncing app with replace (#9187)
* fix: added extra protection to syncing app with replace
Signed-off-by: ciiay <[email protected]>
* Code clean up
Signed-off-by: ciiay <[email protected]>
* Updated logic for isAppOfAppsPattern
Signed-off-by: ciiay <[email protected]>
* Updated text strings as per comment
Signed-off-by: ciiay <[email protected]>
* Fixed lint issue
Signed-off-by: ciiay <[email protected]>
Signed-off-by: Kevin Snyder <[email protected]>
* chore: Simplified GetRepoHTTPClient function (#9396)
* chore: Simplified GetRepoHTTPClient function
Signed-off-by: ls0f <[email protected]>
* simplified code and improve unit test coverage
Signed-off-by: ls0f <[email protected]>
Signed-off-by: Kevin Snyder <[email protected]>
* Only prune if fetch error message indicates that it is worthwhile, add unit tests
Confirmed that `Test_nativeGitClient_Fetch_Prune` fails without the bug fix, succeeds with it.
Signed-off-by: Kevin Snyder <[email protected]>
* fix: avoid k8s call before authorization for terminal endpoint (#9434)
* fix: avoid k8s API call before authorization in k8s endpoint
Signed-off-by: Michael Crenshaw <[email protected]>
* check for bad project
Signed-off-by: Michael Crenshaw <[email protected]>
* lint
Signed-off-by: Michael Crenshaw <[email protected]>
* more logging
Signed-off-by: Michael Crenshaw <[email protected]>
* handle 404, return 500 instead of 400 for other errors
Signed-off-by: Michael Crenshaw <[email protected]>
* use user input
Signed-off-by: Michael Crenshaw <[email protected]>
* refactor validation
Signed-off-by: Michael Crenshaw <[email protected]>
* fix tests
Signed-off-by: Michael Crenshaw <[email protected]>
* fixes, tests
Signed-off-by: Michael Crenshaw <[email protected]>
Signed-off-by: Kevin Snyder <[email protected]>
* Match against "try running 'git remote prune origin'"
Signed-off-by: Kevin Snyder <[email protected]>
Co-authored-by: Yi Cai <[email protected]>
Co-authored-by: ls0f <[email protected]>
Co-authored-by: Michael Crenshaw <[email protected]>
This commit replaces `ioutil.TempDir` with `t.TempDir` in tests. The
directory created by `t.TempDir` is automatically removed when the test
and all its subtests complete.
Prior to this commit, temporary directory created using `ioutil.TempDir`
needs to be removed manually by calling `os.RemoveAll`, which is omitted
in some tests. The error handling boilerplate e.g.
defer func() {
if err := os.RemoveAll(dir); err != nil {
t.Fatal(err)
}
}
is also tedious, but `t.TempDir` handles this for us nicely.
Reference: https://pkg.go.dev/testing#T.TempDir
Signed-off-by: Eng Zer Jun <[email protected]>
* feat: add first class support to access repositories using proxy
Currently, users need to set the proxy URLs as env variables in the repo server. This is not user-friendly and also error-prone. This PR adds support to maintain proxy URLs along with repository configs in the argocd-cm. Argo CD uses this proxy to access your repository. In case the custom proxy is absent, it defaults to reading the proxy from the env variables.
Signed-off-by: Chetan Banavikalmutt <[email protected]>
* set both http & https proxy variables
Signed-off-by: Chetan Banavikalmutt <[email protected]>
Explicitly specify the "C" language during the invocation of the gpg
binary. That way, parsing its output is more robust on non-english
systems.
Signed-off-by: Tom Wieczorek <[email protected]>
* feat: Add autocomplete for repo Revisions
- Introduces api/v1/repositories/{repo}/refs which returns branches and tags
- Add new RevisionFormField component to Create and Edit Application pages
Signed-off-by: Tim Etchells <[email protected]>
* Add initial primitives and tests for GPG related operations
* More tests and test documentation
* Move gpg primitives to own module
* Add initial primitives for running git verify-commit and tests
* Improve and better comment test
* Implement VerifyCommitSignature() primitive for metrics wrapper
* More commentary
* Make reposerver verify gpg signatures when generating manifests
* Make signature validation optional
* Forbid use of local manifests when signature verification is enabled
* Introduce new signatureKeys field in project CRD
* Initial support for only syncing against signed revisions
* Updates to GnuPG primitives and more test cases
* Move signature verification to correct place and add tests
* Add signature verification result to revision metadata and display it in UI
* Add more primitives and move out some stuff to common module
* Add more testdata
* Add key management primitives to ArgoDB
* Move type GnuPGPublicKey to appsv1 package
* Add const ArgoCDGPGKeysConfigMapName
* Handle key operations with appsv1.GnuPGPublicKey
* Add initial API for managing GPG keys
* Remove deprecated code
* Add primitives for adding public keys to configuration
* Change semantics of ValidateGPGKeys to return more key information
* Add key import functionality to public key API
* Fix code quirks reported by linter
* More code quirks fixes
* Fix test
* Add primitives for deleting keys from configuration
* Add delete key operation to API and CLI
* Cosmetics
* Implement logic to sync configuration to keyring in repo-server
* Add IsGPGEnabled() primitive and also update trustdb on ownertrust changes
* Use gpg.IsGPGEnabled() instead of custom test
* Remove all keyring manipulating methods from DB
* Cosmetics/comments
* Require grpc methods from argoproj pkg
* Enable setting config path via ARGOCD_GPG_DATA_PATH
* Allow "no" and any cases in ARGOCD_GPG_ENABLED
* Enable GPG feature on start and start-e2e and set required environment
* Cosmetics/comments
* Cosmetics and commentary
* Update API documentation
* Fix comment
* Only run GPG related operations if GPG is enabled
* Allow setting ARGOCD_GPG_ENABLE from the environment
* Create GPG ConfigMap resource during installation
* Use function instead of constant to get the watcher path
* Re-watch source path in case it gets recreated. Also, error on finish
* Add End-to-End tests for GPG commit verification
* Introduce SignatureKey type for AppProject CRD
* Fix merge error from previous commit
* Adapt test for additional manifest (argocd-gpg-keys-cm.yaml)
* Fix linter issues
* Adapt CircleCI configuration to enable running tests
* Add wrapper scripts for git and gpg
* Sigh.
* Display gpg version in CircleCI
* Install gnupg2 and link it to gpg in CI
* Try to install gnupg2 in CircleCI image
* More CircleCI tweaks
* # This is a combination of 10 commits.
# This is the 1st commit message:
Containerize tests - test cycle
# This is the commit message #2:
adapt working directory
# This is the commit message #3:
Build before running tests (so we might have a cache)
# This is the commit message #4:
Test limiting parallelism
# This is the commit message #5:
Remove unbound variable
# This is the commit message #6:
Decrease parallelism to find out limit
# This is the commit message #7:
Use correct flag
# This is the commit message #8:
Update Docker image
# This is the commit message #9:
Remove build phase and increase parallelism
# This is the commit message #10:
Further increase parallelism
* Dockerize toolchain
* Add new targets to Makefile
* Codegen
* Properly handle permissions for E2E tests
* Remove gnupg2 installation from CircleCI configuration
* Limit parallelism of build
* Fix Yarn lint
* Retrigger CI for possible flaky test
* Codegen
* Remove duplicate target in Makefile
* Pull in pager from dep ensure -v
* Adapt to gitops-engine changes and codegen
* Use new health package for health status constants
* Add GPG methods to ArgoDB mock module
* Fix possible nil pointer dereference
* Fix linter issue in imports
* Introduce RBAC resource type 'gpgkeys' and adapt policies
* Use ARGOCD_GNUPGHOME instead of GNUPGHOME for subsystem configuration
Also remove some deprecated unit tests.
* Also register GPG keys API with gRPC-GW
* Update from codegen
* Update GPG key API
* Add web UI to manage GPG keys
* Lint updates
* Change wording
* Add some plausibility checks for supplied data on key creation
* Update from codegen
* Re-allow binary keys and move check for ASCII armoured to UI
* Make yarn lint happy
* Add editing signature keys for projects in UI
* Add ability to configure signature keys for project in CLI
* Change default value to use for GNUPGHOME
* Do not include data section in default gpg keys CM
* Adapt Docker image for GnuPG feature
* Add required configuration to installation manifests
* Add add-signature-key and remove-signature-key commands to project CLI
* Fix typo
* Add initial user documentation for GnuPG verification
* Fix role name - oops
* Mention required RBAC roles in docs
* Support GPG verification of git annotated tags as well
* Ensure CLI can build succesfully
* Better support verification on tags
* Print key type in upper case
* Update user documentation
* Correctly disable GnuPG verification if ARGOCD_GPG_ENABLE=false
* Clarify that this feature is only available with Git repositories
* codegen
* Move verification code to own function
* Remove deprecated check
* Make things more developer friendly when running locally
* Enable GPG feature by default, and don't require ARGOCD_GNUPGHOME to be set
* Revert changes to manifests to reflect default enable state
* Codegen
* Move utils packages that are required for gitops engine under engine/pkg/utils package.
Following changes were implemented:
* util/health package is split into two parts: resource health assessement & resource health assessement and moved into engine/pkg/utils
* utils packages moved: Closer and Close method of util package moved into engine/pkg/utils/io package
* packages diff, errors, exec, json, kube and tracing moved into engine/pkg/utils
* Move single cluster caching into engine/kube/cache package
* move sync functionality to engine/kube/sync package
* remove dependency on metrics package from engine/pkg/utils/kube/cache
* move annotation label definitions into engine/pkg/utils/kube/sync
* make sure engine/pkg has no dependencies on other argo-cd packages
* allow importing engine as a go module
* implement a high-level interface that might be consumed by flux
* fix deadlock caused by cluster cache event handler
* ClusterCache should return error if requested group kind not found
* remove obsolete tests
* apply reviewer notes