From e1b64d200b2b106662b4b8d2352cedda19a87576 Mon Sep 17 00:00:00 2001 From: Marshall Margenau Date: Fri, 2 Feb 2018 16:20:58 -0600 Subject: [PATCH] style(armada): quality of life and cleanup - adding .editorconfig file - minor cleanup in various files related to .editorconfig - typos, whitespace, etc. - other general housekeeping items on the codebase Change-Id: I104f8dcb06aafb180da12f7ee4c0ded41fc07b9d --- .dockerignore | 1 - .editorconfig | 27 ++++++++ .gitignore | 5 +- .travis.yml | 22 ------ CODE_OF_CONDUCT.rst | 67 +++++++++---------- CONTRIBUTING.rst | 26 +++---- Dockerfile | 10 +-- Makefile | 4 -- OWNERS | 9 --- README.rst | 6 +- armada/cli/apply.py | 26 +++---- armada/cli/delete.py | 31 ++++++--- armada/cli/test.py | 44 +++++++----- armada/cli/tiller.py | 40 ++++++----- armada/cli/validate.py | 11 +-- armada/common/policies/tiller.py | 4 +- armada/conf/default.py | 6 +- armada/exceptions/api_exceptions.py | 10 +-- armada/exceptions/tiller_exceptions.py | 20 +++--- armada/handlers/armada.py | 9 +-- armada/shell.py | 23 ++++--- armada/utils/source.py | 4 +- charts/armada/templates/job-ks-user.yaml | 1 - .../armada/templates/secret-keystone-env.yaml | 1 - charts/tiller/values.yaml | 2 +- controller.sh | 33 +++++---- docs/source/commands/apply.rst | 6 +- etc/armada/policy.yaml | 1 - plugin.yaml | 4 +- setup.cfg | 6 +- tools/helm_tk.sh | 36 +++++----- tox.ini | 27 ++++---- 32 files changed, 272 insertions(+), 250 deletions(-) create mode 100644 .editorconfig delete mode 100644 .travis.yml delete mode 100644 OWNERS diff --git a/.dockerignore b/.dockerignore index 08cd7984..ca2065b9 100644 --- a/.dockerignore +++ b/.dockerignore @@ -4,7 +4,6 @@ examples CODE_OF_CONDUCT.rst ChangeLog LICENSE -OWNERS etc/armada/armada.conf etc/armada/policy.yaml charts/* diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000..a66d0126 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,27 @@ +# EditorConfig is awesome: http://EditorConfig.org + +root = true + +[*] +charset = utf-8 +end_of_line = lf +indent_size = 4 +indent_style = space +insert_final_newline = true +trim_trailing_whitespace = true + +[*.py] +# Armada uses PEP8 line length of 79 +# Note: for VS Code, set "editor.rulers":[79] in your workspace settings +max_line_length = 79 + +[*.{yml,yaml}] +indent_size = 2 + +[Makefile] +indent_style = tab + +[*.md] +# Note: VS Code may not honor the following setting +# See: https://github.com/editorconfig/editorconfig-vscode/issues/153 +trim_trailing_whitespace = false diff --git a/.gitignore b/.gitignore index 8a300dde..d333a39a 100644 --- a/.gitignore +++ b/.gitignore @@ -105,4 +105,7 @@ AUTHORS ChangeLog etc/armada/armada.conf etc/armada/policy.yaml -.editorconfig + +# IDEs +.idea/ +.vscode/ diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 45b39925..00000000 --- a/.travis.yml +++ /dev/null @@ -1,22 +0,0 @@ -language: python - -sudo: required - -python: - - "2.7" - -before_install: - - pip install -r test-requirements.txt - - pip install -r requirements.txt - - pip install tox - -install: - - pip install -e . - -script: - - flake8 - - armada -h - - nosetests -w armada/tests/unit --cover-package=armada --with-coverage --cover-tests - -# after_success: -# - codecov diff --git a/CODE_OF_CONDUCT.rst b/CODE_OF_CONDUCT.rst index 7cafe92f..6177473a 100644 --- a/CODE_OF_CONDUCT.rst +++ b/CODE_OF_CONDUCT.rst @@ -5,10 +5,10 @@ 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, +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, +education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation. Our Standards @@ -25,54 +25,51 @@ include: 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 +- 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 +- 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 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. +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. +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. 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. +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported by contacting the project team. All +complaints will be reviewed and investigated and will result in a response that +is deemed necessary and 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. +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 ----------- diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst index ec00d5ca..88938555 100644 --- a/CONTRIBUTING.rst +++ b/CONTRIBUTING.rst @@ -7,7 +7,7 @@ involved in contributing to Armada. Code of Conduct --------------- By contributing to Armada, you are agreeing to uphold the -`Contributor Convenant Code of Conduct `_. Please familiarize yourself with it before contributing. @@ -37,12 +37,12 @@ the issue type. +=============+===============================================================+ | bug | Indicates a confirmed bug or other unexpected behavior | +-------------+---------------------------------------------------------------+ -| ehancement | Feature request | +| enhancement | Feature request | +-------------+---------------------------------------------------------------+ | question | Indicates a question | +-------------+---------------------------------------------------------------+ | docs | Assigned to issues indicating missing or incomplete | -| | documenation | +| | documentation | +-------------+---------------------------------------------------------------+ | duplicate | Assigned to issues that are duplicates of previously reported | | | issues | @@ -83,9 +83,9 @@ readme.html#getting-started>`_ Armada accepts patches through GerritHub changes. Each commit pushed to GerritHub is recognized as a "change" (the equivalent of a GitHub pull request). When a change is pushed to GerritHub for review, it contains an -intial patch set that shows all of the revised changes. When a Gerrit change is -amended, a new patch set is created to show the differences from the previous -patch set. +initial patch set that shows all of the revised changes. When a Gerrit change +is amended, a new patch set is created to show the differences from the +previous patch set. The general workflow for submitting a change is: @@ -114,7 +114,7 @@ installed. Git-review can be installed using Python pip install git-review -Git-review can also be intalled on Ubuntu by executing: +Git-review can also be installed on Ubuntu by executing: .. code-block:: bash @@ -138,7 +138,7 @@ connecting-to-github-with-ssh/>`_. If you require authentication over HTTPS, you will need to generate an `HTTPS password `_. -Once you have generated an HTTPS passowrd, add the repository to your remote +Once you have generated an HTTPS password, add the repository to your remote repositories .. code-block:: bash @@ -178,7 +178,7 @@ Armada uses Karma inspired `Semantic Commit Messages In the above template, `TYPE` refers to the type of change, `SCOPE` refers to the area where the change occurs (i.e. api, cli, source), `TITLE` is the title -of the commit message, `DESCRIPTION` is a desription of the change, and +of the commit message, `DESCRIPTION` is a description of the change, and `ISSUE-REFERENCE` is a link to the GitHub issue the change addresses. Below is a list of possible types: @@ -201,7 +201,7 @@ Below is a list of possible types: .. NOTE:: - The scope component of a commit message may be ommited if the change + The scope component of a commit message may be committed if the change covers more than a single component of Armada. An commit message for a change that adds a new API endpoint might resemble the @@ -218,7 +218,7 @@ following example: .. NOTE:: It is necessary to leave a blank line between the commit title and - desciption in order for a change to appear properly on GerritHub. + description in order for a change to appear properly on GerritHub. Since each commit is represented as a "change" in GerritHub, multiple commits should be squashed into one commit before pushing to GerritHub for review. To @@ -241,7 +241,7 @@ Your change will now be visible on GerritHub for review. In order to amend your change after pushing it for review, you will need to create additional patch sets. -In order to create an additional patch set, modify your exisiting commit and +In order to create an additional patch set, modify your existing commit and push your new changes for review .. code-block:: bash @@ -304,5 +304,5 @@ and conforms to the PEP8 style guide, execute: .. code-block:: bash tox -e pep8 - tox -e py27,py35 + tox -e py35 tox -e coverage diff --git a/Dockerfile b/Dockerfile index 72deb33f..f15aeb54 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,17 +12,17 @@ RUN pip3 install -r /tmp/requirements.txt COPY . /armada RUN apt-get update && \ apt-get install -y --no-install-recommends \ - netbase \ - curl \ - git && \ + netbase \ + curl \ + git && \ useradd -u 1000 -g users -d /armada armada && \ chown -R armada:users /armada && \ mv /armada/etc/armada /etc/ && \ cd /armada && \ python3 setup.py install && \ rm -rf \ - /root/.cache \ - /var/lib/apt/lists/* + /root/.cache \ + /var/lib/apt/lists/* EXPOSE 8000 diff --git a/Makefile b/Makefile index 437bb715..52c340ca 100644 --- a/Makefile +++ b/Makefile @@ -62,7 +62,6 @@ check-tox: images: check-docker docker build --rm -t ${IMAGE} . - .PHONY: dry-run dry-run: clean tools/helm_tk.sh $(HELM) @@ -107,10 +106,7 @@ helm_lint: @tools/helm_tk.sh $(HELM) $(HELM) lint $(CHART) - .PHONY: charts charts: clean $(HELM) dep up $(CHART) $(HELM) package $(CHART) - - diff --git a/OWNERS b/OWNERS deleted file mode 100644 index 4b870eda..00000000 --- a/OWNERS +++ /dev/null @@ -1,9 +0,0 @@ -reviewers: - - alanmeadows - - v1k0d3n - - intlabs - - wilkers-steve - - larryrensing -approvers: - - alanmeadows - - v1k0d3n diff --git a/README.rst b/README.rst index 6d876df7..e8db6106 100644 --- a/README.rst +++ b/README.rst @@ -1,7 +1,7 @@ Armada ====== -|Docker Repository on Quay| |Build Status| |Doc Status| +|Docker Repository on Quay| |Doc Status| Armada is a tool for managing multiple Helm charts with dependencies by centralizing all configurations in a single Armada YAML and providing @@ -83,7 +83,7 @@ Usage To run Armada, simply supply it with your YAML-based intention for any number of charts:: - $ armada apply examples/openstack-helm.yaml [--debug-loggging ] + $ armada apply examples/openstack-helm.yaml [ --debug ] Which should output something like this:: @@ -121,7 +121,5 @@ Further Reading .. |Docker Repository on Quay| image:: https://quay.io/repository/attcomdev/armada/status :target: https://quay.io/repository/attcomdev/armada -.. |Build Status| image:: https://travis-ci.org/att-comdev/armada.svg?branch=master - :target: https://travis-ci.org/att-comdev/armada .. |Doc Status| image:: https://readthedocs.org/projects/armada-helm/badge/?version=latest :target: http://armada-helm.readthedocs.io/ diff --git a/armada/cli/apply.py b/armada/cli/apply.py index 2523f62a..a38804ab 100644 --- a/armada/cli/apply.py +++ b/armada/cli/apply.py @@ -33,11 +33,11 @@ def apply(): DESC = """ -This command install and updates charts defined in armada manifest +This command installs and updates charts defined in Armada manifest. The apply argument must be relative path to Armada Manifest. Executing apply -commnad once will install all charts defined in manifest. Re-executing apply -commnad will execute upgrade. +command once will install all charts defined in manifest. Re-executing apply +command will execute upgrade. To see how to create an Armada manifest: http://armada-helm.readthedocs.io/en/latest/operations/ @@ -51,7 +51,7 @@ To obtain override manifest: \b $ armada apply examples/simple.yaml \ ---set manifest:simple-armada:relase_name="wordpress" +--set manifest:simple-armada:release_name="wordpress" \b or @@ -62,13 +62,14 @@ To obtain override manifest: """ -SHORT_DESC = "command install manifest charts" +SHORT_DESC = "Command installs manifest charts." @apply.command(name='apply', help=DESC, short_help=SHORT_DESC) -@click.argument('locations', nargs=-1) +@click.argument('locations', + nargs=-1) @click.option('--api', help="Contacts service endpoint.", is_flag=True) @@ -105,8 +106,7 @@ SHORT_DESC = "command install manifest charts" help="Specifies time to wait for charts to deploy.", type=int, default=3600) -@click.option('--values', - '-f', +@click.option('--values', '-f', help=("Use to override multiple Armada Manifest values by " "reading overrides from a values.yaml-type file."), multiple=True, @@ -116,12 +116,12 @@ SHORT_DESC = "command install manifest charts" help="Wait until all charts deployed.", is_flag=True) @click.option('--target-manifest', - help=('The target manifest to run. Required for specifying ' - 'which manifest to run when multiple are available.'), + help=("The target manifest to run. Required for specifying " + "which manifest to run when multiple are available."), default=None) -@click.option('--debug/--no-debug', - help='Enable or disable debugging.', - default=False) +@click.option('--debug', + help="Enable debug logging.", + is_flag=True) @click.pass_context def apply_create(ctx, locations, api, disable_update_post, disable_update_pre, dry_run, enable_chart_cleanup, set, tiller_host, tiller_port, diff --git a/armada/cli/delete.py b/armada/cli/delete.py index 883bae33..be5db330 100644 --- a/armada/cli/delete.py +++ b/armada/cli/delete.py @@ -36,7 +36,7 @@ This command deletes releases. The delete command will delete the releases either via a manifest or by targeting specific releases. -To delete all the releases that are created by the armada manifest: +To delete all the releases that are created by the Armada manifest: $ armada delete --manifest examples/simple.yaml @@ -50,18 +50,27 @@ To delete releases by the name: """ -SHORT_DESC = "command delete releases" +SHORT_DESC = "Command deletes releases." -@delete.command(name='delete', help=DESC, short_help=SHORT_DESC) -@click.option('--manifest', help='Armada manifest file', type=str) -@click.option( - '--releases', help='Comma-separated list of release names', type=str) -@click.option( - '--no-purge', help="Deletes release without purge option", is_flag=True) -@click.option('--tiller-host', help="Tiller Host IP") -@click.option( - '--tiller-port', help="Tiller host Port", type=int, default=44134) +@delete.command(name='delete', + help=DESC, + short_help=SHORT_DESC) +@click.option('--manifest', + help="Armada Manifest file.", + type=str) +@click.option('--releases', + help="Comma-separated list of release names.", + type=str) +@click.option('--no-purge', + help="Deletes release without purge option.", + is_flag=True) +@click.option('--tiller-host', + help="Tiller host IP.") +@click.option('--tiller-port', + help="Tiller host port.", + type=int, + default=44134) @click.pass_context def delete_charts(ctx, manifest, releases, no_purge, tiller_host, tiller_port): DeleteChartManifest( diff --git a/armada/cli/test.py b/armada/cli/test.py index 6744c7f5..e02ebf13 100644 --- a/armada/cli/test.py +++ b/armada/cli/test.py @@ -34,13 +34,13 @@ def test(): DESC = """ -This command test deployed charts +This command tests deployed charts. -The tiller command uses flags to obtain information from tiller services. +The tiller command uses flags to obtain information from Tiller services. The test command will run the release chart tests either via a the manifest or -by targetings a relase. +by targeting a release. -To test armada deployed releases: +To test Armada deployed releases: $ armada test --file examples/simple.yaml @@ -50,22 +50,32 @@ To test release: """ -SHORT_DESC = "command test releases" +SHORT_DESC = "Command tests releases." -@test.command(name='test', help=DESC, short_help=SHORT_DESC) -@click.option('--file', help='armada manifest', type=str) -@click.option('--release', help='helm release', type=str) -@click.option('--tiller-host', help="Tiller Host IP", default=None) -@click.option( - '--tiller-port', help="Tiller Host Port", type=int, - default=CONF.tiller_port) -@click.option( - '--tiller-namespace', '-tn', help="Tiller Namespace", type=str, - default=CONF.tiller_namespace) +@test.command(name='test', + help=DESC, + short_help=SHORT_DESC) +@click.option('--file', + help="Armada manifest.", + type=str) +@click.option('--release', + help="Helm release.", + type=str) +@click.option('--tiller-host', + help="Tiller host IP.", + default=None) +@click.option('--tiller-port', + help="Tiller host port.", + type=int, + default=CONF.tiller_port) +@click.option('--tiller-namespace', '-tn', + help="Tiller Namespace.", + type=str, + default=CONF.tiller_namespace) @click.option('--target-manifest', - help=('The target manifest to run. Required for specifying ' - 'which manifest to run when multiple are available.'), + help=("The target manifest to run. Required for specifying " + "which manifest to run when multiple are available."), default=None) @click.pass_context def test_charts(ctx, file, release, tiller_host, tiller_port, tiller_namespace, diff --git a/armada/cli/tiller.py b/armada/cli/tiller.py index 3ee4e63a..226b3b0d 100644 --- a/armada/cli/tiller.py +++ b/armada/cli/tiller.py @@ -30,33 +30,43 @@ def tiller(): DESC = """ -This command gets tiller information +This command gets Tiller information -The tiller command uses flags to obtain information from tiller services +The tiller command uses flags to obtain information from Tiller services -To obtain armada deployed releases: +To obtain Armada deployed releases: $ armada tiller --releases -To obtain tiller service status/information: +To obtain Tiller service status/information: $ armada tiller --status """ -SHORT_DESC = "command gets tiller infromation" +SHORT_DESC = "Command gets Tiller information." -@tiller.command(name='tiller', help=DESC, short_help=SHORT_DESC) -@click.option('--tiller-host', help="Tiller host ip", default=None) -@click.option( - '--tiller-port', help="Tiller host port", type=int, - default=CONF.tiller_port) -@click.option( - '--tiller-namespace', '-tn', help="Tiller namespace", type=str, - default=CONF.tiller_namespace) -@click.option('--releases', help="list of deployed releses", is_flag=True) -@click.option('--status', help="Status of Armada services", is_flag=True) +@tiller.command(name='tiller', + help=DESC, + short_help=SHORT_DESC) +@click.option('--tiller-host', + help="Tiller host IP.", + default=None) +@click.option('--tiller-port', + help="Tiller host port.", + type=int, + default=CONF.tiller_port) +@click.option('--tiller-namespace', '-tn', + help="Tiller namespace.", + type=str, + default=CONF.tiller_namespace) +@click.option('--releases', + help="List of deployed releases.", + is_flag=True) +@click.option('--status', + help="Status of Armada services.", + is_flag=True) @click.pass_context def tiller_service(ctx, tiller_host, tiller_port, tiller_namespace, releases, status): diff --git a/armada/cli/validate.py b/armada/cli/validate.py index 1e92c2e8..a43d6ec9 100644 --- a/armada/cli/validate.py +++ b/armada/cli/validate.py @@ -30,7 +30,7 @@ def validate(): DESC = """ -This command validates Armada Manifest +This command validates an Armada Manifest. The validate argument must be a relative path to Armada manifest @@ -38,11 +38,14 @@ The validate argument must be a relative path to Armada manifest """ -SHORT_DESC = "command validates Armada Manifest" +SHORT_DESC = "Command validates Armada Manifest." -@validate.command(name='validate', help=DESC, short_help=SHORT_DESC) -@click.argument('locations', nargs=-1) +@validate.command(name='validate', + help=DESC, + short_help=SHORT_DESC) +@click.argument('locations', + nargs=-1) @click.pass_context def validate_manifest(ctx, locations): ValidateManifest(ctx, locations).invoke() diff --git a/armada/common/policies/tiller.py b/armada/common/policies/tiller.py index 6370fdcb..1eb4a10b 100644 --- a/armada/common/policies/tiller.py +++ b/armada/common/policies/tiller.py @@ -19,13 +19,13 @@ tiller_policies = [ policy.DocumentedRuleDefault( name=base.TILLER % 'get_status', check_str=base.RULE_ADMIN_REQUIRED, - description='Get tiller status', + description='Get Tiller status', operations=[{'path': '/api/v1.0/status/', 'method': 'GET'}]), policy.DocumentedRuleDefault( name=base.TILLER % 'get_release', check_str=base.RULE_ADMIN_REQUIRED, - description='Get tiller release', + description='Get Tiller release', operations=[{'path': '/api/v1.0/releases/', 'method': 'GET'}]), ] diff --git a/armada/conf/default.py b/armada/conf/default.py index a116c9a9..cd671d10 100644 --- a/armada/conf/default.py +++ b/armada/conf/default.py @@ -69,17 +69,17 @@ The Keystone project domain name used for authentication. cfg.StrOpt( 'tiller_pod_labels', default='app=helm,name=tiller', - help=utils.fmt('Labels for the tiller pod.')), + help=utils.fmt('Labels for the Tiller pod.')), cfg.StrOpt( 'tiller_namespace', default='kube-system', - help=utils.fmt('Namespace for the tiller pod.')), + help=utils.fmt('Namespace for the Tiller pod.')), cfg.IntOpt( 'tiller_port', default=44134, - help=utils.fmt('Port for the tiller pod.')), + help=utils.fmt('Port for the Tiller pod.')), cfg.ListOpt( 'tiller_release_roles', diff --git a/armada/exceptions/api_exceptions.py b/armada/exceptions/api_exceptions.py index 7be8a8b9..9b68719f 100644 --- a/armada/exceptions/api_exceptions.py +++ b/armada/exceptions/api_exceptions.py @@ -24,28 +24,28 @@ class ApiException(base.ArmadaBaseException): class ApiBaseException(ApiException): '''Exception that occurs during chart cleanup.''' - message = 'There was an error listing the helm chart releases.' + message = 'There was an error listing the Helm chart releases.' class ApiJsonException(ApiException): '''Exception that occurs during chart cleanup.''' - message = 'There was an error listing the helm chart releases.' + message = 'There was an error listing the Helm chart releases.' class ClientUnauthorizedError(ApiException): '''Exception that occurs during chart cleanup.''' - message = 'There was an error listing the helm chart releases.' + message = 'There was an error listing the Helm chart releases.' class ClientForbiddenError(ApiException): '''Exception that occurs during chart cleanup.''' - message = 'There was an error listing the helm chart releases.' + message = 'There was an error listing the Helm chart releases.' class ClientError(ApiException): '''Exception that occurs during chart cleanup.''' - message = 'There was an error listing the helm chart releases.' + message = 'There was an error listing the Helm chart releases.' diff --git a/armada/exceptions/tiller_exceptions.py b/armada/exceptions/tiller_exceptions.py index 80db5b33..861ab27a 100644 --- a/armada/exceptions/tiller_exceptions.py +++ b/armada/exceptions/tiller_exceptions.py @@ -18,20 +18,20 @@ from armada.exceptions.base_exception import ArmadaBaseException as ex class TillerException(ex): '''Base class for Tiller exceptions and error handling.''' - message = 'An unknown Tiller error occured.' + message = 'An unknown Tiller error occurred.' class TillerServicesUnavailableException(TillerException): - '''Exception for tiller services unavailable.''' + '''Exception for Tiller services unavailable.''' message = 'Tiller services unavailable.' class ChartCleanupException(TillerException): - '''Exception that occures during chart cleanup.''' + '''Exception that occurs during chart cleanup.''' def __init__(self, chart_name): - message = 'An error occred during cleanup while removing {}'.format( + message = 'An error occurred during cleanup while removing {}'.format( chart_name) super(ChartCleanupException, self).__init__(message) @@ -39,7 +39,7 @@ class ChartCleanupException(TillerException): class ListChartsException(TillerException): '''Exception that occurs when listing charts''' - message = 'There was an error listing the helm chart releases.' + message = 'There was an error listing the Helm chart releases.' class PostUpdateJobDeleteException(TillerException): @@ -98,9 +98,9 @@ class ReleaseException(TillerException): class ChannelException(TillerException): - '''Exception that occurs during a failed GRPC channel creation''' + '''Exception that occurs during a failed gRPC channel creation''' - message = 'Failed to create GRPC channel.' + message = 'Failed to create gRPC channel.' class GetReleaseStatusException(TillerException): @@ -129,15 +129,15 @@ class TillerPodNotFoundException(TillerException): ''' def __init__(self, labels): - message = 'Could not find tiller pod with labels "{}"'.format(labels) + message = 'Could not find Tiller pod with labels "{}"'.format(labels) super(TillerPodNotFoundException, self).__init__(message) class TillerPodNotRunningException(TillerException): - '''Exception that occurs when no tiller pod is found in a running state''' + '''Exception that occurs when no Tiller pod is found in a running state''' - message = 'No tiller pods found in running state' + message = 'No Tiller pods found in running state' class TillerVersionException(TillerException): diff --git a/armada/handlers/armada.py b/armada/handlers/armada.py index d7b828b8..cd9e3052 100644 --- a/armada/handlers/armada.py +++ b/armada/handlers/armada.py @@ -184,9 +184,10 @@ class Armada(object): if repo_branch not in repos: try: - LOG.info('Cloning repo: %s branch: %s', *repo_branch) + logstr = 'Cloning repo: {} branch: {}'.format(*repo_branch) if proxy_server: - LOG.info('Using proxy to clone: %s', proxy_server) + logstr += ' proxy: {}'.format(proxy_server) + LOG.info(logstr) repo_dir = source.git_clone(*repo_branch, proxy_server) except Exception: raise source_exceptions.GitException( @@ -216,7 +217,7 @@ class Armada(object): def sync(self): ''' - Syncronize Helm with the Armada Config(s) + Synchronize Helm with the Armada Config(s) ''' msg = {'install': [], 'upgrade': [], 'diff': []} @@ -235,7 +236,7 @@ class Armada(object): raise armada_exceptions.KnownReleasesException() for release in known_releases: - LOG.debug("Release %s, Version %s found on tiller", release[0], + LOG.debug("Release %s, Version %s found on Tiller", release[0], release[1]) for entry in self.config[const.KEYWORD_ARMADA][const.KEYWORD_GROUPS]: diff --git a/armada/shell.py b/armada/shell.py index 35aa8ac6..8b9f9f6c 100644 --- a/armada/shell.py +++ b/armada/shell.py @@ -30,15 +30,20 @@ CONF = cfg.CONF @click.group() -@click.option( - '--debug/--no-debug', help='Enable or disable debugging', default=False) -@click.option( - '--api/--no-api', help='Execute service endpoints. (requires url option)', - default=False) -@click.option( - '--url', help='Armada Service Endpoint', envvar='HOST', default=None) -@click.option( - '--token', help='Keystone Service Token', envvar='TOKEN', default=None) +@click.option('--debug', + help="Enable debug logging", + is_flag=True) +@click.option('--api/--no-api', + help="Execute service endpoints. (requires url option)", + default=False) +@click.option('--url', + help="Armada Service Endpoint", + envvar='HOST', + default=None) +@click.option('--token', + help="Keystone Service Token", + envvar='TOKEN', + default=None) @click.pass_context def main(ctx, debug, api, url, token): """ diff --git a/armada/utils/source.py b/armada/utils/source.py index f64bfcc4..9934415d 100644 --- a/armada/utils/source.py +++ b/armada/utils/source.py @@ -47,11 +47,11 @@ def git_clone(repo_url, ref='master', proxy_server=None): try: if proxy_server: - LOG.info('Cloning [%s] with proxy [%s]', repo_url, proxy_server) + LOG.debug('Cloning [%s] with proxy [%s]', repo_url, proxy_server) repo = Repo.clone_from(repo_url, _tmp_dir, config='http.proxy=%s' % proxy_server) else: - LOG.info('Cloning [%s]', repo_url) + LOG.debug('Cloning [%s]', repo_url) repo = Repo.clone_from(repo_url, _tmp_dir) repo.remotes.origin.fetch(ref) diff --git a/charts/armada/templates/job-ks-user.yaml b/charts/armada/templates/job-ks-user.yaml index a69b123e..9521d9cb 100644 --- a/charts/armada/templates/job-ks-user.yaml +++ b/charts/armada/templates/job-ks-user.yaml @@ -65,4 +65,3 @@ spec: name: armada-bin defaultMode: 0555 {{- end }} - diff --git a/charts/armada/templates/secret-keystone-env.yaml b/charts/armada/templates/secret-keystone-env.yaml index 750da107..2f159e29 100644 --- a/charts/armada/templates/secret-keystone-env.yaml +++ b/charts/armada/templates/secret-keystone-env.yaml @@ -28,4 +28,3 @@ data: {{- tuple $userClass "internal" $envAll | include "helm-toolkit.snippets.keystone_secret_openrc" | indent 2 -}} {{- end }} {{- end }} - diff --git a/charts/tiller/values.yaml b/charts/tiller/values.yaml index b1811489..3732e60b 100644 --- a/charts/tiller/values.yaml +++ b/charts/tiller/values.yaml @@ -24,7 +24,7 @@ images: pull_policy: "IfNotPresent" deployment: - # NOTE: CUrrent replica is hard-coded to 1. This is a placeholder variable + # NOTE: Current replica is hard-coded to 1. This is a placeholder variable # for future usage. Updates will be made to the chart when we know that # tiller is stable with multiple instances. replicas: 1 diff --git a/controller.sh b/controller.sh index 2a449a58..bd3aac24 100755 --- a/controller.sh +++ b/controller.sh @@ -7,31 +7,30 @@ clean_container(){ } readlink(){ - ( - cd $(dirname $1) - echo $PWD/$(basename $1) - ) + ( + cd $(dirname $1) + echo $PWD/$(basename $1) + ) } # Check to see if the aramada container exists if [ -n "$( sudo docker ps -a | grep quay.io/attcomdev/armada )" ]; then - echo "Armada container already exists..." - clean_container armada + echo "Armada container already exists..." + clean_container armada fi # Check to see if the user is trying to apply a chart if [ $1 = "apply" ]; then - # TODO Handle erroneous or missing inputs - # Bring up a new armada container with passed in yaml mounted to the container - echo "Creating an Armada container..." - docker run -d --net host -p 8000:8000 --name armada -v $(readlink $(dirname $2)):$(readlink $(dirname $2)) -v ~/.kube/config:/armada/.kube/config -v ~/.kube/plugins/armada/examples/:/examples quay.io/attcomdev/armada:latest - docker exec armada armada apply $(readlink $2) + # TODO Handle erroneous or missing inputs + # Bring up a new armada container with passed in yaml mounted to the container + echo "Creating an Armada container..." + docker run -d --net host -p 8000:8000 --name armada -v $(readlink $(dirname $2)):$(readlink $(dirname $2)) -v ~/.kube/config:/armada/.kube/config -v ~/.kube/plugins/armada/examples/:/examples quay.io/attcomdev/armada:latest + docker exec armada armada apply $(readlink $2) else - # For any other command the chart does not need to be mounted to the container - # Bring up a new armada container - echo "Creating an Armada container..." - docker run -d --net host -p 8000:8000 --name armada -v ~/.kube/config:/armada/.kube/config -v ~/.kube/plugins/armada/examples/:/examples quay.io/attcomdev/armada:latest - docker exec armada armada "$@" + # For any other command the chart does not need to be mounted to the container + # Bring up a new armada container + echo "Creating an Armada container..." + docker run -d --net host -p 8000:8000 --name armada -v ~/.kube/config:/armada/.kube/config -v ~/.kube/plugins/armada/examples/:/examples quay.io/attcomdev/armada:latest + docker exec armada armada "$@" fi clean_container armada - diff --git a/docs/source/commands/apply.rst b/docs/source/commands/apply.rst index 0afc0061..22762e87 100644 --- a/docs/source/commands/apply.rst +++ b/docs/source/commands/apply.rst @@ -24,7 +24,7 @@ Commands To obtain override manifest: - $ armada apply examples/simple.yaml --set manifest:simple-armada:relase_name="wordpress" + $ armada apply examples/simple.yaml --set manifest:simple-armada:release_name="wordpress" or @@ -50,7 +50,7 @@ Commands --target-manifest TEXT The target manifest to run. Required for specifying which manifest to run when multiple are available. - --debug / --no-debug Enable or disable debugging. + --debug Enable debug logging. --help Show this message and exit. Synopsis @@ -61,7 +61,7 @@ that it will deploy into the tiller service in your Kubernetes cluster. Executing the ``armada apply`` again on existing armada deployment will start an update of the armada deployed charts. -``armada apply armada-manifest.yaml [--debug-logging]`` +``armada apply armada-manifest.yaml [--debug]`` If you remove ``armada/Charts/v1`` from the ``armada/ChartGroups/v1`` in the armada manifest and execute an ``armada apply`` with the ``--enable-chart-cleanup`` flag. diff --git a/etc/armada/policy.yaml b/etc/armada/policy.yaml index 4b09078a..4ed6251d 100644 --- a/etc/armada/policy.yaml +++ b/etc/armada/policy.yaml @@ -30,4 +30,3 @@ # Get tiller release # GET /api/v1.0/releases/ #"tiller:get_release": "rule:admin_required" - diff --git a/plugin.yaml b/plugin.yaml index fbf91654..43cc765c 100644 --- a/plugin.yaml +++ b/plugin.yaml @@ -1,8 +1,8 @@ name: "armada" version: "0.0.3" -usage: "Manages multiple helm charts with a centralized armada yaml" +usage: "Manages multiple Helm charts with a centralized Armada yaml" description: |- - This plugin provides helm access to armada. A tool for managing multiple helm charts with dependencies by centralizing all configurations in a single Armada yaml and providing lifecycle hooks for all helm releases + This plugin provides Helm access to Armada. A tool for managing multiple Helm charts with dependencies by centralizing all configurations in a single Armada yaml and providing lifecycle hooks for all Helm releases usage: $ helm armada tiller --status $ helm armada apply /examples/openstack-helm.yaml diff --git a/setup.cfg b/setup.cfg index b7057887..e8e790c0 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = armada -summary = tool for managing multiple chart ocherstartion lifecycle +summary = tool for managing multiple chart orchestration lifecycle description-file = README.rst author = armada team @@ -11,8 +11,6 @@ classifier = License :: OSI Approved :: Apache Software License Operating System :: POSIX :: Linux Programming Language :: Python - Programming Language :: Python :: 2 - Programming Language :: Python :: 2.7 Programming Language :: Python :: 3 Programming Language :: Python :: 3.5 @@ -43,7 +41,7 @@ console_scripts = oslo.config.opts = armada.conf = armada.conf.opts:list_opts oslo.policy.policies = - armada = armada.common.policies:list_rules + armada = armada.common.policies:list_rules [pbr] warnerrors = True diff --git a/tools/helm_tk.sh b/tools/helm_tk.sh index 3efccdd6..9eae2dca 100755 --- a/tools/helm_tk.sh +++ b/tools/helm_tk.sh @@ -20,26 +20,26 @@ HELM=$1 set -x function helm_serve { - if [[ -d "$HOME/.helm" ]]; then - echo ".helm directory found" - else - ${HELM} init --client-only - fi - if [[ -z $(curl -s 127.0.0.1:8879 | grep 'Helm Repository') ]]; then - ${HELM} serve & > /dev/null - while [[ -z $(curl -s 127.0.0.1:8879 | grep 'Helm Repository') ]]; do - sleep 1 - echo "Waiting for Helm Repository" - done - else - echo "Helm serve already running" - fi + if [[ -d "$HOME/.helm" ]]; then + echo ".helm directory found" + else + ${HELM} init --client-only + fi + if [[ -z $(curl -s 127.0.0.1:8879 | grep 'Helm Repository') ]]; then + ${HELM} serve & > /dev/null + while [[ -z $(curl -s 127.0.0.1:8879 | grep 'Helm Repository') ]]; do + sleep 1 + echo "Waiting for Helm Repository" + done + else + echo "Helm serve already running" + fi - if ${HELM} repo list | grep -q "^stable" ; then - ${HELM} repo remove stable - fi + if ${HELM} repo list | grep -q "^stable" ; then + ${HELM} repo remove stable + fi - ${HELM} repo add local http://localhost:8879/charts + ${HELM} repo add local http://localhost:8879/charts } mkdir -p build diff --git a/tox.ini b/tox.ini index e026c1bc..0b26e37d 100644 --- a/tox.ini +++ b/tox.ini @@ -4,47 +4,48 @@ envlist = py35, pep8, coverage, bandit [testenv] deps= - -r{toxinidir}/requirements.txt - -r{toxinidir}/test-requirements.txt + -r{toxinidir}/requirements.txt + -r{toxinidir}/test-requirements.txt passenv=HTTP_PROXY HTTPS_PROXY http_proxy https_proxy NO_PROXY no_proxy setenv= VIRTUAL_ENV={envdir} basepython = python3.5 usedevelop = True install_command = pip install {opts} {packages} -whitelist_externals = find - flake8 +whitelist_externals = + find + flake8 commands = - find . -type f -name "*.pyc" -delete - python -V - {toxinidir}/tools/run-unit-tests.sh {posargs} + find . -type f -name "*.pyc" -delete + python -V + {toxinidir}/tools/run-unit-tests.sh {posargs} [testenv:docs] commands = - python setup.py build_sphinx + python setup.py build_sphinx [testenv:genconfig] commands = - oslo-config-generator --config-file=etc/armada/config-generator.conf + oslo-config-generator --config-file=etc/armada/config-generator.conf [testenv:genpolicy] commands = - oslopolicy-sample-generator --config-file=etc/armada/policy-generator.conf + oslopolicy-sample-generator --config-file=etc/armada/policy-generator.conf [testenv:pep8] commands = - flake8 {posargs} + flake8 {posargs} [testenv:bandit] commands = - bandit -r armada -x armada/tests -n 5 + bandit -r armada -x armada/tests -n 5 [testenv:coverage] passenv=http_proxy https_proxy no_proxy HTTP_PROXY HTTPS_PROXY NO_PROXY setenv= VIRTUAL_ENV={envdir} commands = - python -m pytest \ + python -m pytest \ --cov-branch \ --cov-report term-missing:skip-covered \ --cov-config .coveragerc \