orange-cloudfoundry / orange-cf-bosh-cli

docker file for CF operations clients
12 stars 8 forks source link

Configure testkube alias to filter tests by kustomizations #130

Closed gberche-orange closed 1 year ago

gberche-orange commented 1 year ago

Expected

As a paas-templates user In order to list testkube tests per kustomizations while testkube is installed in a single namespace along with all tests I need a tk alias which injects the --label kusto=$(kubectl ns -c) flag into the testkube commands that support the --label flag : get

$ tk
Usage:                                                                                                                                                                                                             
  testkube [flags]                                                                                                                                                                                                 
  testkube [command]                                                                                                                                                                                               

Available Commands:
[...]
  get           Get resources

Workaround

FIXME: this currently breaks the testkube completion, not yet clear why

# Injects transparently a label argument with the current namespace

# Original Usage:
#  testkube [flags]
#  testkube [command]

function ltk() {
  local command="$1"
  shift
  local insertFlags=""

  case "${command}" in
    get)
      insertFlags="--label kusto=$(kubectl ns -c)"
      ;;
    *)
      #don't assign the flag
      ;;
  esac
  testkube "$command" ${insertFlags} $*
}
alias testkube=ltk
ogrand commented 1 year ago

Done with latest version