diff --git a/.travis.yml b/.travis.yml index b6496b5e..45b39925 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,11 +6,9 @@ python: - "2.7" before_install: - - sudo sh tools/libgit2.sh - pip install -r test-requirements.txt - pip install -r requirements.txt - pip install tox - - pip install pygit2==0.25.0 install: - pip install -e . diff --git a/Dockerfile b/Dockerfile index 19aba144..6a0b2c6d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,7 +3,6 @@ FROM ubuntu:16.04 MAINTAINER Armada Team ENV DEBIAN_FRONTEND noninteractive -ENV LIBGIT_VERSION 0.25.0 COPY . /armada @@ -16,36 +15,23 @@ RUN apt-get update && \ python-setuptools && \ apt-get install -y \ build-essential \ - cmake \ curl \ git \ - libffi-dev \ python-all-dev && \ useradd -u 1000 -g users -d /armada armada && \ \ - curl -sSL https://github.com/libgit2/libgit2/archive/v$LIBGIT_VERSION.tar.gz \ - | tar zx -C /tmp && \ - cd /tmp/libgit2-$LIBGIT_VERSION && \ - cmake . && \ - cmake --build . --target install && \ - ldconfig && \ - \ cd /armada && \ pip install --upgrade pip && \ - pip install -r requirements.txt pygit2==$LIBGIT_VERSION && \ + pip install -r requirements.txt && \ pip install . && \ \ apt-get purge --auto-remove -y \ build-essential \ - cmake \ curl \ - git \ - libffi-dev \ python-all-dev && \ apt-get clean -y && \ rm -rf \ /root/.cache \ - /tmp/libgit2-$LIBGIT_VERSION \ /var/lib/apt/lists/* EXPOSE 8000 diff --git a/README.rst b/README.rst index 5cd3a534..e49ec8ed 100644 --- a/README.rst +++ b/README.rst @@ -56,7 +56,6 @@ Your output will look something like this: $ armada apply examples/openstack-helm.yaml 2017-02-10 09:42:36,753 armada INFO Cloning git: -.. _pygit2: http://www.pygit2.org/install.html#libgit2-within-a-virtual-environment .. _kubectl: https://kubernetes.io/docs/user-guide/kubectl/kubectl_config/ .. |Docker Repository on Quay| image:: https://quay.io/repository/attcomdev/armada/status diff --git a/armada/handlers/armada.py b/armada/handlers/armada.py index 9fc93e73..8c4ae9e3 100644 --- a/armada/handlers/armada.py +++ b/armada/handlers/armada.py @@ -303,7 +303,7 @@ class Armada(object): ''' Operations to run after deployment process has terminated ''' - # Delete git repos cloned for deployment + # Delete temp dirs used for deployment for group in self.config.get(KEYWORD_ARMADA).get(KEYWORD_GROUPS): for ch in group.get(KEYWORD_CHARTS): if ch.get('chart').get('source').get('type') == 'git': diff --git a/armada/tests/unit/utils/test_source.py b/armada/tests/unit/utils/test_source.py index 561049e7..ffeb7af9 100644 --- a/armada/tests/unit/utils/test_source.py +++ b/armada/tests/unit/utils/test_source.py @@ -24,10 +24,10 @@ class GitTestCase(unittest.TestCase): SOURCE_UTILS_LOCATION = 'armada.utils.source' @mock.patch('armada.utils.source.tempfile') - @mock.patch('armada.utils.source.pygit2') - def test_git_clone_good_url(self, mock_pygit, mock_temp): + @mock.patch('armada.utils.source.Repo') + def test_git_clone_good_url(self, mock_git_repo, mock_temp): mock_temp.mkdtemp.return_value = '/tmp/armada' - mock_pygit.clone_repository.return_value = "Repository" + mock_git_repo.clone_from.return_value = "Repository" url = 'http://github.com/att-comdev/armada' dir = source.git_clone(url) diff --git a/armada/utils/source.py b/armada/utils/source.py index f560e5e0..a8015ddf 100644 --- a/armada/utils/source.py +++ b/armada/utils/source.py @@ -1,24 +1,29 @@ -import pygit2 +import os import requests import tarfile import tempfile import shutil +from git import Repo from os import path from ..exceptions import source_exceptions def git_clone(repo_url, branch='master'): ''' - clones repo to a /tmp/ dir + :params repo_url - URL of git repo to clone + :params branch - branch of the repo to clone + + Returns a path to the cloned repo ''' if repo_url == '': raise source_exceptions.GitLocationException(repo_url) + os.environ['GIT_TERMINAL_PROMPT'] = '0' _tmp_dir = tempfile.mkdtemp(prefix='armada', dir='/tmp') try: - pygit2.clone_repository(repo_url, _tmp_dir, checkout_branch=branch) + Repo.clone_from(repo_url, _tmp_dir, **{'branch': branch}) except Exception: raise source_exceptions.GitLocationException(repo_url) diff --git a/docs/source/development/getting-started.rst b/docs/source/development/getting-started.rst index af56f0c3..9da6679b 100644 --- a/docs/source/development/getting-started.rst +++ b/docs/source/development/getting-started.rst @@ -25,17 +25,10 @@ To use the docker containter to develop: Virtualenv ########## -To use VirtualEnv we will need to add some extra steps +To use VirtualEnv: 1. virtualenv venv 2. source ./venv/bin/activate -3. sudo sh ./tools/libgit2.sh - -Test that it worked with: - -.. code-block:: bash - - python -c 'import pygit2' From the directory of the forked repository: @@ -47,8 +40,8 @@ From the directory of the forked repository: .. note:: - this will install the latest libgit2 library so you have to make sure you - install the same version library with pip ( current version: 0.25.0 ) + If building from source, Armada requires that git be installed on + the system. Kubernetes ########## diff --git a/docs/source/operations/guide-exceptions.rst b/docs/source/operations/guide-exceptions.rst index e4bd7600..9f592e7e 100644 --- a/docs/source/operations/guide-exceptions.rst +++ b/docs/source/operations/guide-exceptions.rst @@ -13,9 +13,9 @@ Tiller Exceptions +------------------------------------+--------------------------------------------------------------------------------------------+ | Exception | Error Description | +====================================+============================================================================================+ -| ChartCleanupException | An error occurred removing a chart. | +| ChartCleanupException | An error occurred removing a chart. | +------------------------------------+--------------------------------------------------------------------------------------------+ -| ListChartsException | An error occurred listing helm charts. | +| ListChartsException | An error occurred listing helm charts. | +------------------------------------+--------------------------------------------------------------------------------------------+ | PostUpdateJobDeleteException | An error occurred deleting a job after an update. | +------------------------------------+--------------------------------------------------------------------------------------------+ @@ -29,7 +29,7 @@ Tiller Exceptions +------------------------------------+--------------------------------------------------------------------------------------------+ | ReleaseInstallException | A release failed to install. | +------------------------------------+--------------------------------------------------------------------------------------------+ -| ReleaseUpdateException | A release failed to update. | +| ReleaseUpdateException | A release failed to update. | +------------------------------------+--------------------------------------------------------------------------------------------+ | TillerServicesUnavailableException | Occurs when Tiller services are unavailable. | +------------------------------------+--------------------------------------------------------------------------------------------+ @@ -79,9 +79,9 @@ Lint Exceptions +----------------------------------+------------------------------+ | InvalidChartNameException | Chart name invalid. | +----------------------------------+------------------------------+ -| InvalidChartDefinitionException | Chart definition invalid. | +| InvalidChartDefinitionException | Chart definition invalid. | +----------------------------------+------------------------------+ | InvalidReleaseException | Release invalid. | +----------------------------------+------------------------------+ -| InvalidArmadaObjectException | Armada object not declared. | +| InvalidArmadaObjectException | Armada object not declared. | +----------------------------------+------------------------------+ diff --git a/docs/source/operations/guide-use-armada.rst b/docs/source/operations/guide-use-armada.rst index 58cb6e88..964a6a5a 100644 --- a/docs/source/operations/guide-use-armada.rst +++ b/docs/source/operations/guide-use-armada.rst @@ -54,14 +54,12 @@ Usage docker run -d --net host -p 8000:8000 --name armada -v ~/.kube/config:/root/.kube/config -v $(pwd)/examples/:/examples quay.io/attcomdev/armada:latest - 3. Check that tiller is Available .. code:: bash docker exec armada armada tiller --status - 4. If tiller is up then we can start deploying our armada yamls .. code:: bash diff --git a/requirements.txt b/requirements.txt index acd4cc20..1c569172 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,4 @@ +gitpython==2.1.5 grpc==0.3.post19 grpcio==1.1.3 grpcio-tools==1.1.3 diff --git a/tools/libgit2.sh b/tools/libgit2.sh deleted file mode 100755 index ee929032..00000000 --- a/tools/libgit2.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/sh - -set -ex - -# Ubuntu 16.04 Install only - -apt-get update -apt-get install -y \ - cmake \ - git \ - libffi-dev \ - libssh2-1 \ - libssh2-1-dev \ - libssl-dev \ - libxml2-dev \ - libxslt1-dev \ - libz-dev \ - make \ - pkg-config \ - python-dev \ - python-pip \ - wget - -LIBGIT_VERSION=${LIBGIT_VERSION:-'0.25.0'} - -wget https://github.com/libgit2/libgit2/archive/v${LIBGIT_VERSION}.tar.gz -tar xzf v${LIBGIT_VERSION}.tar.gz -cd libgit2-${LIBGIT_VERSION}/ -cmake . -make -make install -ldconfig diff --git a/tox.ini b/tox.ini index 5d58befb..52e16561 100644 --- a/tox.ini +++ b/tox.ini @@ -8,10 +8,6 @@ deps= setenv= PYTHONWARNINGS=all -[testenv:ubuntu] -commands = - sh {toxinidir}/tools/libgit2.sh - [testenv:docs] commands = python setup.py build_sphinx @@ -26,5 +22,5 @@ commands = nosetest -w armada [flake8] #TODO: Remove E402 ignore=E302,H306,E402,W503 -exclude= libgit2-0.25.0, .git, .idea, .tox, *.egg-info, *.eggs, bin, dist, hapi +exclude= .git, .idea, .tox, *.egg-info, *.eggs, bin, dist, hapi