forked from Fediversity/Fediversity
Seperate deployment from form validation
This commit is contained in:
parent
d5fdc35e75
commit
df833063e2
1 changed files with 38 additions and 33 deletions
|
@ -150,37 +150,42 @@ class DeploymentStatus(LoginRequiredMixin, FormView):
|
|||
|
||||
# Check for deploy button
|
||||
if "deploy" in self.request.POST.keys():
|
||||
submission = obj.parsed_value.model_dump_json()
|
||||
# FIXME: let the user specify these from the form (#190)
|
||||
dummy_user = {
|
||||
"initialUser": {
|
||||
"displayName": "Testy McTestface",
|
||||
"username": "test",
|
||||
"password": "testtest",
|
||||
"email": "test@test.com",
|
||||
},
|
||||
}
|
||||
# serialize back and forth now we still need to manually inject the dummy user
|
||||
deployment = json.dumps(dummy_user | json.loads(submission))
|
||||
env = {
|
||||
"PATH": settings.nix_bin_dir,
|
||||
# pass in form info to our deployment
|
||||
"DEPLOYMENT": deployment,
|
||||
}
|
||||
cmd = [
|
||||
"nix",
|
||||
"develop",
|
||||
"--extra-experimental-features",
|
||||
"configurable-impure-env",
|
||||
"--command",
|
||||
"nixops4",
|
||||
"apply",
|
||||
"test",
|
||||
]
|
||||
subprocess.run(
|
||||
cmd,
|
||||
cwd=settings.repo_dir,
|
||||
env=env,
|
||||
)
|
||||
self.deployment(obj)
|
||||
|
||||
return super().form_valid(form)
|
||||
return super().form_valid(form)
|
||||
|
||||
def deployment(self, obj):
|
||||
submission = obj.parsed_value.model_dump_json()
|
||||
# FIXME: let the user specify these from the form (#190)
|
||||
dummy_user = {
|
||||
"initialUser": {
|
||||
"displayName": "Testy McTestface",
|
||||
"username": "test",
|
||||
"password": "testtest",
|
||||
"email": "test@test.com",
|
||||
},
|
||||
}
|
||||
# serialize back and forth now we still need to manually inject the dummy user
|
||||
deployment = json.dumps(dummy_user | json.loads(submission))
|
||||
env = {
|
||||
"PATH": settings.nix_bin_dir,
|
||||
# pass in form info to our deployment
|
||||
"DEPLOYMENT": deployment,
|
||||
}
|
||||
cmd = [
|
||||
"nix",
|
||||
"develop",
|
||||
"--extra-experimental-features",
|
||||
"configurable-impure-env",
|
||||
"--command",
|
||||
"nixops4",
|
||||
"apply",
|
||||
"test",
|
||||
]
|
||||
result = subprocess.run(
|
||||
cmd,
|
||||
cwd=settings.repo_dir,
|
||||
env=env,
|
||||
)
|
||||
print(result)
|
||||
return result
|
Loading…
Add table
Reference in a new issue