Use relaxed config reader. #71

This commit is contained in:
Andrey Smirnov
2015-03-19 23:54:35 +03:00
parent c573746896
commit 02a82f3545
2 changed files with 20 additions and 0 deletions
+1
View File
@@ -1,6 +1,7 @@
gom 'github.com/AlekSi/pointer', :commit => '5f6d527dae3d678b46fbb20331ddf44e2b841943'
gom 'github.com/awalterschulze/gographviz', :commit => '20d1f693416d9be045340150094aa42035a41c9e'
gom 'github.com/cheggaaa/pb', :commit => '2c1b74620cc58a81ac152ee2d322e28c806d81ed'
gom 'github.com/DisposaBoy/JsonConfigReader', :commit => '33a99fdf1d5ee1f79b5077e9c06f955ad356d5f4'
gom 'github.com/gin-gonic/gin', :commit => 'b1758d3bfa09e61ddbc1c9a627e936eec6a170de'
gom 'github.com/jlaffaye/ftp', :commit => 'fec71e62e457557fbe85cefc847a048d57815d76'
gom 'github.com/julienschmidt/httprouter', :commit => '46807412fe50aaceb73bb57061c2230fd26a1640'
+19
View File
@@ -1,6 +1,8 @@
package deb
import (
"encoding/json"
"github.com/DisposaBoy/JsonConfigReader"
"github.com/smira/aptly/utils"
)
@@ -18,6 +20,23 @@ type Uploaders struct {
Rules []UploadersRule `json:"rules"`
}
// NewUploadersFromFile loads Uploaders structue from .json file
func NewUploadersFromFile(path string) (*Uploaders, error) {
uploaders = &deb.Uploaders{}
f, err := os.Open(path)
if err != nil {
return nil, fmt.Errorf("error loading uploaders file: %s", err)
}
defer f.Close()
err = json.NewDecoder(JsonConfigReader.New(f)).Decode(&uploaders)
if err != nil {
return nil, fmt.Errorf("error loading uploaders file: %s", err)
}
return uploaders, nil
}
func (u *Uploaders) expandGroupsInternal(items []string, trail []string) []string {
result := []string{}