mirror of https://github.com/matrix-org/go-neb.git
Browse Source
Add YAML tags to things so we can unmarshal them. Cannot partially unmarshal json.RawMessage-like though...
pull/98/head
Add YAML tags to things so we can unmarshal them. Cannot partially unmarshal json.RawMessage-like though...
pull/98/head
Kegan Dougal
8 years ago
5 changed files with 60 additions and 30 deletions
-
30config.sample.yaml
-
12src/github.com/matrix-org/go-neb/api.go
-
32src/github.com/matrix-org/go-neb/config.go
-
4src/github.com/matrix-org/go-neb/goneb.go
-
12src/github.com/matrix-org/go-neb/types/types.go
@ -1,12 +1,38 @@ |
|||||
package main |
package main |
||||
|
|
||||
import ( |
import ( |
||||
|
"fmt" |
||||
log "github.com/Sirupsen/logrus" |
log "github.com/Sirupsen/logrus" |
||||
"github.com/matrix-org/go-neb/database" |
"github.com/matrix-org/go-neb/database" |
||||
|
"github.com/matrix-org/go-neb/types" |
||||
|
"gopkg.in/yaml.v2" |
||||
|
"io/ioutil" |
||||
) |
) |
||||
|
|
||||
func loadFromConfig(db *database.ServiceDB, configFile string) error { |
|
||||
logger := log.WithField("config_file", configFile) |
|
||||
|
type configFile struct { |
||||
|
Clients []types.ClientConfig `yaml:"clients"` |
||||
|
Realms []configureAuthRealmRequest `yaml:"realms"` |
||||
|
// Sessions []sessionConfig `yaml:"sessions"`
|
||||
|
// Services []serviceConfig `yaml:"services"`
|
||||
|
} |
||||
|
|
||||
|
func loadFromConfig(db *database.ServiceDB, configFilePath string) (*configFile, error) { |
||||
|
logger := log.WithField("config_file", configFilePath) |
||||
logger.Info("Loading from config file") |
logger.Info("Loading from config file") |
||||
return nil |
|
||||
|
|
||||
|
contents, err := ioutil.ReadFile(configFilePath) |
||||
|
if err != nil { |
||||
|
return nil, err |
||||
|
} |
||||
|
var cfg configFile |
||||
|
if err = yaml.Unmarshal(contents, &cfg); err != nil { |
||||
|
return nil, err |
||||
|
} |
||||
|
|
||||
|
// sanity check (at least 1 client and 1 service)
|
||||
|
if len(cfg.Clients) == 0 { |
||||
|
return nil, fmt.Errorf("At least 1 client and 1 service must be specified") |
||||
|
} |
||||
|
|
||||
|
return &cfg, nil |
||||
} |
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue