Skip to content

Commit

Permalink
Add forward compatible support for click 7.0
Browse files Browse the repository at this point in the history
click changed command names to use dashes instead of underscores, so force the underscore name to be used to maintain backward compatibility.
pallets/click#1123 (comment)

Handle changed click exit_code
pallets/click#533
  • Loading branch information
rectalogic committed Nov 29, 2018
1 parent 9028197 commit 78508a1
Show file tree
Hide file tree
Showing 10 changed files with 21 additions and 17 deletions.
4 changes: 2 additions & 2 deletions curator/cli_singletons/delete.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from curator.cli_singletons.utils import get_width, validate_filter_json

#### Indices ####
@click.command(context_settings=get_width())
@click.command(name="delete_indices", context_settings=get_width())
@click.option('--ignore_empty_list', is_flag=True, help='Do not raise exception if there are no actionable indices')
@click.option('--allow_ilm_indices/--no-allow_ilm_indices', help='Allow Curator to operate on Index Lifecycle Management monitored indices.', default=False, show_default=True)
@click.option('--filter_list', callback=validate_filter_json, help='JSON array of filters selecting indices to act on.', required=True)
Expand All @@ -17,7 +17,7 @@ def delete_indices(ctx, ignore_empty_list, allow_ilm_indices, filter_list):
action.do_singleton_action(dry_run=ctx.obj['dry_run'])

#### Snapshots ####
@click.command(context_settings=get_width())
@click.command(name="delete_snapshots", context_settings=get_width())
@click.option('--repository', type=str, required=True, help='Snapshot repository name')
@click.option('--retry_count', type=int, help='Number of times to retry (max 3)')
@click.option('--retry_interval', type=int, help='Time in seconds between retries')
Expand Down
4 changes: 2 additions & 2 deletions curator/cli_singletons/show.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from datetime import datetime

#### Indices ####
@click.command(context_settings=get_width())
@click.command(name="show_indices", context_settings=get_width())
@click.option('--verbose', help='Show verbose output.', is_flag=True, show_default=True)
@click.option('--header', help='Print header if --verbose', is_flag=True, show_default=True)
@click.option('--epoch', help='Print time as epoch if --verbose', is_flag=True, show_default=True)
Expand Down Expand Up @@ -69,7 +69,7 @@ def show_indices(ctx, verbose, header, epoch, ignore_empty_list, allow_ilm_indic
click.echo('{0}'.format(idx))

#### Snapshots ####
@click.command(context_settings=get_width())
@click.command(name="show_snapshots", context_settings=get_width())
@click.option('--repository', type=str, required=True, help='Snapshot repository name')
@click.option('--ignore_empty_list', is_flag=True, help='Do not raise exception if there are no actionable snapshots')
@click.option('--filter_list', callback=validate_filter_json, default='{"filtertype":"none"}', help='JSON string representing an array of filters.')
Expand Down
4 changes: 4 additions & 0 deletions docs/Changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ Changelog

* TravisCI testing for Elasticsearch 6.5.0 (untergeek)

**General**

* Bumped ``click`` (python module) version dependency to 7.0

**Bug Fixes**

* Report rollover results in both dry-run and regular runs. Requested
Expand Down
6 changes: 3 additions & 3 deletions docs/asciidoc/installation.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -351,10 +351,10 @@ or uncompress and run `python setup.py install`
 

=== click
Download and install the http://click.pocoo.org/[click] dependency (6.7):
Download and install the http://click.pocoo.org/[click] dependency (7.0):

. `wget https://github.com/pallets/click/archive/6.7.tar.gz -O click-6.7.tar.gz`
. `pip install click-6.7.tar.gz`
. `wget https://github.com/pallets/click/archive/7.0.tar.gz -O click-7.0.tar.gz`
. `pip install click-7.0.tar.gz`

or uncompress and run `python setup.py install`

Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ voluptuous>=0.9.3
elasticsearch>=6.1.0,<7.0.0
boto3>=1.7.24
requests_aws4auth>=0.9
click>=6.7,<7.0
click>=6.7,<8.0
pyyaml>=3.10
certifi>=2018.10.15
six>=1.11.0
4 changes: 2 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ install_requires =
elasticsearch>=6.1.0,<7.0.0
boto3>=1.7.24
requests_aws4auth>=0.9
click>=6.7,<7.0
click>=6.7,<8.0
pyyaml>=3.10
certifi>=2018.10.15
six>=1.11.0
Expand All @@ -34,7 +34,7 @@ setup_requires =
elasticsearch>=6.1.0,<7.0.0
boto3>=1.7.24
requests_aws4auth>=0.9
click>=6.7,<7.0
click>=6.7,<8.0
pyyaml>=3.10
certifi>=2018.10.15
six>=1.11.0
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def get_install_requires():
res = ['elasticsearch>=6.1.0,<7.0.0' ]
res.append('boto3>=1.7.24')
res.append('requests_aws4auth>=0.9')
res.append('click>=6.7,<7.0')
res.append('click>=6.7,<8.0')
res.append('pyyaml>=3.10')
res.append('voluptuous>=0.9.3')
res.append('certifi>=2018.10.15')
Expand Down
4 changes: 2 additions & 2 deletions test/integration/test_replicas.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def test_no_count(self):
self.args['actionfile']
],
)
self.assertEqual(-1, _.exit_code)
self.assertNotEqual(0, _.exit_code)
def test_extra_option(self):
self.create_index('foo')
self.write_config(
Expand All @@ -67,7 +67,7 @@ def test_extra_option(self):
self.args['actionfile']
],
)
self.assertEqual(-1, _.exit_code)
self.assertNotEqual(0, _.exit_code)

class TestCLIReplicas(CuratorTestCase):
def test_increase_count(self):
Expand Down
4 changes: 2 additions & 2 deletions test/integration/test_rollover.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ def test_conditions_one_empty_one_true(self):
],
)
self.assertEqual(expected, self.client.indices.get_alias(name=alias))
self.assertEqual(-1, _.exit_code)
self.assertNotEqual(0, _.exit_code)
def test_bad_settings(self):
oldindex = 'rolltome-000001'
alias = 'delamitri'
Expand Down Expand Up @@ -254,7 +254,7 @@ def test_extra_option(self):
],
)
self.assertEqual([], curator.get_indices(self.client))
self.assertEqual(-1, _.exit_code)
self.assertNotEqual(0, _.exit_code)
def test_max_age_with_new_name(self):
oldindex = 'rolltome-000001'
newindex = 'crazy_test'
Expand Down
4 changes: 2 additions & 2 deletions test/integration/test_snapshot.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def test_no_repository(self):
self.args['actionfile']
],
)
self.assertEqual(-1, _.exit_code)
self.assertNotEqual(0, _.exit_code)
def test_extra_option(self):
self.create_indices(5)
self.write_config(
Expand All @@ -131,7 +131,7 @@ def test_extra_option(self):
self.args['actionfile']
],
)
self.assertEqual(-1, _.exit_code)
self.assertNotEqual(0, _.exit_code)

class TestCLISnapshot(CuratorTestCase):
def test_snapshot(self):
Expand Down

0 comments on commit 78508a1

Please sign in to comment.