This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
SwiftkubeModel is a zero-dependency Swift package providing Codable, Hashable, Sendable model structs for all Kubernetes API objects. Currently tracks Kubernetes v1.33.3.
swift build # Build the package
swift test # Run all tests
swift test --filter SwiftkubeModelTests.GroupVersionKindTests # Run a single test class
swift format -i Sources/ Tests/ # Format codeMost files under Sources/Model/ are generated by an external tool called Swiftkube:ModelGen (not in this repo). Generated files have this header comment:
// Generated by Swiftkube:ModelGen
// Kubernetes v1.33.3
Do not manually edit generated files unless you understand they will be overwritten on the next generation run.
-
Sources/Model/<group>/<version>/— Generated Kubernetes API structs, one file per type. Files follow the naming conventionTypeName+group.version.swift(e.g.,Pod+core.v1.swift). Each API group is a Swift namespace enum (e.g.,core.v1,apps.v1,networking.v1beta1). -
Sources/Model/(top-level files) — Core infrastructure:KubernetesResource.swift— Protocol hierarchy:KubernetesResource→MetadataHavingResource→KubernetesAPIResource, plus capability marker protocols (NamespacedResource,ClusterScopedResource,ReadableResource,ListableResource,CreatableResource,DeletableResource, etc.)GroupVersionKind.swift/GroupVersionResource.swift— GVK/GVR types and their lookup tables (+DefaultResources,+KubernetesAPIResource,+Meta,+ResourceName)UnstructuredResource.swift— Type-erased resource for unknown/CRD typesIntOrString.swift,Quantity.swift,JSONObject.swift— Special Kubernetes types
-
Sources/Builders/— Closure-based builder functions under thesknamespace enum. Only covers common types (core/v1, apps/v1, meta/v1). -
Sources/Codable/— Custom encoding/decoding support (Any+Codable.swift,NullWrapper.swift). -
Sources/Extensions/— Convenience extensions on model types andHashes.swiftfor Hashable conformance.
- All resources are
Codable,Hashable, andSendablestructs. - API resources use
varproperties (notlet) for mutability. apiVersionandkindareletconstants with default values on each API resource struct.- Resources with
JSONObjectfields (dictionary-backed) store values asDictionary<String, any Sendable>. - The
skenum provides builder functions that useinoutclosure patterns via the internalbuild(_:with:)helper.