Skip to content

2010 | Use a Library for Reading Configuration from Environment Variables#2019

Open
nandhu-kumar wants to merge 1 commit into
mosip:develop-gofrom
nandhu-kumar:develop-2010
Open

2010 | Use a Library for Reading Configuration from Environment Variables#2019
nandhu-kumar wants to merge 1 commit into
mosip:develop-gofrom
nandhu-kumar:develop-2010

Conversation

@nandhu-kumar

@nandhu-kumar nandhu-kumar commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • New Features

    • Loads .env from the working directory at startup early enough to affect configuration and logging level.
  • Documentation

    • Updated the README and .env example to reflect .env loading behavior across development runs, builds, Docker, and tests, and that real environment variables override .env.
  • Improvements

    • More consistent, resilient environment-based configuration parsing across auth, engine, database, Redis, and issuer/JWKS-related settings, including safer defaults and improved fallback rules for empty/invalid values.
  • Tests

    • Added/expanded unit tests for .env initialization and configuration loaders (including Redis parsing and lenient “lax” decoding).

@coderabbitai

coderabbitai Bot commented Jun 19, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

The PR refactors the esignet-service configuration subsystem to load .env at startup via godotenv and parse all env vars through envconfig spec structs. It introduces lax decoders (laxBool, laxInt, laxInt64, secondsDuration) and a process helper, removes manual os.Getenv calls from all seven config loaders, adds a config.Init() entry point called early in main(), and adds new tests for decoder types, clientmgmt, and Redis loaders.

Changes

Envconfig-driven configuration loading

Layer / File(s) Summary
Dependencies, .env loading, and entry point wiring
esignet-service/go.mod, esignet-service/internal/config/init.go, esignet-service/cmd/esignet/main.go, esignet-service/.env.example, esignet-service/README.md
Adds godotenv and envconfig module dependencies, introduces config.Init() that loads .env without overriding already-set env vars, wires config.Init() into main() before logger initialization, and updates docs to describe startup loading behavior.
Lax envconfig decoders and process helper
esignet-service/internal/config/types.go
Adds laxBool, laxInt, laxInt64, secondsDuration decoders (never fail; log warnings on bad input), a process wrapper around envconfig.Process, and applyStringDefaults (reflection-based empty-string-to-default restoration).
Tests for decoders and config.Init
esignet-service/internal/config/types_test.go
Tests cover all four lax decoders (boolean spellings, invalid integer fallback, seconds-to-duration conversion), the process helper's empty-string-to-default behavior, and config.Init() precedence and missing-file handling.
Authentication provider loader
esignet-service/internal/config/authn.go
Refactors LoadAuthn to use an internal authnSpec struct processed via process(&s), replacing the previous manual envOrDefault call and module-level fallback.
Client management loader and tests
esignet-service/internal/config/clientmgmt.go, esignet-service/internal/config/clientmgmt_test.go
Refactors LoadClientMgmt to use spec-driven parsing; derives JWKS endpoint from issuer when env var is empty; defaults required scope and applies cache TTL fallback logic. Tests cover defaults, overrides, and invalid-TTL behavior.
Database configuration loader
esignet-service/internal/config/db.go
Refactors LoadDB to use spec-driven parsing; constructs DSN from POSTGRES_URL or builds from host/port/db/user, conditionally omitting password to avoid lib/pq misparse; normalizes pool tuning parameters via fallback logic.
Engine and OAuth loader
esignet-service/internal/config/engine.go
Refactors LoadEngine to use spec-driven parsing; preserves gate-client port fallback and default issuer construction; removes legacy custom parsing helpers.
MOSIP authentication loader
esignet-service/internal/config/mosip.go, esignet-service/internal/config/mosip_test.go
Refactors LoadMosipAuthn to use spec-driven parsing; trims trailing slashes from API base URL; conditionally derives per-endpoint URLs and defaults DomainURI. Test assertions updated for empty-base-URL behavior.
Redis loader and tests
esignet-service/internal/config/redis.go, esignet-service/internal/config/redis_test.go
Refactors LoadRedis to use spec-driven parsing; moves connection defaults to struct tags; normalizes pool size and all timeout durations via fallback logic; preserves sentinel address parsing. Tests cover defaults, override mapping, sentinel normalization, and invalid-numeric fallback.
SunbirdRC authentication loader
esignet-service/internal/config/sunbird.go
Refactors LoadSunbirdAuthn to use spec-driven parsing; request timeout parsed via lax decoder and falls back to default when non-positive; optional strings defaulted by checking for empty values after processing.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

  • mosip/esignet#1973: Both PRs refactor SunbirdRC authentication configuration loading (LoadSunbirdAuthn, URL normalization, defaults, and timeout parsing).
  • mosip/esignet#1989: Both PRs refactor DB, Redis, and client-management configuration loaders, replacing direct os.Getenv parsing with structured approaches.

