Skip to content

Implement project specific undeploy command - #98

Merged
sciabarracom merged 8 commits into
apache:mainfrom
almartino:issue-117
Oct 25, 2025
Merged

Implement project specific undeploy command#98
sciabarracom merged 8 commits into
apache:mainfrom
almartino:issue-117

Conversation

@almartino

Copy link
Copy Markdown
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

@almartinoalmartino changed the title Implement project Implement project specific undeploy commandJun 16, 2025
@wtfzambo

wtfzambo commented Jun 18, 2025

Copy link
Copy Markdown
Contributor

@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).

added a process.exit inside undeploy. Added missing license header on info.js and syncDeployInfo.js. Added icons on error messages
@sciabarracom
sciabarracom merged commit f2dffc6 into apache:mainOct 25, 2025
Sign up for freeto 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.

4 participants

@almartino@wtfzambo@sciabarracom@d4rkstar