Compare commits

..

14 commits

Author SHA1 Message Date
caa497c4a2
get TF in prod to the same 'installable ... does not correspond to a Nix language value' for non-flakes
seemingly gets further when a similar command is tried from terminal.
as per https://github.com/NixOS/nix/issues/8752#issuecomment-1694714693,
this may have to do with aligning the current working directory.
2025-03-28 21:14:16 +01:00
659a3593b5
document updating TF module 2025-03-28 21:14:16 +01:00
7e24b9e478
update 2025-03-28 21:14:16 +01:00
7048058d6b
specify XDG_CACHE_HOME, workaround to error writing to /var/empty/.cache 2025-03-28 21:14:16 +01:00
ed63b582ed
skip tf lock in views.py over read-only nix env 2025-03-28 21:14:16 +01:00
f04e1d0f40
move tf init out of python over read-only nix env 2025-03-28 21:14:16 +01:00
2365d9a044
properly pass repo dir for prod, be it with hard-coded TF init 2025-03-28 21:14:16 +01:00
ecc41a7dfd
use flake-sourced nixos-anywhere in tf, to reproduce modules for nix 2025-03-28 21:14:16 +01:00
0419ec38f5
switch launch shell to root flake's nixpkgs, see #279 2025-03-28 21:14:16 +01:00
65bba16d83
Revert "deduplicate flake inputs"
This reverts commit 95769084ce.
2025-03-28 21:14:16 +01:00
264fbf8729
make re-exports explicit again 2025-03-28 21:14:16 +01:00
65159cdc18
deduplicate flake inputs 2025-03-28 21:14:16 +01:00
6bb5768ddc
tf 2025-03-28 21:14:16 +01:00
88674c8efc Show if deployment succeeded (#283)
Show which services deployed and if so, the urls

Co-authored-by: kevin <kevin@procolix.com>
Reviewed-on: Fediversity/Fediversity#283
Reviewed-by: kiara Grouwstra <kiara@procolix.eu>
Co-authored-by: lois <lois@procolix.eu>
Co-committed-by: lois <lois@procolix.eu>
2025-03-28 13:36:02 +01:00
3 changed files with 44 additions and 13 deletions

View file

@ -9,7 +9,8 @@
hx-trigger="click" hx-trigger="click"
hx-indicator="#spinner-container" hx-indicator="#spinner-container"
hx-disabled-elt="this" hx-disabled-elt="this"
hx-swap="none" hx-target="#deployment-result"
hx-swap="innerHTML"
name="deploy"> name="deploy">
Deploy Deploy
</button> </button>
@ -19,5 +20,8 @@
<div id="spinner-container" class="htmx-indicator"> <div id="spinner-container" class="htmx-indicator">
<span class="loader"></span> <span class="loader"></span>
</div> </div>
<div id="deployment-result">
</div>
</form> </form>
{% endblock %} {% endblock %}

View file

@ -0,0 +1,13 @@
{% if deployment_status %}
<p>{{ deployment_status }}</p>
<ul>
{% for service, state in services.items %}
{% if state %}
<li>
✓ {{ service }}
</li>
{% endif %}
{% endfor %}
</ul>
{% endif %}

View file

@ -10,10 +10,11 @@ from django.contrib.auth.models import User
from django.views.generic import TemplateView, DetailView from django.views.generic import TemplateView, DetailView
from django.views.generic.edit import FormView from django.views.generic.edit import FormView
from django.shortcuts import render
from panel import models, settings from panel import models, settings
from panel import models
from panel.configuration import forms from panel.configuration import forms
class Index(TemplateView): class Index(TemplateView):
template_name = 'index.html' template_name = 'index.html'
@ -83,6 +84,7 @@ class ConfigurationForm(LoginRequiredMixin, FormView):
initial.update(self.convert_enums_to_names(config_dict)) initial.update(self.convert_enums_to_names(config_dict))
return initial return initial
class Save(ConfigurationForm): class Save(ConfigurationForm):
def form_valid(self, form): def form_valid(self, form):
obj = self.get_object() obj = self.get_object()
@ -91,6 +93,7 @@ class Save(ConfigurationForm):
return super().form_valid(form) return super().form_valid(form)
class DeploymentStatus(ConfigurationForm): class DeploymentStatus(ConfigurationForm):
def form_valid(self, form): def form_valid(self, form):
obj = self.get_object() obj = self.get_object()
@ -99,9 +102,20 @@ class DeploymentStatus(ConfigurationForm):
# Check for deploy button # Check for deploy button
if "deploy" in self.request.POST.keys(): if "deploy" in self.request.POST.keys():
self.deployment(obj) deployment_result, deployment_params = self.deployment(obj)
if deployment_result.returncode == 0:
deployment_status = "Deployment Succeeded"
else:
deployment_status = "Deployment Failed"
return super().form_valid(form) return render(self.request, "partials/deployment_result.html", {
"deployment_status": deployment_status,
"services": {
"peertube": deployment_params['peertube']['enable'],
"pixelfed": deployment_params['pixelfed']['enable'],
"mastodon": deployment_params['mastodon']['enable']
}
})
def deployment(self, obj): def deployment(self, obj):
submission = obj.parsed_value.model_dump_json() submission = obj.parsed_value.model_dump_json()
@ -115,7 +129,7 @@ class DeploymentStatus(ConfigurationForm):
}, },
} }
# serialize back and forth now we still need to manually inject the dummy user # serialize back and forth now we still need to manually inject the dummy user
deployment = dummy_user | json.loads(submission) deployment_params = dummy_user | json.loads(submission)
env = { env = {
"PATH": settings.bin_path, "PATH": settings.bin_path,
# used in nixos-anywhere for ssh-copy-id # used in nixos-anywhere for ssh-copy-id
@ -124,7 +138,7 @@ class DeploymentStatus(ConfigurationForm):
} | { } | {
# pass in form info to our deployment # pass in form info to our deployment
# FIXME: ensure sensitive info is protected # FIXME: ensure sensitive info is protected
f"TF_VAR_{k}": v if isinstance(v, str) else json.dumps(v) for k, v in deployment.items() f"TF_VAR_{k}": v if isinstance(v, str) else json.dumps(v) for k, v in deployment_params.items()
} }
cwd = f"{settings.repo_dir}/launch" cwd = f"{settings.repo_dir}/launch"
# FIXME: move init to packaging phase # FIXME: move init to packaging phase
@ -138,4 +152,4 @@ class DeploymentStatus(ConfigurationForm):
] ]
deployment_result = subprocess.run(cmd, cwd=cwd, env=env) deployment_result = subprocess.run(cmd, cwd=cwd, env=env)
print(deployment_result) print(deployment_result)
return deployment_result return deployment_result, deployment_params