You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by GitBox <gi...@apache.org> on 2021/05/31 05:09:58 UTC

[GitHub] [camel-k] tadayosi commented on a change in pull request #2332: feat(cli): make kamel delete command aware of KameletBindings

tadayosi commented on a change in pull request #2332:
URL: https://github.com/apache/camel-k/pull/2332#discussion_r642212974



##########
File path: pkg/cmd/delete.go
##########
@@ -120,3 +127,53 @@ func (command *deleteCmdOptions) run(args []string) error {
 
 	return nil
 }
+
+func getIntegration(ctx context.Context, c client.Client, name string, namespace string) (*v1.Integration, error) {
+	key := k8sclient.ObjectKey{
+		Name:      name,
+		Namespace: namespace,
+	}
+	answer := v1.NewIntegration(namespace, name)
+	if err := c.Get(ctx, key, &answer); err != nil {
+		return nil, err
+	}
+	return &answer, nil
+}
+
+func deleteIntegration(ctx context.Context, c client.Client, integration *v1.Integration) error {
+	deleted, binding, err := deleteKameletBindingIfExists(ctx, c, integration)
+	if err != nil {
+		return err
+	}
+	if deleted {
+		// Deleting KameletBinding will automatically clean up the integration
+		fmt.Println("KameletBinding " + binding + " deleted")
+		return nil
+	}
+	return c.Delete(ctx, integration)

Review comment:
       Actually, the code already relies on the cascading delete. In this code, when the KameletBinding is `deleted` it early returns in the previous block so `c.Delete(ctx, integration)` won't be executed. Isn't it what you suggest?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org