Description
After issuing a PATCH to apply BMC attributes, capture the ETag from the response (or a follow-up GET) and return it as part of ApplyResult. This is the "write side" of ETag-based drift detection — we record what the BMC told us after a successful write so we can cheaply detect drift later.
Changes
-
httpBasedUpdateBMCAttributes — after a successful PATCH, read the ETag response header. If absent, perform a follow-up GET to obtain the current ETag. Return map[string]ApplyResult keyed by attribute name.
-
fetchAndCaptureETag(client, uri) — helper that GETs a resource and returns its URI + ETag. Used as fallback when the PATCH response doesn't include an ETag header.
-
ComputeValueHash(value string) — SHA-256 hash of the effective value at apply time. Stored alongside the ETag so that desired-state changes (Secret/ConfigMap rotation) can be detected without relying on spec.generation.
-
redfish_local.go — same ETag capture pattern for the local/mock BMC implementation (GET current ETag → PatchWithHeaders using If-Match → capture new ETag from response).
Tests
TestComputeValueHash — deterministic hash, empty input
TestFetchAndCaptureETag — mock HTTP server returning ETag header
Files
bmc/oem_helpers.go (PATCH return path + helpers)
bmc/redfish_local.go (ETag capture in local implementation)
bmc/oem_helpers_test.go (tests for this PR's scope)
Acceptance Criteria
Description
After issuing a PATCH to apply BMC attributes, capture the ETag from the response (or a follow-up GET) and return it as part of
ApplyResult. This is the "write side" of ETag-based drift detection — we record what the BMC told us after a successful write so we can cheaply detect drift later.Changes
httpBasedUpdateBMCAttributes— after a successful PATCH, read theETagresponse header. If absent, perform a follow-up GET to obtain the current ETag. Returnmap[string]ApplyResultkeyed by attribute name.fetchAndCaptureETag(client, uri)— helper that GETs a resource and returns its URI + ETag. Used as fallback when the PATCH response doesn't include an ETag header.ComputeValueHash(value string)— SHA-256 hash of the effective value at apply time. Stored alongside the ETag so that desired-state changes (Secret/ConfigMap rotation) can be detected without relying onspec.generation.redfish_local.go— same ETag capture pattern for the local/mock BMC implementation (GET current ETag →PatchWithHeadersusingIf-Match→ capture new ETag from response).Tests
TestComputeValueHash— deterministic hash, empty inputTestFetchAndCaptureETag— mock HTTP server returning ETag headerFiles
bmc/oem_helpers.go(PATCH return path + helpers)bmc/redfish_local.go(ETag capture in local implementation)bmc/oem_helpers_test.go(tests for this PR's scope)Acceptance Criteria
httpBasedUpdateBMCAttributesreturns(map[string]ApplyResult, error)ComputeValueHashis deterministic and testedmake testgreen