|
| 1 | +import click |
| 2 | +import yaml |
| 3 | +import json |
| 4 | +import traceback |
| 5 | + |
| 6 | +from ckan_cloud_operator import logs |
| 7 | +from ckan_cloud_operator import kubectl |
| 8 | + |
| 9 | +from . import manager |
| 10 | + |
| 11 | + |
| 12 | +@click.group() |
| 13 | +def env(): |
| 14 | + '''Manage CKAN Environments |
| 15 | + ''' |
| 16 | + pass |
| 17 | + |
| 18 | +@env.command('list') |
| 19 | +def list_env(): |
| 20 | + ''' |
| 21 | + Lists existing environments |
| 22 | +
|
| 23 | + \b |
| 24 | + cco ckan env list |
| 25 | + > POC |
| 26 | + > DEV |
| 27 | + > PRD |
| 28 | + ''' |
| 29 | + |
| 30 | +@env.command() |
| 31 | +@click.argument('ENVIRONMENT') |
| 32 | +@click.option('--cloud-provider', help='One of minukube, azure, gcp, aws', required=True) |
| 33 | +@click.option('--cluster-name', help='Kubernetes cluster name', required=True) |
| 34 | +@click.option('--resource-group', help='Azure resource group name [Azure only]') |
| 35 | +@click.option('--subscription', help='Azure subscription id [Azure only]') |
| 36 | +@click.option('--region', help='GCP region id Eg: europe-west1 [GCP only]') |
| 37 | +@click.option('--project', help='GCP project name [GCP only]') |
| 38 | +def add(environment, cloud_provider, cluster_name, resource_group, subscription, region, project): |
| 39 | + ''' |
| 40 | + Adds an environment |
| 41 | +
|
| 42 | + ENVIRONMENT: The name of the environment Eg: poc |
| 43 | +
|
| 44 | + \b |
| 45 | + cco ckan env add poc --cloud-provider cloud-provider-name \\ |
| 46 | + --resource-group resource-group-name \\ |
| 47 | + --cluster-name cluster-name \\ |
| 48 | + --subscription subscription-id \\ |
| 49 | + --region region-name \\ |
| 50 | + --project project-name |
| 51 | + > POC environment was succefully added |
| 52 | + ''' |
| 53 | + |
| 54 | +@env.command() |
| 55 | +@click.argument('ENVIRONMENT') |
| 56 | +@click.option('--cloud-provider', help='One of minukube, azure, gcp, aws') |
| 57 | +@click.option('--cluster-name', help='Kubernetes cluster name') |
| 58 | +@click.option('--resource-group', help='Azure resource group name [Azure only]') |
| 59 | +@click.option('--subscription', help='Azure subscription id [Azure only]') |
| 60 | +@click.option('--region', help='GCP region id Eg: europe-west1 [GCP only]') |
| 61 | +@click.option('--project', help='GCP project name [GCP only]') |
| 62 | +def update(environment, cloud_provider, cluster_name, resource_group, subscription, region, project): |
| 63 | + ''' |
| 64 | + Update configurations for given environment |
| 65 | +
|
| 66 | + ENVIRONMENT: The name of the environment Eg: dev |
| 67 | +
|
| 68 | + \b |
| 69 | + cco ckan env add poc --cloud-provider cloud-provider-name \\ |
| 70 | + --resource-group resource-group-name \\ |
| 71 | + --cluster-name new-cluster-name \\ |
| 72 | + --subscription subscription-id \\ |
| 73 | + --region region-name \\ |
| 74 | + --project project-name |
| 75 | + > POC environment was succefully updated |
| 76 | + ''' |
| 77 | + |
| 78 | +@env.command() |
| 79 | +@click.argument('ENVIRONMENT') |
| 80 | +def set(environment): |
| 81 | + ''' |
| 82 | + Sets given environment as a current working environment |
| 83 | +
|
| 84 | + ENVIRONMENT: The name of the environment Eg: dev |
| 85 | +
|
| 86 | + \b |
| 87 | + cco ckan env set poc |
| 88 | + > You are working with POC environment now |
| 89 | + ''' |
| 90 | + |
| 91 | +@env.command() |
| 92 | +@click.argument('ENVIRONMENT') |
| 93 | +def rm(environment): |
| 94 | + ''' |
| 95 | + Deletes given environment |
| 96 | +
|
| 97 | + ENVIRONMENT: The name of the environment Eg: dev |
| 98 | +
|
| 99 | + cco ckan env rm poc |
| 100 | + > POC environment was succesfully removed |
| 101 | + ''' |
0 commit comments