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

Talos Provider: translation to Python produces incompatible types #3812

Open
danielBreitlauch opened this issue Jan 27, 2025 · 0 comments
Open

Comments

@danielBreitlauch
Copy link
Contributor

danielBreitlauch commented Jan 27, 2025

I have a CDKTF python project and use

"terraformProviders": [
      "hashicorp/aws@~>5.60.0",
      "siderolabs/talos@~> 0.7.1"
  ],

Talos Terraform Provider example from the docs:

resource "talos_machine_secrets" "this" {}

data "talos_machine_configuration" "this" {
  cluster_name     = "example-cluster"
  machine_type     = "controlplane"
  cluster_endpoint = "https://cluster.local:6443"
  machine_secrets  = talos_machine_secrets.this.machine_secrets
}

I imported the provider with cdktf get and replicated the example:

from cdktfimports.talos.machine_secrets import MachineSecrets
from cdktfimports.talos.data_talos_machine_configuration import DataTalosMachineConfiguration

        talos_machine_secrets = MachineSecrets(self, "machine_secrets")

        DataTalosMachineConfiguration(
            self,"control_plane_config",
            cluster_name="example-cluster",
            machine_type="controlplane",
            cluster_endpoint = "https://cluster.local:6443",
            machine_secrets=talos_machine_secrets.machine_secrets,
        )

And running this generates this TypeError:

        DataTalosMachineConfiguration(
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "virtualenvs/CDKTF-lG0LMH7y/lib/python3.12/site-packages/jsii/_runtime.py", line 118, in __call__
        inst = super(JSIIMeta, cast(JSIIMeta, cls)).__call__(*args, **kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "cdktfimports/cdktfimports/talos/data_talos_machine_configuration/__init__.py", line 81, in __init__
        config = DataTalosMachineConfigurationConfig(
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "cdktfimports/cdktfimports/talos/data_talos_machine_configuration/__init__.py", line 427, in __init__
        check_type(argname="argument machine_secrets", value=machine_secrets, expected_type=type_hints["machine_secrets"])
      File "virtualenvs/CDKTF-lG0LMH7y/lib/python3.12/site-packages/typeguard/__init__.py", line 757, in check_type
        checker_func(argname, value, expected_type, memo)
      File "virtualenvs/CDKTF-lG0LMH7y/lib/python3.12/site-packages/typeguard/__init__.py", line 558, in check_union
        raise TypeError('type of {} must be one of ({}); got {} instead'.
    TypeError: type of argument machine_secrets must be one of (cdktfimports.talos.data_talos_machine_configuration.DataTalosMachineConfigurationMachineSecrets, Dict[str, Any]); got cdktfimports.talos.machine_secrets.MachineSecretsMachineSecretsOutputReference instead

The source of the DataTalosMachineConfiguration init parameter:

machine_secrets: typing.Union["DataTalosMachineConfigurationMachineSecrets", typing.Dict[builtins.str, typing.Any]],

The member function of the MachineSecrets class:

@builtins.property
    @jsii.member(jsii_name="machineSecrets")
    def machine_secrets(self) -> "MachineSecretsMachineSecretsOutputReference":
        return typing.cast("MachineSecretsMachineSecretsOutputReference", jsii.get(self, "machineSecrets"))

Not sure how these types get generated but seem to be incompatible.
Any idea how this can be fixed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant