NixOS / nixops

NixOps is a tool for deploying to NixOS machines in a network or cloud.
https://nixos.org/nixops
GNU Lesser General Public License v3.0
1.86k stars 365 forks source link

Fix SSHKeyPairDefinition #1536

Closed doshitan closed 1 year ago

doshitan commented 2 years ago

The base ResourceDefinition class requires the config property's type annotation to not be a string (added https://github.com/NixOS/nixops/commit/cd9319be1ccceb80bd70faa6157774b600b51ef3 / https://github.com/NixOS/nixops/commit/a70af27155717e9e437fe4facb9526ffc9ce5c35), but the ssh_keypair.py module activates postponed annotations via the from __future__ import annotations syntax (added https://github.com/NixOS/nixops/commit/e48422a9b0d2f4db38af7db7edc7c13f799a656b), which turns all type annotations in the module into strings[1], breaking the SSHKeyPairDefinition class when initialized.

Thus any defined resources.sshKeyPairs break nixops commands, causing failures with the message:

TypeError: <class 'nixops.resources.ssh_keypair.SSHKeyPairDefinition'>.config's type annotation is not allowed to be a string, see: https://nixops.readthedocs.io/en/latest/plugins/authoring.html

A number of possible workarounds for this, but the simplest would seem to just not activate PEP 563-style postponed annotations in ssh_keypair.py.

[1] https://peps.python.org/pep-0563/

roberth commented 1 year ago

bors r+

bors[bot] commented 1 year ago

This PR was included in a batch that successfully built, but then failed to merge into master (it was a non-fast-forward update). It will be automatically retried.

bors[bot] commented 1 year ago

Build succeeded: