Skip to content

Commit

Permalink
Fixing an issue with default binding name
Browse files Browse the repository at this point in the history
  • Loading branch information
navidsh committed May 18, 2020
1 parent e648d5a commit 5a782ab
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
14 changes: 7 additions & 7 deletions pkg/controller/runtimecomponent/enqueue_with_matcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const (
// the modified resource
type EnqueueRequestsForCustomIndexField struct {
handler.Funcs
Matcher CustomMatcher
Matcher CustomMatcher
}

// Update implements EventHandler
Expand Down Expand Up @@ -67,28 +67,28 @@ type CustomMatcher interface {

// ImageStreamMatcher implements CustomMatcher for Image Streams
type ImageStreamMatcher struct {
klient client.Client
watchNamespaces []string
Klient client.Client
WatchNamespaces []string
}

// Match returns all applications using the input ImageStreamTag
func (i *ImageStreamMatcher) Match(imageStreamTag metav1.Object) ([]appstacksv1beta1.RuntimeComponent, error) {
apps := []appstacksv1beta1.RuntimeComponent{}
var namespaces []string
if appstacksutils.IsClusterWide(i.watchNamespaces) {
if appstacksutils.IsClusterWide(i.WatchNamespaces) {
nsList := &corev1.NamespaceList{}
if err := i.klient.List(context.Background(), nsList, client.InNamespace("")); err != nil {
if err := i.Klient.List(context.Background(), nsList, client.InNamespace("")); err != nil {
return nil, err
}
for _, ns := range nsList.Items {
namespaces = append(namespaces, ns.Name)
}
} else {
namespaces = watchNamespaces
namespaces = i.WatchNamespaces
}
for _, ns := range namespaces {
appList := &appstacksv1beta1.RuntimeComponentList{}
err := i.klient.List(context.Background(),
err := i.Klient.List(context.Background(),
appList,
client.InNamespace(ns),
client.MatchingFields{indexFieldImageStreamName: imageStreamTag.GetNamespace() + "/" + imageStreamTag.GetName()})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,8 +256,8 @@ func add(mgr manager.Manager, r reconcile.Reconciler) error {
&source.Kind{Type: &imagev1.ImageStream{}},
&EnqueueRequestsForCustomIndexField{
Matcher: &ImageStreamMatcher{
klient: mgr.GetClient(),
watchNamespaces: watchNamespaces,
Klient: mgr.GetClient(),
WatchNamespaces: watchNamespaces,
},
})
}
Expand Down
8 changes: 5 additions & 3 deletions pkg/utils/service_binding_reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -308,8 +308,10 @@ func (r *ReconcilerBase) reconcileExternals(ba common.BaseComponent) (retRes rec
bindingObj := &unstructured.Unstructured{}
bindingObj.SetGroupVersionKind(gvk)
err := r.client.Get(context.Background(), key, bindingObj)
if client.IgnoreNotFound(err) != nil {
log.Error(errors.Wrapf(err, "failed to find a service binding resource during auto-detect for GVK %q", gvk), "failed to get Service Binding CR")
if err != nil {
if !kerrors.IsNotFound(err) {
log.Error(errors.Wrapf(err, "failed to find a service binding resource during auto-detect for GVK %q", gvk), "failed to get Service Binding CR")
}
continue
}

Expand Down Expand Up @@ -590,5 +592,5 @@ func (r *ReconcilerBase) updateEmbeddedObject(object map[string]interface{}, emb
}

func getDefaultServiceBindingName(ba common.BaseComponent) string {
return (ba.(metav1.Object)).GetName() + "-bindings"
return (ba.(metav1.Object)).GetName() + "-binding"
}

0 comments on commit 5a782ab

Please sign in to comment.