mirror of
https://github.com/hauler-dev/hauler.git
synced 2026-04-05 10:17:31 +00:00
25 lines
658 B
Go
25 lines
658 B
Go
package content
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
|
"k8s.io/apimachinery/pkg/runtime/schema"
|
|
"k8s.io/apimachinery/pkg/util/yaml"
|
|
|
|
"github.com/rancherfederal/hauler/pkg/apis/hauler.cattle.io/v1alpha1"
|
|
)
|
|
|
|
func Load(data []byte) (schema.ObjectKind, error) {
|
|
var tm *metav1.TypeMeta
|
|
if err := yaml.Unmarshal(data, &tm); err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
if tm.GroupVersionKind().GroupVersion() != v1alpha1.ContentGroupVersion && tm.GroupVersionKind().GroupVersion() != v1alpha1.CollectionGroupVersion {
|
|
return nil, fmt.Errorf("unrecognized content/collection type: %s", tm.GroupVersionKind().String())
|
|
}
|
|
|
|
return tm, nil
|
|
}
|