diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 00000000..a0ce71d2 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,33 @@ +# ref: https://docs.travis-ci.com/user/languages/python +language: python + +# Keep this matrix in sync with main repo's test matrix +matrix: + include: + - python: 2.7 + env: TOXENV=py27 + - python: 2.7 + env: TOXENV=py27-functional + - python: 2.7 + env: TOXENV=update-pep8 + - python: 2.7 + env: TOXENV=docs + - python: 2.7 + env: TOXENV=coverage,codecov + - python: 3.4 + env: TOXENV=py34 + - python: 3.5 + env: TOXENV=py35 + - python: 3.5 + env: TOXENV=py35-functional + - python: 3.6 + env: TOXENV=py36 + - python: 3.6 + env: TOXENV=py36-functional + +install: + - pip install tox + +script: + - tox + diff --git a/configuration.py b/configuration.py index bf0fd733..e2c82a9a 100644 --- a/configuration.py +++ b/configuration.py @@ -89,6 +89,10 @@ def __init__(self): # Set this to True/False to enable/disable SSL hostname verification. self.assert_hostname = None + # http proxy setting + self.http_proxy_url = None + + @property def logger_file(self): """ diff --git a/rest.py b/rest.py index 8b3a5dab..947104ce 100644 --- a/rest.py +++ b/rest.py @@ -107,9 +107,14 @@ def __init__(self, pools_size=4, config=configuration): kwargs['assert_hostname'] = config.assert_hostname # https pool manager - self.pool_manager = urllib3.PoolManager( - **kwargs - ) + if config.http_proxy_url is not None: + self.pool_manager = urllib3.proxy_from_url( + config.http_proxy_url, **kwargs + ) + else: + self.pool_manager = urllib3.PoolManager( + **kwargs + ) def request(self, method, url, query_params=None, headers=None, body=None, post_params=None, _preload_content=True, _request_timeout=None): diff --git a/run_tox.sh b/run_tox.sh new file mode 100755 index 00000000..d970de24 --- /dev/null +++ b/run_tox.sh @@ -0,0 +1,49 @@ +#!/bin/bash + +# Copyright 2017 The Kubernetes 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. + +# Script to fetch latest swagger spec. +# Puts the updated spec at api/swagger-spec/ + +set -o errexit +set -o nounset +set -o pipefail + +RUNNING_DIR=$(pwd) +TMP_DIR=$(mktemp -d) + +function cleanup() +{ + cd "${RUNNING_DIR}" +# rm -rf "${TMP_DIR}" +} +trap cleanup EXIT SIGINT + + +SCRIPT_ROOT=$(dirname "${BASH_SOURCE}") +pushd "${SCRIPT_ROOT}" > /dev/null +SCRIPT_ROOT=`pwd` +popd > /dev/null + +cd "${TMP_DIR}" +git clone https://github.com/kubernetes-incubator/client-python.git +cd client-python +cp -r "${SCRIPT_ROOT}/." kubernetes/base +pip install -r requirements.txt +pip install -r test-requirements.txt + +# Run the user-provided command. +"${@}" + diff --git a/tox.ini b/tox.ini new file mode 100644 index 00000000..db9df4ac --- /dev/null +++ b/tox.ini @@ -0,0 +1,11 @@ +[tox] +skipsdist = True +envlist = py27, py34, py35, py36, py27-functional, py36-functional, py35-functional, coverage, codecov + +[testenv] +passenv = TOXENV CI TRAVIS TRAVIS_* +commands = + python -V + pip install nose + ./run_tox.sh nosetests [] +