Skip to content

Refactor server configuration and internal module structure#147

Merged
akiidjk merged 3 commits intorefactor/configfrom
refactor/akiidjk-server
Apr 1, 2026
Merged

Refactor server configuration and internal module structure#147
akiidjk merged 3 commits intorefactor/configfrom
refactor/akiidjk-server

Conversation

@akiidjk
Copy link
Copy Markdown
Collaborator

@akiidjk akiidjk commented Mar 31, 2026

Server Config management refactor

Refactor server config management based on the #146 PR by @giovanni-iannaccone, i replicated the same implementation used in the client and also change the Statuses handling by int with enum (#142), updated also tests based on new implementation and change the method to handling VERSION in the build


COPILOT SUMMARY

This pull request introduces significant refactoring and modernization to the CookieFarm client, especially around API handling, configuration management, and CI/CD improvements. The main highlights include a complete rewrite of the client API HTTP logic, a major cleanup and simplification of the configuration command handling, enhancements to the Dockerfile for improved security, and updates to CI workflows and linting rules.

API Client Refactor and Configuration Handling:

  • Major refactor of the client API: Introduced a new Client struct in api/http.go to encapsulate HTTP logic, token management, and request methods (get, postJSON, postForm), replacing the previous ad-hoc approach and simplifying error handling and authentication. ([[1]](https://github.com/ByteTheCookies/CookieFarm/pull/147/files#diff-8cfda5b1b8a36f6a2b7bcba8899b9d762c82b73c4f0c81466e9d261e86912286R1-R113), [[2]](https://github.com/ByteTheCookies/CookieFarm/pull/147/files#diff-541421de56f950a17be957aef633c8e0ba38e120dbaa26564402391f8388cb2aL1-R100))
  • Simplified and modernized the configuration command system: Renamed and refactored cmd/config.go to cmd/args.go, streamlined flag handling, and improved the update, login, logout, and show logic to use a singleton config instance and more idiomatic Go patterns. ([[1]](https://github.com/ByteTheCookies/CookieFarm/pull/147/files#diff-799c55e86d41152eaf3a3e34e1433c04ac86dc52902c11fc36192fd5dee5ce10L1), [[2]](https://github.com/ByteTheCookies/CookieFarm/pull/147/files#diff-799c55e86d41152eaf3a3e34e1433c04ac86dc52902c11fc36192fd5dee5ce10L16-R125), [[3]](https://github.com/ByteTheCookies/CookieFarm/pull/147/files#diff-799c55e86d41152eaf3a3e34e1433c04ac86dc52902c11fc36192fd5dee5ce10L152-R135), [[4]](https://github.com/ByteTheCookies/CookieFarm/pull/147/files#diff-799c55e86d41152eaf3a3e34e1433c04ac86dc52902c11fc36192fd5dee5ce10L161-R152))

Security and Docker Improvements:

  • Hardened the Dockerfile: Changed the base image to a specific Alpine version, added a non-root user (vincenzino), and set the container to run as this user for improved security. Also fixed the build context to only copy the server directory. ([cookiefarm/DockerfileL9-R20](https://github.com/ByteTheCookies/CookieFarm/pull/147/files#diff-f3723ada23514f7af4b71d258d2c2f5a8cbd08a808429e5198d38ef4a241130fL9-R20))

CI/CD and Linting Enhancements:

  • Expanded CI workflow: Updated .github/workflows/sonar.yml to include running Go tests with coverage before SonarQube analysis, fixed shallow clone issues, and added a SonarQube quality gate step. ([[1]](https://github.com/ByteTheCookies/CookieFarm/pull/147/files#diff-9a1c250ec072fc76ad44435cd9462d5693ea81f304d650922d3c2792bef267c2L1-R1), [[2]](https://github.com/ByteTheCookies/CookieFarm/pull/147/files#diff-9a1c250ec072fc76ad44435cd9462d5693ea81f304d650922d3c2792bef267c2L13-R48))
  • Improved linting: Enabled additional linters (dupl, zerologlint, whitespace) and configured the dupl linter with a threshold in .golangci.yml for better code quality enforcement. ([[1]](https://github.com/ByteTheCookies/CookieFarm/pull/147/files#diff-6179837f7df53a6f05c522b6b7bb566d484d5465d9894fb04910dd08bb40dcc9R30), [[2]](https://github.com/ByteTheCookies/CookieFarm/pull/147/files#diff-6179837f7df53a6f05c522b6b7bb566d484d5465d9894fb04910dd08bb40dcc9L59-R61), [[3]](https://github.com/ByteTheCookies/CookieFarm/pull/147/files#diff-6179837f7df53a6f05c522b6b7bb566d484d5465d9894fb04910dd08bb40dcc9R83-R85))

Dependency Updates:

  • Added github.com/stretchr/testify as a test dependency in go.mod for improved testing capabilities. ([cookiefarm/client/api/go.modR12](https://github.com/ByteTheCookies/CookieFarm/pull/147/files#diff-3adfb85d1ae8e32ff5c1112b6803c559264f4bb187d856dd58dbff4a7c8c2c68R12))

These changes collectively make the client more maintainable, secure, and robust, while also improving developer experience and code quality enforcement.

akiidjk added 3 commits March 31, 2026 12:53
Update go.work to reference new internal paths and add
server/internal/config go.mod

Refactor config package: use sharedconfig.Shared for SharedConfig
and add a Config struct to hold flagTTL
Convert flag status from string to int across models, database schema,
queries, protocols and tests
Add a ConfigManager singleton for server configuration and inject it
into
Runner, handlers and related components
Update sqlc config and internal package paths, add controllers module,
and misc refactors (slice append optimization, import tweaks)
@akiidjk akiidjk self-assigned this Mar 31, 2026
@akiidjk akiidjk added enhancement New feature or request Clean Code Clean THIS! go Pull requests that update go code labels Mar 31, 2026
Copy link
Copy Markdown
Member

@giovanni-iannaccone giovanni-iannaccone left a comment

Choose a reason for hiding this comment

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

LGTM

@akiidjk akiidjk merged commit cc1b3cf into refactor/config Apr 1, 2026
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Clean Code Clean THIS! enhancement New feature or request go Pull requests that update go code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants