mirror of
https://github.com/redhat-developer/odo.git
synced 2025-10-19 03:06:19 +03:00
* Adds support for linking using service binding without the service binding operator * Uses isLinkResource() to detect the service binding resources * Updates the success message for operator based links * Updates the flow to creating the deployment first * Adds annotations to the Redis CR in devfile-with-link.yaml file * Updates the flow to create only the services before the deployment. It also separates the push related code for link and service creation. * Moves the for loop in setLinksServiceNames() inside the if condition * Adds and returns a error message when the pipeline throws a forbidden type of error * Moves the updation of services and pvcs with owner references before attempting creation of links
52 lines
1.2 KiB
Go
52 lines
1.2 KiB
Go
package apis
|
|
|
|
import (
|
|
"errors"
|
|
"k8s.io/apimachinery/pkg/api/meta"
|
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
|
"k8s.io/apimachinery/pkg/runtime"
|
|
)
|
|
|
|
const finalizerName = "finalizer.servicebinding.openshift.io"
|
|
|
|
func MaybeAddFinalizer(obj Object) bool {
|
|
finalizers := obj.GetFinalizers()
|
|
for _, f := range finalizers {
|
|
if f == finalizerName {
|
|
return false
|
|
}
|
|
}
|
|
obj.SetFinalizers(append(finalizers, finalizerName))
|
|
return true
|
|
}
|
|
|
|
func MaybeRemoveFinalizer(obj Object) bool {
|
|
finalizers := obj.GetFinalizers()
|
|
for i, f := range finalizers {
|
|
if f == finalizerName {
|
|
obj.SetFinalizers(append(finalizers[:i], finalizers[i+1:]...))
|
|
return true
|
|
}
|
|
}
|
|
return false
|
|
}
|
|
|
|
type Object interface {
|
|
runtime.Object
|
|
GetFinalizers() []string
|
|
SetFinalizers([]string)
|
|
HasDeletionTimestamp() bool
|
|
StatusConditions() []metav1.Condition
|
|
}
|
|
|
|
func CanUpdateBinding(obj Object) error {
|
|
if obj.HasDeletionTimestamp() {
|
|
return nil
|
|
}
|
|
if meta.IsStatusConditionTrue(obj.StatusConditions(), BindingReady) {
|
|
return errors.New("cannot update Service Binding if 'Ready' condition is True. If you want to rebind to another service/application, remove this binding and create a new one.")
|
|
}
|
|
|
|
return nil
|
|
}
|