parent
928c5f81da
commit
c1fa5c3e52
23
.travis.yml
23
.travis.yml
|
@ -6,30 +6,19 @@ python:
|
||||||
- "2.7"
|
- "2.7"
|
||||||
|
|
||||||
before_install:
|
before_install:
|
||||||
- export LIGGIT2_VERSION=0.24.0
|
- sudo sh tools/libgit2.sh
|
||||||
- export LIBGIT2=$VIRTUAL_ENV
|
|
||||||
- wget https://github.com/libgit2/libgit2/archive/v${LIGGIT2_VERSION}.tar.gz
|
|
||||||
- tar xzf v${LIGGIT2_VERSION}.tar.gz
|
|
||||||
- cd libgit2-${LIGGIT2_VERSION}/
|
|
||||||
- cmake . -DCMAKE_INSTALL_PREFIX=$LIBGIT2
|
|
||||||
- make
|
|
||||||
- make install
|
|
||||||
- export LDFLAGS="-Wl,-rpath='$LIBGIT2/lib',--enable-new-dtags $LDFLAGS"
|
|
||||||
- cd ..
|
|
||||||
- pip install -r test-requirements.txt
|
- pip install -r test-requirements.txt
|
||||||
- pip install -r requirements.txt
|
- pip install -r requirements.txt
|
||||||
- pip install tox
|
- pip install tox
|
||||||
- pip install pygit2==0.24.0
|
- pip install pygit2==0.25.0
|
||||||
|
|
||||||
install:
|
install:
|
||||||
- pip install .
|
- pip install -e .
|
||||||
|
|
||||||
script:
|
script:
|
||||||
- flake8
|
- flake8
|
||||||
- armada -h
|
- armada -h
|
||||||
# - armada -c examples/armada.yaml -d
|
- nosetests -w ./armada --with-coverage --cover-package=armada --cover-tests
|
||||||
|
|
||||||
after_success:
|
# after_success:
|
||||||
- cd docs && make html
|
# - codecov
|
||||||
- touch .nojekyll
|
|
||||||
- git clean -fdx
|
|
||||||
|
|
|
@ -0,0 +1,84 @@
|
||||||
|
Contributor Covenant Code of Conduct
|
||||||
|
====================================
|
||||||
|
|
||||||
|
Our Pledge
|
||||||
|
----------
|
||||||
|
|
||||||
|
In the interest of fostering an open and welcoming environment, we as
|
||||||
|
contributors and maintainers pledge to making participation in our
|
||||||
|
project and our community a harassment-free experience for everyone,
|
||||||
|
regardless of age, body size, disability, ethnicity, gender identity and
|
||||||
|
expression, level of experience, nationality, personal appearance, race,
|
||||||
|
religion, or sexual identity and orientation.
|
||||||
|
|
||||||
|
Our Standards
|
||||||
|
-------------
|
||||||
|
|
||||||
|
Examples of behavior that contributes to creating a positive environment
|
||||||
|
include:
|
||||||
|
|
||||||
|
- Using welcoming and inclusive language
|
||||||
|
- Being respectful of differing viewpoints and experiences
|
||||||
|
- Gracefully accepting constructive criticism
|
||||||
|
- Focusing on what is best for the community
|
||||||
|
- Showing empathy towards other community members
|
||||||
|
|
||||||
|
Examples of unacceptable behavior by participants include:
|
||||||
|
|
||||||
|
- The use of sexualized language or imagery and unwelcome sexual
|
||||||
|
attention or advances
|
||||||
|
- Trolling, insulting/derogatory comments, and personal or political
|
||||||
|
attacks
|
||||||
|
- Public or private harassment
|
||||||
|
- Publishing others’ private information, such as a physical or
|
||||||
|
electronic address, without explicit permission
|
||||||
|
- Other conduct which could reasonably be considered inappropriate in a
|
||||||
|
professional setting
|
||||||
|
|
||||||
|
Our Responsibilities
|
||||||
|
--------------------
|
||||||
|
|
||||||
|
Project maintainers are responsible for clarifying the standards of
|
||||||
|
acceptable behavior and are expected to take appropriate and fair
|
||||||
|
corrective action in response to any instances of unacceptable behavior.
|
||||||
|
|
||||||
|
Project maintainers have the right and responsibility to remove, edit,
|
||||||
|
or reject comments, commits, code, wiki edits, issues, and other
|
||||||
|
contributions that are not aligned to this Code of Conduct, or to ban
|
||||||
|
temporarily or permanently any contributor for other behaviors that they
|
||||||
|
deem inappropriate, threatening, offensive, or harmful.
|
||||||
|
|
||||||
|
Scope
|
||||||
|
-----
|
||||||
|
|
||||||
|
This Code of Conduct applies both within project spaces and in public
|
||||||
|
spaces when an individual is representing the project or its community.
|
||||||
|
Examples of representing a project or community include using an
|
||||||
|
official project e-mail address, posting via an official social media
|
||||||
|
account, or acting as an appointed representative at an online or
|
||||||
|
offline event. Representation of a project may be further defined and
|
||||||
|
clarified by project maintainers.
|
||||||
|
|
||||||
|
Enforcement
|
||||||
|
-----------
|
||||||
|
|
||||||
|
Instances of abusive, harassing, or otherwise unacceptable behavior may
|
||||||
|
be reported by contacting the project team at garivera89@gmail.com. The
|
||||||
|
project team will review and investigate all complaints, and will
|
||||||
|
respond in a way that it deems appropriate to the circumstances. The
|
||||||
|
project team is obligated to maintain confidentiality with regard to the
|
||||||
|
reporter of an incident. Further details of specific enforcement
|
||||||
|
policies may be posted separately.
|
||||||
|
|
||||||
|
Project maintainers who do not follow or enforce the Code of Conduct in
|
||||||
|
good faith may face temporary or permanent repercussions as determined
|
||||||
|
by other members of the project’s leadership.
|
||||||
|
|
||||||
|
Attribution
|
||||||
|
-----------
|
||||||
|
|
||||||
|
This Code of Conduct is adapted from the `Contributor Covenant`_,
|
||||||
|
version 1.4, available at `http://contributor-covenant.org/version/1/4`_
|
||||||
|
|
||||||
|
.. _Contributor Covenant: http://contributor-covenant.org
|
||||||
|
.. _`http://contributor-covenant.org/version/1/4`: http://contributor-covenant.org/version/1/4/
|
|
@ -110,8 +110,8 @@ class ChartBuilder(object):
|
||||||
Process metadata
|
Process metadata
|
||||||
'''
|
'''
|
||||||
# extract Chart.yaml to construct metadata
|
# extract Chart.yaml to construct metadata
|
||||||
chart_yaml = dotify(yaml.load(open(
|
chart_yaml = dotify(yaml.load(open(os.path.join(self.source_directory,
|
||||||
os.path.join(self.source_directory, 'Chart.yaml')).read()))
|
'Chart.yaml')).read()))
|
||||||
|
|
||||||
# construct Metadata object
|
# construct Metadata object
|
||||||
return Metadata(
|
return Metadata(
|
||||||
|
|
|
@ -0,0 +1,100 @@
|
||||||
|
# Copyright 2017 The Armada 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.
|
||||||
|
|
||||||
|
|
||||||
|
import unittest
|
||||||
|
import mock
|
||||||
|
|
||||||
|
from supermutes.dot import dotify
|
||||||
|
|
||||||
|
from armada.handlers.chartbuilder import ChartBuilder
|
||||||
|
|
||||||
|
|
||||||
|
class ChartBuilderTestCase(unittest.TestCase):
|
||||||
|
chart_stream = """
|
||||||
|
chart:
|
||||||
|
name: mariadb
|
||||||
|
release_name: mariadb
|
||||||
|
namespace: openstack
|
||||||
|
install:
|
||||||
|
no_hooks: false
|
||||||
|
upgrade:
|
||||||
|
no_hooks: false
|
||||||
|
values:
|
||||||
|
replicas: 1
|
||||||
|
volume:
|
||||||
|
size: 1Gi
|
||||||
|
source:
|
||||||
|
type: git
|
||||||
|
location: git://github.com/openstack/openstack-helm
|
||||||
|
subpath: mariadb
|
||||||
|
reference: master
|
||||||
|
dependencies: []
|
||||||
|
"""
|
||||||
|
|
||||||
|
chart_yaml = """
|
||||||
|
apiVersion: v1
|
||||||
|
description: A Helm chart for Kubernetes
|
||||||
|
name: hello-world-chart
|
||||||
|
version: 0.1.0
|
||||||
|
"""
|
||||||
|
|
||||||
|
chart_value = """
|
||||||
|
# Default values for hello-world-chart.
|
||||||
|
# This is a YAML-formatted file.
|
||||||
|
# Declare variables to be passed into your templates.
|
||||||
|
replicaCount: 1
|
||||||
|
image:
|
||||||
|
repository: nginx
|
||||||
|
tag: stable
|
||||||
|
pullPolicy: IfNotPresent
|
||||||
|
service:
|
||||||
|
name: nginx
|
||||||
|
type: ClusterIP
|
||||||
|
externalPort: 38443
|
||||||
|
internalPort: 80
|
||||||
|
resources:
|
||||||
|
limits:
|
||||||
|
cpu: 100m
|
||||||
|
memory: 128Mi
|
||||||
|
requests:
|
||||||
|
cpu: 100m
|
||||||
|
memory: 128Mi
|
||||||
|
"""
|
||||||
|
|
||||||
|
def test_chartbuilder_source_clone(self):
|
||||||
|
|
||||||
|
chart = dotify(self.chart_stream)
|
||||||
|
ChartBuilder.source_clone = mock.Mock(return_value='path')
|
||||||
|
chartbuilder = ChartBuilder(chart)
|
||||||
|
resp = getattr(chartbuilder, 'source_directory', None)
|
||||||
|
|
||||||
|
self.assertIsNotNone(resp)
|
||||||
|
self.assertIsInstance(resp, basestring)
|
||||||
|
|
||||||
|
@unittest.skip("we are having wierd scenario")
|
||||||
|
@mock.patch('armada.handlers.chartbuilder.dotify')
|
||||||
|
@mock.patch('armada.handlers.chartbuilder.os')
|
||||||
|
def test_chart_source_clone(self, mock_os, mock_dot):
|
||||||
|
from supermutes.dot import dotify
|
||||||
|
import yaml
|
||||||
|
mock_dot.dotify.return_value = dotify(yaml.load(self.chart_stream))
|
||||||
|
mock_os.path.join.return_value = self.chart_stream
|
||||||
|
|
||||||
|
ChartBuilder.source_clone = mock.Mock(return_value='path')
|
||||||
|
chartbuilder = ChartBuilder(self.chart_stream)
|
||||||
|
resp = chartbuilder.get_metadata()
|
||||||
|
|
||||||
|
self.assertIsNotNone(resp)
|
||||||
|
self.assertIsInstance(resp, basestring)
|
|
@ -0,0 +1,53 @@
|
||||||
|
# Copyright 2017 The Armada 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.
|
||||||
|
|
||||||
|
import mock
|
||||||
|
import unittest
|
||||||
|
|
||||||
|
from armada.utils import git
|
||||||
|
|
||||||
|
class GitTestCase(unittest.TestCase):
|
||||||
|
|
||||||
|
@mock.patch('armada.utils.git.tempfile')
|
||||||
|
@mock.patch('armada.utils.git.pygit2')
|
||||||
|
def test_git_clone_repo_pass(self, mock_pygit, mock_temp):
|
||||||
|
mock_temp.mkdtemp.return_value = '/tmp/armada'
|
||||||
|
mock_pygit.clone_repository.return_value = "Repository"
|
||||||
|
url = 'http://github.com/att-comdev/armada'
|
||||||
|
dir = git.git_clone(url)
|
||||||
|
|
||||||
|
self.assertIsNotNone(dir)
|
||||||
|
|
||||||
|
def test_git_clone_empty_url(self):
|
||||||
|
url = ''
|
||||||
|
dir = git.git_clone(url)
|
||||||
|
|
||||||
|
self.assertFalse(dir)
|
||||||
|
|
||||||
|
def test_git_clone_bad_url(self):
|
||||||
|
url = 'http://github.com/dummy/armada'
|
||||||
|
dir = git.git_clone(url)
|
||||||
|
|
||||||
|
self.assertFalse(dir)
|
||||||
|
|
||||||
|
def test_check_available_repo_pass(self):
|
||||||
|
url = 'http://github.com/att-comdev/armada'
|
||||||
|
resp = git.check_available_repo(url)
|
||||||
|
|
||||||
|
self.assertTrue(resp)
|
||||||
|
|
||||||
|
def test_check_available_repo_dummy_url(self):
|
||||||
|
url = 'http://github.com/dummy/armada'
|
||||||
|
resp = git.check_available_repo(url)
|
||||||
|
self.assertFalse(resp)
|
|
@ -0,0 +1,75 @@
|
||||||
|
# Copyright 2017 The Armada 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.
|
||||||
|
|
||||||
|
import unittest
|
||||||
|
import yaml
|
||||||
|
|
||||||
|
from armada.utils import lint
|
||||||
|
|
||||||
|
class LintTestCase(unittest.TestCase):
|
||||||
|
|
||||||
|
def test_lint_armada_yaml_pass(self):
|
||||||
|
config = yaml.load("""
|
||||||
|
armada:
|
||||||
|
release_prefix: armada-test
|
||||||
|
charts:
|
||||||
|
- chart:
|
||||||
|
name: chart
|
||||||
|
release_name: chart
|
||||||
|
namespace: chart
|
||||||
|
""")
|
||||||
|
resp = lint.valid_manifest(config)
|
||||||
|
self.assertTrue(resp)
|
||||||
|
|
||||||
|
def test_lint_armada_keyword_removed(self):
|
||||||
|
config = yaml.load("""
|
||||||
|
armasda:
|
||||||
|
release_prefix: armada-test
|
||||||
|
charts:
|
||||||
|
- chart:
|
||||||
|
name: chart
|
||||||
|
release_name: chart
|
||||||
|
namespace: chart
|
||||||
|
""")
|
||||||
|
|
||||||
|
with self.assertRaises(Exception):
|
||||||
|
lint.valid_manifest(config)
|
||||||
|
|
||||||
|
def test_lint_prefix_keyword_removed(self):
|
||||||
|
config = yaml.load("""
|
||||||
|
armada:
|
||||||
|
release: armada-test
|
||||||
|
charts:
|
||||||
|
- chart:
|
||||||
|
name: chart
|
||||||
|
release_name: chart
|
||||||
|
namespace: chart
|
||||||
|
""")
|
||||||
|
|
||||||
|
with self.assertRaises(Exception):
|
||||||
|
lint.valid_manifest(config)
|
||||||
|
|
||||||
|
def test_lint_armada_removed(self):
|
||||||
|
config = yaml.load("""
|
||||||
|
armasda:
|
||||||
|
release_prefix: armada-test
|
||||||
|
chart:
|
||||||
|
- chart:
|
||||||
|
name: chart
|
||||||
|
release_name: chart
|
||||||
|
namespace: chart
|
||||||
|
""")
|
||||||
|
|
||||||
|
with self.assertRaises(Exception):
|
||||||
|
lint.valid_manifest(config)
|
|
@ -0,0 +1,37 @@
|
||||||
|
# Copyright 2017 The Armada 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.
|
||||||
|
|
||||||
|
import unittest
|
||||||
|
|
||||||
|
from armada.utils import release as rel
|
||||||
|
|
||||||
|
class ReleaseTestCase(unittest.TestCase):
|
||||||
|
|
||||||
|
def test_release_prefix_pass(self):
|
||||||
|
expected = 'armada-test'
|
||||||
|
prefix, chart = ('armada', 'test')
|
||||||
|
|
||||||
|
assert rel.release_prefix(prefix, chart) == expected
|
||||||
|
|
||||||
|
def test_release_prefix_int_string(self):
|
||||||
|
expected = 'armada-4'
|
||||||
|
prefix, chart = ('armada', 4)
|
||||||
|
|
||||||
|
assert rel.release_prefix(prefix, chart) == expected
|
||||||
|
|
||||||
|
def test_release_prefix_int_int(self):
|
||||||
|
expected = '4-4'
|
||||||
|
prefix, chart = (4, 4)
|
||||||
|
|
||||||
|
assert rel.release_prefix(prefix, chart) == expected
|
|
@ -9,6 +9,10 @@ def git_clone(repo_url, branch='master'):
|
||||||
'''
|
'''
|
||||||
clones repo to a /tmp/ dir
|
clones repo to a /tmp/ dir
|
||||||
'''
|
'''
|
||||||
|
|
||||||
|
if repo_url == '' or not check_available_repo(repo_url):
|
||||||
|
return False
|
||||||
|
|
||||||
_tmp_dir = tempfile.mkdtemp(prefix='armada', dir='/tmp')
|
_tmp_dir = tempfile.mkdtemp(prefix='armada', dir='/tmp')
|
||||||
pygit2.clone_repository(repo_url, _tmp_dir, checkout_branch=branch)
|
pygit2.clone_repository(repo_url, _tmp_dir, checkout_branch=branch)
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
grpc==0.3.post19
|
grpc==0.3.post19
|
||||||
grpcio==1.1.3
|
grpcio==1.1.3
|
||||||
grpcio-tools==1.1.3
|
grpcio-tools==1.1.3
|
||||||
kubernetes==1.0.0
|
kubernetes>=1.0.0
|
||||||
oslo.log==3.28.0
|
oslo.log==3.28.0
|
||||||
oslo.messaging==5.28.0
|
oslo.messaging==5.28.0
|
||||||
protobuf==3.2.0
|
protobuf==3.2.0
|
||||||
|
@ -18,5 +18,6 @@ gunicorn==19.7.1
|
||||||
cliff==2.7.0
|
cliff==2.7.0
|
||||||
|
|
||||||
# Oslo
|
# Oslo
|
||||||
|
oslo.log==3.28.0
|
||||||
oslo.config>=3.22.0 # Apache-2.0
|
oslo.config>=3.22.0 # Apache-2.0
|
||||||
oslo.middleware>=3.27.0 # Apache-2.0
|
oslo.middleware>=3.27.0 # Apache-2.0
|
||||||
|
|
|
@ -47,3 +47,7 @@ warnerrors = True
|
||||||
|
|
||||||
[wheel]
|
[wheel]
|
||||||
universal = 1
|
universal = 1
|
||||||
|
|
||||||
|
[nosetests]
|
||||||
|
verbosity=3
|
||||||
|
with-doctest=1
|
||||||
|
|
|
@ -1,3 +1,11 @@
|
||||||
flake8==3.3.0
|
# General
|
||||||
tox
|
tox
|
||||||
|
|
||||||
|
# Docs
|
||||||
Sphinx
|
Sphinx
|
||||||
|
|
||||||
|
# Testing
|
||||||
|
flake8==3.3.0
|
||||||
|
nose==1.3.7
|
||||||
|
testtools==2.3.0
|
||||||
|
codecov
|
||||||
|
|
Loading…
Reference in New Issue