Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
5255ffc2f7 | |||
fd1c579ec4 | |||
0f4adeea86 | |||
245f3adea3 | |||
21d08204b5 | |||
1de4888599 |
@ -26,12 +26,12 @@ import (
|
|||||||
func GetConfLoader() *onion.Onion {
|
func GetConfLoader() *onion.Onion {
|
||||||
logger := zerolog.New(os.Stdout).With().Timestamp().Logger()
|
logger := zerolog.New(os.Stdout).With().Timestamp().Logger()
|
||||||
AppName := GetAppName()
|
AppName := GetAppName()
|
||||||
EnvPrefix := strings.ToUpper(AppName[0:2]+AppName[3:]) + "_"
|
EnvPrefix := "OC_"
|
||||||
defaultConfigFile := "/etc/oc/" + AppName[3:] + ".json"
|
defaultConfigFile := "/etc/oc/" + AppName[3:] + ".json"
|
||||||
localConfigFile := "./" + AppName[3:] + ".json"
|
localConfigFile := "./" + AppName[3:] + ".json"
|
||||||
var configFile string
|
var configFile string
|
||||||
var o *onion.Onion
|
var o *onion.Onion
|
||||||
l3 := onion.NewEnvLayerPrefix("_", EnvPrefix)
|
l3 := GetEnvVarLayer(EnvPrefix)
|
||||||
l2, err := onion.NewFileLayer(localConfigFile, nil)
|
l2, err := onion.NewFileLayer(localConfigFile, nil)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
logger.Info().Msg("Local config file found " + localConfigFile + ", overriding default file")
|
logger.Info().Msg("Local config file found " + localConfigFile + ", overriding default file")
|
||||||
@ -54,3 +54,17 @@ func GetConfLoader() *onion.Onion {
|
|||||||
}
|
}
|
||||||
return o
|
return o
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GetEnvVarLayer(prefix string) onion.Layer {
|
||||||
|
envVars := make(map[string]interface{})
|
||||||
|
|
||||||
|
for _, e := range os.Environ() {
|
||||||
|
pair := strings.SplitN(e, "=", 2)
|
||||||
|
key := pair[0]
|
||||||
|
if strings.HasPrefix(key, prefix) {
|
||||||
|
envVars[strings.TrimPrefix(key, prefix)] = pair[1]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return onion.NewMapLayer(envVars)
|
||||||
|
}
|
||||||
|
@ -21,16 +21,17 @@ type WebResource struct {
|
|||||||
* it defines the resource data
|
* it defines the resource data
|
||||||
*/
|
*/
|
||||||
type AbstractResource struct {
|
type AbstractResource struct {
|
||||||
utils.AbstractObject // AbstractObject contains the basic fields of an object (id, name)
|
utils.AbstractObject // AbstractObject contains the basic fields of an object (id, name)
|
||||||
ShortDescription string `json:"short_description,omitempty" bson:"short_description,omitempty" validate:"required"` // ShortDescription is the short description of the resource
|
ShortDescription string `json:"short_description,omitempty" bson:"short_description,omitempty" validate:"required"` // ShortDescription is the short description of the resource
|
||||||
Description string `json:"description,omitempty" bson:"description,omitempty"` // Description is the description of the resource
|
Description string `json:"description,omitempty" bson:"description,omitempty"` // Description is the description of the resource
|
||||||
Logo string `json:"logo,omitempty" bson:"logo,omitempty" validate:"required"` // Logo is the logo of the resource
|
Logo string `json:"logo,omitempty" bson:"logo,omitempty" validate:"required"` // Logo is the logo of the resource
|
||||||
Owner string `json:"owner,omitempty" bson:"owner,omitempty" validate:"required"` // Owner is the owner of the resource
|
Owner string `json:"owner,omitempty" bson:"owner,omitempty" validate:"required"` // Owner is the owner of the resource
|
||||||
OwnerLogo string `json:"owner_logo,omitempty" bson:"owner_logo,omitempty"` // OwnerLogo is the owner logo of the resource
|
OwnerLogo string `json:"owner_logo,omitempty" bson:"owner_logo,omitempty"` // OwnerLogo is the owner logo of the resource
|
||||||
SourceUrl string `json:"source_url,omitempty" bson:"source_url,omitempty" validate:"required"` // SourceUrl is the source URL of the resource
|
SourceUrl string `json:"source_url,omitempty" bson:"source_url,omitempty" validate:"required"` // SourceUrl is the source URL of the resource
|
||||||
PeerID string `json:"peer_id,omitempty" bson:"peer_id,omitempty" validate:"required"` // PeerID is the ID of the peer getting this resource
|
|
||||||
License string `json:"license,omitempty" bson:"license,omitempty"` // License is the license of the resource
|
PeerID string `json:"peer_id,omitempty" bson:"peer_id,omitempty"` // PeerID is the ID of the peer getting this resource
|
||||||
ResourceModel *ResourceModel `json:"resource_model,omitempty" bson:"resource_model,omitempty"` // ResourceModel is the model of the resource
|
License string `json:"license,omitempty" bson:"license,omitempty"` // License is the license of the resource
|
||||||
|
ResourceModel *ResourceModel `json:"resource_model,omitempty" bson:"resource_model,omitempty"` // ResourceModel is the model of the resource
|
||||||
|
|
||||||
AllowedPeersGroup map[string][]string `json:"allowed_peers_group,omitempty" bson:"allowed_peers_group,omitempty"` // AllowedPeersGroup is the group of allowed peers
|
AllowedPeersGroup map[string][]string `json:"allowed_peers_group,omitempty" bson:"allowed_peers_group,omitempty"` // AllowedPeersGroup is the group of allowed peers
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user