ansible / eda-server-prototype

Apache License 2.0
33 stars 14 forks source link

Add Sync Project Endpoint #286

Closed Dostonbek1 closed 1 year ago

Dostonbek1 commented 1 year ago

Description

Adds an API endpoint to sync an existing project.

Currently syncs an existing project based on two factors:

  1. If the content of an existing file has changed, the code updates the respective DB entry.
  2. If there is a new file created, the code imports the file into its respective table (rulebook, inventory, etc.)
  3. TO BE IMPLEMENTED: If the existing file's name has changed but the content is the same.

Testing

Testing this PR mainly involves importing a Github project and syncing new changes from the project. Feel free to use the following test project.

  1. Fork this Github project
  2. Create an EDA project by calling POST on http://localhost:9000/api/projects with the following request body:
    {
    "url": "<link to your forked project repo>",
    "name": "Test Project",
    "description": "Test project"
    }
  3. Check the DB tables (project, rulebook, inventory, etc.) to make sure the project files have been imported.
  4. Push new changes to your forked repo; could be a new rulebook, extra_var, etc. files or change the contents of the existing files.
  5. Send a POST request on http://localhost:9000/api/projects/<project_id>.
  6. Verify the above request is successful.
  7. Check DB and verify all changes from the project have been synced including the git_hash of the project.

Resolves: AAP-5704