Skip to content

Implement project specific undeploy command #98

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

almartino
Copy link
Contributor

The solution implements a project-specific undeployment mechanism that:

  1. Keeps track of which packages and actions are deployed in the current project
  2. Organizes actions by package in a more detailed structure
  3. Allows removing a specific action and updating the deployment file
  4. Returns an error if executed in a directory without an OpenServerless project

Implementation Details

1. Improved Structure for Deployment Information

When ops ide deploy is executed, the system now saves information about deployed packages and actions in a file with an improved structure:

  • Information is stored in .ops/deployment.json in the project root
  • The file contains a JSON object with:
    • packages: An array of package names that have been deployed
    • packageActions: An object that maps each package to an array of its actions

Example:

{
    "packages": ["foo", "bar", "baz"],
    "packageActions": {
        "foo": ["hello", "world"],
        "bar": ["some_action"],
        "baz": []
    }
}
Sidenote 1: could be useful to automatically add the .ops dir to the .gitignore file when creating a project?
Sidenote 2: should we make this retro compatible for projects prior to this fix?

2. Project-Specific Undeployment

When ops ide undeploy is executed without arguments:

  • The system checks for the existence of .ops/deployment.json
  • If the file exists, it reads the deployment information
  • It removes only the actions and packages listed in the file
  • If the file doesn't exist, it returns an error message indicating that no OpenServerless project was found

3. Single Action Undeployment

When ops ide undeploy contact/index is executed:

  • The system removes the specific action
  • It updates the .ops/deployment.json file to remove the action from the list
  • If the package no longer has actions, it also removes the package from the list

references apache/openserverless#117

@almartino almartino changed the title Implement project Implement project specific undeploy command Jun 16, 2025
@wtfzambo
Copy link

wtfzambo commented Jun 18, 2025

@almartino thanks for taking the time to work on this! This is pretty much the idea I had in mind when I opened the issue (and executed way better than I would have been able to).

I just tested it on the openserverless tutorial and I encountered just a small issue:

error: Unable to delete package 'contact': Package not empty (contains 2 entities).
Set force param or delete package contents.

The 2 entities are the sequences: submit-write and submit-notify. Maybe sequences should be added too to deployment.json?

Regarding your questions:

  1. could be useful to automatically add the .ops dir to the .gitignore file when creating a project?

I think .ops dir should be version controlled 🤔. Imagine a CICD pipeline running either ops ide deploy / undeploy. What would happen if it didn't have access to deployment.json?

  1. should we make this retro compatible for projects prior to this fix?

I wouldn't bother: the deployment.json file can be generated on an existing project by running ops ide deploy once, which will just update the current packages and actions AND generate the file. I didn't encounter other issues (albeit, I tested it on a simple deployment).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants