Skip to content

Commit

Permalink
chore: remove status update from plugin ops (#772)
Browse files Browse the repository at this point in the history
* chore: remove status update from plugin ops

Signed-off-by: Mattia Lavacca <[email protected]>

* address review comments

Signed-off-by: Mattia Lavacca <[email protected]>

---------

Signed-off-by: Mattia Lavacca <[email protected]>
  • Loading branch information
mlavacca authored Oct 22, 2024
1 parent 32bbcd9 commit df4f5b4
Showing 1 changed file with 8 additions and 13 deletions.
21 changes: 8 additions & 13 deletions controller/konnect/ops/ops_kongpluginbinding.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ func createPlugin(
}

pluginBinding.SetKonnectID(*resp.Plugin.ID)
SetKonnectEntityProgrammedCondition(pluginBinding)

return nil
}
Expand All @@ -66,34 +65,30 @@ func updatePlugin(
ctx context.Context,
sdk sdkops.PluginSDK,
cl client.Client,
pb *configurationv1alpha1.KongPluginBinding,
pluginBinding *configurationv1alpha1.KongPluginBinding,
) error {
controlPlaneID := pb.GetControlPlaneID()
controlPlaneID := pluginBinding.GetControlPlaneID()
if controlPlaneID == "" {
return CantPerformOperationWithoutControlPlaneIDError{Entity: pb, Op: UpdateOp}
return CantPerformOperationWithoutControlPlaneIDError{Entity: pluginBinding, Op: UpdateOp}
}

pluginInput, err := kongPluginBindingToSDKPluginInput(ctx, cl, pb)
pluginInput, err := kongPluginBindingToSDKPluginInput(ctx, cl, pluginBinding)
if err != nil {
return err
}

id := pluginBinding.GetKonnectID()
_, err = sdk.UpsertPlugin(ctx,
sdkkonnectops.UpsertPluginRequest{
ControlPlaneID: controlPlaneID,
PluginID: pb.GetKonnectID(),
PluginID: id,
Plugin: *pluginInput,
},
)

// TODO: handle already exists
// Can't adopt it as it will cause conflicts between the controller
// that created that entity and already manages it, hm
if errWrap := wrapErrIfKonnectOpFailed[configurationv1alpha1.KongPluginBinding](err, UpdateOp, pb); errWrap != nil {
SetKonnectEntityProgrammedConditionFalse(pb, "FailedToUpdate", errWrap.Error())
if errWrap := wrapErrIfKonnectOpFailed(err, UpdateOp, pluginBinding); errWrap != nil {
return errWrap
}
SetKonnectEntityProgrammedCondition(pb)

return nil
}
Expand All @@ -108,7 +103,7 @@ func deletePlugin(
) error {
id := pb.GetKonnectID()
_, err := sdk.DeletePlugin(ctx, pb.GetControlPlaneID(), id)
if errWrap := wrapErrIfKonnectOpFailed[configurationv1alpha1.KongPluginBinding](err, DeleteOp, pb); errWrap != nil {
if errWrap := wrapErrIfKonnectOpFailed(err, DeleteOp, pb); errWrap != nil {
return handleDeleteError(ctx, err, pb)
}

Expand Down

0 comments on commit df4f5b4

Please sign in to comment.