# Copyright [2018] IBM Corp. All Rights Reserved.
#
#   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.

#!/bin/bash -e

# This script is intended to be run by Travis CI. If running elsewhere, invoke
# it with: TRAVIS_PULL_REQUEST=false [path to script]
# If no credentials are provided at runtime, bx will use the environment
# variable BLUEMIX_API_KEY. If no API key is set, it will prompt for
# credentials.

# shellcheck disable=SC1090
source "$(dirname "$0")"/../scripts/resources.sh

BLUEMIX_ORG="Developer Advocacy"
BLUEMIX_SPACE="dev"

is_pull_request "$0"

echo "Authenticating to Bluemix"
bx login -a https://api.ng.bluemix.net

echo "Targeting Bluemix org and space"
bx target -o "$BLUEMIX_ORG" -s "$BLUEMIX_SPACE"

echo "Initializing Bluemix Container Service"
bx cs init
