// translateTree is internal method for translating value.yaml tree
translateTree is internal method for translating value.yaml tree
// translateTree is internal method for translating value . yaml tree
func (t *ReverseTranslator) translateTree(valueTree map[string]interface{},
	cpSpecTree map[string]interface{}) error {
	for inPath, v := range t.APIMapping {
		log.Infof("Checking for path %s in helm Value.yaml tree", inPath)
		m, found, err := tpath.GetFromTreePath(valueTree, util.ToYAMLPath(inPath))
		if err != nil {
			return err
		}
		if !found {
			log.Infof("path %s not found in helm Value.yaml tree, skip mapping.", inPath)
			continue
		}
		if mstr, ok := m.(string); ok && mstr == "" {
			log.Infof("path %s is empty string, skip mapping.", inPath)
			continue
		}
		if mint, ok := util.ToIntValue(m); ok && mint == 0 {
			log.Infof("path %s is int 0, skip mapping.", inPath)
			continue
		}
		path := util.ToYAMLPath(v.OutPath)
		log.Infof("path has value in helm Value.yaml tree, mapping to output path %s", path)
		if err := tpath.WriteNode(cpSpecTree, path, m); err != nil {
			return err
		}
		if _, err := tpath.DeleteFromTree(valueTree, util.ToYAMLPath(inPath), util.ToYAMLPath(inPath)); err != nil {
			return err
		}
	}
	return nil
}
func ( t * ReverseTranslator ) translateTree ( valueTree map [ string ] interface { } , cpSpecTree map [ string ] interface { } ) error { for inPath , v := range t . APIMapping { log . Infof ( " " , inPath ) m , found , err := tpath . GetFromTreePath ( valueTree , util . ToYAMLPath ( inPath ) ) if err != nil { return err } if ! found { log . Infof ( " " , inPath ) continue } if mstr , ok := m . ( string ) ; ok && mstr == " " { log . Infof ( " " , inPath ) continue } if mint , ok := util . ToIntValue ( m ) ; ok && mint == 0 { log . Infof ( " " , inPath ) continue } path := util . ToYAMLPath ( v . OutPath ) log . Infof ( " " , path ) if err := tpath . WriteNode ( cpSpecTree , path , m ) ; err != nil { return err } if _ , err := tpath . DeleteFromTree ( valueTree , util . ToYAMLPath ( inPath ) , util . ToYAMLPath ( inPath ) ) ; err != nil { return err } } return nil }
translateTree is internal method for translating value.yaml tree
translateTree is internal method for translating value . yaml tree
// Zero int values are due to proto3 compiling to scalars rather than ptrs. Skip these because values of 0 are // the default in destination fields and need not be set explicitly.