Skip to content
4 changes: 2 additions & 2 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
FROM public.ecr.aws/docker/library/debian:bookworm-slim

# change this one to change EDA version
ARG EDA_VERSION=25.12.2
ARG EDA_VERSION=26.4.1

ARG EDA_PLAYGROUND_REPO=nokia-eda/playground
ARG EDA_PLAYGROUND_DIR=/home/vscode/.playground
Expand Down Expand Up @@ -73,4 +73,4 @@ COPY k9s/dracula.yaml /home/vscode/.config/k9s/skins/dracula.yaml
# edactl wrapper
COPY --chmod=755 --chown=vscode:vscode shell/edactl /usr/local/bin/edactl

RUN bash -c "/home/vscode/install-zsh-plugins.sh"
RUN bash -c "/home/vscode/install-zsh-plugins.sh"
4 changes: 2 additions & 2 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Nokia EDA in GitHub Codespaces",
"image": "ghcr.io/eda-labs/codespaces/base:25.12.2-1",
"image": "ghcr.io/eda-labs/codespaces/base:26.4.1-1",
"features": {
"ghcr.io/devcontainers/features/docker-in-docker:2": {
"version": "latest",
Expand Down Expand Up @@ -64,4 +64,4 @@
},
"privileged": true,
"remoteUser": "vscode"
}
}
47 changes: 33 additions & 14 deletions .devcontainer/overrides.mk
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
KPT_RETRY ?= 5
KPT_RECONCILE_TIMEOUT ?= 3m
KPT_LIVE_APPLY_ARGS += --reconcile-timeout=$(KPT_RECONCILE_TIMEOUT)
EDA_PORT ?= 9443

ifdef CODESPACE_EDA_VERSION
EDA_CORE_VERSION=$(CODESPACE_EDA_VERSION)
Expand Down Expand Up @@ -53,27 +54,45 @@ patch-codespaces-engineconfig: | $(YQ) $(KPT_PKG) ## Patch the EngineConfig mani
.PHONY: configure-try-eda-params
configure-try-eda-params: | $(BASE) $(BUILD) $(KPT) $(KPT_SETTERS_TRY_EDA_FILE) patch-codespaces-engineconfig ## Configure parameters specific to try-eda

.PHONY: ls-ways-to-reach-api-server
ls-ways-to-reach-api-server: | $(KUBECTL) configure-codespaces-keycloak
.PHONY: ls-ways-to-reach-api-server
ls-ways-to-reach-api-server: configure-codespaces-auth-client

