#!/usr/bin/env bash

function namespace() {
  # we control the subs, so this is the most reliable way to get the namespace
  ns=$( oc get subs -A --field-selector metadata.name='performance-addon-operator-subscription' -o=jsonpath='{.items[0].metadata.namespace}{"\n"}' )
  # trying again with the pods, which are _usually_ reliable - but users can change them
  [ -z "${ns}" ] && ns=$( oc get pods -A -l name='performance-operator' -o=jsonpath='{.items[0].metadata.namespace}{"\n"}' )
  # if namespace not found, fallback to the old default
  [ -z "${ns}" ] && ns="openshift-performance-addon"
  echo ${ns}
}
