Skip to content

Commit

Permalink
Fix: Adjust to recent Radix changes (#670)
Browse files Browse the repository at this point in the history
  • Loading branch information
anders-kiaer authored Jun 23, 2023
1 parent 591c008 commit 6a79054
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 9 deletions.
7 changes: 7 additions & 0 deletions webviz_config/_deployment/github_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,13 @@ def create_github_repository(github_slug: str, directory: Path) -> Path:
cwd=directory,
)

subprocess.run(
["gh", "repo", "clone", github_slug],
capture_output=True,
check=True,
cwd=directory,
)

return directory / github_slug.split("/")[1]


Expand Down
11 changes: 8 additions & 3 deletions webviz_config/_deployment/radix.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ def radix_initial_deployment(github_slug: str, build_directory: pathlib.Path) ->
repository_url=repository_url,
shared_secret=webhook_secret,
context=radix_config["context"],
ad_group=radix_config["ad_group"],
)
progress_bar.update()

Expand All @@ -182,9 +183,13 @@ def radix_initial_deployment(github_slug: str, build_directory: pathlib.Path) ->
progress_bar.update()

progress_bar.write("✓ Adding Radix deploy key to GitHub repository.")
github_cli.add_deploy_key(
directory=cloned_path, title="Radix deploy key", key=public_key
)

# gh api currently fails - add manually:
# https://github.com/equinor/radix-cli/issues/48
progress_bar.write(f"Add following deploy key: {public_key}")
# github_cli.add_deploy_key(
# directory=cloned_path, title="Radix deploy key", key=public_key
# )
progress_bar.update()

# Wait for application to be reconciled
Expand Down
16 changes: 10 additions & 6 deletions webviz_config/_deployment/radix_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ def create_application(
repository_url: str,
shared_secret: str,
context: str,
ad_group: str,
) -> str:
result = subprocess.run(
[
Expand All @@ -89,19 +90,22 @@ def create_application(
shared_secret,
"--context",
context,
"--ad-groups",
ad_group,
],
capture_output=True,
check=True,
)

stderr = result.stderr.decode()
if not stderr.startswith("ssh-rsa"):
error_message = stderr
if "registerApplicationBadRequest" in stderr:
error_message += (
f"Is {repository_url} being used by another Radix application?"
)
raise RuntimeError(error_message)
pass # https://github.com/equinor/radix-cli/issues/48
# error_message = stderr
# if "registerApplicationBadRequest" in stderr:
# error_message += (
# f"Is {repository_url} being used by another Radix application?"
# )
# raise RuntimeError(error_message)

return stderr

Expand Down
7 changes: 7 additions & 0 deletions webviz_config/_deployment/radix_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ def radix_configuration() -> Dict[str, str]:
if radix_context == "playground":
radix_subdomain = "playground." + radix_subdomain

interactive_terminal.terminal_title("Radix AD group")
radix_ad_group = interactive_terminal.user_input_from_stdin(
"WEBVIZ_RADIX_AD_GROUP",
"AD group object ID",
)

interactive_terminal.terminal_title("Radix application name")
radix_application_name = interactive_terminal.user_input_optional_reuse(
"WEBVIZ_RADIX_APPLICATION",
Expand All @@ -28,4 +34,5 @@ def radix_configuration() -> Dict[str, str]:
"application_name": radix_application_name,
"app_url": f"https://{radix_application_name}.app.{radix_subdomain}",
"webhook_receiver_url": f"https://webhook.{radix_subdomain}/events/github",
"ad_group": radix_ad_group,
}

0 comments on commit 6a79054

Please sign in to comment.