@@ -904,6 +904,107 @@ var _ = Describe("Operator Controller Test", func() {
904904 Expect (cond .Message ).To (Equal ("installation has not been attempted as resolution failed" ))
905905 })
906906 })
907+ When ("the operator specifies a package with a plain+v0 bundle" , func () {
908+ var pkgName string
909+ var pkgVer string
910+ var pkgChan string
911+ BeforeEach (func () {
912+ By ("initializing cluster state" )
913+ pkgName = "plain"
914+ pkgVer = "0.1.0"
915+ pkgChan = "beta"
916+ operator = & operatorsv1alpha1.Operator {
917+ ObjectMeta : metav1.ObjectMeta {Name : opKey .Name },
918+ Spec : operatorsv1alpha1.OperatorSpec {
919+ PackageName : pkgName ,
920+ Version : pkgVer ,
921+ Channel : pkgChan ,
922+ },
923+ }
924+ err := cl .Create (ctx , operator )
925+ Expect (err ).NotTo (HaveOccurred ())
926+ })
927+ It ("sets resolution success status" , func () {
928+ By ("running reconcile" )
929+ res , err := reconciler .Reconcile (ctx , ctrl.Request {NamespacedName : opKey })
930+ Expect (res ).To (Equal (ctrl.Result {}))
931+ Expect (err ).NotTo (HaveOccurred ())
932+ By ("fetching updated operator after reconcile" )
933+ Expect (cl .Get (ctx , opKey , operator )).NotTo (HaveOccurred ())
934+
935+ By ("Checking the status fields" )
936+ Expect (operator .Status .ResolvedBundleResource ).To (Equal ("quay.io/operatorhub/plain@sha256:plain" ))
937+ Expect (operator .Status .InstalledBundleResource ).To (Equal ("" ))
938+
939+ By ("checking the expected conditions" )
940+ cond := apimeta .FindStatusCondition (operator .Status .Conditions , operatorsv1alpha1 .TypeResolved )
941+ Expect (cond ).NotTo (BeNil ())
942+ Expect (cond .Status ).To (Equal (metav1 .ConditionTrue ))
943+ Expect (cond .Reason ).To (Equal (operatorsv1alpha1 .ReasonSuccess ))
944+ Expect (cond .Message ).To (Equal ("resolved to \" quay.io/operatorhub/plain@sha256:plain\" " ))
945+ cond = apimeta .FindStatusCondition (operator .Status .Conditions , operatorsv1alpha1 .TypeInstalled )
946+ Expect (cond ).NotTo (BeNil ())
947+ Expect (cond .Status ).To (Equal (metav1 .ConditionUnknown ))
948+ Expect (cond .Reason ).To (Equal (operatorsv1alpha1 .ReasonInstallationStatusUnknown ))
949+ Expect (cond .Message ).To (Equal ("bundledeployment status is unknown" ))
950+
951+ By ("fetching the bundled deployment" )
952+ bd := & rukpakv1alpha1.BundleDeployment {}
953+ Expect (cl .Get (ctx , types.NamespacedName {Name : opKey .Name }, bd )).NotTo (HaveOccurred ())
954+ Expect (bd .Spec .ProvisionerClassName ).To (Equal ("core-rukpak-io-plain" ))
955+ Expect (bd .Spec .Template .Spec .ProvisionerClassName ).To (Equal ("core-rukpak-io-plain" ))
956+ Expect (bd .Spec .Template .Spec .Source .Type ).To (Equal (rukpakv1alpha1 .SourceTypeImage ))
957+ Expect (bd .Spec .Template .Spec .Source .Image ).NotTo (BeNil ())
958+ Expect (bd .Spec .Template .Spec .Source .Image .Ref ).To (Equal ("quay.io/operatorhub/plain@sha256:plain" ))
959+ })
960+ })
961+ When ("the operator specifies a package with a bad bundle mediatype" , func () {
962+ var pkgName string
963+ var pkgVer string
964+ var pkgChan string
965+ BeforeEach (func () {
966+ By ("initializing cluster state" )
967+ pkgName = "badmedia"
968+ pkgVer = "0.1.0"
969+ pkgChan = "beta"
970+ operator = & operatorsv1alpha1.Operator {
971+ ObjectMeta : metav1.ObjectMeta {Name : opKey .Name },
972+ Spec : operatorsv1alpha1.OperatorSpec {
973+ PackageName : pkgName ,
974+ Version : pkgVer ,
975+ Channel : pkgChan ,
976+ },
977+ }
978+ err := cl .Create (ctx , operator )
979+ Expect (err ).NotTo (HaveOccurred ())
980+ })
981+ It ("sets resolution success status" , func () {
982+ By ("running reconcile" )
983+ res , err := reconciler .Reconcile (ctx , ctrl.Request {NamespacedName : opKey })
984+ Expect (res ).To (Equal (ctrl.Result {}))
985+ Expect (err ).To (HaveOccurred ())
986+ Expect (err .Error ()).To (Equal ("unknown bundle mediatype: badmedia+v1" ))
987+
988+ By ("fetching updated operator after reconcile" )
989+ Expect (cl .Get (ctx , opKey , operator )).NotTo (HaveOccurred ())
990+
991+ By ("Checking the status fields" )
992+ Expect (operator .Status .ResolvedBundleResource ).To (Equal ("quay.io/operatorhub/badmedia@sha256:badmedia" ))
993+ Expect (operator .Status .InstalledBundleResource ).To (Equal ("" ))
994+
995+ By ("checking the expected conditions" )
996+ cond := apimeta .FindStatusCondition (operator .Status .Conditions , operatorsv1alpha1 .TypeResolved )
997+ Expect (cond ).NotTo (BeNil ())
998+ Expect (cond .Status ).To (Equal (metav1 .ConditionTrue ))
999+ Expect (cond .Reason ).To (Equal (operatorsv1alpha1 .ReasonSuccess ))
1000+ Expect (cond .Message ).To (Equal ("resolved to \" quay.io/operatorhub/badmedia@sha256:badmedia\" " ))
1001+ cond = apimeta .FindStatusCondition (operator .Status .Conditions , operatorsv1alpha1 .TypeInstalled )
1002+ Expect (cond ).NotTo (BeNil ())
1003+ Expect (cond .Status ).To (Equal (metav1 .ConditionFalse ))
1004+ Expect (cond .Reason ).To (Equal (operatorsv1alpha1 .ReasonInstallationFailed ))
1005+ Expect (cond .Message ).To (Equal ("unknown bundle mediatype: badmedia+v1" ))
1006+ })
1007+ })
9071008 When ("an invalid semver is provided that bypasses the regex validation" , func () {
9081009 var (
9091010 pkgName string
@@ -955,7 +1056,6 @@ var _ = Describe("Operator Controller Test", func() {
9551056 Expect (cond .Message ).To (Equal ("installation has not been attempted as spec is invalid" ))
9561057 })
9571058 })
958-
9591059 })
9601060})
9611061
@@ -1000,4 +1100,18 @@ var testEntitySource = input.NewCacheQuerier(map[deppy.Identifier]input.Entity{
10001100 "olm.package" : `{"packageName":"badimage","version":"0.1.0"}` ,
10011101 "olm.gvk" : `[]` ,
10021102 }),
1103+ "operatorhub/plain/0.1.0" : * input .NewEntity ("operatorhub/plain/0.1.0" , map [string ]string {
1104+ "olm.bundle.path" : `"quay.io/operatorhub/plain@sha256:plain"` ,
1105+ "olm.channel" : `{"channelName":"beta","priority":0}` ,
1106+ "olm.package" : `{"packageName":"plain","version":"0.1.0"}` ,
1107+ "olm.gvk" : `[]` ,
1108+ "olm.bundle.mediatype" : `"plain+v0"` ,
1109+ }),
1110+ "operatorhub/badmedia/0.1.0" : * input .NewEntity ("operatorhub/badmedia/0.1.0" , map [string ]string {
1111+ "olm.bundle.path" : `"quay.io/operatorhub/badmedia@sha256:badmedia"` ,
1112+ "olm.channel" : `{"channelName":"beta","priority":0}` ,
1113+ "olm.package" : `{"packageName":"badmedia","version":"0.1.0"}` ,
1114+ "olm.gvk" : `[]` ,
1115+ "olm.bundle.mediatype" : `"badmedia+v1"` ,
1116+ }),
10031117})
0 commit comments