Suggested reviewers

  • mohanachandran-s
  • zesu22

Poem

🐇 Hop, hop, no more os.Getenv loops,
A .env file now joins the startup troops!
laxInt won't crash on a mistyped string,
godotenv loads the whole configuration ring.
Defaults restored by reflection's gentle paw—
The cleanest config this rabbit ever saw! 🌿

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 40.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main objective: introducing a library-based approach for reading environment variables, which is the core change across the configuration module.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@esignet-service/internal/config/engine.go`:
- Around line 87-94: The condition checking gatePort validity at the beginning
of the fallback block only validates against zero but allows negative values to
pass through as invalid port numbers. Modify the condition `if gatePort == 0` to
`if gatePort <= 0` to ensure that both zero and negative port values trigger the
fallback logic that defaults to either the parsed s.Port value or
defaultGatePort, preventing invalid negative port configurations from
propagating at runtime.

In `@esignet-service/internal/config/sunbird.go`:
- Around line 90-93: The EntityURL field in the SunbirdAuthn struct
initialization is missing whitespace trimming before slash normalization. Apply
strings.TrimSpace to the EntityURL value (similar to how SearchURL is handled)
before passing it to the trimTrailingSlash function to ensure leading and
trailing whitespace is removed before the trailing slash is normalized.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 5a97d025-bbd6-4e7f-bafb-4b96bbcc2f44

📥 Commits

Reviewing files that changed from the base of the PR and between d701aad and eb04ef6.

⛔ Files ignored due to path filters (1)
  • esignet-service/go.sum is excluded by !**/*.sum
📒 Files selected for processing (16)
  • esignet-service/.env.example
  • esignet-service/README.md
  • esignet-service/cmd/esignet/main.go
  • esignet-service/go.mod
  • esignet-service/internal/config/authn.go
  • esignet-service/internal/config/clientmgmt.go
  • esignet-service/internal/config/clientmgmt_test.go
  • esignet-service/internal/config/db.go
  • esignet-service/internal/config/engine.go
  • esignet-service/internal/config/init.go
  • esignet-service/internal/config/mosip.go
  • esignet-service/internal/config/redis.go
  • esignet-service/internal/config/redis_test.go
  • esignet-service/internal/config/sunbird.go
  • esignet-service/internal/config/types.go
  • esignet-service/internal/config/types_test.go

Comment thread esignet-service/internal/config/engine.go Outdated
Comment thread esignet-service/internal/config/sunbird.go Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@esignet-service/internal/config/mosip.go`:
- Around line 40-54: The endpoint construction logic for certURL, sendOTP,
kycAuth, and kycExchange currently builds invalid relative paths when APIBaseURL
(apiBase) is empty. Guard all the fallback URL construction assignments (the
concatenation operations that append paths like "/mosip-certs/ida-partner.cer",
"/idauthentication/v1/otp/", etc.) by first checking if apiBase is non-empty
before executing these assignments. If apiBase is empty, these derived URLs
should not be constructed from the empty base.

In `@esignet-service/internal/config/redis.go`:
- Around line 112-113: The ConnMaxLifetime field currently allows negative
values to be used directly, which breaks the intended non-positive fallback
strategy. In the line where lifetime is assigned from s.ConnMaxLifetime, add a
check to clamp any negative ConnMaxLifetime value to 0 before creating the
time.Duration. This ensures that negative values are treated the same as 0
(meaning no limit), maintaining consistency with the other duration settings'
fallback behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 1cc054fe-ac92-4ca6-a91b-a06d0799eb2b

📥 Commits

Reviewing files that changed from the base of the PR and between eb04ef6 and 38e8257.

