diff --git a/armada/__init__.py b/armada/__init__.py index edcec8e2..1c59b688 100644 --- a/armada/__init__.py +++ b/armada/__init__.py @@ -12,10 +12,10 @@ # See the License for the specific language governing permissions and # limitations under the License. -__all__ = ['__version__'] - import pbr.version +__all__ = ['__version__'] + version_info = pbr.version.VersionInfo('armada') try: __version__ = version_info.version_string() diff --git a/armada/api/armada_controller.py b/armada/api/armada_controller.py index 4d19fb65..62ad12de 100644 --- a/armada/api/armada_controller.py +++ b/armada/api/armada_controller.py @@ -22,6 +22,7 @@ from armada.handlers.armada import Armada LOG = logging.getLogger(__name__) + class Apply(api.BaseResource): ''' apply armada endpoint service diff --git a/armada/cli/apply.py b/armada/cli/apply.py index 0e41e93f..8a35ec82 100644 --- a/armada/cli/apply.py +++ b/armada/cli/apply.py @@ -16,6 +16,7 @@ from cliff import command as cmd from armada.handlers.armada import Armada + def applyCharts(args): armada = Armada(open(args.file).read(), @@ -30,6 +31,7 @@ def applyCharts(args): args.debug_logging) armada.sync() + class ApplyChartsCommand(cmd.Command): def get_parser(self, prog_name): parser = super(ApplyChartsCommand, self).get_parser(prog_name) diff --git a/armada/cli/tiller.py b/armada/cli/tiller.py index 22f7a663..abb82c8d 100644 --- a/armada/cli/tiller.py +++ b/armada/cli/tiller.py @@ -23,6 +23,7 @@ LOG = logging.getLogger(__name__) CONF = cfg.CONF + def tillerServer(args): tiller = Tiller() @@ -37,6 +38,7 @@ def tillerServer(args): LOG.info("Release: %s ( namespace= %s )", release.name, release.namespace) + class TillerServerCommand(cmd.Command): def get_parser(self, prog_name): parser = super(TillerServerCommand, self).get_parser(prog_name) diff --git a/armada/cli/validate.py b/armada/cli/validate.py index 560eeb13..fd1c09fd 100644 --- a/armada/cli/validate.py +++ b/armada/cli/validate.py @@ -25,6 +25,7 @@ LOG = logging.getLogger(__name__) CONF = cfg.CONF + def validateYaml(args): documents = yaml.safe_load_all(open(args.file).read()) manifest_obj = Manifest(documents).get_manifest() @@ -37,6 +38,7 @@ def validateYaml(args): except Exception: raise Exception('Failed to validate: %s', args.file) + class ValidateYamlCommand(cmd.Command): def get_parser(self, prog_name): parser = super(ValidateYamlCommand, self).get_parser(prog_name) diff --git a/armada/conf/__init__.py b/armada/conf/__init__.py index 24e759df..11a61288 100644 --- a/armada/conf/__init__.py +++ b/armada/conf/__init__.py @@ -24,5 +24,6 @@ CONF = cfg.CONF if (os.path.exists('etc/armada/armada.conf')): CONF(['--config-file', 'etc/armada/armada.conf']) + def set_app_default_configs(): default.register_opts(CONF) diff --git a/armada/conf/default.py b/armada/conf/default.py index bd87462e..303d7961 100644 --- a/armada/conf/default.py +++ b/armada/conf/default.py @@ -68,8 +68,10 @@ The Keystone project domain name used for authentication. help=utils.fmt('IDs of approved API access roles.')) ] + def register_opts(conf): conf.register_opts(default_options) + def list_opts(): return {'DEFAULT': default_options} diff --git a/armada/exceptions/api_exceptions.py b/armada/exceptions/api_exceptions.py index 6ac10c01..a5c8838a 100644 --- a/armada/exceptions/api_exceptions.py +++ b/armada/exceptions/api_exceptions.py @@ -14,6 +14,7 @@ import base_exception as base + class ApiException(base.ArmadaBaseException): '''Base class for API exceptions and error handling.''' diff --git a/armada/exceptions/armada_exceptions.py b/armada/exceptions/armada_exceptions.py index 7591d548..3aec0c96 100644 --- a/armada/exceptions/armada_exceptions.py +++ b/armada/exceptions/armada_exceptions.py @@ -14,11 +14,13 @@ import base_exception + class ArmadaException(base_exception.ArmadaBaseException): '''Base class for Armada handler exception and error handling.''' message = 'An unknown Armada handler error occured.' + class KnownReleasesException(ArmadaException): '''Exception that occurs when no known releases are found''' diff --git a/armada/exceptions/chartbuilder_exceptions.py b/armada/exceptions/chartbuilder_exceptions.py index 8ff27a40..2229df0b 100644 --- a/armada/exceptions/chartbuilder_exceptions.py +++ b/armada/exceptions/chartbuilder_exceptions.py @@ -14,11 +14,13 @@ import base_exception + class ChartBuilderException(base_exception.ArmadaBaseException): '''Base class for the Chartbuilder handler exception and error handling.''' message = 'An unknown Armada handler error occured.' + class DependencyException(ChartBuilderException): '''Exception that occurs when dependencies cannot be resolved.''' @@ -29,6 +31,7 @@ class DependencyException(ChartBuilderException): super(DependencyException, self).__init__(self._message) + class HelmChartBuildException(ChartBuilderException): '''Exception that occurs when Helm Chart fails to build.''' @@ -39,17 +42,20 @@ class HelmChartBuildException(ChartBuilderException): super(HelmChartBuildException, self).__init__(self._message) + class IgnoredFilesLoadException(ChartBuilderException): '''Exception that occurs when there is an error loading ignored files.''' message = 'An error occured while loading the ignored files in \ .helmignore' + class MetadataLoadException(ChartBuilderException): ''' Exception that occurs when metadata loading fails.''' message = 'Failed to load metadata from chart yaml file' + class UnknownChartSourceException(ChartBuilderException): '''Exception for unknown chart source type.''' diff --git a/armada/exceptions/lint_exceptions.py b/armada/exceptions/lint_exceptions.py index 00b2173a..8ca2276b 100644 --- a/armada/exceptions/lint_exceptions.py +++ b/armada/exceptions/lint_exceptions.py @@ -14,31 +14,37 @@ import base_exception + class LintException(base_exception.ArmadaBaseException): '''Base class for linting exceptions and errors.''' message = 'An unknown linting error occured.' + class InvalidManifestException(LintException): '''Exception for invalid manifests.''' message = 'Armada manifest invalid.' + class InvalidChartNameException(LintException): '''Exception that occurs when an invalid filename is encountered.''' message = 'Chart name must be a string,' + class InvalidChartDefinitionException(LintException): '''Exception when invalid chart definition is encountered.''' message = 'Invalid chart definition.Chart definition must be array.' + class InvalidReleaseException(LintException): '''Exception that occurs when a release is invalid.''' message = 'Release needs to be a string.' + class InvalidArmadaObjectException(LintException): '''Exception that occurs when an Armada object is not declared.''' diff --git a/armada/exceptions/source_exceptions.py b/armada/exceptions/source_exceptions.py index 2fbc7f08..dc9318d5 100644 --- a/armada/exceptions/source_exceptions.py +++ b/armada/exceptions/source_exceptions.py @@ -14,11 +14,13 @@ import base_exception + class SourceException(base_exception.ArmadaBaseException): '''Base class for Git exceptions and error handling.''' message = 'An unknown error occured while accessing a chart source' + class GitLocationException(SourceException): '''Exception that occurs when an error occurs cloning a Git repository.''' @@ -28,6 +30,7 @@ class GitLocationException(SourceException): super(GitLocationException, self).__init__(self._message) + class SourceCleanupException(SourceException): '''Exception that occurs for an invalid dir.''' @@ -37,6 +40,7 @@ class SourceCleanupException(SourceException): super(SourceCleanupException, self).__init__(self._message) + class TarballDownloadException(SourceException): '''Exception that occurs when the tarball cannot be downloaded from the provided URL @@ -48,6 +52,7 @@ class TarballDownloadException(SourceException): super(TarballDownloadException, self).__init__(self._message) + class TarballExtractException(SourceException): '''Exception that occurs when extracting the tarball fails''' @@ -57,6 +62,7 @@ class TarballExtractException(SourceException): super(TarballExtractException, self).__init__(self._message) + class InvalidPathException(SourceException): '''Exception that occurs when a nonexistant path is accessed''' diff --git a/armada/exceptions/tiller_exceptions.py b/armada/exceptions/tiller_exceptions.py index ff4d6b6c..76aea982 100644 --- a/armada/exceptions/tiller_exceptions.py +++ b/armada/exceptions/tiller_exceptions.py @@ -14,16 +14,19 @@ from base_exception import ArmadaBaseException as ex + class TillerException(ex): '''Base class for Tiller exceptions and error handling.''' message = 'An unknown Tiller error occured.' + class TillerServicesUnavailableException(TillerException): '''Exception for tiller services unavailable.''' message = 'Tiller services unavailable.' + class ChartCleanupException(TillerException): '''Exception that occures during chart cleanup.''' @@ -32,11 +35,13 @@ class ChartCleanupException(TillerException): chart_name) super(ChartCleanupException, self).__init__(message) + class ListChartsException(TillerException): '''Exception that occurs when listing charts''' message = 'There was an error listing the helm chart releases.' + class PostUpdateJobDeleteException(TillerException): '''Exception that occurs when a job deletion''' @@ -47,6 +52,7 @@ class PostUpdateJobDeleteException(TillerException): super(PostUpdateJobDeleteException, self).__init__(message) + class PostUpdateJobCreateException(TillerException): '''Exception that occurs when a job creation fails.''' @@ -57,6 +63,7 @@ class PostUpdateJobCreateException(TillerException): super(PostUpdateJobCreateException, self).__init__(message) + class PreUpdateJobDeleteException(TillerException): '''Exception that occurs when a job deletion''' @@ -67,6 +74,7 @@ class PreUpdateJobDeleteException(TillerException): super(PreUpdateJobDeleteException, self).__init__(message) + class PreUpdateJobCreateException(TillerException): '''Exception that occurs when a job creation fails.''' @@ -77,6 +85,7 @@ class PreUpdateJobCreateException(TillerException): super(PreUpdateJobCreateException, self).__init__(message) + class ReleaseException(TillerException): '''Exception that occurs when a release fails to install.''' @@ -87,11 +96,13 @@ class ReleaseException(TillerException): super(ReleaseException, self).__init__(message) + class ChannelException(TillerException): '''Exception that occurs during a failed GRPC channel creation''' message = 'Failed to create GRPC channel.' + class GetReleaseStatusException(TillerException): '''Exception that occurs during a failed Release Testing''' @@ -101,6 +112,7 @@ class GetReleaseStatusException(TillerException): super(GetReleaseStatusException, self).__init__(message) + class GetReleaseContentException(TillerException): '''Exception that occurs during a failed Release Testing''' @@ -110,6 +122,7 @@ class GetReleaseContentException(TillerException): super(GetReleaseContentException, self).__init__(message) + class TillerVersionException(TillerException): '''Exception that occurs during a failed Release Testing''' diff --git a/armada/handlers/chartbuilder.py b/armada/handlers/chartbuilder.py index c21670aa..43fde09d 100644 --- a/armada/handlers/chartbuilder.py +++ b/armada/handlers/chartbuilder.py @@ -80,7 +80,7 @@ class ChartBuilder(object): if os.path.exists(os.path.join(self.source_directory, '.helmignore')): with open(os.path.join(self.source_directory, - '.helmignore')) as f: + '.helmignore')) as f: ignored_files = f.readlines() return [filename.strip() for filename in ignored_files] except Exception: @@ -94,8 +94,8 @@ class ChartBuilder(object): false otherwise ''' for ignored_file in self.ignored_files: - if (ignored_file.startswith('*') - and filename.endswith(ignored_file.strip('*'))): + if (ignored_file.startswith('*') and + filename.endswith(ignored_file.strip('*'))): return True elif ignored_file == filename: return True diff --git a/armada/handlers/k8s.py b/armada/handlers/k8s.py index 462e1782..6f4a98be 100644 --- a/armada/handlers/k8s.py +++ b/armada/handlers/k8s.py @@ -168,8 +168,8 @@ class K8s(object): new_pod_name = event_name elif new_pod_name: for condition in pod_conditions: - if (condition.type == 'Ready' - and condition.status == 'True'): + if (condition.type == 'Ready' and + condition.status == 'True'): LOG.info('New pod %s deployed', new_pod_name) w.stop() diff --git a/armada/handlers/manifest.py b/armada/handlers/manifest.py index 686f318f..2a88b3ba 100644 --- a/armada/handlers/manifest.py +++ b/armada/handlers/manifest.py @@ -14,6 +14,7 @@ from ..const import DOCUMENT_CHART, DOCUMENT_GROUP, DOCUMENT_MANIFEST + class Manifest(object): def __init__(self, documents): self.config = None diff --git a/armada/shell.py b/armada/shell.py index 0d48dcca..276737cd 100644 --- a/armada/shell.py +++ b/armada/shell.py @@ -23,6 +23,7 @@ import armada CONF = cfg.CONF + class ArmadaApp(app.App): def __init__(self, **kwargs): super(ArmadaApp, self).__init__( @@ -42,6 +43,7 @@ class ArmadaApp(app.App): log.set_defaults(default_log_levels=CONF.default_log_levels) log.setup(CONF, 'armada') + def main(argv=None): if argv is None: argv = sys.argv[1:] diff --git a/armada/tests/unit/api/test_api.py b/armada/tests/unit/api/test_api.py index c31242c2..06c12668 100644 --- a/armada/tests/unit/api/test_api.py +++ b/armada/tests/unit/api/test_api.py @@ -64,7 +64,8 @@ class TestAPI(APITestCase): # Mock tiller status value mock_tiller.tiller_status.return_value = 'Active' - doc = {u'message': u'Tiller Server is Active'} + # FIXME(lamt) This variable is unused. Uncomment when it is. + # doc = {u'message': u'Tiller Server is Active'} result = self.simulate_get('/v1.0/status') @@ -85,7 +86,8 @@ class TestAPI(APITestCase): # Mock tiller status value mock_tiller.list_releases.return_value = None - doc = {u'releases': {}} + # FIXME(lamt) This variable is unused. Uncomment when it is. + # doc = {u'releases': {}} result = self.simulate_get('/v1.0/releases') diff --git a/armada/tests/unit/utils/test_lint.py b/armada/tests/unit/utils/test_lint.py index 3bfd1ebe..18633c04 100644 --- a/armada/tests/unit/utils/test_lint.py +++ b/armada/tests/unit/utils/test_lint.py @@ -18,6 +18,7 @@ import os from armada.utils import lint + class LintTestCase(unittest.TestCase): def setUp(self): diff --git a/armada/tests/unit/utils/test_release.py b/armada/tests/unit/utils/test_release.py index 37b66256..805348f5 100644 --- a/armada/tests/unit/utils/test_release.py +++ b/armada/tests/unit/utils/test_release.py @@ -16,6 +16,7 @@ import unittest from armada.utils import release as rel + class ReleaseTestCase(unittest.TestCase): def test_release_prefix_pass(self): diff --git a/armada/tests/unit/utils/test_source.py b/armada/tests/unit/utils/test_source.py index d3b44a9f..104ac969 100644 --- a/armada/tests/unit/utils/test_source.py +++ b/armada/tests/unit/utils/test_source.py @@ -19,6 +19,7 @@ from armada.exceptions import source_exceptions from armada.utils import source + class GitTestCase(unittest.TestCase): SOURCE_UTILS_LOCATION = 'armada.utils.source' diff --git a/armada/utils/release.py b/armada/utils/release.py index 3b52c440..c622e95e 100644 --- a/armada/utils/release.py +++ b/armada/utils/release.py @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. + def release_prefix(prefix, chart): ''' how to attach prefix to chart diff --git a/armada/utils/source.py b/armada/utils/source.py index 87897f76..f918993a 100644 --- a/armada/utils/source.py +++ b/armada/utils/source.py @@ -24,6 +24,7 @@ from git import Git from ..exceptions import source_exceptions + def git_clone(repo_url, branch='master'): ''' :params repo_url - URL of git repo to clone @@ -47,10 +48,12 @@ def git_clone(repo_url, branch='master'): return _tmp_dir + def get_tarball(tarball_url): tarball_path = download_tarball(tarball_url) return extract_tarball(tarball_path) + def download_tarball(tarball_url): ''' Downloads a tarball to /tmp and returns the path @@ -64,6 +67,7 @@ def download_tarball(tarball_url): raise source_exceptions.TarballDownloadException(tarball_url) return tarball_filename + def extract_tarball(tarball_path): ''' Extracts a tarball to /tmp and returns the path @@ -80,6 +84,7 @@ def extract_tarball(tarball_path): raise source_exceptions.TarballExtractException(tarball_path) return _tmp_dir + def source_cleanup(target_dir): ''' Clean up source diff --git a/armada/version.py b/armada/version.py index edcec8e2..1c59b688 100644 --- a/armada/version.py +++ b/armada/version.py @@ -12,10 +12,10 @@ # See the License for the specific language governing permissions and # limitations under the License. -__all__ = ['__version__'] - import pbr.version +__all__ = ['__version__'] + version_info = pbr.version.VersionInfo('armada') try: __version__ = version_info.version_string() diff --git a/tox.ini b/tox.ini index 4dcf94fe..5f50f479 100644 --- a/tox.ini +++ b/tox.ini @@ -42,5 +42,5 @@ commands = [flake8] filename= *.py -ignore = W503,E302 +ignore = exclude= .git, .idea, .tox, *.egg-info, *.eggs, bin, dist, hapi