Skip to content
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

script_defs: open state files and deployments with a context manager #1263

Merged
merged 43 commits into from Mar 26, 2020

Conversation

@grahamc
Copy link
Member

@grahamc grahamc commented Mar 24, 2020

Use context managers to open and manage statefiles and deployments. This lets us do some fancier things with those state files. For example, storing the state other places.

This change is almost entirely whitespace. Check it out without whitespace in the diff: https://github.com/NixOS/nixops/pull/1263/files?w=1

Also consider looking commit-by-commit, which makes it easier, I think, to review.

Here is a diff adding state backends using this: legacy, in-memory, and s3: https://github.com/grahamc/nixops/compare/context-manager...grahamc:context-manager-states-rebase?expand=1

@grahamc grahamc force-pushed the grahamc:context-manager branch 4 times, most recently from 2841369 to 0c7c2a6 Mar 24, 2020
nixops/script_defs.py Outdated Show resolved Hide resolved
@grahamc grahamc force-pushed the grahamc:context-manager branch from 0c7c2a6 to f37541a Mar 25, 2020
grahamc added 23 commits Mar 24, 2020
grahamc added 20 commits Mar 23, 2020
@grahamc grahamc force-pushed the grahamc:context-manager branch from f37541a to 4d014a9 Mar 26, 2020
state = nixops.statefile.StateFile(args.state_file)
try:
yield state
finally:

This comment has been minimized.

@grahamc

grahamc Mar 26, 2020
Author Member

This used to catch the exception and no longer tries to.

"ssh://{}".format(m.get_ssh_name()),
args.storepath,
],
m.logger,

This comment has been minimized.

@domenkozar domenkozar merged commit f2804bc into NixOS:master Mar 26, 2020
6 checks passed
6 checks passed
parsing
Details
build
Details
black
Details
mypy
Details
mypy-ratchet
Details
coverage
Details
@grahamc grahamc deleted the grahamc:context-manager branch Mar 26, 2020
@grahamc grahamc added this to the 2.0 milestone Apr 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants
You can’t perform that action at this time.