⛔ Files ignored due to path filters (1)
  • esignet-service/go.sum is excluded by !**/*.sum
📒 Files selected for processing (16)
  • esignet-service/.env.example
  • esignet-service/README.md
  • esignet-service/cmd/esignet/main.go
  • esignet-service/go.mod
  • esignet-service/internal/config/authn.go
  • esignet-service/internal/config/clientmgmt.go
  • esignet-service/internal/config/clientmgmt_test.go
  • esignet-service/internal/config/db.go
  • esignet-service/internal/config/engine.go
  • esignet-service/internal/config/init.go
  • esignet-service/internal/config/mosip.go
  • esignet-service/internal/config/redis.go
  • esignet-service/internal/config/redis_test.go
  • esignet-service/internal/config/sunbird.go
  • esignet-service/internal/config/types.go
  • esignet-service/internal/config/types_test.go

Comment thread esignet-service/internal/config/mosip.go Outdated
Comment thread esignet-service/internal/config/redis.go Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@esignet-service/internal/config/mosip.go`:
- Around line 37-57: The raw environment variable strings assigned to apiBase at
line 37 (via s.APIBaseURL) and domainURI at line 55 (via s.DomainURI) can
contain leading or trailing spaces, which bypass the empty string checks and
result in malformed URLs. Normalize whitespace by trimming leading and trailing
spaces from all raw env string assignments: s.APIBaseURL before passing to
trimTrailingSlash, s.DomainURI, s.SendOTPBaseURL, s.KYCAuthBaseURL, and
s.KYCExchangeBaseURL. Apply a whitespace trim function (such as
strings.TrimSpace) to each of these values before they are used in the empty
checks and URL construction logic.

In `@esignet-service/internal/config/sunbird.go`:
- Around line 73-88: The Sunbird field validation logic (for idField,
entityIDField, fieldDetails, and claimsMapping) currently only checks for empty
strings but does not handle whitespace-only values. Apply the strings.TrimSpace
function to each field before checking if it equals an empty string, so that
whitespace-only environment values are properly treated as empty and replaced
with their respective default values (defaultSunbirdIDField,
defaultSunbirdEntityIDField, defaultSunbirdFieldDetails,
defaultSunbirdClaimsMapping).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: f4730db4-7e48-4da4-9e7e-c44b37b4e509

📥 Commits

Reviewing files that changed from the base of the PR and between 38e8257 and e384671.

⛔ Files ignored due to path filters (1)
  • esignet-service/go.sum is excluded by !**/*.sum
📒 Files selected for processing (16)
  • esignet-service/.env.example
  • esignet-service/README.md
  • esignet-service/cmd/esignet/main.go
  • esignet-service/go.mod
  • esignet-service/internal/config/authn.go
  • esignet-service/internal/config/clientmgmt.go
  • esignet-service/internal/config/clientmgmt_test.go
  • esignet-service/internal/config/db.go
  • esignet-service/internal/config/engine.go
  • esignet-service/internal/config/init.go
  • esignet-service/internal/config/mosip.go
  • esignet-service/internal/config/redis.go
  • esignet-service/internal/config/redis_test.go
  • esignet-service/internal/config/sunbird.go
  • esignet-service/internal/config/types.go
  • esignet-service/internal/config/types_test.go

