Skip to content

Import generated directory structure invalid for python import with dashes #274

@gabe-l-hart

Description

@gabe-l-hart

Description of the bug:

When running cdk8s import against a CRD whose custom resource group name contains dash characters (-), the resulting directory structure also contains dashes in the directory names. For a python app, this is invalid for import, making the resulting package unreachable from within the python code.

Reproduction Steps:

  1. In the crd example, update the version.yaml file so that the group is sample-controller instead of samplecontroller

  2. Run cdk8s import version.yaml

  3. tree imports

    imports/
    └── sample-controller
        └── k8s
            └── io
                └── foo
                    ├── __init__.py
                    ├── _jsii
                    │   ├── __init__.py
                    │   └── generated@0.0.0.jsii.tgz
                    └── py.typed
    
    5 directories, 4 files
    
  4. python -c 'from imports.sample-controller.k8s.io import foo'

Error Log:

  File "<string>", line 1
    from imports.sample-controller.k8s.io import foo
                       ^
SyntaxError: invalid syntax

Environment:

  • Framework Version:
0.25.0
  • OS: MacOS

Other:

I'm fairly certain I have a fix, but I haven't gotten the test env set up and have been distracted with other items this morning. I think that this section needs to do a replace of - with _. I'll keep this ticket up to date with anything else I find while testing.


This is 🐛 Bug Report

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingeffort/small1 day tops

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions