func TestReadConfig(t *testing.T) { config, err := configparser.Read("fastforward.conf") if err != nil { t.Error(err) } log.Printf("full configuration:\n%s", config) }
func TestOption(t *testing.T) { config, err := configparser.Read("fastforward.conf") if err != nil { t.Error(err) } section, err := config.Section("DEFAULT") if err != nil { t.Error(err) } options := section.Options() log.Printf("option names:\n%s", options["provisioning_driver"]) assert.Equal(t, "playback", options["provisioning_driver"]) }
func TestSection(t *testing.T) { config, err := configparser.Read("fastforward.conf") if err != nil { t.Error(err) } section, err := config.Section("DEFAULT") if err != nil { t.Error(err) } log.Printf("the default section:\n%s", section) section, err = config.Section("PLAYBACK") if err != nil { t.Error(err) } log.Printf("the playback section:\n%s", section) }
// LoadConf loads the FastForward configuration and return the Conf pointer. func (c *Conf) LoadConf() *Conf { path := "/etc/fastforward/fastforward.conf" conf, err := configparser.Read(path) if err != nil { log.Fatal(err) } DefaultSection, err := conf.Section("DEFAULT") checkErr(err) PlaybackSection, err := conf.Section("PLAYBACK") checkErr(err) FFconf := &Conf{ // Keys are the configuration file field, Values are the value of field. DEFAULT: map[string]string{"provisioning_driver": DefaultSection.Options()["provisioning_driver"], "orchestration_driver": DefaultSection.Options()["orchestration_driver"], "monitoring_driver": DefaultSection.Options()["monitoring_driver"]}, PLAYBACK: map[string]string{"use_ansible": PlaybackSection.Options()["use_ansible"], "ansible_cfg": PlaybackSection.Options()["ansible_cfg"], "private_key": PlaybackSection.Options()["private_key"]}, } return FFconf }