diff --git a/pkg/operator/resource/resourceread/images.go b/pkg/operator/resource/resourceread/images.go new file mode 100644 index 0000000000..62a80d1284 --- /dev/null +++ b/pkg/operator/resource/resourceread/images.go @@ -0,0 +1,26 @@ +package resourceread + +import ( + imagev1 "github.com/openshift/api/image/v1" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime/serializer" +) + +var ( + imagesScheme = runtime.NewScheme() + imagesCodecs = serializer.NewCodecFactory(imagesScheme) +) + +func init() { + if err := imagev1.AddToScheme(imagesScheme); err != nil { + panic(err) + } +} + +func ReadImageStreamV1OrDie(objBytes []byte) *imagev1.ImageStream { + requiredObj, err := runtime.Decode(imagesCodecs.UniversalDecoder(imagev1.SchemeGroupVersion), objBytes) + if err != nil { + panic(err) + } + return requiredObj.(*imagev1.ImageStream) +}