MCPcopy Create free account
hub / github.com/conforma/cli / NewLocalBackend

Function NewLocalBackend

internal/validate/vsa/storage_local.go:36–60  ·  view source on GitHub ↗

NewLocalBackend creates a new local file storage backend

(config *StorageConfig)

Source from the content-addressed store, hash-verified

34
35// NewLocalBackend creates a new local file storage backend
36func NewLocalBackend(config *StorageConfig) (StorageBackend, error) {
37 basePath := "./vsa-upload" // Default
38
39 // Use base URL as path if provided
40 if config.BaseURL != "" {
41 basePath = config.BaseURL
42 }
43
44 // Check parameters
45 for key, value := range config.Parameters {
46 switch key {
47 case "path", "dir", "directory":
48 basePath = value
49 default:
50 log.Warnf("[VSA] Local backend: ignoring unknown parameter '%s'", key)
51 }
52 }
53
54 // Ensure directory exists
55 if err := os.MkdirAll(basePath, 0o755); err != nil {
56 return nil, fmt.Errorf("failed to create storage directory %s: %w", basePath, err)
57 }
58
59 return &LocalBackend{basePath: basePath}, nil
60}
61
62// Name returns the backend name
63func (l *LocalBackend) Name() string {

Callers 2

CreateStorageBackendFunction · 0.85
TestNewLocalBackendFunction · 0.85

Calls 2

WarnfMethod · 0.65
ErrorfMethod · 0.65

Tested by 1

TestNewLocalBackendFunction · 0.68