// ReadYAML read placemat-menu resource files
ReadYAML read placemat-menu resource files
// ReadYAML read placemat - menu resource files
func ReadYAML(r *bufio.Reader) (*Menu, error) {
	var m Menu
	var c baseConfig
	y := k8sYaml.NewYAMLReader(r)
	for {
		data, err := y.Read()
		if err == io.EOF {
			break
		} else if err != nil {
			return nil, err
		}
		err = yaml.Unmarshal(data, &c)
		if err != nil {
			return nil, err
		}
		switch c.Kind {
		case "Network":
			r, err := unmarshalNetwork(data)
			if err != nil {
				return nil, err
			}
			m.Network = r
		case "Inventory":
			r, err := unmarshalInventory(data)
			if err != nil {
				return nil, err
			}
			m.Inventory = r
		case "Image":
			r, err := unmarshalImage(data)
			if err != nil {
				return nil, err
			}
			m.Images = append(m.Images, r)
		case "Node":
			r, err := unmarshalNode(data)
			if err != nil {
				return nil, err
			}
			m.Nodes = append(m.Nodes, r)
		default:
			return nil, errors.New("unknown resource: " + c.Kind)
		}
	}
	return &m, nil
}
func ReadYAML ( r * bufio . Reader ) ( * Menu , error ) { var m Menu var c baseConfig y := k8sYaml . NewYAMLReader ( r ) for { data , err := y . Read ( ) if err == io . EOF { break } else if err != nil { return nil , err } err = yaml . Unmarshal ( data , & c ) if err != nil { return nil , err } switch c . Kind { case " " : r , err := unmarshalNetwork ( data ) if err != nil { return nil , err } m . Network = r case " " : r , err := unmarshalInventory ( data ) if err != nil { return nil , err } m . Inventory = r case " " : r , err := unmarshalImage ( data ) if err != nil { return nil , err } m . Images = append ( m . Images , r ) case " " : r , err := unmarshalNode ( data ) if err != nil { return nil , err } m . Nodes = append ( m . Nodes , r ) default : return nil , errors . New ( " " + c . Kind ) } } return & m , nil }
ReadYAML read placemat-menu resource files
ReadYAML read placemat - menu resource files