wso2 / wso2/api-platform

Improve configuration management in platform-api to use standard approach

Open
#83 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Type/Improvement
Dominant language
Go
Stars
71
Forks
111
Avg merge
1d 14h
Merged PRs (30d)
110

Description

Current Limitation

The configuration management in platform-api/src/config/config.go has several issues:

  1. Non-standard library dependency: Uses github.com/kelseyhightower/envconfig, which is a third-party library that's not widely adopted as a standard
  2. Environment variables only: All configuration is only read from environment variables, with no support for config files (YAML/JSON)
  3. Hardcoded overrides: Lines 97-98 hardcode database driver and path values, overriding the environment variable configuration:
    settingInstance.Database.Driver = "sqlite3"
    settingInstance.Database.Path = "./data/api_platform.db"
    

This approach lacks flexibility and makes configuration management inconsistent.

Suggested Improvement

Replace the current configuration approach with a more standard and consistent solution:

  1. Use a configuration file (e.g., config.yaml) for managing application configuration

  2. Support multiple configuration sources in order of precedence:

    • Command-line flags (highest priority)
    • Environment variables
    • Configuration file (config.yaml)
    • Default values (lowest priority)
  3. Remove hardcoded values and ensure all configuration comes from the defined sources

Benefits

  • More flexible configuration management
  • Better alignment with Go ecosystem standards
  • Easier to manage different environment configurations
  • No hardcoded overrides that bypass configuration system

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with platform-api/src/config/config.go, including the hardcoded assignments on lines 97-98, and trace how github.com/kelseyhightower/envconfig currently loads settings. Define the intended precedence among flags, environment variables, config.yaml, and defaults before changing the design. Done means configuration comes from those defined sources without hardcoded overrides and supports the requested file formats.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
backend
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.