#!/bin/bash
#
# Copyright (c) 2024 Oracle and/or its affiliates. All rights reserved.
# Licensed under the GNU General Public License Version 3 as shown at https://www.gnu.org/licenses/gpl-3.0.txt.

KUBECFG=$1
export KUBECONFIG=${KUBECFG}

# Re: calico unable to uinstall cleanly
# https://github.com/tigera/operator/issues/2031
# RFC: Graceful termination of the operator https://github.com/tigera/operator/pull/2662

kubectl delete installation default --timeout=15s

res=$(kubectl get installations..operator.tigera.io --no-headers | awk '{print $1}')
if [[ $res == "default" ]]; then
  kubectl patch -n calico-system installations.operator.tigera.io/default  --type json \
  --patch='[{"op":"remove","path":"/metadata/finalizers"}]'
fi