Comment thread esignet-service/internal/config/mosip.go Outdated
Comment thread esignet-service/internal/config/sunbird.go Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@esignet-service/internal/config/mosip.go`:
- Around line 47-55: The `s.LicenseKey` value is being used without trimming
whitespace in lines 47, 51, and 55 when constructing sendOTP, kycAuth, and
kycExchange URLs, and also at line 63 (as mentioned in the review), which
results in malformed endpoints when the license key has leading or trailing
whitespace. Normalize the license key once at the beginning by applying
strings.TrimSpace to s.LicenseKey and storing it in a variable (similar to how
apiBase, kycAuth, and kycExchange are handled), then use this trimmed variable
consistently throughout all URL derivations and for the MosipAuthn.LicenseKey
assignment to ensure clean endpoint construction.

In `@esignet-service/internal/config/redis_test.go`:
- Around line 95-103: The test TestLoadRedis_invalidNumbersFallBackToDefaults
currently validates invalid numeric fallbacks for REDIS_POOL_SIZE and
REDIS_DIAL_TIMEOUT_SECS but does not cover the negative value clamping behavior
for REDIS_CONN_MAX_LIFETIME_SECS. Add a test case by setting the environment
variable REDIS_CONN_MAX_LIFETIME_SECS to a negative value (such as -1) and then
add a require.Equal assertion to verify that the resulting cfg.ConnMaxLifetime
is clamped to 0 (representing no limit). This will lock in the regression test
for the negative-lifetime clamp path in the LoadRedis function.

In `@esignet-service/internal/config/types_test.go`:
- Around line 96-97: The test is unsetting the TEST_INIT_UNSET environment
variable but not preserving its pre-test state, which can cause test pollution.
Before calling os.Unsetenv on TEST_INIT_UNSET at line 96, capture its current
value using os.LookupEnv to determine whether it was originally set and what its
value was. Then in the t.Cleanup function, restore the original state by setting
the variable back to its original value if it was set, or leaving it unset if it
wasn't originally present. This ensures the test doesn't leak state to other
tests running in the same process.

In `@esignet-service/internal/config/types.go`:
- Around line 118-145: The process function calls applyStringDefaults even when
envconfig.Process returns an error, and the applyStringDefaults function uses
reflection on spec without validating it first. The reflect.ValueOf(spec).Elem()
call will panic if spec is nil, not a pointer, or not a struct. Add a return
statement in the process function after the envconfig.Process error check to
exit early, preventing applyStringDefaults from executing when configuration
processing fails, or add validation in applyStringDefaults to ensure spec is a
valid pointer to a struct before attempting reflection operations.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: d2b16eee-6ddc-4d2d-9884-a7b437454096

📥 Commits

Reviewing files that changed from the base of the PR and between e384671 and 230e995.

⛔ Files ignored due to path filters (1)
  • esignet-service/go.sum is excluded by !**/*.sum
📒 Files selected for processing (17)
  • esignet-service/.env.example
  • esignet-service/README.md
  • esignet-service/cmd/esignet/main.go
  • esignet-service/go.mod
  • esignet-service/internal/config/authn.go
  • esignet-service/internal/config/clientmgmt.go
  • esignet-service/internal/config/clientmgmt_test.go
  • esignet-service/internal/config/db.go
  • esignet-service/internal/config/engine.go
  • esignet-service/internal/config/init.go
  • esignet-service/internal/config/mosip.go
  • esignet-service/internal/config/mosip_test.go
  • esignet-service/internal/config/redis.go
  • esignet-service/internal/config/redis_test.go
  • esignet-service/internal/config/sunbird.go
  • esignet-service/internal/config/types.go
  • esignet-service/internal/config/types_test.go

Comment thread esignet-service/internal/config/mosip.go Outdated
Comment thread esignet-service/internal/config/redis_test.go Outdated
Comment thread esignet-service/internal/config/types_test.go Outdated
Comment thread esignet-service/internal/config/types.go Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

♻️ Duplicate comments (1)
esignet-service/internal/config/types.go (1)

118-123: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Guard spec shape before reflection to avoid startup panic paths.

Line 122 can still reach applyStringDefaults(spec) after a failed envconfig.Process, and Line 133 dereferences spec via .Elem() without validating kind/nil. A nil/non-pointer/non-struct spec will panic.

Suggested minimal fix
 func process(spec any) {
+	rv := reflect.ValueOf(spec)
+	if !rv.IsValid() || rv.Kind() != reflect.Ptr || rv.IsNil() || rv.Elem().Kind() != reflect.Struct {
+		applog.GetLogger().Warn("process configuration",
+			applog.String("reason", "spec must be a non-nil pointer to struct"))
+		return
+	}
 	if err := envconfig.Process("", spec); err != nil {
 		applog.GetLogger().Warn("process configuration", applog.Error(err))
+		return
 	}
 	applyStringDefaults(spec)
 }

Also applies to: 132-134

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@esignet-service/internal/config/types.go` around lines 118 - 123, The process
function calls applyStringDefaults(spec) unconditionally even after
envconfig.Process fails, and applyStringDefaults dereferences spec via .Elem()
without validating that spec is a non-nil pointer to a struct. Add a guard
before calling applyStringDefaults to validate that spec is a non-nil pointer
and has a valid struct kind, or alternatively add validation inside
applyStringDefaults itself to check the type and nil status of spec before
attempting to dereference it with .Elem().
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Duplicate comments:
In `@esignet-service/internal/config/types.go`:
- Around line 118-123: The process function calls applyStringDefaults(spec)
unconditionally even after envconfig.Process fails, and applyStringDefaults
dereferences spec via .Elem() without validating that spec is a non-nil pointer
to a struct. Add a guard before calling applyStringDefaults to validate that
spec is a non-nil pointer and has a valid struct kind, or alternatively add
validation inside applyStringDefaults itself to check the type and nil status of
spec before attempting to dereference it with .Elem().

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 2135c538-a920-40b9-9bbd-2c7da91bb186

