func readConfig(key string) (string, error) {
	data, err := rpcvmx.NewConfig().String(key, "")
	if err == nil {
		log.Printf("Read from %q: %q\n", key, data)
	} else {
		log.Printf("Failed to read from %q: %v\n", key, err)
	}
	return data, err
}
Beispiel #2
0
func main() {
	if !vmcheck.IsVirtualWorld() {
		fmt.Println("not in a virtual world... :(")
		return
	}

	version, typ := vmcheck.GetVersion()
	fmt.Println(version, typ)

	config := rpcvmx.NewConfig()
	fmt.Println(config.GetString("foo", "foo"))
	fmt.Println(config.GetString("bar", "foo"))
}
Beispiel #3
0
func main() {
	if !vmcheck.IsVirtualWorld() {
		fmt.Println("not in a virtual world... :(")
		return
	}

	config := rpcvmx.NewConfig()

	fmt.Println(config.SetString("foo", "bar"))
	fmt.Println(config.String("foo", "foo"))

	fmt.Println(config.SetInt("foo", 3))
	fmt.Println(config.Int("foo", 0))

	fmt.Println(config.SetBool("foo", false))
	fmt.Println(config.Bool("foo", true))

}
Beispiel #4
0
func (p provider) FetchConfig() (types.Config, error) {
	info := rpcvmx.NewConfig()
	data, err := info.String("coreos.config.data", "")
	if err != nil {
		p.logger.Debug("failed to fetch config: %v", err)
		return types.Config{}, err
	}

	encoding, err := info.String("coreos.config.data.encoding", "")
	if err != nil {
		p.logger.Debug("failed to fetch config encoding: %v", err)
		return types.Config{}, err
	}

	decodedData, err := decodeData(data, encoding)
	if err != nil {
		p.logger.Debug("failed to decode config: %v", err)
		return types.Config{}, err
	}

	p.logger.Debug("config successfully fetched")
	return config.Parse(decodedData)
}