summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Majewsky <majewsky@gmx.net>2026-07-17 11:37:22 +0200
committerStefan Majewsky <majewsky@gmx.net>2026-07-17 11:38:23 +0200
commit558c59e7628245d7fbd21a0453444b59534e8957 (patch)
tree0460a5fb578adbe673fab8ef2ff7497a2ddb388d
parentb43f1fe9155c18f5032ff1b328c81671fd5098ea (diff)
downloadgo-schwift-558c59e7628245d7fbd21a0453444b59534e8957.tar.gz
add Account.ModifyReportedCapabilities
-rw-r--r--CHANGELOG.md7
-rw-r--r--account.go24
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:
diff --git a/account.go b/account.go
index cfc5b31..2bc3b2b 100644
--- a/account.go
+++ b/account.go
@@ -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.