fleet icon indicating copy to clipboard operation
fleet copied to clipboard

Feature Request: would it be possible to add a hook to perform actions after bundle deployments

Open ThibaultDelaune-pro opened this issue 1 year ago • 3 comments

Is your feature request related to a problem?

I try to sync my ci with the cd performed by Fleet. But as there's no simple way to know when my bundles are deployed, I have to loop on their status (without forgot to define a timeout).

Solution you'd like

I would like a webhook that Fleet would call after deployment's done and bundle's ready

Alternatives you've considered

No response

Anything else?

here is the script I currently use to loop on the bundles status:

i=0
deployed=false
while [ $i -lt $RETRY_NUMBER ] && ! $deployed; do
    bundles_list=$( kubectl --namespace "$FLEET_NAMESPACE" get bundles -l "fleet.cattle.io/repo-name=$FLEET_REPO_NAME" --output jsonpath="{range .items[?(@.spec.helm.releaseName=='$CHART_RELEASE')]}{.metadata.name}{'\t'}{.spec.helm.chart}{'\t'}{.spec.helm.releaseName}{'\t'}{.metadata.labels.fleet\.cattle\.io/commit}{'\t'}{.status.conditions[?(@.type=='Ready')].status}{'\n'}{end}" )

    IFS="\n"
    for bundle in $bundles_list; do
        IFS=$'\t'
        read -r name chart release commit status <<< $bundle
        IFS="\n"
        if [[ "$status" == "True"  &&  "$chart" == "$CHART_NAME" && "$release" == "$CHART_RELEASE" && "$commit" == "$GIT_COMMIT_REF" ]]; then        
          deployed=true && break 3
        fi
    done

  i=`expr $i + 1`
  [ $i -lt $RETRY_NUMBER ] && echo -e "\nnext try in $RETRY_TIMEOUT seconds..."
  sleep $RETRY_TIMEOUT

ThibaultDelaune-pro avatar Sep 02 '22 15:09 ThibaultDelaune-pro