Skip to content
This repository has been archived by the owner on May 30, 2022. It is now read-only.

Don't let the app crash on 404s #97

Merged

Conversation

fabriziosestito
Copy link
Member

@fabriziosestito fabriziosestito commented Jun 15, 2021

This PR adds checks and adds error handling on every parametric route (e.g./hosts/:host)
It also adds tests for every handler.

WIP:

I am not sure on how the NewLandscapeHandler should behave, since it just tries to pull all the environments and then passes them to the view context, which does some filtering if the envName query param is passed or it just shows all the environments otherwise.
See:

func NewLandscapeHandler(client consul.Client) gin.HandlerFunc {

I could cycle to check if the landscape exists, but I think I am missing some context here.

Thoughts?

@rtorrero
Copy link
Contributor

@fabriziosestito great work again!

@lee-martin This probably belongs to a different discussion but as they are mentioned here: are we keeping the environments? it might make little sense making changes on them if they are going to go anyway.

@arbulu89
Copy link
Contributor

This PR adds checks and adds error handling on every parametric route (e.g./hosts/:host)
It also adds tests for every handler.

WIP:

I am not sure on how the NewLandscapeHandler should behave, since it just tries to pull all the environments and then passes them to the view context, which does some filtering if the envName query param is passed or it just shows all the environments otherwise.
See:

func NewLandscapeHandler(client consul.Client) gin.HandlerFunc {

I could cycle to check if the landscape exists, but I think I am missing some context here.

Thoughts?

Hi @fabriziosestito ,

The why about the sending the environment in the NewLandscapeHandler is that we show the environment which this particular landscape belongs to in the view.
As the environment -> landscape -> system is a hierarchical thing, the landscape itself doesn't store which is its environment. That's why we pass it.
About the filtering, I think this is some leftover, as initially the landscape didn't have to belong to any environment by force. I think we could remove the statement where it checks if the environment is empty.

This way, we need to guarantee that the environment is passed in the query, and the provided c.Param("land") exists in the loaded environments

@fabriziosestito
Copy link
Member Author

fabriziosestito commented Jun 15, 2021

About the filtering, I think this is some leftover, as initially the landscape didn't have to belong to any environment by force. I think we could remove the statement where it checks if the environment is empty.

I think that the filtering is still needed, because we are using the sapystems_table partial also in the sapsystems list view, and it expects many or one environment (by filtering).

If I can assume that the envName has to be an existing environment in the NewLandscapeHandler I can just 404 if I find this is not true and keep the template as it is in this PR and we can think maybe to restructure it later.

@fabriziosestito fabriziosestito marked this pull request as ready for review June 15, 2021 14:36
@fabriziosestito fabriziosestito changed the title WIP: Don't let the app crash on 404s Don't let the app crash on 404s Jun 15, 2021
Copy link
Member

@stefanotorresi stefanotorresi left a comment

Choose a reason for hiding this comment

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

LGTM.

Copy link
Contributor

@rtorrero rtorrero left a comment

Choose a reason for hiding this comment

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

This looks already like it's good to merge. Thanks!

@stefanotorresi stefanotorresi merged commit 6d2bfbd into trento-project:main Jun 16, 2021
@stefanotorresi
Copy link
Member

gj 🏖️

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants