#!/bin/bash

# Copyright 2017 Istio Authors

#   Licensed under the Apache License, Version 2.0 (the "License");
#   you may not use this file except in compliance with the License.
#   You may obtain a copy of the License at

#       http://www.apache.org/licenses/LICENSE-2.0

#   Unless required by applicable law or agreed to in writing, software
#   distributed under the License is distributed on an "AS IS" BASIS,
#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#   See the License for the specific language governing permissions and
#   limitations under the License.

ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
TESTS_DIR="${ROOT}/tests"
. ${TESTS_DIR}/commonUtils.sh || { echo "Cannot load common utilities"; exit 1; }

ISTIOCLI="${ROOT}/demos/istioctl-linux"

function create_rule() {
    $ISTIOCLI -n $NAMESPACE create -f $1 \
      || error_exit 'Could not create rule'
}

function cleanup_all_rules() {
    print_block_echo "Cleaning up rules"
    ${ISTIOCLI} -n ${NAMESPACE} list route-rule | grep "name:" \
      | awk '{print $2}' | xargs ${ISTIOCLI} -n ${NAMESPACE} delete route-rule
    return $?
}

function delete_rule() {
    $ISTIOCLI -n $NAMESPACE delete -f $1
    return $?
}

#!/bin/bash

# Copyright 2017 Istio Authors

#   Licensed under the Apache License, Version 2.0 (the "License");
#   you may not use this file except in compliance with the License.
#   You may obtain a copy of the License at

#       http://www.apache.org/licenses/LICENSE-2.0

#   Unless required by applicable law or agreed to in writing, software
#   distributed under the License is distributed on an "AS IS" BASIS,
#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#   See the License for the specific language governing permissions and
#   limitations under the License.

ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
TESTS_DIR="${ROOT}/tests"
. ${TESTS_DIR}/commonUtils.sh || { echo "Cannot load common utilities"; exit 1; }

ISTIOCLI="${ROOT}/demos/istioctl-linux -c ${HOME}/.kube/config"

function create_rule() {
    $ISTIOCLI -n $NAMESPACE create -f $1 \
      || error_exit 'Could not create rule'
}

function cleanup_all_rules() {
    print_block_echo "Cleaning up rules"
    ${ISTIOCLI} -n ${NAMESPACE} list route-rule | grep "name:" \
      | awk '{print $2}' | xargs ${ISTIOCLI} -n ${NAMESPACE} delete route-rule
    return $?
}

function delete_rule() {
    $ISTIOCLI -n $NAMESPACE delete -f $1
    return $?
}

Use specific kube config for istio
Use specific kube config for istio
