forked from Fediversity/Fediversity
set de deploy routine back to before merge conflicts
This commit is contained in:
parent
92016a74c0
commit
dfcb18d7e7
1 changed files with 18 additions and 16 deletions
|
@ -90,38 +90,40 @@ class ConfigurationForm(LoginRequiredMixin, FormView):
|
|||
obj.value = form.to_python().model_dump_json()
|
||||
obj.save()
|
||||
|
||||
# Check for deploy button
|
||||
if "deploy" in self.request.POST.keys():
|
||||
#threading.Thread(target=self.run_deployment, args=(obj,)).start()
|
||||
print("DEPLOYING:")
|
||||
print(os.getenv("REPO_DIR"))
|
||||
print(os.getenv("NIX_DIR"))
|
||||
submission = obj.parsed_value.model_dump_json()
|
||||
deployment = json.dumps(json.loads(submission) | {
|
||||
"initialUser": {
|
||||
# FIXME: let the user specify these from the form (#190)
|
||||
dummy_user = {
|
||||
"initialUser": {
|
||||
"displayName": "Testy McTestface",
|
||||
"username": "test",
|
||||
"password": "testtest",
|
||||
"email": "test@test.com",
|
||||
},
|
||||
})
|
||||
env = {
|
||||
"DEPLOYMENT": deployment,
|
||||
"PATH": f"{os.getenv("NIX_DIR")}/bin/",
|
||||
},
|
||||
}
|
||||
# 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,
|
||||
}
|
||||
print(f"env: {env}")
|
||||
print(f"Path: {os.getcwd()}/..")
|
||||
cmd = [
|
||||
"nix",
|
||||
"develop",
|
||||
# workaround to pass in info to nixops4 thru env vars, tho impure :(
|
||||
"--extra-experimental-features",
|
||||
"configurable-impure-env",
|
||||
"--command",
|
||||
"nixops4",
|
||||
"--show-trace",
|
||||
"--verbose",
|
||||
"apply",
|
||||
"test",
|
||||
]
|
||||
subprocess.run(cmd, cwd=os.getenv("REPO_DIR") or f"{os.getcwd()}/..", env=env)
|
||||
subprocess.run(
|
||||
cmd,
|
||||
cwd=settings.repo_dir,
|
||||
env=env,
|
||||
)
|
||||
|
||||
return super().form_valid(form)
|
||||
|
|
Loading…
Add table
Reference in a new issue