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

furnace/cli.py: add command line interface to furnace #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

kocsob
Copy link
Collaborator

@kocsob kocsob commented Dec 20, 2018

No description provided.

@kocsob kocsob changed the title Add command line interface furnace/cli.py: add command line interface to furnace Dec 20, 2018
furnace/utils.py Outdated
@@ -69,10 +69,12 @@ def __init__(self, source, destination, read_only=False):
self.read_only = read_only

def get_mount_parameters(self):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is get_mount_parameters unused now? Maybe it would need to be called from mount() below?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this commit related to the CLI related PR?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm pretty sure this is because PR #5 is based on PR #4.

Copy link
Collaborator Author

@kocsob kocsob Dec 21, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is get_mount_parameters unused now?

No, it is called by the base MountContext, which uses this parameters. There is an unfortunate situation, that for the read-only bind mount requires two mount system call.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm pretty sure this is because PR #5 is based on PR #4.

That was right. I rebased this branch to the master.

Copy link
Collaborator

@badicsalex badicsalex left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only merge after #4?

if args.persistent:
run_container(args.root_dir, args.volume, args.isolate_networking, args.hostname, args.cmd)
else:
with tempfile.TemporaryDirectory(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clever.

furnace/utils.py Outdated
@@ -69,10 +69,12 @@ def __init__(self, source, destination, read_only=False):
self.read_only = read_only

def get_mount_parameters(self):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm pretty sure this is because PR #5 is based on PR #4.

furnace/cli.py Outdated
if readwrite == 'rw':
readonly = False

if destination.startswith('/'):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would "cast" destination to a Path object sooner, so destination.is_absolute() could be called here, which is more meaningful.

furnace/cli.py Outdated
return parser.parse_args(argv[1:])


def create_bind_mount_list(volumes):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A unit test would be nice for this function.

furnace/cli.py Outdated
return parser.parse_args(argv[1:])


def create_bind_mount_list(volumes):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be more user-friendly if this method would raise a meaningful error message in case of invalid values, and should be more strict if
E.g. it silently ignores "/host/path:/container/path:asdf" and makes the mount read-only, but raises ValueError for "/host/path" It should say something specific about the problem with this parameter and exit non-zero without a traceback.

furnace/cli.py Outdated
help="this command that will be run. If it is empty, than furnace will give an interactive shell"
)
parser.add_argument(
'--version',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-V is common for linux tools for version alias

furnace/cli.py Outdated
parser.add_argument(
'cmd',
nargs='*',
help="this command that will be run. If it is empty, than furnace will give an interactive shell"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would reprase this a bit: "the command that will be run. If empty, furnace will drop into an interactive shell"

furnace/cli.py Outdated
version='%(prog)s {version}'.format(version=version.get_version()),
)
parser.add_argument(
'--hostname',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe -H for alias?

furnace/cli.py Outdated
parser.add_argument(
'-v', '--volume',
action='append',
metavar='src:dst:rw',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would add the dest parameter here (e.g. volumes), because it's confusing later that args.volume contains a list, not a single value.

@kocsob kocsob force-pushed the add-cli-interface branch 3 times, most recently from 72ff252 to da9c0d8 Compare January 24, 2019 10:55
@kocsob kocsob force-pushed the add-cli-interface branch from da9c0d8 to ab71880 Compare February 6, 2020 15:31
@lgtm-com
Copy link

lgtm-com bot commented Feb 6, 2020

This pull request introduces 1 alert when merging ab71880 into 309bd07 - view on LGTM.com

new alerts:

  • 1 for Use of the return value of a procedure

@kocsob kocsob force-pushed the add-cli-interface branch from ab71880 to 4369c3b Compare April 14, 2020 19:55
@kocsob kocsob requested review from badicsalex and kissgyorgy April 14, 2020 20:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants