Skip to content

feat(abstractions): resolve kind and apiVersion from the entity type - #1372

Merged
kimpenhaus merged 1 commit into
mainfrom
feat/abstractions-resolve-kind
Dec 4, 2026
Merged

kimpenhaus merged 1 commit into
mainfrom
feat/abstractions-resolve-kind

Conversation

@kimpenhaus

Copy link
Copy Markdown
Collaborator

Summary

Built-in types created with new (e.g. new V1Secret { Metadata = ... }) carry no kind and apiVersion. The
operator logged entity.Kind directly, so such an entity, e.g. one put into ITimedEntityQueue<V1Secret> by a
controller, showed up as null/my-secret or /my-secret in logs. This matches #989, which could not be reproduced
with an entity from a watch event, since watch events always carry kind.

  • New public API in KubeOps.Abstractions.Entities.KubernetesExtensions: GetKind() and GetApiVersion()
    return the value of the object, or the one of its [KubernetesEntity] attribute if the object carries none. They
    were private helpers for owner and object references since feat(abstractions)!: add controller references and deduplicate owner references #1355.
  • Logging: ToIdentifierString() and the Kind field of the entity logging scope use GetKind().
  • Exceptions: the three owner reference exceptions (already controlled by, has no namespace,
    must be cluster-scoped) name the resource with GetKind(); a child resource is usually created with new.
  • Docs: one sentence in the owner references section of controllers.mdx; the XML docs say "built-in type"
    consistently.

Relates to #989. Items from ListAsync carry both fields since #1371, so this covers the remaining case.

Public instead of internal with InternalsVisibleTo: KubeOps.Operator only requires a minimum version of
KubeOps.Abstractions, so an internal API could break at runtime with mixed package versions, and the repo grants
InternalsVisibleTo only to test projects.

Tests

  • KubernetesExtensions.TypeMeta.Test.cs (new): values of the object, fallback for null and empty values, group and
    version for V1Deployment.
  • KubernetesExtensions.OwnerReferences.Test.cs: the child ConfigMap is created without kind/apiVersion, and
    the exception messages must contain ConfigMap resource (5 tests fail with resource.Kind).
  • KubernetesObjectExtensions.Test.cs and EntityLoggingScope.Test.cs (new): a V1Secret without kind is logged
    as Secret/my-secret (4 tests fail without the logging change).

Checks

  • /code-review (low): no findings.
  • /simplify: switched the three exception messages to GetKind() (altitude), kept null in the logging scope like
    the other fields instead of "", unified the wording to "built-in type". Not changed: no cache for the attribute
    lookup, as it only runs when the object has no kind.
  • /security-review: no findings.
  • dotnet build -c Release without warnings, dotnet format --verify-no-changes, npm run build in docs/, all
    tests of KubeOps.Abstractions.Test (338) and KubeOps.Operator.Test (358 per framework) pass on net10.0 and
    net11.0, including the integration tests against a local OrbStack cluster. One earlier full run hung in an
    integration test; the reruns per framework passed.

GetKind() and GetApiVersion() return the kind and apiVersion of an object, or those of its type if the object
carries none, e.g. a built-in type created with new. The operator logging and the owner reference exceptions use
GetKind(), so they no longer show an empty or null kind for such objects (#989).
@kimpenhaus
kimpenhaus enabled auto-merge (squash) December 4, 2026 13:51
@kimpenhaus
kimpenhaus merged commit 285b917 into main Dec 4, 2026
7 checks passed
@kimpenhaus
kimpenhaus deleted the feat/abstractions-resolve-kind branch December 4, 2026 13:56
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

Successfully merging this pull request may close these issues.

1 participant