-
-
Notifications
You must be signed in to change notification settings - Fork 363
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add nixops eval subcommand #1319
base: master
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -527,6 +527,16 @@ | |||||
help="include the physical specification in the evaluation", | ||||||
) | ||||||
|
||||||
subparser = add_subparser( | ||||||
subparsers, "eval", help="eval the given file is nix code in the network expression" | ||||||
) | ||||||
subparser.set_defaults(op=op_eval) | ||||||
subparser.add_argument("code", metavar="CODE", help="code") | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
subparser.add_argument( | ||||||
"--json", action="store_true", help="print the option value in JSON format" | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
what does it print without |
||||||
) | ||||||
subparser.add_argument("--strict", action="store_true", help="enable strict evaluation") | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't have a specific suggestion, but we might want to crib what the nix-instantiate manual says:
I wonder why someone wouldn't use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, The use-case here was if you wanted to evaluate something but finely control the level of strictness and output Nix instead of JSON. For that you'd want lazy evaluation of functions, which is impossible if Given that this is supposed to be used by other tooling (that's why I don't pass a plain string but a file instead), it shouldn't be too confusing or hard to configure it for the specific usage. |
||||||
|
||||||
subparser = add_subparser( | ||||||
subparsers, | ||||||
"list-generations", | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -893,6 +893,14 @@ def op_show_option(args): | |
) | ||
|
||
|
||
def op_eval(args): | ||
with deployment(args) as depl: | ||
depl.evaluate() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not necessarily to be fixed here, but it would be nice to think of a way for the deployment API to not require being careful about calling |
||
sys.stdout.write( | ||
depl.evaluate_code(args.code, json=args.json, strict=args.strict) | ||
) | ||
|
||
|
||
@contextlib.contextmanager | ||
def deployment_with_rollback(args): | ||
with deployment(args) as depl: | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
my proposed wording isn't quite right, but maybe something like this?