feat(corev1): migrate kubernetes_namespace_v1 to Plugin Framework (fixes #2812)#2858
feat(corev1): migrate kubernetes_namespace_v1 to Plugin Framework (fixes #2812)#2858gaetanars wants to merge 1 commit intohashicorp:mainfrom
Conversation
hashicorp#2812) Migrates kubernetes_namespace_v1 from SDKv2 to the Terraform Plugin Framework, enabling `moved` block support for cross-type state migration. Key changes: - New internal/framework/provider/corev1/ package (8 files) - ResourceWithMoveState: accepts state from kubernetes_namespace (deprecated alias) - ResourceWithUpgradeState (v0→v1): converts SDKv2 TypeList metadata to SingleNestedAttribute transparently for all existing state files - Removes kubernetes_namespace and kubernetes_namespace_v1 from SDKv2 ResourcesMap (mux constraint: same type cannot be registered in both providers simultaneously) - Extends KubeClientsets interface with GetIgnoreAnnotations/GetIgnoreLabels - Exports DiffStringMap, IsInternalKey, IgnoreKey from kubernetes package for reuse by Framework resources Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
882d531 to
4f4e5f7
Compare
|
Endorsing this pilot from downstream. We have ~26 resources in production that hit #2812 (details in that issue). The file layout here ( Two things I want to flag from a consumer's perspective, since they both land as expected based on the PR description but it's worth confirming for anyone reviewing:
Offering to contribute Happy to wait for maintainer feedback on the RFC (#2857) before I start. No local fork of the provider in the meantime — we're holding on the workaround and the hope that this lands cleanly. |
Summary
This PR is the Phase 0 pilot of the progressive SDKv2 → Plugin Framework migration proposed in #2857. It migrates
kubernetes_namespace_v1to the Plugin Framework and re-enablesmovedblock support broken since v3.0.0.What changed
internal/framework/provider/corev1/package (8 files, mirroring theadmissionregistrationv1/pattern)kubernetes_namespaceandkubernetes_namespace_v1removed from SDKv2ResourcesMap(mux constraint: same type cannot be in both providers simultaneously)KubeClientsetsinterface extended withGetIgnoreAnnotations()/GetIgnoreLabels()(needed to access provider-level ignore patterns from Framework resources)DiffStringMap,IsInternalKey,IgnoreKeyexported from thekubernetespackage for reuse by Framework resourcesState migration
Two interfaces are implemented to cover all upgrade paths:
ResourceWithUpgradeState(v0→v1)terraform planon any existingkubernetes_namespace_v1state[{...}]→ Framework SingleNestedAttribute{...}ResourceWithMoveStatemoved { from = kubernetes_namespace.x to = kubernetes_namespace_v1.x }Critical implementation details established in this pilot (and reusable for all subsequent migrations):
PriorSchemamust useschema.ListNestedAttributefor SDKv2 TypeList fields (notSingleNestedAttribute)timeoutsmust be present inPriorSchemaeven if not all keys are in the new schemaSchema.Version = 1on the Framework resource is required to trigger UpgradeStateannotations: {}/labels: {}→nil(not empty non-null map) to avoid perpetual plan diffsTesting
movedblock, SDKv2→Framework upgradeChecklist
ResourceWithMoveStateimplementedResourceWithUpgradeStateimplementedplancheck.ExpectEmptyPlan()moved {}block →plancheck.ExpectEmptyPlan()ImportStateVerify: truepassesmake build+make test+make fmtcheckpass.changelog/NEXT-namespace-v1-migration.txt)Post-Deploy Monitoring & Validation
No additional operational monitoring required: this change affects provider binary distribution only; no infrastructure changes are made at runtime. Existing
kubernetes_namespace_v1resources will silently upgrade their state schema on nextterraform plan.Relates to: #2857 (migration strategy discussion)
Fixes: #2812