diff --git a/.travis.yml b/.travis.yml index 4036c17..09c3405 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,20 +1,22 @@ language: shell dist: bionic - jobs: include: - - script: ./bin/ci_test_wrapper 'rc' - - script: ./bin/ci_test_wrapper '5.0.17' - - script: ./bin/ci_test_wrapper '4.4.23' - - script: ./bin/ci_test_wrapper '4.3.48' - - stage: deploy - script: ./bin/package - deploy: - provider: releases - skip_cleanup: true - token: - secure: c5h0E4QkBWe7Bka6mkowP/z6QEiqwKGV5/E9MhX9COzxhtQGlDa7rYJ7AlS43o9sXOqJR7P8Hq5KJAXqYoOamKpXB7M+1IGlDjeVB8uHBKZ/53Iwj6ZUrnXvmIrbY3X6Cr2cK2JVkmKeHx4MhT3HZKCv+MGbA3EfcIghEk/KSi8GcP84oqMLLvOhXStvVgOh2n80w4KUlqXct7DWBTc8kZAhlp2jFXBXOTdk7ihwGzS98qvHyFEO+asW63PwqpCAj74Qmj9KECIStTWGr/ieArpIuoWMVB3yvmmmZkAcm0hckwdgnwcwS47MWo3PDoUO/QuAy0CoVdWGmkz+NekudXrN7xTuTgP0afA5VF0hX7DtDsu18BoiQonauAfImNz5dYVonqMXqHSVZXcwCuyAs/zfbpFVjrngUnPrZN+rD/NwdAB3EbTIFHdQz3dqsrFhKbeHzg2dQv6NNUn9FY/hD7kol2xODONLk0A8tnZwEVRLEKSA/aBPcjh1gq63im4DpONUpf2EjtHSWVJ/kaqiKgc+kQGeF/KdH36O57qP5ttiZuYmjftiNS2n6vlu2ODgQiBrwVlbTXOdR2+lYLrQKF26L7IvslLX7PJUG9S79OjSxob/+NyuFgKYbD0SUT7nN6enwS1UVi3vO+LOJkWmq3fFULjy3stbcreH9L48iTs= - file: sbp-${TRAVIS_TAG}.tar.gz - on: - tags: true - cleanup: 'false' + - script: "./bin/ci_test_wrapper 'rc'" + - script: "./bin/ci_test_wrapper '5.0.17'" + - script: "./bin/ci_test_wrapper '4.4.23'" + - script: "./bin/ci_test_wrapper '4.3.48'" + - stage: deploy + script: "./bin/package" + deploy: + provider: releases + skip_cleanup: true + token: + secure: c5h0E4QkBWe7Bka6mkowP/z6QEiqwKGV5/E9MhX9COzxhtQGlDa7rYJ7AlS43o9sXOqJR7P8Hq5KJAXqYoOamKpXB7M+1IGlDjeVB8uHBKZ/53Iwj6ZUrnXvmIrbY3X6Cr2cK2JVkmKeHx4MhT3HZKCv+MGbA3EfcIghEk/KSi8GcP84oqMLLvOhXStvVgOh2n80w4KUlqXct7DWBTc8kZAhlp2jFXBXOTdk7ihwGzS98qvHyFEO+asW63PwqpCAj74Qmj9KECIStTWGr/ieArpIuoWMVB3yvmmmZkAcm0hckwdgnwcwS47MWo3PDoUO/QuAy0CoVdWGmkz+NekudXrN7xTuTgP0afA5VF0hX7DtDsu18BoiQonauAfImNz5dYVonqMXqHSVZXcwCuyAs/zfbpFVjrngUnPrZN+rD/NwdAB3EbTIFHdQz3dqsrFhKbeHzg2dQv6NNUn9FY/hD7kol2xODONLk0A8tnZwEVRLEKSA/aBPcjh1gq63im4DpONUpf2EjtHSWVJ/kaqiKgc+kQGeF/KdH36O57qP5ttiZuYmjftiNS2n6vlu2ODgQiBrwVlbTXOdR2+lYLrQKF26L7IvslLX7PJUG9S79OjSxob/+NyuFgKYbD0SUT7nN6enwS1UVi3vO+LOJkWmq3fFULjy3stbcreH9L48iTs= + file: sbp-${TRAVIS_TAG}.tar.gz + on: + tags: true + cleanup: 'false' +env: + global: + secure: roAB7S38UveB2rG0zo0aUHJZK7rchCmpyqNX2dn646jLW1omyDsRn6oLH6fwZf9kYk4FhJQq7Bdylzb6UGxjLxkphs2W54gmf1qzKu6zmdKLCNCSUP/h3URfyEKgLAuCAQf+pqKfFvGHjWktUSK2OyEVaY48bk0c6cN0Vq1qcWk85jNp/arj+0Sw/2ER/6q5mrKerqv0fl+dlGKd7YWg+fkjOg3ecZ+4R2C/DJckuh2MHxN8FF3H4uvbbIsaXNRaqf7jDGJWtpTPP9FcKlmZbWMOVJDFnaGzESr5omzDOKe1tJysORw944kxtQ9YeyYlrydEFVES+gMh2S/HJruXTSlwlk2FmeaQPjNsARd/b0a1EgCvOZyf/eCL5hw+jvRdjUUzqzQVjJOx5DL2Of5D2t7uKtNHvXf66OEXDsrX/k4z/hNEXDpkqEKfQ4hFZqUdTYSwsjQJM8fcaeXJWhEr7g+lHIb4kPx1WVRHizdSDzz0e43IuM5mXhSlptoJuvgwQ0Uuh9W2/tgXCtQ1mZIT0X2HUVBB9ogv98J/dl593E5TgO/vJ22ujHz8MPsMPFJqv8qagkCZlW2QCV9uHQ/q3s0nX76X03Cz/onUBxRAxroLWIlbuQO39fOEkOf4L3PA6IUG57x81G5g9W+D9R281H0LV5gFQN/P5iv8pWXsODE= diff --git a/bin/ci_test_wrapper b/bin/ci_test_wrapper index 06a0022..bbeb75f 100755 --- a/bin/ci_test_wrapper +++ b/bin/ci_test_wrapper @@ -2,6 +2,8 @@ BASH=$1 +docker login --username brujoand --password "$DOCKER_TOKEN" + docker pull bash:$BASH docker run bash:$BASH --version docker run -v $PWD:/bash bash:$BASH /bash/bin/ci_test diff --git a/bin/run_tests b/bin/run_tests index ce7dcce..b22c413 100755 --- a/bin/run_tests +++ b/bin/run_tests @@ -5,4 +5,4 @@ set -e SBP_PATH=$( cd "$( dirname "${BASH_SOURCE[0]}" )/.." && pwd ) export SBP_PATH -bats -r "${SBP_PATH}/test/" +bats "${SBP_PATH}/test/" diff --git a/src/segments/k8s.bash b/src/segments/k8s.bash index da78f2e..f3a554a 100644 --- a/src/segments/k8s.bash +++ b/src/segments/k8s.bash @@ -5,20 +5,15 @@ segments::k8s() { [[ -f "$KUBE_CONFIG" ]] || return 0 context="$(sed -n 's/.*current-context: \(.*\)/\1/p' "$KUBE_CONFIG")" [[ -z "$context" ]] && return 0 - user=${context##*/} - namespace_and_host=${context%/*} - host=${namespace_and_host##*/} - host=${host%:*} - namespace=${namespace_and_host%/*} + namespace="$(pcregrep -M -- "- context:\n(^\s\s\w*.*\n)* name: ${context}" ${KUBE_CONFIG} | sed -n 's/ *namespace: \(\w*\)/\1/p')" + if [[ -z "$namespace" ]]; then + namespace='default' + fi - if [[ "${user,,}" == "${SEGMENTS_K8S_DEFAULT_USER,,}" ]]; then - if [[ "$SEGMENTS_K8S_HIDE_CLUSTER" -eq 1 ]]; then - segment="${namespace}" - else - segment="${host}:${namespace}" - fi + if [[ -z $namespace || "$SEGMENTS_K8S_HIDE_CLUSTER" -eq 1 ]]; then + segment="${context}" else - segment="${user}@${host}/${namespace}" + segment="${context}/${namespace}" fi print_themed_segment 'normal' "${segment,,}"