.PHONY: configure-codespaces-keycloak
configure-codespaces-keycloak: | $(KUBECTL) ## Configure Keycloak frontendUrl for GitHub Codespaces
.PHONY: configure-codespaces-auth-client
configure-codespaces-auth-client: | $(KUBECTL) ## Configure Keycloak auth client redirect base for GitHub Codespaces
@if [ -n "$(CODESPACE_NAME)" ] && [ -n "$(GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN)" ]; then \
CODESPACE_URL="https://$(CODESPACE_NAME)-$(EDA_PORT).$(GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN)" ;\
KC_URL="https://eda-keycloak:9443/core/httpproxy/v1/keycloak" ;\
echo "--> INFO: Configuring Keycloak frontendUrl for Codespaces..." ;\
KC_URL="https://eda-api/core/httpproxy/v1/keycloak" ;\
echo "--> INFO: Configuring Keycloak auth client rootUrl for Codespaces..." ;\
$(KUBECTL) wait --for=condition=ready pod -l eda.nokia.com/app=keycloak -n $(EDA_CORE_NAMESPACE) --timeout=300s ;\
TOKEN=$$($(KUBECTL) exec -n $(EDA_CORE_NAMESPACE) deploy/eda-toolbox -- curl -sk -X POST \
TOKEN=$$($(KUBECTL) exec -n $(EDA_CORE_NAMESPACE) deploy/eda-toolbox -- curl -skf -X POST \
"$${KC_URL}/realms/master/protocol/openid-connect/token" \
-d "username=admin" -d "password=admin" -d "grant_type=password" -d "client_id=admin-cli" | jq -r '.access_token') ;\
$(KUBECTL) exec -n $(EDA_CORE_NAMESPACE) deploy/eda-toolbox -- curl -sk -X PUT \
"$${KC_URL}/admin/realms/eda" \
CLIENT_ID=$$($(KUBECTL) exec -n $(EDA_CORE_NAMESPACE) deploy/eda-toolbox -- curl -skf \
-H "Authorization: Bearer $${TOKEN}" \
-H "Content-Type: application/json" \
-d "{\"attributes\": {\"frontendUrl\": \"$${CODESPACE_URL}/core/httpproxy/v1/keycloak\"}}" ;\
echo "--> INFO: Keycloak frontendUrl set to: $${CODESPACE_URL}/core/httpproxy/v1/keycloak" ;\
"$${KC_URL}/admin/realms/eda/clients?clientId=auth" | jq -r '.[0].id') ;\
if [[ -z "$${CLIENT_ID}" || "$${CLIENT_ID}" == "null" ]]; then echo "[ERROR] Keycloak auth client not found" && exit 1; fi ;\
$(KUBECTL) exec -n $(EDA_CORE_NAMESPACE) deploy/eda-toolbox -- sh -c "curl -skf \
-H 'Authorization: Bearer $${TOKEN}' \
'$${KC_URL}/admin/realms/eda/clients/$${CLIENT_ID}' \
| jq '.rootUrl = \"$${CODESPACE_URL}\" | .baseUrl = \"/\" | .redirectUris = [\"/*\"] | .webOrigins = [\"+\"]' \
| curl -skf -X PUT \
'$${KC_URL}/admin/realms/eda/clients/$${CLIENT_ID}' \
-H 'Authorization: Bearer $${TOKEN}' \
-H 'Content-Type: application/json' \
--data @-" ;\
$(KUBECTL) exec -n $(EDA_CORE_NAMESPACE) deploy/eda-toolbox -- sh -c "curl -skf \
-H 'Authorization: Bearer $${TOKEN}' \
'$${KC_URL}/admin/realms/eda' \
| jq '.attributes.frontendUrl = \"$${CODESPACE_URL}/core/proxy/v1/identity\"' \
| curl -skf -X PUT \
'$${KC_URL}/admin/realms/eda' \
-H 'Authorization: Bearer $${TOKEN}' \
-H 'Content-Type: application/json' \
--data @-" ;\
echo "--> INFO: Keycloak auth client rootUrl set to: $${CODESPACE_URL}" ;\
echo "--> INFO: Keycloak realm frontendUrl set to: $${CODESPACE_URL}/core/proxy/v1/identity" ;\
else \
echo "--> INFO: Not running in Codespaces, skipping Keycloak frontendUrl configuration" ;\
echo "--> INFO: Not running in Codespaces, skipping Keycloak auth client configuration" ;\
fi

ifdef NO_TOPO
Expand All @@ -88,4 +107,4 @@ endif
start-ui-port-forward:
@{ \
echo "--> Triggering browser window open 0.0.0.0:9443" ;\
}
}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[![Codespaces][codespaces-4vcpu-svg]][codespaces-4vcpu-url]
[![Discord][discord-svg]][discord-url]
[Learn more about EDA in Codespaces](https://docs.eda.dev/25.12/getting-started/codespaces/)
[Learn more about EDA in Codespaces](https://docs.eda.dev/26.4/getting-started/try-eda/#try-nokia-eda-in-codespaces)
<!-- TODO:rdodin: change for tour of eda url for codespaces in the main readme -->

[codespaces-4vcpu-svg]: https://gitlab.com/-/project/7617705/uploads/3f69f403e1371b3b578ee930df8930e8/codespaces-btn-4vcpu-export.svg
Expand Down
Loading