Skip to content

Commit

Permalink
Merge branch 'develop' into pydantic2
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam-D-Lewis authored Apr 10, 2024
2 parents c4b8c6e + e743bad commit 89e73aa
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 18 deletions.
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,13 @@ repos:

# python
- repo: https://github.com/psf/black
rev: 24.1.1
rev: 24.3.0
hooks:
- id: black
args: ["--line-length=88", "--exclude=/src/_nebari/template/"]

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.2.0
rev: v0.3.5
hooks:
- id: ruff
args: ["--fix"]
Expand All @@ -73,7 +73,7 @@ repos:

# terraform
- repo: https://github.com/antonbabenko/pre-commit-terraform
rev: v1.86.0
rev: v1.88.4
hooks:
- id: terraform_fmt
args:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,28 @@ resource "kubernetes_manifest" "jupyterhub" {
port = 80
}
]
middlewares = [
{
name = kubernetes_manifest.jupyterhub-proxy-add-slash.manifest.metadata.name
namespace = var.namespace
}
]
},
{
kind = "Rule"
match = "Host(`${var.external-url}`) && (PathPrefix(`/home`) || PathPrefix(`/token`) || PathPrefix(`/admin`))"
middlewares = [
{
name = kubernetes_manifest.jupyterhub-middleware-addprefix.manifest.metadata.name
namespace = var.namespace
}
]
services = [
{
name = "proxy-public"
port = 80
}
]
}
]
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
resource "kubernetes_manifest" "jupyterhub-middleware-addprefix" {
manifest = {
apiVersion = "traefik.containo.us/v1alpha1"
kind = "Middleware"
metadata = {
name = "nebari-jupyterhub-add-prefix"
namespace = var.namespace
}
spec = {
addPrefix = {
prefix = "/hub"
}
}
}
}

resource "kubernetes_manifest" "jupyterhub-proxy-add-slash" {
manifest = {
apiVersion = "traefik.containo.us/v1alpha1"
kind = "Middleware"
metadata = {
name = "nebari-jupyterhub-proxy-add-slash"
namespace = var.namespace
}
spec = {
redirectRegex = {
regex = "^https://${var.external-url}/user/([^/]+)/proxy/(\\d+)$"
replacement = "https://${var.external-url}/user/$${1}/proxy/$${2}/"
permanent = true
}
}
}
}
15 changes: 13 additions & 2 deletions src/_nebari/subcommands/init.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,15 @@

LATEST = "latest"

CLOUD_PROVIDER_FULL_NAME = {
"Local": ProviderEnum.local.name,
"Existing": ProviderEnum.existing.name,
"Digital Ocean": ProviderEnum.do.name,
"Amazon Web Services": ProviderEnum.aws.name,
"Google Cloud Platform": ProviderEnum.gcp.name,
"Microsoft Azure": ProviderEnum.azure.name,
}


class GitRepoEnum(str, enum.Enum):
github = "github.com"
Expand Down Expand Up @@ -647,12 +656,14 @@ def guided_init_wizard(ctx: typer.Context, guided_init: str):
)
)
# try:
inputs.cloud_provider = questionary.select(
cloud_provider: str = questionary.select(
"Where would you like to deploy your Nebari cluster?",
choices=enum_to_list(ProviderEnum),
choices=CLOUD_PROVIDER_FULL_NAME.keys(),
qmark=qmark,
).unsafe_ask()

inputs.cloud_provider = CLOUD_PROVIDER_FULL_NAME.get(cloud_provider)

if not disable_checks:
check_cloud_provider_creds(
cloud_provider=inputs.cloud_provider,
Expand Down
19 changes: 6 additions & 13 deletions tests/tests_unit/test_render.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import os

from _nebari.stages.bootstrap import CiEnum
from nebari import schema
from nebari.plugins import nebari_plugin_manager


Expand All @@ -22,18 +21,12 @@ def test_render_config(nebari_render):
"03-kubernetes-initialize",
}.issubset(os.listdir(output_directory / "stages"))

if config.provider == schema.ProviderEnum.do:
assert (output_directory / "stages" / "01-terraform-state/do").is_dir()
assert (output_directory / "stages" / "02-infrastructure/do").is_dir()
elif config.provider == schema.ProviderEnum.aws:
assert (output_directory / "stages" / "01-terraform-state/aws").is_dir()
assert (output_directory / "stages" / "02-infrastructure/aws").is_dir()
elif config.provider == schema.ProviderEnum.gcp:
assert (output_directory / "stages" / "01-terraform-state/gcp").is_dir()
assert (output_directory / "stages" / "02-infrastructure/gcp").is_dir()
elif config.provider == schema.ProviderEnum.azure:
assert (output_directory / "stages" / "01-terraform-state/azure").is_dir()
assert (output_directory / "stages" / "02-infrastructure/azure").is_dir()
assert (
output_directory / "stages" / f"01-terraform-state/{config.provider.value}"
).is_dir()
assert (
output_directory / "stages" / f"02-infrastructure/{config.provider.value}"
).is_dir()

if config.ci_cd.type == CiEnum.github_actions:
assert (output_directory / ".github/workflows/").is_dir()
Expand Down

0 comments on commit 89e73aa

Please sign in to comment.