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 }
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")) }
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)) }
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) }