Skip to content

Commit

Permalink
fix(#4336): Restrict Knative binding provider execution for v1alpha1
Browse files Browse the repository at this point in the history
- Also restrict v1alpha1 binding provider
- Only run the binding provider when Knative is installed on the cluster
- Only run the binding provider when referencing a known Knative resource (e.g. broker, channel, service)
  • Loading branch information
christophd authored and squakez committed May 10, 2023
1 parent 67f8671 commit 2417203
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions pkg/util/bindings/knative_ref.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,17 @@ func (k V1alpha1KnativeRefBindingProvider) Translate(ctx V1alpha1BindingContext,
return nil, nil
}

if ok, err := isKnownKnativeResource(e.Ref); !ok {
// only operates on known Knative endpoint resources (e.g. channels, brokers)
return nil, err
}

if knativeInstalled, _ := knative.IsInstalled(ctx.Client); !knativeInstalled {
// works only when Knative is installed
return nil, fmt.Errorf("integration referencing Knative endpoint '%s' that cannot run, "+
"because Knative is not installed on the cluster", e.Ref.Name)
}

serviceType, err := knative.GetServiceType(*e.Ref)
if err != nil {
return nil, err
Expand Down

0 comments on commit 2417203

Please sign in to comment.