Merge "Remove duplicate code"

This commit is contained in:
Zuul 2023-09-05 15:35:26 +00:00 committed by Gerrit Code Review
commit dce174f305
2 changed files with 2 additions and 12 deletions

View File

@ -23,10 +23,6 @@ from apt_ostree.utils import run_command
@pass_state_context @pass_state_context
@compose_options @compose_options
def create(state, repo, base, branch, edit): def create(state, repo, base, branch, edit):
if state.repo is None:
click.secho("You did not supply an ostree repository", fg="red")
sys.exit(1)
if not state.repo.exists(): if not state.repo.exists():
click.secho(f"Creating ostree repository: {state.repo}") click.secho(f"Creating ostree repository: {state.repo}")
run_command(["ostree", "init", f"--repo={state.repo}", run_command(["ostree", "init", f"--repo={state.repo}",
@ -34,19 +30,12 @@ def create(state, repo, base, branch, edit):
else: else:
click.secho(f"Found ostree repository: {state.repo}") click.secho(f"Found ostree repository: {state.repo}")
if state.branch is None:
click.secho("You did not supply an ostree branch.", fg="red")
sys.exit(1)
click.secho(f"Found ostree branch: {state.branch}") click.secho(f"Found ostree branch: {state.branch}")
if state.base is None:
click.secho("You did not supply a configuration directory.", fg="red")
sys.exit(1)
if not state.base.exists(): if not state.base.exists():
click.secho("Configuration directory does not exist.", fg="red") click.secho("Configuration directory does not exist.", fg="red")
sys.exit(1) sys.exit(1)
else: click.secho(f"Found configuration directory: {state.base}")
click.secho(f"Found configuration directory: {state.base}")
config = state.base.joinpath("bootstrap.yaml") config = state.base.joinpath("bootstrap.yaml")
if not config.exists(): if not config.exists():

View File

@ -97,6 +97,7 @@ def branch_option(f):
return click.argument( return click.argument(
"branch", "branch",
nargs=1, nargs=1,
required=True,
callback=callback callback=callback
)(f) )(f)