deprecated-oc-catalog/README.md

99 lines
3.3 KiB
Markdown
Raw Normal View History

2023-03-03 14:43:11 +01:00
# OC Catalog
2023-03-03 11:49:07 +01:00
2023-10-18 11:01:41 +02:00
## OpenCloud Catalog API
2023-03-03 14:43:11 +01:00
2023-10-18 11:01:41 +02:00
Uses the Beego framework
To install the Beego bee command :
go install github.com/beego/bee/v2@master
2024-02-19 17:24:14 +01:00
## Running the app locally
In order to run the application we need to correct some errors that beego generates.
2023-10-18 11:01:41 +02:00
2024-02-19 17:24:14 +01:00
**Router generation**
2023-03-03 14:43:11 +01:00
2024-02-19 17:24:14 +01:00
Beego generates the routers from the comment of the controllers methods. However, there seems to be some errors when we let beego generate th routers from `bee run`.
We need to use `bee generate routers` to have a working router file.
**Swagger generation**
Using `bee run -downdoc=true -gendoc=true` beego download a swagger template and generate the JSON file (swagger.json) in `swagger/`. However the swagger template in `swagger/index.html` does not change the exemple's url for our current JSON file. When running locally we have to edit the call to construct the object holding the swagger information, with the parameter url set with the relative path to our JSON swagger file :
```
const ui = SwaggerUIBundle({
url: "swagger.json",
...
...
});
```
This issue is fixed in the Dockerfile build with two `sed` to change the value of the swagger file URL.
## Deployment with Docker compose
2023-03-03 14:43:11 +01:00
Deploy with docker:
`docker-compose -f docker-compose.yml -f docker-compose.backend.yml up --build`
and populate DB (or other scripts) with:
`docker exec -it oc-catalog_oc-catalog_1 ./scripts/populate_models.sh ./scripts/demo.json`
2023-10-18 11:01:41 +02:00
or out of docker `./scripts/populate_models.sh ./scripts/demo.json`
2024-02-19 17:24:14 +01:00
### Dev
- Start DB with `docker-compose up -d`
- Run the API with `bee run -downdoc=true -gendoc=true`
2023-03-03 14:43:11 +01:00
2024-02-19 17:24:14 +01:00
### Multinode
2023-03-03 14:43:11 +01:00
2024-02-19 17:24:14 +01:00
Deploy :
2023-03-03 14:43:11 +01:00
`docker-compose -f docker-compose.yml -f docker-compose.backend.yml -f docker-compose.multi.yml up --build`
2024-02-19 17:24:14 +01:00
## Populating the MongoDB database
2024-07-04 15:56:36 +02:00
On the machine running the mongoDB container, from the root of the project run this line :
2024-02-19 17:24:14 +01:00
2024-07-04 15:56:36 +02:00
`./scripts/populate_models.sh ./scripts/demo.json`
2024-02-19 17:24:14 +01:00
This script should be updated to be ran from anywhere.
# More documentation
2024-03-29 17:55:38 +01:00
[Visit the docs/ directory](/docs/)
## UML
We are currently using [goplantuml](https://github.com/jfeliu007/goplantuml/) to generate the oject diagrams directly from the go files. This tools creates `.plums` files directly from the directory where the go files are located. These UML files can then be visualized using plantuml and the VS Code extensions plantuml.
**Setting up the plantuml environment** :
```
# Downloading the go tool goplantuml
go get github.com/jfeliu007/goplantuml/parser
go install github.com/jfeliu007/goplantuml/cmd/goplantuml@latest
# Install the plantuml environment
sudo apt install default-jre
sudo apt install plantuml
```
**Rich PlantUML extension Link**: https://marketplace.visualstudio.com/items?itemName=jebbs.plantuml or search it in the marketplace panel of VS Code
**Generate and view an UML diagram**
```
goplantuml path/to/code/directory > path/to/dest/file.puml
```
- open the .puml file generated
- alt + d to have the extension preview the plantUML code
- right click inside the .puml and select 'Export Current Diagram' to create an image file
- the output will be generated in a `out/` directory in the current path
### Note
Only `.puml` files ought to be commited to the git repository, because their nature allows to track changes, while image file do not fit the purpose of versioning.