-
-
Notifications
You must be signed in to change notification settings - Fork 366
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The base `ResourceDefinition` class requires the `config` property's type annotation to not be a string (added cd9319b / a70af27), but the `ssh_keypair.py` module activates postponed annotations via the `from __future__ import annotations` syntax (added e48422a), 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/
- Loading branch information
Showing
4 changed files
with
29 additions
and
6 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
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,5 @@ | ||
{ | ||
network = {}; | ||
|
||
resources.sshKeyPairs.ssh-key = {}; | ||
} |
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,20 @@ | ||
from os import path | ||
|
||
from tests.functional.generic_deployment_test import GenericDeploymentTest | ||
|
||
from nixops.evaluation import NetworkFile | ||
|
||
parent_dir = path.dirname(__file__) | ||
|
||
ssh_key_pair_spec = "%s/ssh-key-pair-resource.nix" % (parent_dir) | ||
|
||
|
||
class TestSSHKeyPairResource(GenericDeploymentTest): | ||
def setup(self): | ||
super(TestSSHKeyPairResource, self).setup() | ||
self.depl.network_expr = NetworkFile(ssh_key_pair_spec) | ||
|
||
def test_evaluate(self): | ||
self.depl.evaluate() | ||
|
||
assert "ssh-key" in self.depl.definitions |