Skip to content

chore: remove gin and zap from test app#911

Open
silvestre wants to merge 6 commits intomainfrom
remove-gin
Open

chore: remove gin and zap from test app#911
silvestre wants to merge 6 commits intomainfrom
remove-gin

Conversation

@silvestre
Copy link
Member

Issue

As an app-autoscaler developer
I want to have as few dependencies as possible
So that I don't have to watch out for so many vulnerabilities in
unmaintained dependencies.

Fix

  • As we already have two HTTP libraries (gorilla/mux and net/http) get
    rid of a third one for the test app (gin).
  • As we already have two log libraries (lager and slog) get rid of a
    third one for the test app (zap).

AI Disclaimer

Prompted by the committer, most of the work was done by GitHub copilot.

@silvestre silvestre added the skip-dependency-postprocessing This label prevents a dependency post-processing that is normally required for Renovate PRs mostly label Jan 29, 2026
@silvestre silvestre marked this pull request as ready for review January 29, 2026 15:58
@silvestre
Copy link
Member Author

@geigerj0 Sorry, I now recognized that this PR was set to ready to early.

What happened is that I was working on it over on app-autoscaler-release and stopped when when the move of the repository was starting.

I then came back to it a few months later and thought it was ready when I ported it over, but did not really check my work.

My bad, sorry for having you look for such glaring issues, that I should have caught. I think I was blinded by the tests all passing.

# 4. Optionally: `make generate-fakes` to update the fakes as well.
.PHONY: go-mod-tidy
go-mod-tidy: ./go.mod ./go.sum ${go_deps_without_fakes}
go-mod-tidy: ./go.mod ./go.sum ${go_deps_without_fakes} ## run go mod tidy
Copy link
Contributor

Choose a reason for hiding this comment

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

do you find these comments helpful? 🤷

Copy link
Member Author

@silvestre silvestre Feb 3, 2026

Choose a reason for hiding this comment

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

Yes, they are part of 9f2770a and this how it looks like:

$ make help
build                build the app
check                run linting, build and tests
clean                clean up build artifacts
deploy               Deploy the app to Cloud Foundry, requires the CONFIG env variable to be pointing to the acceptance test config file
generate-fakes       generate Go code (fakes, clients from OpenAPI specs)
go-mod-tidy          run go mod tidy
help                 Show this help
lint-fix             run linting with auto-fix
start                start the app locally in a cflinuxfs5 container
test                 run tests

WDYT?

go_deps_without_fakes = $(shell find . -type f -name '*.go' \
| grep --invert-match --regexp='${app-fakes-dir}')

.PHONY: help
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

Hmm, it seems the Go 1.25 update came in through renovate already ...

@@ -1,75 +1,53 @@
module code.cloudfoundry.org/app-autoscaler-release/src/acceptance/assets/app/go_app
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

}
c.JSON(http.StatusOK, gin.H{"utilization": utilisation, "minutes": minutes})
if err := writeJSON(w, http.StatusOK, JSONResponse{"utilization": utilisation, "minutes": minutes}); err != nil {
slog.Error("Failed to write JSON response", slog.Any("error", err))
Copy link
Contributor

Choose a reason for hiding this comment

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

why not using the logger that got already passed to the func?

Suggested change
slog.Error("Failed to write JSON response", slog.Any("error", err))
logger.Error("Failed to write JSON response", slog.Any("error", err))

# Issue
As an app-autoscaler developer
I want to have as few dependencies as possible
So that I don't have to watch out for so many vulnerabilities in
unmaintained dependencies.

# Fix

- As we already have two HTTP libraries (gorilla/mux and net/http) get
rid of a third one for the test app (gin).
- As we already have two log libraries (lager and slog) get rid of a
third one for the test app (zap).

# AI Disclaimer

Prompted by the committer, most of the work was done by GitHub Copilot.
# Issue

The package names still referenced the old `app-autoscaler-release`
repo.

# Fix

Adapt to the new location
# Issue

The app was responding to every GET request with a successful request, regardless of path

# Fix

Use `/{$}` to match root path "/" exactly, see https://pkg.go.dev/net/http#hdr-Patterns-ServeMux
# Issue

Having to read through `Makefile` to understand which targets are available is cumbersome.

# Fix

add some self-documentation which can be shown with the default `help` target.
# Issue

The stop endpoint was inadvertently renamed.

# Fix

Rename it back.
# Issue

otel was updated inadvertently

# Fix

revert otel to previous version
@sonarqubecloud
Copy link

sonarqubecloud bot commented Feb 3, 2026

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

chore skip-cleanup skip-dependency-postprocessing This label prevents a dependency post-processing that is normally required for Renovate PRs mostly

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants