-
-
Notifications
You must be signed in to change notification settings - Fork 363
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add deploy without creating a state file
- Loading branch information
1 parent
880dd55
commit 02001ca
Showing
4 changed files
with
82 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
from dataclasses import dataclass | ||
import subprocess | ||
import typing | ||
import json | ||
|
||
|
||
@dataclass | ||
class NetworkEval: | ||
|
||
description: str = "Unnamed NixOps network" | ||
enableRollback: bool = False | ||
enableState: bool = True | ||
|
||
|
||
def _eval_attr( | ||
attr, nix_exprs: typing.List[str] | ||
) -> typing.Dict[typing.Any, typing.Any]: | ||
p = subprocess.run( | ||
[ | ||
"nix-instantiate", | ||
"--eval-only", | ||
"--json", | ||
"--strict", | ||
# Arg | ||
"--arg", | ||
"checkConfigurationOptions", | ||
"false", | ||
# Attr | ||
"-A", | ||
attr, | ||
] | ||
+ nix_exprs, | ||
stdout=subprocess.PIPE, | ||
stderr=subprocess.PIPE, | ||
) | ||
if p.returncode != 0: | ||
raise RuntimeError(p.stderr.decode()) | ||
|
||
return json.loads(p.stdout) | ||
|
||
|
||
def eval_network(nix_exprs: typing.List[str]) -> NetworkEval: | ||
result = _eval_attr("network", nix_exprs) | ||
return NetworkEval(**result) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters