Created
April 3, 2021 20:27
-
-
Save nastacio/1c90de2eb362d9dd37b0f879d3939fd1 to your computer and use it in GitHub Desktop.
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
# | |
# Updates the target branch for all ArgoCD applications on a namespace | |
# | |
# arg1 name of the new gitops branch | |
# arg2 namespace for the ArgoCD applications to be patched | |
# | |
function set_argo_branch() { | |
local new_branch=${1} | |
local namespace=${2:-openshift-gitops} | |
kubectl get Application --namespace "${namespace}" -o name \ | |
| cut -d "/" -f 2 \ | |
| xargs -Iargoapp \ | |
kubectl patch Application argoapp \ | |
--namespace "${namespace}" \ | |
--patch "\"spec\": { \"source\": { \"targetRevision\":\"${new_branch}\" } }" \ | |
--type merge | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment