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()
|
||||
|
||||
dcpCol := newDcpsCollection(map[string]DCPMetadata{
|
||||
"Internet Gateway_1": {"internetgateway1"},
|
||||
"Internet Gateway_2": {"internetgateway2"},
|
||||
})
|
||||
dcpCol := newDcpsCollection()
|
||||
for _, f := range globFiles("standardizeddcps/*/*.zip", specArchive.Reader) {
|
||||
dirName := strings.TrimPrefix(f.Name, "standardizeddcps/")
|
||||
slashIndex := strings.Index(dirName, "/")
|
||||
@ -100,14 +97,17 @@ type DCPMetadata struct {
|
||||
Name string
|
||||
}
|
||||
|
||||
var dcpMetadataByDir = map[string]DCPMetadata{
|
||||
"Internet Gateway_1": {"internetgateway1"},
|
||||
"Internet Gateway_2": {"internetgateway2"},
|
||||
}
|
||||
|
||||
type dcpCollection struct {
|
||||
dcpMetadataByDir map[string]DCPMetadata
|
||||
dcpByAlias map[string]*DCP
|
||||
}
|
||||
|
||||
func newDcpsCollection(dcpMetadataByDir map[string]DCPMetadata) *dcpCollection {
|
||||
func newDcpsCollection() *dcpCollection {
|
||||
c := &dcpCollection{
|
||||
dcpMetadataByDir: dcpMetadataByDir,
|
||||
dcpByAlias: make(map[string]*DCP),
|
||||
}
|
||||
for _, metadata := range dcpMetadataByDir {
|
||||
@ -117,7 +117,7 @@ func newDcpsCollection(dcpMetadataByDir map[string]DCPMetadata) *dcpCollection {
|
||||
}
|
||||
|
||||
func (c *dcpCollection) dcpForDir(dirName string) *DCP {
|
||||
metadata, ok := c.dcpMetadataByDir[dirName]
|
||||
metadata, ok := dcpMetadataByDir[dirName]
|
||||
if !ok {
|
||||
return nil
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user