#7417·kubevela

ConfigTemplate CRs are missing from Factory.ListTemplates, so template lists omit them

Author: briankaneCreated Sep 29, 2026Updated Sep 29, 2026

Describe the bug

A ConfigTemplate custom resource (kubevela#7211) is missing from pkg/config's Factory.ListTemplates, which lists only the legacy config-template-* ConfigMaps. Factory.LoadTemplate already reads the CR first and falls back to the ConfigMap, so a CR template can be fetched by name but never appears in a list. Consumers that offer a choice of templates therefore cannot offer CR templates: VelaUX's config page lists none, so a user cannot create a config from a template installed as a CR.

vela config-template list in its default auto mode goes the other way and lists only CRs, and it includes SourceDefinition's internal templates (source-<name>-<hash>), which are not meant for users to create configs from.

Affects KubeVela master (1.12 line) since #7211, and VelaUX, which calls Factory.ListTemplates for /api/v1/config_templates.

To Reproduce

  1. Apply a ConfigTemplate CR:
yaml
apiVersion: config.oam.dev/v1alpha1
kind: ConfigTemplate
metadata:
  name: demo-endpoint
  namespace: vela-system
spec:
  scope: system
  template: |
    metadata: name: "demo-endpoint"
    template: {
      parameter: url: string
      output: {
        apiVersion: "v1"
        kind:       "Secret"
        stringData: url: parameter.url
      }
    }
  1. It reconciles:
bash
$ kubectl -n vela-system get configtemplate demo-endpoint
NAME            SCOPE    PHASE       AGE
demo-endpoint   system   Available   5s
  1. List templates through Factory.ListTemplates (here via VelaUX, which calls it directly) and fetch the same one by name (Factory.LoadTemplate):
bash
$ curl -s -H "Authorization: Bearer $TOKEN" localhost:8000/api/v1/config_templates | jq '[.templates[].name]'
[]
$ curl -s -H "Authorization: Bearer $TOKEN" 'localhost:8000/api/v1/config_templates/demo-endpoint?namespace=vela-system' | jq .name
"demo-endpoint"
  1. The CLI lists it, along with SourceDefinition's internal templates:
bash
$ vela config-template list -n vela-system
NAME                               ALIAS            SCOPE   SENSITIVE
demo-endpoint                      Demo endpoint    system  false
source-configmap-local-7a08375a    configmap-local  system  false
source-git-file-603c7eae           git-file         system  false
...

Expected behavior

ListTemplates returns ConfigTemplate CRs as well as legacy ConfigMap templates, as LoadTemplate already reads both ("dual-read, single-write", kubevela#7308). Internal templates are not offered to users in either list.

Screenshots

N/A.

KubeVela Version

Core: master at f450c6e (built locally; `pkg/config` and the config controllers unchanged from master)
CLI: built from the same commit

Cluster information

k3d, local single-node, Kubernetes v1.35.5 (k3s).

Additional context

  • Where it appears in the code:
    • pkg/config/factory.go:440 ListTemplates lists ConfigMaps labelled config.oam.dev/catalog=velacore-config only.
    • pkg/config/factory.go:503 LoadTemplate reads the ConfigTemplate CR first, then the ConfigMap.
    • references/cli/config.go:159-175 lists CRs only in CRD mode.
    • SourceDefinition writes its templates as ConfigTemplate CRs labelled sourcedefinition.oam.dev/name (pkg/controller/core.oam.dev/v1beta1/core/sources/sourcedefinition/sourcedefinition_controller.go:51-53, 139-188).
  • Suggested fix: make ListTemplates dual-read, returning CRs and ConfigMaps with the CR winning a name clash (matching LoadTemplate), and leaving out templates labelled sourcedefinition.oam.dev/name. A CR's scope is system or namespace; callers filtering on a legacy scope such as VelaUX's project would need that mapping documented, namespace in a project's namespace being the natural equivalent.
  • Requirements from a consumer (VelaUX): each returned template says which store it came from and, for a CR, its phase, so a UI can mark a template that is not yet Available; and ListTemplates and LoadTemplate agree on which wins when a CR and a ConfigMap share a name.
  • Related: Config CRs are likewise missing from Factory.ListConfigs (separate issue, https://github.com/kubevela/kubevela/issues/7416).
  • Verified: steps 1 to 4 were run against a controller built from master on k3d, with VelaUX built against the same KubeVela commit; the outputs shown are observed (the CLI table is trimmed).