Skip to content

Instantly share code, notes, and snippets.

@nastacio
Created April 3, 2021 20:27
Show Gist options
  • Save nastacio/1c90de2eb362d9dd37b0f879d3939fd1 to your computer and use it in GitHub Desktop.
Save nastacio/1c90de2eb362d9dd37b0f879d3939fd1 to your computer and use it in GitHub Desktop.
#
# 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