github.com/cozy/cozy-stack@v0.0.0-20240603063001-31110fa4cae1/model/instance/init.go (about) 1 package instance 2 3 import ( 4 "github.com/cozy/cozy-stack/pkg/logger" 5 ) 6 7 var service *InstanceService 8 9 // Service handle all the interactions with the "instance" domain. 10 // 11 // This interface has several implementations: 12 // - [InstanceService] with the business logic 13 // - [Mock] with a mock implementation 14 type Service interface { 15 Get(domain string) (*Instance, error) 16 Update(inst *Instance) error 17 Delete(inst *Instance) error 18 CheckPassphrase(inst *Instance, pass []byte) error 19 } 20 21 func Init() *InstanceService { 22 service = NewService(logger.WithNamespace("instance")) 23 24 return service 25 } 26 27 // Get finds an instance from its domain by using CouchDB. 28 // 29 // Deprecated: Use [InstanceService.Get] instead. 30 func Get(domain string) (*Instance, error) { 31 return service.Get(domain) 32 } 33 34 // Update saves the changes in CouchDB. 35 // 36 // Deprecated: Use [InstanceService.Update] instead. 37 func Update(inst *Instance) error { 38 return service.Update(inst) 39 } 40 41 // Delete removes the instance document in CouchDB. 42 // 43 // Deprecated: Use [InstanceService.Delete] instead. 44 func Delete(inst *Instance) error { 45 return service.Delete(inst) 46 } 47 48 // CheckPassphrase confirm an instance password 49 // 50 // Deprecated: Use [InstanceService.CheckPassphrase] instead. 51 func CheckPassphrase(inst *Instance, pass []byte) error { 52 return service.CheckPassphrase(inst, pass) 53 }