diff options
| author | Stefan Majewsky <majewsky@gmx.net> | 2026-07-17 11:37:22 +0200 |
|---|---|---|
| committer | Stefan Majewsky <majewsky@gmx.net> | 2026-07-17 11:38:23 +0200 |
| commit | 558c59e7628245d7fbd21a0453444b59534e8957 (patch) | |
| tree | 0460a5fb578adbe673fab8ef2ff7497a2ddb388d | |
| parent | b43f1fe9155c18f5032ff1b328c81671fd5098ea (diff) | |
| download | go-schwift-558c59e7628245d7fbd21a0453444b59534e8957.tar.gz | |
add Account.ModifyReportedCapabilities
| -rw-r--r-- | CHANGELOG.md | 7 | ||||
| -rw-r--r-- | account.go | 24 |
2 files changed, 28 insertions, 3 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 5deae87..97a2ccb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +# v2.2.0 (TBD) + +Changes: + +- Add `Account.ModifyReportedCapabilities()` to allow working around incorrect + capability reporting in Swift emulation of Ceph. + # v2.1.0 (2026-04-19) Changes: @@ -36,9 +36,10 @@ type Account struct { baseURL string name string // cache - headers *AccountHeaders - caps *Capabilities - capsMutex sync.Mutex + headers *AccountHeaders + caps *Capabilities + modifyCaps func(*Capabilities) + capsMutex sync.Mutex } // IsEqualTo returns true if both Account instances refer to the same account. @@ -207,11 +208,28 @@ func (a *Account) Capabilities(ctx context.Context) (Capabilities, error) { if err != nil { return caps, err } + if a.modifyCaps != nil { + a.modifyCaps(&caps) + } a.caps = &caps return caps, nil } +// ModifyReportedCapabilities allows the caller to tamper with the capabilities reported by [Account.Capabilities]. +// This is necessary when dealing with non-compliant server implementations that do not report their capabilities correctly +// (e.g. Ceph does not report "tempurl.allowed_digests", which breaks [Object.TempURL]). +// +// This call impacts all calls to [Account.Capabilities] that are made after this call succeeds. +// Calls to [Account.RawCapabilities] are not affected by this modification. +// Calls to this method do not stack: If this method is called multiple times, only the last modification will take effect. +func (a *Account) ModifyReportedCapabilities(modify func(*Capabilities)) { + a.capsMutex.Lock() + defer a.capsMutex.Unlock() + a.caps = nil // to force refetch+modify during next Capabilities() call + a.modifyCaps = modify +} + // RawCapabilities queries the GET /info endpoint of the Swift server providing // this account, and returns the response body. Unlike Account.Capabilities, // this method does not employ any caching. |
