Skip to content

Refactor dav: Adopt two-layer architecture to match other storage providers#98

Merged
kathap merged 3 commits into
mainfrom
refactor-dav-two-layer-structure
May 21, 2026
Merged

Refactor dav: Adopt two-layer architecture to match other storage providers#98
kathap merged 3 commits into
mainfrom
refactor-dav-two-layer-structure

Conversation

@kathap
Copy link
Copy Markdown
Contributor

@kathap kathap commented May 18, 2026

Restructure the DAV client to align with S3, Azure, GCS, and AliOSS provider patterns in storage-cli. This is the first step in
modernizing the DAV implementation, with advanced features to follow in subsequent PRs.

Structural Changes:

  • Split client into two layers:
  • client.go: High-level DavBlobstore implementing storage.Storager
  • storage_client.go: Low-level StorageClient for HTTP/WebDAV operations
  • Remove cmd/ and app/ layers (now integrated directly via storage/factory.go)
  • Remove test_assets/ and old fakes/ directories
  • Add helpers.go for shared utilities (getCertPool)
  • Generate clientfakes/ with counterfeiter for testing

Stub Methods (to be implemented in follow-up PRs):

  • List, Copy, DeleteRecursive, Properties, EnsureStorageExists

Path Handling:

  • Remove automatic 2-character path fan-out (previously "abcdef..." was stored as "ab/cd/abcdef...")
  • Object IDs are now used exactly as provided by the caller
  • This aligns with other storage-cli providers (S3, Azure, GCS, AliOSS) which don't apply automatic path transformations
  • Enables consistent cross-provider behavior and allows callers to implement their own partitioning strategy if needed

Breaking Changes:

  • Removed automatic path partitioning - callers must include desired directory structure in object IDs

…oviders

Restructure the DAV client to align with S3, Azure, GCS, and AliOSS provider
patterns in storage-cli. This is the first step in modernizing the DAV
implementation, with advanced features to follow in subsequent PRs.

**Structural Changes:**
- Split client into two layers:
- `client.go`: High-level DavBlobstore implementing storage.Storager
- `storage_client.go`: Low-level StorageClient for HTTP/WebDAV operations
- Remove cmd/ and app/ layers (now integrated directly via storage/factory.go)
- Remove test_assets/ directory (replaced by Docker-based testing)
- Remove old fakes/fake_client.go (replaced by clientfakes/fake_storage_client.go)
- Add helpers.go for shared utilities (getCertPool)

**Stub Methods (to be implemented in follow-up PRs):**
- List: List blobs with optional prefix filter
- Copy: Server-side blob copying via WebDAV COPY
- DeleteRecursive: Delete all blobs matching prefix
- Properties: Retrieve blob metadata
- EnsureStorageExists: Initialize WebDAV directory structure

**Path Handling:**
- Remove automatic 2-character path fan-out. Previously "abcdef..." was stored
as "ab/cd/abcdef...". Now object IDs are passed through unchanged.
- This aligns with other storage-cli providers (S3/Azure/GCS/AliOSS) and
matches existing CCNG usage (BaseClient#partitioned_key already handles
partitioning before calling storage-cli).
- Callers are responsible for any path layout or partitioning strategy.

**Testing:**
- Update tests to use mocked StorageClient with counterfeiter
- Add comprehensive test coverage for Exists (found, not found, error cases)
- Add docker-compose.yml for local WebDAV testing
- Update README with breaking change notice and usage examples

**Code Quality:**
- Align logging style with other providers (lowercase, Debug for success messages)
- All linter checks pass (golangci-lint, go vet, gofmt)
- 100% test pass rate

**Breaking Changes:**
- Removed automatic path partitioning. Object IDs are used exactly as provided.
- Callers must include any desired directory structure in the object ID.
- See dav/README.md "Path Handling Contract" section for migration guidance.
@kathap kathap force-pushed the refactor-dav-two-layer-structure branch from e035a02 to 3756a9c Compare May 19, 2026 10:51
@kathap kathap force-pushed the refactor-dav-two-layer-structure branch from f57155b to bd414ce Compare May 19, 2026 11:42
Comment thread dav/client/client.go Outdated
return nil, err
}
func (d *DavBlobstore) Exists(dest string) (bool, error) {
slog.Debug("checking if file exists on webdav", "dest", dest)
Copy link
Copy Markdown
Contributor

@serdarozerr serdarozerr May 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason this log is debug but not info

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not really. I will change it to info.

Comment thread dav/client/client.go Outdated

blobPrefix := getBlobPrefix(blobID)
func (d *DavBlobstore) Sign(dest string, action string, expiration time.Duration) (string, error) {
slog.Debug("signing url for webdav", "dest", dest, "action", action, "expiration", expiration)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

Copy link
Copy Markdown
Contributor

@johha johha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@github-project-automation github-project-automation Bot moved this from Inbox to Pending Merge | Prioritized in Foundational Infrastructure Working Group May 21, 2026
@kathap kathap merged commit 89f2ad7 into main May 21, 2026
3 checks passed
@github-project-automation github-project-automation Bot moved this from Pending Merge | Prioritized to Done in Foundational Infrastructure Working Group May 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

3 participants