Skip to content

flux-local diff fails if spec.template exists in manifest #986

@bolsblue

Description

@bolsblue

When running flux-local diff (ks or hr), it fails with a traceback when a manifest contains a spec.template field.
For example:

apiVersion: postgresql.cnpg.io/v1
kind: Database
metadata:
  name: paperless
  namespace: postgres
spec:
  name: paperless
  owner: paperless
  cluster:
    name: pg
  template: template0
  encoding: UTF8
  localeCollate: en_US.UTF-8
  localeCType: en_US.UTF-8
$ flux-local diff ks -A  
Traceback (most recent call last):
  File "/Users/mbg/.local/bin/flux-local", line 10, in <module>
    sys.exit(main())
             ~~~~^^
  File "/Users/mbg/.local/share/uv/tools/flux-local/lib/python3.13/site-packages/flux_local/tool/flux_local.py", line 64, in main
    asyncio.get_event_loop().run_until_complete(action.run(**vars(args)))
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/[email protected]/3.13.5/Frameworks/Python.framework/Versions/3.13/lib/python3.13/asyncio/base_events.py", line 725, in run_until_complete
    return future.result()
           ~~~~~~~~~~~~~^^
  File "/Users/mbg/.local/share/uv/tools/flux-local/lib/python3.13/site-packages/flux_local/tool/diff.py", line 147, in run
    await git_repo.build_manifest(
        selector=query, options=selector.options(**kwargs)
    )
  File "/Users/mbg/.local/share/uv/tools/flux-local/lib/python3.13/site-packages/flux_local/git_repo.py", line 826, in build_manifest
    await asyncio.gather(*kustomization_tasks)
  File "/Users/mbg/.local/share/uv/tools/flux-local/lib/python3.13/site-packages/flux_local/git_repo.py", line 811, in update_kustomization
    await asyncio.gather(*build_tasks)
  File "/Users/mbg/.local/share/uv/tools/flux-local/lib/python3.13/site-packages/flux_local/git_repo.py", line 643, in build_kustomization
    await kustomization_selector.visitor.func(
    ...<3 lines>...
    )
  File "/Users/mbg/.local/share/uv/tools/flux-local/lib/python3.13/site-packages/flux_local/visitor.py", line 195, in call_async
    strip_resource_attributes(resource, self.strip_attributes)
    ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/mbg/.local/share/uv/tools/flux-local/lib/python3.13/site-packages/flux_local/manifest.py", line 1056, in strip_resource_attributes
    and (meta := templ.get("metadata"))
                 ^^^^^^^^^
AttributeError: 'str' object has no attribute 'get'

Removing the template field fixes the problem.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions