Factored dcpMetadataByDir out as a global.
This commit is contained in:
parent
eadcb12812
commit
4370c89058
@ -64,10 +64,7 @@ func TaskSpecgen(t *tasking.T) {
|
|||||||
}
|
}
|
||||||
defer specArchive.Close()
|
defer specArchive.Close()
|
||||||
|
|
||||||
dcpCol := newDcpsCollection(map[string]DCPMetadata{
|
dcpCol := newDcpsCollection()
|
||||||
"Internet Gateway_1": {"internetgateway1"},
|
|
||||||
"Internet Gateway_2": {"internetgateway2"},
|
|
||||||
})
|
|
||||||
for _, f := range globFiles("standardizeddcps/*/*.zip", specArchive.Reader) {
|
for _, f := range globFiles("standardizeddcps/*/*.zip", specArchive.Reader) {
|
||||||
dirName := strings.TrimPrefix(f.Name, "standardizeddcps/")
|
dirName := strings.TrimPrefix(f.Name, "standardizeddcps/")
|
||||||
slashIndex := strings.Index(dirName, "/")
|
slashIndex := strings.Index(dirName, "/")
|
||||||
@ -100,14 +97,17 @@ type DCPMetadata struct {
|
|||||||
Name string
|
Name string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var dcpMetadataByDir = map[string]DCPMetadata{
|
||||||
|
"Internet Gateway_1": {"internetgateway1"},
|
||||||
|
"Internet Gateway_2": {"internetgateway2"},
|
||||||
|
}
|
||||||
|
|
||||||
type dcpCollection struct {
|
type dcpCollection struct {
|
||||||
dcpMetadataByDir map[string]DCPMetadata
|
|
||||||
dcpByAlias map[string]*DCP
|
dcpByAlias map[string]*DCP
|
||||||
}
|
}
|
||||||
|
|
||||||
func newDcpsCollection(dcpMetadataByDir map[string]DCPMetadata) *dcpCollection {
|
func newDcpsCollection() *dcpCollection {
|
||||||
c := &dcpCollection{
|
c := &dcpCollection{
|
||||||
dcpMetadataByDir: dcpMetadataByDir,
|
|
||||||
dcpByAlias: make(map[string]*DCP),
|
dcpByAlias: make(map[string]*DCP),
|
||||||
}
|
}
|
||||||
for _, metadata := range dcpMetadataByDir {
|
for _, metadata := range dcpMetadataByDir {
|
||||||
@ -117,7 +117,7 @@ func newDcpsCollection(dcpMetadataByDir map[string]DCPMetadata) *dcpCollection {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *dcpCollection) dcpForDir(dirName string) *DCP {
|
func (c *dcpCollection) dcpForDir(dirName string) *DCP {
|
||||||
metadata, ok := c.dcpMetadataByDir[dirName]
|
metadata, ok := dcpMetadataByDir[dirName]
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user