func (r *Repo) readDepRepos(v *viper.Viper) ([]*Repo, error) { rdesc := r.rdesc repos := []*Repo{} branch, _, ok := rdesc.Match(r) if !ok { // No matching branch, barf! return nil, util.NewNewtError(fmt.Sprintf("No "+ "matching branch for %s repo", r.Name())) } repoTag := fmt.Sprintf("%s.repositories", branch) repoList := v.GetStringMap(repoTag) for repoName, repoItf := range repoList { repoVars := cast.ToStringMapString(repoItf) dl, err := downloader.LoadDownloader(repoName, repoVars) if err != nil { return nil, err } rversreq := repoVars["vers"] newRepo, err := NewRepo(repoName, rversreq, dl) if err != nil { return nil, err } rd, err := NewRepoDependency(repoName, rversreq) if err != nil { return nil, err } rd.Storerepo = newRepo r.AddDependency(rd) repos = append(repos, newRepo) } return repos, nil }
func (v *Viper) GetStringMapString(key string) map[string]string { return cast.ToStringMapString(v.Get(key)) }
func GetStringMapString(key string) map[string]string { return cast.ToStringMapString(Get(key)) }
// Returns the value associated with the key as a map of strings func (c RawConfig) GetStringMapString(key string) map[string]string { return cast.ToStringMapString(c.Get(key)) }
func (manager *Config) GetStringMapString(key string) map[string]string { return cast.ToStringMapString(manager.Get(key)) }
func parseFlashArea( name string, ymlFields map[string]interface{}) (FlashArea, error) { area := FlashArea{ Name: name, } idPresent := false devicePresent := false offsetPresent := false sizePresent := false var isSystem bool area.Id, isSystem = SYSTEM_AREA_NAME_ID_MAP[name] var err error fields := cast.ToStringMapString(ymlFields) for k, v := range fields { switch k { case "user_id": if isSystem { return area, flashAreaErr(name, "system areas cannot specify a user ID") } userId, err := util.AtoiNoOct(v) if err != nil { return area, flashAreaErr(name, "invalid user id: %s", v) } area.Id = userId + AREA_USER_ID_MIN idPresent = true case "device": area.Device, err = util.AtoiNoOct(v) if err != nil { return area, flashAreaErr(name, "invalid device: %s", v) } devicePresent = true case "offset": area.Offset, err = util.AtoiNoOct(v) if err != nil { return area, flashAreaErr(name, "invalid offset: %s", v) } offsetPresent = true case "size": area.Size, err = parseSize(v) if err != nil { return area, flashAreaErr(name, err.Error()) } sizePresent = true default: util.StatusMessage(util.VERBOSITY_QUIET, "Warning: flash area \"%s\" contains unrecognized field: %s", name, k) } } if !isSystem && !idPresent { return area, flashAreaErr(name, "required field \"user_id\" missing") } if !devicePresent { return area, flashAreaErr(name, "required field \"device\" missing") } if !offsetPresent { return area, flashAreaErr(name, "required field \"offset\" missing") } if !sizePresent { return area, flashAreaErr(name, "required field \"size\" missing") } return area, nil }
func (l *Language) GetStringMapString(key string) map[string]string { return cast.ToStringMapString(l.Get(key)) }
func Load(basePkg *pkg.LocalPackage) (*MfgImage, error) { v, err := util.ReadConfig(basePkg.BasePath(), strings.TrimSuffix(MFG_YAML_FILENAME, ".yml")) if err != nil { return nil, err } mi := &MfgImage{ basePkg: basePkg, } bootName := v.GetString("mfg.bootloader") if bootName == "" { return nil, mi.loadError("mfg.bootloader field required") } mi.boot, err = mi.loadTarget(bootName) if err != nil { return nil, err } imgNames := v.GetStringSlice("mfg.images") if imgNames != nil { for _, imgName := range imgNames { imgTarget, err := mi.loadTarget(imgName) if err != nil { return nil, err } mi.images = append(mi.images, imgTarget) } } if len(mi.images) > 2 { return nil, mi.loadError("too many images (%d); maximum is 2", len(mi.images)) } itf := v.Get("mfg.raw") slice := cast.ToSlice(itf) if slice != nil { for i, entryItf := range slice { yamlEntry := cast.ToStringMapString(entryItf) entry, err := mi.loadRawEntry(i, yamlEntry) if err != nil { return nil, err } mi.rawEntries = append(mi.rawEntries, entry) } } proj := project.GetProject() bspLpkg, err := proj.ResolvePackage(mi.basePkg.Repo(), mi.boot.BspName) if err != nil { return nil, mi.loadError( "could not resolve boot loader BSP package: %s", mi.boot.BspName) } mi.bsp, err = pkg.NewBspPackage(bspLpkg) if err != nil { return nil, mi.loadError(err.Error()) } for _, imgTarget := range mi.images { if len(mi.images) > 1 && imgTarget.LoaderName != "" { return nil, mi.loadError("only one image allowed in "+ "split image mode (%s is a split build)", imgTarget.Name()) } if imgTarget.Bsp() != mi.bsp.LocalPackage { return nil, mi.loadError( "image target \"%s\" specified conflicting BSP; "+ "boot loader uses %s, image uses %s", imgTarget.Name(), mi.bsp.Name(), imgTarget.BspName) } } if err := mi.detectInvalidDevices(); err != nil { return nil, err } return mi, nil }