Module for generating state file.
generate(state_name=None, folder_path=None)
Generates a new statefile.
Source code in dapla_team_cli/pr/ready/generate_state.py
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48 | def generate(state_name: Optional[str] = None, folder_path: Optional[Path] = None) -> None:
"""Generates a new statefile."""
result = subprocess.run(
["gcloud", "config", "list", "account", "--format", "value(core.account)"],
stdout=subprocess.PIPE,
check=True,
) # noqa
# Decode the output from bytes to a string
run_invoker = result.stdout.decode().strip().replace("@ssb.no", "")
if not state_name:
run_name_prompt = questionary.text(
f"What do you want to call this run? It will be called 'batch-{run_invoker}-[your-input]. Run name:'"
).ask()
state_name = f"batch-{run_invoker}-{run_name_prompt}"
if folder_path is None:
folder_path = questionary.path(
"What's the path to the root folder of the repos to be updated?",
only_directories=True,
).ask()
state: State = _generate_state_data_from_path(folder_path, state_name)
state_object_handler.set_state(state)
print(f"\n[green]✅ state file {state_name} created and uploaded to {STATE_BUCKET_NAME_URI}")
|