MCPcopy Create free account
hub / github.com/ericls/imgdd / FromJSONConfig

Method FromJSONConfig

storage/s3_backend.go:54–73  ·  view source on GitHub ↗
(config []byte)

Source from the content-addressed store, hash-verified

52}
53
54func (s *S3StorageBackend) FromJSONConfig(config []byte) (Storage, error) {
55 var conf S3StorageConfig
56 err := json.Unmarshal(config, &conf)
57 if err != nil {
58 return nil, err
59 }
60 hash := conf.Hash()
61 if storage, ok := s.cache.Get(hash); ok {
62 return storage, nil
63 }
64 store := S3Storage{
65 endpoint: conf.Endpoint,
66 bucket: conf.Bucket,
67 access: conf.Access,
68 secret: conf.Secret,
69 }
70 store.ensureClient()
71 s.cache.Add(hash, &store)
72 return &store, nil
73}
74
75func (s *S3StorageBackend) ValidateJSONConfig(config []byte) error {
76 var conf S3StorageConfig

Callers

nothing calls this directly

Calls 3

HashMethod · 0.95
ensureClientMethod · 0.95
GetMethod · 0.65

Tested by

no test coverage detected