📥 Commits

Reviewing files that changed from the base of the PR and between 230e995 and 00ceb9c.

⛔ Files ignored due to path filters (1)
  • esignet-service/go.sum is excluded by !**/*.sum
📒 Files selected for processing (17)
  • esignet-service/.env.example
  • esignet-service/README.md
  • esignet-service/cmd/esignet/main.go
  • esignet-service/go.mod
  • esignet-service/internal/config/authn.go
  • esignet-service/internal/config/clientmgmt.go
  • esignet-service/internal/config/clientmgmt_test.go
  • esignet-service/internal/config/db.go
  • esignet-service/internal/config/engine.go
  • esignet-service/internal/config/init.go
  • esignet-service/internal/config/mosip.go
  • esignet-service/internal/config/mosip_test.go
  • esignet-service/internal/config/redis.go
  • esignet-service/internal/config/redis_test.go
  • esignet-service/internal/config/sunbird.go
  • esignet-service/internal/config/types.go
  • esignet-service/internal/config/types_test.go

Comment thread esignet-service/internal/config/init.go Outdated
Comment thread esignet-service/cmd/esignet/main.go Outdated
Comment thread esignet-service/internal/config/envvar/envvar.go Outdated
Comment thread esignet-service/internal/config/envvar/envvar.go Outdated
Comment thread esignet-service/internal/config/db.go Outdated
Comment thread esignet-service/.env.example Outdated
Comment thread esignet-service/go.mod Outdated
Comment thread esignet-service/README.md Outdated

@sacrana0 sacrana0 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Pls resolve the comments given and there might be some requirement change on how to handle configuration, pr will be on hold till then.

Comment thread esignet-service/cmd/esignet/main.go Outdated
Comment thread esignet-service/internal/config/envvar/envvar.go Outdated
Comment thread esignet-service/internal/config/envvar/envvar.go Outdated
Comment thread esignet-service/internal/config/db.go
Comment thread esignet-service/internal/config/db.go Outdated
Comment thread esignet-service/internal/config/db.go Outdated
Comment thread esignet-service/internal/config/redis.go Outdated
Comment thread esignet-service/internal/config/app.go Outdated
Comment thread esignet-service/internal/config/redis.go Outdated
Comment thread esignet-service/internal/config/redis.go
Comment thread esignet-service/internal/config/redis.go Outdated
// endpoint URLs are derived from MOSIP_API_INTERNAL_HOST and MOSIP_ESIGNET_MISP_KEY
// when not supplied individually, so they carry no envconfig default.
type mosipSpec struct {
LicenseKey string `envconfig:"MOSIP_ESIGNET_MISP_KEY"`

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I believe this config is required? Mark all required configuration as 'required: true'. Check other places as well. And so no need of nil check in code.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@sacrana0

Thanks! I had one clarification regarding MOSIP_ESIGNET_MISP_KEY and MOSIP_API_INTERNAL_HOST before marking them as required:"true".

These two values are currently used only to derive the default IDA endpoint URLs when the individual IDA_URL values are not provided. If all the endpoint URLs are configured explicitly, these two values are never used by the runtime.

Should I still mark them as required:"true" and require them in all deployments, or do we want to continue supporting the configuration where all IDA endpoint URLs are provided explicitly without MOSIP_API_INTERNAL_HOST and MOSIP_ESIGNET_MISP_KEY?

MOSIP_P12_PATH and MOSIP_P12_PASSWORD are unconditionally required, so I'll keep those as required:"true"

Comment thread esignet-service/internal/engine/sunbird/config.go Outdated
…bles

Signed-off-by: Nandhukumar <nandhukumare@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

eSigent-Thunder: Use a Library for Reading Configuration from Environment Variables

2 participants