feat:(CLI) add delete app, bundle and entry points#75
feat:(CLI) add delete app, bundle and entry points#75thabti wants to merge 7 commits intostaticdeploy:masterfrom
Conversation
|
Hello @sabeurthabti , great PR, thanks! Sorry had a busy day yesterday and didn't get around to review it yet, but I should be able to take a look at it tonight. For updating the website and the documentation, I think the only two files that need updating are the reference documentation for the CLI, and the CLI's README. |
|
No rush mate, thanks for the support. I'd like to contribute more, getting understanding of the architecture. |
|
@pscanf any update on this? the ci command runs perfectly fine on my machine. I tried to spend time to debug it .. not luck. |
|
Hadn't looked at the build yet, sorry. Definitely an odd error. Seeing that it's thrown by the Unfortunately these last days I got a bit swamped with work, so I can't offer much help until the second half of next week. |
|
As I suspected, the issue is caused by newer versions of s3Client.deleteObjects({
Bucket: "bucket",
Delete: { Objects: [] },
})Maybe this was not a legal operation to begin with, but older versions of In any case, I updated the integration test so that it won't issue such operations, and also updated the Some CI steps still fail, but I think it's because - for security reasons - some secret env variables are not injected in the PR pipelines, so those steps should succeed when the PR is merged. Alas, still haven't reviewed the code, will try to do that tomorrow. |
pscanf
left a comment
There was a problem hiding this comment.
Other than a few nitpicks, I have one change request and one doubt.
Change request
Split the delete command in two commands deleteAppWithEntrypoints (or maybe cleanupApp, or teardownApp) and deleteBundles.
Motivation
There is no connection between apps and bundles. They might have the same name, but it's by choice of whoever creates them, not a general rule. I could, for example, have bundles for my webapp my-webapp, which I sell to two different clients and deploy to the two apps client-A and client-B.
Doubt
The deleteApp command deletes entrypoints one by one, then deletes the app. This process could fail at any point, leaving StaticDeploy in an "unexpected" state. That is, the developer expects the app and all its entrypoints to have been deleted, but only a few entrypoints were deleted, while the others and the app still exist.
Solution
The ideal solution would be to move the process to the server, adding a CleanupAppByName usecase which issues all the delete commands in a transaction. However, this would greatly complicate things, so I think that given the unlikelihood of these failures, and given the relative harmless consequences, we can stick to the current implementation. I would however add some logs, for instance after each entrypoint deletion, so that it's easier for the user to see at which point of the process things went wrong (there are operation logs for that as well, but more feedback doesn't hurt).
| // Read the config file | ||
| const config = readStaticdeployConfig(configPath); | ||
|
|
||
| // Return the deploy config, defaulting to an empty object |
| // Options for the deploy command as specified above | ||
| }, | ||
| delete: { | ||
| // Options for the deploy command as specified above |
| }); | ||
|
|
||
| const apps = await client.apps.getAll(); | ||
| const app = apps.find((item) => item.name === argv.app); |
There was a problem hiding this comment.
Here you should handle the possibility of the app not existing, occurring for instance when the user specifies a non-existing app name, and throwing an error.
| const apps = await client.apps.getAll(); | ||
| const app = apps.find((item) => item.name === argv.app); | ||
| const appId = String(app?.id); | ||
| const appEntries = await client.entrypoints.getAll({ appId }); |
| const appId = String(app?.id); | ||
| const appEntries = await client.entrypoints.getAll({ appId }); | ||
|
|
||
| for (const index of appEntries.keys()) { |
There was a problem hiding this comment.
for (const { id } of entrypoints) {
await client.entrypoints.delete(id);
}| @@ -0,0 +1,168 @@ | |||
| // import StaticdeployClient from "@staticdeploy/sdk"; | |||
|
(Btw, sorry for the delay in reviewing, busy work period) |
|
thanks fo rthe comments, will spend today resolving them. @pscanf |
issue: #74
Adding CLI to support delete app, bundle and all attached entry points
usage: