Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build checks catalog #3

Merged
merged 9 commits into from
Mar 18, 2022

Conversation

arbulu89
Copy link
Contributor

@arbulu89 arbulu89 commented Mar 17, 2022

Implement the checks catalog built process.

This is what we have:

In the Ansible code:

  • Update the ansible code to create the catalog for all the available providers. It looks in the ansible/vars folder for the different entries, and based on the folders there, it will create a catalog entry for each of the items. So the catalog now is compose like a map where the key is the provider name, and it contains the catalog (the same we were using now).
  • Besides this, the catalog is stored in a file (provider in CATALOG_DESTINATION instead of posted to the trento web server

Rest of the code:

  • Restructure the App creation to make it testeable with the Dependencies usage.
  • Transform the Runner struct to a service like struct. To make the mocks possible
  • Add /api/ready and /api/catalog GET requests
  • Build the catalog on boot up. The catalog later on is stored on memory, in the runner service. During the catalog creation the /api/ready endpoints returns {"ready": false} and it is set to true once the catalog creation is done
  • The catalog build process is like:
  1. Start ansible process
  2. Ansible creates the catalog and dump it to a file
  3. Golang reads the file and loads it to a variable

The /api/catalog would return something like this:
image

PD: If at some point, we want to send the catalog creation as an event, we could use the future webhooks logic, and sent the created catalog once it is built

PD2: By now, all the golang code goes in the same folder, as I didn't want to make more fuzz of it. We can change in the next PR if needed

@arbulu89 arbulu89 force-pushed the feature/return-catalog branch from 7c4656a to 4b4768f Compare March 18, 2022 07:44
@arbulu89 arbulu89 force-pushed the feature/return-catalog branch from 563fed9 to c84666b Compare March 18, 2022 08:15
@arbulu89 arbulu89 marked this pull request as ready for review March 18, 2022 08:22

func CatalogHandler(runnerService RunnerService) gin.HandlerFunc {
return func(c *gin.Context) {
c.JSON(200, runnerService.GetCatalog())
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This returns always 200 state, even though you request the catalog and it is not ready.
We can modify it of course

Copy link
Contributor

@dottorblaster dottorblaster left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One nitpick then we can go

runner/app.go Outdated Show resolved Hide resolved
@arbulu89 arbulu89 requested a review from dottorblaster March 18, 2022 09:16
@dottorblaster dottorblaster merged commit ed22c4a into trento-project:main Mar 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants