Go to file
pb a1f04dc2f0 bugfix empty workflow 2024-04-25 15:48:32 +02:00
conf Solved the problem of generating swagger and minimal image (scratch) 2024-02-19 17:57:06 +01:00
controllers Modified the conf loading process, now with onion in conf/conf.go 2024-02-19 17:57:06 +01:00
docs New class link to handle links between components and possible errors 2024-04-16 16:12:54 +02:00
models bugfix empty workflow 2024-04-25 15:48:32 +02:00
out/docs/UML/plantuml/diagram_object_models added some doc 2024-04-09 15:40:03 +02:00
routers Fixed router not working 2024-02-19 17:57:06 +01:00
scripts bugfix empty workflow 2024-04-25 15:48:32 +02:00
selfapi initial commit 2023-03-03 14:43:11 +01:00
services Swagger returning only 404s 2024-02-19 17:57:06 +01:00
.dockerignore initial commit 2023-03-03 14:43:11 +01:00
.gitignore initial commit 2023-03-03 14:43:11 +01:00
Dockerfile corrected typo in dockerfile 2024-04-11 17:01:24 +02:00
LICENSE Initial commit 2023-03-03 11:49:07 +01:00
README.md improved UML documentation 2024-04-11 17:06:22 +02:00
conf_template.json Modified the conf loading process, now with onion in conf/conf.go 2024-02-19 17:57:06 +01:00
docker-compose.backend.yml Fixed router not working 2024-02-19 17:57:06 +01:00
docker-compose.multi.yml initial commit 2023-03-03 14:43:11 +01:00
docker-compose.yml Swagger returning only 404s 2024-02-19 17:57:06 +01:00
docker_catalog.json Swagger returning only 404s 2024-02-19 17:57:06 +01:00
go.mod structtomap import 2024-04-16 16:16:15 +02:00
go.sum structtomap import 2024-04-16 16:16:15 +02:00
local_catalog.json improved Dockerisation 2024-02-19 17:57:06 +01:00
main.go Swagger returning only 404s 2024-02-19 17:57:06 +01:00

README.md

OC Catalog

OpenCloud Catalog API

Uses the Beego framework

To install the Beego bee command :

go install github.com/beego/bee/v2@master

Running the app locally

In order to run the application we need to correct some errors that beego generates.

Router generation

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

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

or out of docker ./scripts/populate_models.sh ./scripts/demo.json

Dev

  • Start DB with docker-compose up -d
  • Run the API with bee run -downdoc=true -gendoc=true

Multinode

Deploy :

docker-compose -f docker-compose.yml -f docker-compose.backend.yml -f docker-compose.multi.yml up --build

Populating the MongoDB database

From the root of the projet run :

./scripts/multinode.sh ./scripts/demo.json

This script should be updated to be ran from anywhere.

More documentation

Visit the docs/ directory

UML

We are currently using 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.