func (*CfgBlockSystemAdminMapper) Map(kv *types.KeyValue) (*types.KeyValue, error) {
	var resKV *types.KeyValue
	var err error
	if vmap, ok := kv.Value.(map[string]types.Value); ok {
		res := types.CfgBlockSystemAdmin{}
		keys := make(map[string]struct{})
		for k := range vmap {
			keys[k] = struct{}{}
		}
		if enabled, ok := vmap["enabled"]; ok {
			delete(keys, "enabled")
			res.Enabled = enabled.(bool)
		}
		if bind, ok := vmap["bind"]; ok {
			delete(keys, "bind")
			res.Bind = bind.(string)
		}
		if len(keys) > 0 {
			err = errUnknownKeys("CfgBlockSystemAdmin", kv, keys)
		} else {
			resKV = &types.KeyValue{Key: kv.Key, Value: res}
		}
	} else {
		err = errUnknownValType("CfgBlockSystemAdmin", kv)
	}
	if err != nil {
		return nil, err
	}
	return resKV, nil
}
Map converts map[string]Value to types.CfgBlockSystemAdmin{} structure.
Lookup keys are:
* enabled
* bind_addr
No extra keys are allowed under this section.
package cast
import (
	"fmt"
	"sort"
	"strings"
	"github.com/awesome-flow/flow/pkg/types"
)
type CfgMapper struct{}
var _ Mapper = (*CfgMapper)(nil)
func errUnknownValType(castType string, kv *types.KeyValue) error {
	return fmt.Errorf("%s cast failed for key: %q, val: %#v: unknown value type", castType, kv.Key, kv.Value)
}
func errUnknownKeys(castType string, kv *types.KeyValue, unknown map[string]struct{}) error {
	unknownArr := make([]string, 0, len(unknown))
	for k := range unknown {
		unknownArr = append(unknownArr, k)
	}
	sort.Strings(unknownArr)
	return fmt.Errorf("%s cast failed for key: %q: unknown attributes: [%s]", castType, kv.Key, strings.Join(unknownArr, ", "))
}
func (*CfgMapper) Map(kv *types.KeyValue) (*types.KeyValue, error) {
	var resKV *types.KeyValue
	var err error
	if vmap, ok := kv.Value.(map[string]types.Value); ok {
		res := types.Cfg{}
		keys := make(map[string]struct{})
		for k := range vmap {
			keys[k] = struct{}{}
		}
		if components, ok := vmap["actors"]; ok {
			delete(keys, "actors")
			res.Actors = components.(map[string]types.CfgBlockActor)
		}
		if pipeline, ok := vmap["pipeline"]; ok {
			delete(keys, "pipeline")
			res.Pipeline = pipeline.(map[string]types.CfgBlockPipeline)
		}
		if system, ok := vmap["system"]; ok {
			delete(keys, "system")
			res.System = system.(types.CfgBlockSystem)
		}
		if len(keys) > 0 {
			err = errUnknownKeys("Cfg", kv, keys)
		} else {
			resKV = &types.KeyValue{Key: kv.Key, Value: res}
		}
	} else {
		err = errUnknownValType("Cfg", kv)
	}
	if err != nil {
		return nil, err
	}
	return resKV, nil
}
type CfgBlockSystemMapper struct{}
var _ Mapper = (*CfgBlockSystemMapper)(nil)
func (*CfgBlockSystemMapper) Map(kv *types.KeyValue) (*types.KeyValue, error) {
	var resKV *types.KeyValue
	var err error
	if vmap, ok := kv.Value.(map[string]types.Value); ok {
		res := types.CfgBlockSystem{}
		keys := make(map[string]struct{})
		for k := range vmap {
			keys[k] = struct{}{}
		}
		if maxprocs, ok := vmap["maxprocs"]; ok {
			delete(keys, "maxprocs")
			res.Maxprocs = maxprocs.(int)
		}
		if admin, ok := vmap["admin"]; ok {
			delete(keys, "admin")
			res.Admin = admin.(types.CfgBlockSystemAdmin)
		}
		if metrics, ok := vmap["metrics"]; ok {
			delete(keys, "metrics")
			res.Metrics = metrics.(types.CfgBlockSystemMetrics)
		}
		if len(keys) > 0 {
			err = errUnknownKeys("CfgBlockSystem", kv, keys)
		} else {
			resKV = &types.KeyValue{Key: kv.Key, Value: res}
		}
	} else {
		err = errUnknownValType("CfgBlockSystem", kv)
	}
	if err != nil {
		return nil, err
	}
	return resKV, nil
}
type CfgBlockSystemAdminMapper struct{}
var _ Mapper = (*CfgBlockSystemAdminMapper)(nil)