@@ -27,33 +27,37 @@ type Settings struct {
2727}
2828
2929// Takes configuration data as string and updates the state of a given configuration based on it.
30- func (conf * Settings ) Load (path string , filename string ) {
30+ func (conf * Settings ) Load (path string , filename string ) error {
3131 // full path of the file.
32- var filepath = fmt .Sprintf ("%s/%s.yaml " , path , filename )
32+ var filepath = fmt .Sprintf ("%s/%s.yml " , path , filename )
3333
3434 // load the data into the memory
3535 data , err := os .ReadFile (filepath )
3636 errors .Raise (err )
3737
3838 // unmarshal the data into the configuration settings.
39- err = yaml .Unmarshal ([] byte ( data ) , & conf )
39+ err = yaml .Unmarshal (data , & conf )
4040 errors .Raise (err )
41+
42+ return err
4143}
4244
4345// Stores the configuration into the given path in `.yml` format.
44- func (conf Settings ) Save (path string , filename string ) {
46+ func (conf Settings ) Save (path string , filename string ) error {
4547 // marshal the content of the configuration into a `.yaml` document
4648 d , err := yaml .Marshal (& conf )
4749 errors .Raise (err )
4850
4951 // full path of the file.
50- var filepath = fmt .Sprintf ("%s/%s.yaml " , path , filename )
52+ var filepath = fmt .Sprintf ("%s/%s.yml " , path , filename )
5153
5254 // Save to file.
5355 // Mode 640: https://chmodcommand.com/chmod-640/
5456 // Note: this truncates the file if it already exists !!!
5557 err = os .WriteFile (filepath , d , 0640 )
5658 errors .Raise (err )
59+
60+ return err
5761}
5862
5963// This method overwrites the settings with the values from the environment
@@ -87,14 +91,14 @@ func (conf Settings) ResolveEnv() {
8791// Provides common identification attributes for each configuration.
8892// This structure must be private for each configuration object.
8993type ConfigIdentity struct {
90- id string
91- name string
94+ ID string
95+ Name string `yaml:"name"`
9296}
9397
9498// RiotPot configuration structure. It includes all the attributes related to the riotpot framework.
9599// Moreover, it defines the emulators that must be loaded, and watches over them during runtime.
96100type ConfigRiotpot struct {
97- identity ConfigIdentity
101+ Identity ConfigIdentity
98102
99103 /* Riotpot configuration attributes: */
100104 // Defines if the emulators must be loaded directly from the file system.
@@ -134,7 +138,7 @@ func (conf *ConfigRiotpot) Validated() []string {
134138
135139// Database configuration structure. It gives an interface to load and access specific databases.
136140type ConfigDatabase struct {
137- identity ConfigIdentity
141+ Identity ConfigIdentity
138142
139143 /* Database configuration */
140144 // engine used in the db e.g. sql, postgres, sqlite
0 commit comments