Skip to main content

Python CLI to manage stacks from DNX.

Project description

one-cli

CLI to manage all stacks from DNX.

Build PyPI LICENSE

Quick start

  1. Download the latest release with the command.
curl -sSL https://raw.githubusercontent.com/DNXLabs/one-cli/master/get_one.sh | bash
  1. Test to ensure the version you installed is up-to-date.
one --version
  1. Install shell completion (Optional)
curl -sSL https://raw.githubusercontent.com/DNXLabs/one-cli/master/shell_completion.py | python3

Install specific version

export ONE_VERSION=<version>

# Linux
sudo curl -L https://github.com/DNXLabs/one-cli/releases/download/$ONE_VERSION/one_linux_amd64 -o /usr/local/bin/one
# Macos
sudo curl -L https://github.com/DNXLabs/one-cli/releases/download/$ONE_VERSION/one_macos_amd64 -o /usr/local/bin/one

sudo chmod +x /usr/local/bin/one

Install with PyPi

PyPI Project

pip3 install one-cli

# or setting a version

pip3 install one-cli==<version>

Running with Docker

To easy start with docker just add this line to your bash profile.

alias one='docker run -it -v /var/run/docker.sock:/var/run/docker.sock -v $(pwd):/root -v $HOME/.one:/root/.one dnxsolutions/one-cli'

Or if you want to run the script by yourself, here we have one example:

docker run -it -v /var/run/docker.sock:/var/run/docker.sock \
               -v $HOME/.one:/root/.one \
               --entrypoint /bin/bash \
               dnxsolutions/one-cli

Usage

Usage: one [OPTIONS] COMMAND [ARGS]...

  CLI to manage all stacks from DNX.

Options:
  --version  Show the version and exit.
  --help     Show this message and exit.

Commands:
  app        Group of app commands wrapped inside docker.
  idp        Manage the IDP configuration in your local.
  init       Create config file for CLI in current directory.
  login      Group of commands to login specifying one SSO provider.
  my_plugin  My plugin command
  terraform  Group of terraform commands wrapped inside docker.
  workspace  Manage workspaces.

Configuration Example

one.yaml

images:
  terraform: dnxsolutions/terraform:0.12.24-dnx1
  gsuite: dnxsolutions/aws-google-auth:latest
  azure: dnxsolutions/docker-aws-azure-ad:latest
  aws: dnxsolutions/aws:1.18.44-dnx2
  ecs-deploy: dnxsolutions/ecs-deploy:1.2.0

app:
  name: copacabana
  port: 80
  docker:
    file: Dockerfile
    image-name: copacabana
    registry-type: ecr
    registry-options:
      ecr-aws-account-id: <redact>
      ecr-aws-region: ap-southeast-2
      ecr-aws-assume-role: true
      ecr-aws-role: <redact>
  ecs-task-definition-file: task-definition.tpl.json

workspaces:
  mgmt-app:
    type: ecs
    aws-account-id: <redact>
    aws-role: <redact>
    aws-assume-role: true|false
    aws-region: ap-southeast-2
    ecs-cluster-name: cluster-01
  mgmt:
    aws-account-id:
    aws-role:
  nonprod:
    aws-account-id:
    aws-role:
  prod:
    aws-account-id:
    aws-role:
  default:
    aws-account-id:
    aws-role:
    aws-assume-role: true|false

Setup

Dependencies

  • Python 3

Python Virtual Environment

# Create environment
python3 -m venv env

# To activate the environment
source env/bin/activate

# When you finish you can exit typing
deactivate

Install dependencies

pip3 install --editable .

Manualy generate binary

pyinstaller --clean --hidden-import one.__main__ cli.py --onefile --noconsole -n one

Plugin System

To give better support for customization inside the CLI we created a plugin system that you can extend code, creating new commands and groups and even modify the existing ones.

All plugins need to be created inside ~/.one/plugins/*

Folder Structure

└── plugins
    ├── __init__.py (empty file)
    └── my_plugin.py

Plugin Example

~/.one/plugins/my_plugin.py

import click
from one.one import cli


def __init__():
    cli.add_command(my_plugin)


@click.command(name='my_plugin', help='My plugin command')
def my_plugin():
    click.echo('It works!')

Running

$ one my_plugin
It works!

Author

Managed by DNX Solutions.

License

Apache 2 Licensed. See LICENSE for full details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

one-cli-0.4.5.tar.gz (15.7 kB view details)

Uploaded Source

Built Distribution

one_cli-0.4.5-py3-none-any.whl (25.4 kB view details)

Uploaded Python 3

File details

Details for the file one-cli-0.4.5.tar.gz.

File metadata

  • Download URL: one-cli-0.4.5.tar.gz
  • Upload date:
  • Size: 15.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.3.1 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.3

File hashes

Hashes for one-cli-0.4.5.tar.gz
Algorithm Hash digest
SHA256 75d16d1e3f5ed5017d4c93ee5213afce7a312f697a590db22e0037749911eb1d
MD5 7a5467ef3317570b42a1be7bbc53b7b7
BLAKE2b-256 0f7762e82bb7debf534fd4d2c0c65db31de334740ec8e9196fa98a06152e1176

See more details on using hashes here.

File details

Details for the file one_cli-0.4.5-py3-none-any.whl.

File metadata

  • Download URL: one_cli-0.4.5-py3-none-any.whl
  • Upload date:
  • Size: 25.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.3.1 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.3

File hashes

Hashes for one_cli-0.4.5-py3-none-any.whl
Algorithm Hash digest
SHA256 e94184cce496ebbb379d4cbe79923defddbae8665c9e6d99aa48ac703ea63a6f
MD5 054417bdd9e1e5eac4fc99799424adb5
BLAKE2b-256 a3aaab761f837462165223f1531485004345cf8ebaeb434cc3e38ff798fc8dd8

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page