@@ -402,38 +402,40 @@ func (m *ODLMOperator) GetOperatorNamespace(installMode, namespace string) strin
402402// GetOperandFromRegistry gets the Operand from the OperandRegistry
403403func (m * ODLMOperator ) GetOperandFromRegistry (ctx context.Context , reg * apiv1alpha1.OperandRegistry , operandName string ) (* apiv1alpha1.Operator , error ) {
404404 opt := reg .GetOperator (operandName )
405- // Get excluded CatalogSource from annotation
406- // excluded-catalogsource: catalogsource1, catalogsource2
407- var excludedCatalogSources []string
408- if reg .Annotations != nil && reg .Annotations ["excluded-catalogsource" ] != "" {
409- excludedCatalogSources = strings .Split (reg .Annotations ["excluded-catalogsource" ], "," )
410- }
411- // Get catalog used by ODLM itself by check its own subscription
412- opts := []client.ListOption {
413- client.MatchingLabels {fmt .Sprintf ("operators.coreos.com/ibm-odlm.%s" , util .GetOperatorNamespace ()): "" },
414- client .InNamespace (util .GetOperatorNamespace ()),
415- }
416- odlmCatalog := ""
417- odlmCatalogNs := ""
418- odlmSubList := & olmv1alpha1.SubscriptionList {}
419- if err := m .Reader .List (ctx , odlmSubList , opts ... ); err != nil || len (odlmSubList .Items ) == 0 {
420- klog .Warningf ("No Subscription found for ibm-odlm in the namespace %s" , util .GetOperatorNamespace ())
421- } else {
422- odlmCatalog = odlmSubList .Items [0 ].Spec .CatalogSource
423- odlmCatalogNs = odlmSubList .Items [0 ].Spec .CatalogSourceNamespace
424- }
425-
426- if opt .SourceName == "" || opt .SourceNamespace == "" {
427- catalogSourceName , catalogSourceNs , err := m .GetCatalogSourceFromPackage (ctx , opt .PackageName , opt .Namespace , opt .Channel , reg .Namespace , odlmCatalog , odlmCatalogNs , excludedCatalogSources )
428- if err != nil {
429- return nil , err
430- }
405+ if opt != nil {
406+ // Get excluded CatalogSource from annotation
407+ // excluded-catalogsource: catalogsource1, catalogsource2
408+ var excludedCatalogSources []string
409+ if reg .Annotations != nil && reg .Annotations ["excluded-catalogsource" ] != "" {
410+ excludedCatalogSources = strings .Split (reg .Annotations ["excluded-catalogsource" ], "," )
411+ }
412+ // Get catalog used by ODLM itself by check its own subscription
413+ opts := []client.ListOption {
414+ client.MatchingLabels {fmt .Sprintf ("operators.coreos.com/ibm-odlm.%s" , util .GetOperatorNamespace ()): "" },
415+ client .InNamespace (util .GetOperatorNamespace ()),
416+ }
417+ odlmCatalog := ""
418+ odlmCatalogNs := ""
419+ odlmSubList := & olmv1alpha1.SubscriptionList {}
420+ if err := m .Reader .List (ctx , odlmSubList , opts ... ); err != nil || len (odlmSubList .Items ) == 0 {
421+ klog .Warningf ("No Subscription found for ibm-odlm in the namespace %s" , util .GetOperatorNamespace ())
422+ } else {
423+ odlmCatalog = odlmSubList .Items [0 ].Spec .CatalogSource
424+ odlmCatalogNs = odlmSubList .Items [0 ].Spec .CatalogSourceNamespace
425+ }
426+
427+ if opt .SourceName == "" || opt .SourceNamespace == "" {
428+ catalogSourceName , catalogSourceNs , err := m .GetCatalogSourceFromPackage (ctx , opt .PackageName , opt .Namespace , opt .Channel , reg .Namespace , odlmCatalog , odlmCatalogNs , excludedCatalogSources )
429+ if err != nil {
430+ return nil , err
431+ }
431432
432- if catalogSourceName == "" || catalogSourceNs == "" {
433- klog .V (2 ).Infof ("no catalogsource found for %v" , opt .PackageName )
434- }
433+ if catalogSourceName == "" || catalogSourceNs == "" {
434+ klog .V (2 ).Infof ("no catalogsource found for %v" , opt .PackageName )
435+ }
435436
436- opt .SourceName , opt .SourceNamespace = catalogSourceName , catalogSourceNs
437+ opt .SourceName , opt .SourceNamespace = catalogSourceName , catalogSourceNs
438+ }
437439 }
438440
439441 return opt , nil
0 commit comments