func getNodeChildPath(n astnode.AstNode, key ...interface{}) (astnode.AstNode, error) {
	if len(key) == 0 {
		return n, nil
	}
	next, err := getNodeChild(n, key[0])
	if err != nil {
		return nil, err
	}
	return getNodeChildPath(next, key[1:]...)
}
GetPath works like calling Get() repeatly with each argument.
package types
import (
	"errors"
	"fmt"
	"reflect"
	ignTypes "github.com/coreos/ignition/config/v2_3/types"
	"github.com/coreos/ignition/config/validate/astnode"
	"github.com/coreos/ignition/config/validate/report"
	"github.com/flatcar-linux/container-linux-config-transpiler/config/platform"
	"github.com/flatcar-linux/container-linux-config-transpiler/config/templating"
	"github.com/flatcar-linux/container-linux-config-transpiler/config/types/util"
	iutil "github.com/flatcar-linux/container-linux-config-transpiler/internal/util"
)
var (
	ErrPlatformUnspecified = fmt.Errorf("platform must be specified to use templating")
	ErrInvalidKey          = errors.New("Key is invalid (wrong type or not found")
	ErrNilNode             = errors.New("Ast node is nil")
	ErrKeyNotFound         = errors.New("Key not found")
)
func init() {
	register(func(in Config, ast astnode.AstNode, out ignTypes.Config, p string) (ignTypes.Config, report.Report, astnode.AstNode) {
		if p == platform.OpenStackMetadata || p == platform.CloudStackConfigDrive {
			out.Systemd.Units = append(out.Systemd.Units, ignTypes.Unit{
				Name: "coreos-metadata.service",
				Dropins: []ignTypes.SystemdDropin{{
					Name:     "20-clct-provider-override.conf",
					Contents: fmt.Sprintf("[Service]\nEnvironment=COREOS_METADATA_OPT_PROVIDER=--provider=%s", p),
				}},
			})
			out.Systemd.Units = append(out.Systemd.Units, ignTypes.Unit{
				Name:    "coreos-metadata-sshkeys@.service",
				Enabled: iutil.BoolToPtr(true),
				Dropins: []ignTypes.SystemdDropin{{
					Name:     "20-clct-provider-override.conf",
					Contents: fmt.Sprintf("[Service]\nEnvironment=COREOS_METADATA_OPT_PROVIDER=--provider=%s", p),
				}},
			})
		}
		return out, report.Report{}, ast
	})
}
func isZero(v interface{}) bool {
	if v == nil {
		return true
	}
	zv := reflect.Zero(reflect.TypeOf(v))
	return reflect.DeepEqual(v, zv.Interface())
}
func assembleUnit(exec string, args, vars []string, p string) (util.SystemdUnit, error) {
	hasTemplating := templating.HasTemplating(args)
	out := util.NewSystemdUnit()
	if hasTemplating {
		if p == "" {
			return util.SystemdUnit{}, ErrPlatformUnspecified
		}
		out.Unit.Add("Requires=coreos-metadata.service")
		out.Unit.Add("After=coreos-metadata.service")
		out.Service.Add("EnvironmentFile=/run/metadata/coreos")
		var err error
		args, err = templating.PerformTemplating(p, args)
		if err != nil {
			return util.SystemdUnit{}, err
		}
	}
	for _, v := range vars {
		out.Service.Add(fmt.Sprintf("Environment=\"%s\"", v))
	}
	for _, a := range args {
		exec += fmt.Sprintf(" \\\n  %s", a)
	}
	out.Service.Add("ExecStart=")
	out.Service.Add(fmt.Sprintf("ExecStart=%s", exec))
	return out, nil
}
func getArgs(format, tagName string, e interface{}) []string {
	if e == nil {
		return nil
	}
	et := reflect.TypeOf(e)
	ev := reflect.ValueOf(e)
	vars := []string{}
	for i := 0; i < et.NumField(); i++ {
		if val := ev.Field(i).Interface(); !isZero(val) {
			if et.Field(i).Anonymous {
				vars = append(vars, getCliArgs(val)...)
			} else {
				key := et.Field(i).Tag.Get(tagName)
				if ev.Field(i).Kind() == reflect.Ptr {
					val = reflect.Indirect(ev.Field(i)).Interface()
				}
				if _, ok := val.(string); ok {
					val = fmt.Sprintf("%q", val)
				}
				vars = append(vars, fmt.Sprintf(format, key, val))
			}
		}
	}
	return vars
}
func getCliArgs(e interface{}) []string {
	return getArgs("--%s=%v", "cli", e)
}
func getNodeChild(n astnode.AstNode, key interface{}) (astnode.AstNode, error) {
	if n == nil {
		return nil, ErrNilNode
	}
	switch k := key.(type) {
	case int:
		if child, ok := n.SliceChild(k); ok {
			return child, nil
		}
	case string:
		kvmap, ok := n.KeyValueMap()
		if !ok {
			return nil, ErrInvalidKey
		}
		if v, ok := kvmap[k]; ok {
			return v, nil
		}
	default:
		return nil, ErrInvalidKey
	}
	return nil, ErrKeyNotFound
}