Example #1
0
func NewMirrorFromConfig(conf *mirror.Config) backend.BlobHandler {
	backends := []backend.BlobHandler{}
	backs := conf.Backends
	if backs != nil {
		for _, b := range backs {
			backends = append(backends, NewFromConfig2(b))
		}
	}
	wbackends := []backend.BlobHandler{}
	backs = conf.WriteBackends
	if backs != nil {
		for _, b := range backs {
			wbackends = append(wbackends, NewFromConfig2(b))
		}
	}
	return mirror.New(backends, wbackends)
}
Example #2
0
func NewMirror(conf map[string]interface{}) backend.BlobHandler {
	backends := []backend.BlobHandler{}
	backs := conf["backends"]
	if backs != nil {
		for _, b := range backs.([]interface{}) {
			bconf := b.(map[string]interface{})
			backends = append(backends, NewFromConfig(bconf))
		}
	}
	wbackends := []backend.BlobHandler{}
	backs = conf["write-backends"]
	if backs != nil {
		for _, b := range backs.([]interface{}) {
			bconf := b.(map[string]interface{})
			wbackends = append(wbackends, NewFromConfig(bconf))
		}
	}
	return mirror.New(backends, wbackends)
}