github.com/qri-io/qri@v0.10.1-0.20220104210721-c771715036cb/config/registry.go (about) 1 package config 2 3 import ( 4 "github.com/qri-io/jsonschema" 5 ) 6 7 // Registry encapsulates configuration options for centralized qri registries 8 type Registry struct { 9 Location string `json:"location"` 10 } 11 12 // SetArbitrary is an interface implementation of base/fill/struct in order to safely 13 // consume config files that have definitions beyond those specified in the struct. 14 // This simply ignores all additional fields at read time. 15 func (cfg *Registry) SetArbitrary(key string, val interface{}) error { 16 return nil 17 } 18 19 // DefaultRegistry generates a new default registry instance 20 func DefaultRegistry() *Registry { 21 r := &Registry{ 22 Location: "https://registry.qri.cloud", 23 } 24 return r 25 } 26 27 // Validate validates all fields of p2p returning all errors found. 28 func (cfg Registry) Validate() error { 29 schema := jsonschema.Must(`{ 30 "$schema": "http://json-schema.org/draft-06/schema#", 31 "title": "Registry", 32 "description": "Config for registry", 33 "type": "object", 34 "required": ["location"], 35 "properties": { 36 "location": { 37 "description": "the", 38 "type": "string" 39 } 40 } 41 }`) 42 return validate(schema, &cfg) 43 } 44 45 // Copy makes a deep copy of the Registry struct 46 func (cfg *Registry) Copy() *Registry { 47 res := &Registry{ 48 Location: cfg.Location, 49 } 50 return res 51 }