// -------------------------------------------------------------------
// [NAML Type Switch]
//
// Because of the lack of generics in Go, we are having a lot of fun
// doing things like this.
//
// Anyway if you are interested in adding a NAML type it MUST be switched
// on here.
//
switch x := decoded.(type) {
case *corev1.List:
// Lists are recursive items
// But we error each time and just
// base the error from the inner system.
for _, item := range x.Items {
cObjects, err := toCodify(item.Raw)
if err != nil {
return objects, err
}
// Merge the items
for _, c := range cObjects {
objects = append(objects, c)
}
}
case *corev1.Pod:
objects = append(objects, codify.NewPod(x))
case *appsv1.Deployment:
objects = append(objects, codify.NewDeployment(x))
case *appsv1.StatefulSet:
objects = append(objects, codify.NewStatefulSet(x))
case *appsv1.DaemonSet:
objects = append(objects, codify.NewDaemonSet(x))
case *corev1.ConfigMap:
objects = append(objects, codify.NewConfigMap(x))
case *corev1.Service:
objects = append(objects, codify.NewService(x))
case *corev1.PersistentVolume:
objects = append(objects, codify.NewPersistentVolume(x))
case *corev1.PersistentVolumeClaim:
objects = append(objects, codify.NewPersistentVolumeClaim(x))
case *batchv1.Job:
objects = append(objects, codify.NewJob(x))
case *batchv1.CronJob:
objects = append(objects, codify.NewCronJob(x))
case *rbacv1.Role:
objects = append(objects, codify.NewRole(x))
case *rbacv1.ClusterRole:
objects = append(objects, codify.NewClusterRole(x))
case *rbacv1.RoleBinding:
objects = append(objects, codify.NewRoleBinding(x))
case *rbacv1.ClusterRoleBinding:
objects = append(objects, codify.NewClusterRoleBinding(x))
case *networkingv1.Ingress:
objects = append(objects, codify.NewIngress(x))
case *appsv1.ReplicaSet:
case *corev1.Endpoints:
// Ignore ReplicaSet, Endpoints
break
default:
return nil, fmt.Errorf("missing NAML support for type: %s", x.GetObjectKind().GroupVersionKind().Kind)
}
// -------------------------------------------------------------------
Full resource switch