Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added exclude commands feature #27

Merged
merged 3 commits into from
Jul 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions RAMP/disposableredis/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,9 @@ def __enter__(self):
args,
#cwd=os.getcwd(),
stdin=subprocess.PIPE,
stdout=sys.stdout,
env=os.environ.copy()
stdout=open(os.devnull, 'w')
# stdout=sys.stdout,
# env=os.environ.copy()
)

while True:
Expand Down
4 changes: 3 additions & 1 deletion RAMP/module_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
MODULE_VERSION = 1
MODULE_SEMANTIC_VERSION = '0.0.1'
MODULE_COMMANDS = []
EXCLUDE_COMMANDS = []
MODULE_CAPABILITIES = []
COMMAND_LINE_ARGS = ""
MIN_REDIS_VERSION = "4.0"
Expand Down Expand Up @@ -58,6 +59,7 @@ def create_default_metadata(module_path):
"sha256": sha256_checksum(module_path),
"commands": MODULE_COMMANDS,
"ramp_format_version": RAMP_FORMAT_VERSION,
"config_command": CONFIG_COMMAND
"config_command": CONFIG_COMMAND,
"exclude_commands": EXCLUDE_COMMANDS
}
return metadata
5 changes: 3 additions & 2 deletions RAMP/packer.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def archive(module_path, metadata, archive_name='module.zip'):
def package(module, output, verbose, manifest, display_name, module_name, author,
email, architecture, description, homepage, license, cmdargs,
redis_min_version, redis_pack_min_version, config_command, os, os_list, capabilities,
print_filename_only):
print_filename_only, exclude_commands):
module_path = module
metadata = set_defaults(module_path)

Expand All @@ -85,13 +85,14 @@ def package(module, output, verbose, manifest, display_name, module_name, author
metadata["min_redis_pack_version"] = redis_pack_min_version
metadata["capabilities"] = capabilities
metadata["config_command"] = config_command
metadata["exclude_commands"] = exclude_commands

# Load module into redis and discover its commands
module = discover_modules_commands(module_path, metadata["command_line_args"])
metadata["module_name"] = module.name
metadata["version"] = module.version
metadata["semantic_version"] = str(version_to_semantic_version(module.version))
metadata["commands"] = [cmd.to_dict() for cmd in module.commands]
metadata["commands"] = [cmd.to_dict() for cmd in module.commands if cmd.command_name not in metadata["exclude_commands"]]

if module_name:
metadata["module_name"] = module_name
Expand Down
5 changes: 3 additions & 2 deletions RAMP/ramp.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,15 @@ def unpack(bundle):
@click.option('--os_list', '-ol', default=module_metadata.OS_LIST, help='list of supported os')
@click.option('--capabilities', '-C', callback=comma_seperated_to_list, help='comma seperated list of module capabilities')
@click.option('--print-filename-only', '-P', is_flag=True, help="Print package path, but don't generate file")
@click.option('--exclude-commands', '-E', callback=comma_seperated_to_list, help='comma seperated list of exclude commands')
def pack(module, output, verbose, manifest, display_name, module_name, author,
email, architecture, description, homepage, license, cmdargs,
redis_min_version, redis_pack_min_version, config_command, os, os_list, capabilities,
print_filename_only):
print_filename_only, exclude_commands):
return package(module, output, verbose, manifest, display_name, module_name, author,
email, architecture, description, homepage, license, cmdargs,
redis_min_version, redis_pack_min_version, config_command, os, os_list, capabilities,
print_filename_only)
print_filename_only, exclude_commands)

if __name__ == '__main__':
ramp()
2 changes: 1 addition & 1 deletion RAMP/version.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
MAJOR_VERSION = 1
MINOR_VERSION = 6
MINOR_VERSION = 7
PATCH_VERSION = 0
VERSION = '{}.{}.{}'.format(MAJOR_VERSION, MINOR_VERSION, PATCH_VERSION)
2 changes: 2 additions & 0 deletions example.manifest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,5 @@ capabilities:
- eviction_expiry
- failover_migrate
- flash
exclude_commands:
- graph.BULK
16 changes: 5 additions & 11 deletions test.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def sha256_checksum(filename, block_size=65536):


def validate_module_commands(commands):
assert len(commands) == 4
assert len(commands) == 3

# Expected commands:
expected_command = []
Expand All @@ -37,13 +37,6 @@ def validate_module_commands(commands):
"last_key": 1,
"step": 1})

expected_command.append({"command_arity": -1,
"command_name": "graph.BULK",
"first_key": 1,
"flags": ["write","denyoom","noscript"],
"last_key": 1,
"step": 1})

expected_command.append({"command_arity": -1,
"command_name": "graph.QUERY",
"first_key": 1,
Expand All @@ -63,7 +56,7 @@ def validate_module_commands(commands):
def test_defaults():
"""Test auto generated metadata from module is as expected."""
runner = CliRunner()
result = runner.invoke(ramp.pack, [MODULE_FILE_PATH, '-o', BUNDLE_ZIP_FILE])
result = runner.invoke(ramp.pack, [MODULE_FILE_PATH, '-o', BUNDLE_ZIP_FILE, '-E', 'graph.BULK'])
assert result.exit_code == 0

metadata, _ = unpacker.unpack(BUNDLE_ZIP_FILE)
Expand Down Expand Up @@ -111,11 +104,12 @@ def test_bundle_from_cmd():
'-h', homepage, '-l', _license, '-c', command_line_args,
'-r', min_redis_version, '-R', min_redis_pack_version,
'-C', ','.join([cap['name'] for cap in MODULE_CAPABILITIES]),
'-o', BUNDLE_ZIP_FILE, '-cc', CONFIG_COMMAND]
'-o', BUNDLE_ZIP_FILE, '-cc', CONFIG_COMMAND, '-E', 'graph.bulk',
'-E', 'graph.BULK']

runner = CliRunner()
result = runner.invoke(ramp.pack, argv)

assert result.exit_code == 0
metadata, _ = unpacker.unpack(BUNDLE_ZIP_FILE)

Expand Down