Fix(linting): Make Armada pep8 compliant

This patch set makes Armada pep8 compliant. Note the hapi/** is
autogenerated and therefore should be excluded from linting.

Change-Id: I123eefb543f9bd9cf0bc6bd98ed95646d8d72cc3
This commit is contained in:
Pete Birley 2017-09-28 16:42:28 -05:00
parent 6ca2875c81
commit 746cbd0bd8
25 changed files with 70 additions and 12 deletions

View File

@ -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()

View File

@ -22,6 +22,7 @@ from armada.handlers.armada import Armada
LOG = logging.getLogger(__name__)
class Apply(api.BaseResource):
'''
apply armada endpoint service

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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}

View File

@ -14,6 +14,7 @@
import base_exception as base
class ApiException(base.ArmadaBaseException):
'''Base class for API exceptions and error handling.'''

View File

@ -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'''

View File

@ -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.'''

View File

@ -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.'''

View File

@ -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'''

View File

@ -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'''

View File

@ -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

View File

@ -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()

View File

@ -14,6 +14,7 @@
from ..const import DOCUMENT_CHART, DOCUMENT_GROUP, DOCUMENT_MANIFEST
class Manifest(object):
def __init__(self, documents):
self.config = None

View File

@ -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:]

View File

@ -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')

View File

@ -18,6 +18,7 @@ import os
from armada.utils import lint
class LintTestCase(unittest.TestCase):
def setUp(self):

View File

@ -16,6 +16,7 @@ import unittest
from armada.utils import release as rel
class ReleaseTestCase(unittest.TestCase):
def test_release_prefix_pass(self):

View File

@ -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'

View File

@ -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

View File

@ -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

View File

@ -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()

View File

@ -42,5 +42,5 @@ commands =
[flake8]
filename= *.py
ignore = W503,E302
ignore =
exclude= .git, .idea, .tox, *.egg-info, *.eggs, bin, dist, hapi