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

kapitan lint incorrectly reports no usage for classes with variables #998

Open
gburiola opened this issue May 1, 2023 · 1 comment
Open

Comments

@gburiola
Copy link
Contributor

gburiola commented May 1, 2023

Reclass allows using references in class names (docs)

This works fine when expanding the inventory with kapitan inventory.

However, when you run kapitan lint, it fails to identify that a given classes is being used through a reference.

Example inventory

./classes/common.yaml
parameters:
  env: prod

--------------------

./classes/app/init.yaml
classes:
  - app.${env}

--------------------

./classes/app/prod.yaml
parameters:
  myapp:
   replicas: 2

--------------------

./targets/prod-target1.yaml
classes:
  - common
  - app

parameters:

kapitan inventory

$ kapitan inventory
__reclass__:
  timestamp: Mon May  1 09:12:45 2023
applications: {}
classes:
  app:
    - prod-target1
  app.${env}:
    - prod-target1
  common:
    - prod-target1
nodes:
  prod-target1:
    __reclass__:
      environment: base
      name: prod-target1
      node: prod-target1
      timestamp: Mon May  1 09:12:45 2023
      uri: yaml_fs:///src/inventory/targets/prod-target1.yaml
    applications: []
    classes:
      - app.${env}
      - common
      - app
    environment: base
    exports: {}
    parameters:
      _reclass_:
        environment: base
        name:
          full: prod-target1
          parts:
            - prod-target1
          path: prod-target1
          short: prod-target1
      env: prod
      myapp:
        replicas: 2

kapitan lint

incorrectly reports that class app.prod is not used.
it's used, but using a variable reference

$ kapitan lint

Running yamllint on all inventory files...

.yamllint not found. Using default values

Checking for orphan classes in inventory...

No usage found for the following 1 classes:
{'app.prod'}
@gburiola gburiola added the bug label May 1, 2023
@github-actions
Copy link

github-actions bot commented Oct 2, 2023

This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this will be closed in 7 days.

@github-actions github-actions bot added the Stale label Oct 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant