fix(standalone): resolve env var references in config pushed via Admin API#37
Closed
AlinsRan wants to merge 1 commit into
Closed
fix(standalone): resolve env var references in config pushed via Admin API#37AlinsRan wants to merge 1 commit into
AlinsRan wants to merge 1 commit into
Conversation
…n API
In standalone mode, the file-based config path resolves ${{VAR}} / $ENV://
references in config_yaml.parse(), but config pushed through the Admin API
(`PUT /apisix/admin/configs`) is JSON-decoded straight into _update_config
and bypassed that step, so the references were kept literal.
Resolve them in the Admin API update path before applying the config, so
both standalone config sources behave consistently. Adds a test that pushes
a route whose proxy-rewrite uri uses a ${{VAR:=default}} reference and
verifies the gateway resolves it.
Signed-off-by: AlinsRan <alinsran@apache.org>
dea16d7 to
3fa7450
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
In standalone mode there are two config sources:
apisix.yaml) —${{VAR}}/$ENV://references are resolved inconfig_yaml.parse().PUT /apisix/admin/configs) — the JSON body is decoded straight intoconfig_yaml._update_config(), which (since the parse-time resolution was introduced) no longer resolves those references, so they are kept literal.This restores resolution for the Admin API path:
apisix/admin/standalone.luanow callsfile.resolve_conf_var(config)before applying the pushed config, so both sources behave consistently. Because the Admin API body is JSON (already typed), table-level resolution does not reintroduce the YAML type-inference issue that motivated moving resolution to parse time.Test
Adds a case to
t/admin/standalone.spec.ts: push a route whoseproxy-rewrite.uriis${{STANDALONE_ENV_TEST:=/hello}}and assert the route returns the hello body (i.e. the reference was resolved to its default; a literal value would not match).