Skip to content

Commit 4eeec59

Browse files
authored
fix(ci): Update API Flagsmith Defaults fails with jq compile errors (#8333)
1 parent 41e2c4e commit 4eeec59

1 file changed

Lines changed: 29 additions & 20 deletions

File tree

api/Makefile

Lines changed: 29 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -208,30 +208,39 @@ generate-docs-private:
208208
add-known-sdk-version:
209209
uv run python scripts/add-known-sdk-version.py $(opts)
210210

211+
# Exported so the recipe can pass it to jq as a single argument. Do not inline this
212+
# into the recipe: line continuations inside single quotes are passed to jq verbatim.
213+
define MASK_ENVIRONMENT_DOCUMENT_JQ
214+
{
215+
id: 0,
216+
api_key: "masked",
217+
name,
218+
use_identity_composite_key_for_hashing,
219+
feature_states: [.feature_states[] | select(.feature.id | IN($$ids[]))],
220+
project: {
221+
id: 0,
222+
name: .project.name,
223+
hide_disabled_flags: .project.hide_disabled_flags,
224+
segments: [],
225+
organisation: {
226+
id: 0,
227+
name: .project.organisation.name,
228+
feature_analytics: .project.organisation.feature_analytics,
229+
stop_serving_flags: .project.organisation.stop_serving_flags,
230+
persist_trait_data: .project.organisation.persist_trait_data
231+
}
232+
}
233+
}
234+
endef
235+
export MASK_ENVIRONMENT_DOCUMENT_JQ
236+
211237
.PHONY: update-flagsmith-environment
212238
update-flagsmith-environment:
213239
project=$$(jq -er .project ../flagsmith.json) && \
214240
tag=$$(flagsmith api "/api/v1/projects/$$project/tags/" --no-input \
215241
| jq -er '(if type == "array" then . else .results end) | map(select(.label == "api")) | .[0].id') && \
216242
ids=$$(flagsmith api "/api/v1/projects/$$project/features/?tags=$$tag&page_size=1000" --no-input \
217243
| jq -ec '[.results[].id]') && \
218-
flagsmith environment document --no-input | jq --argjson ids "$$ids" '{ \
219-
id: 0, \
220-
api_key: "masked", \
221-
name, \
222-
use_identity_composite_key_for_hashing, \
223-
feature_states: [.feature_states[] | select(.feature.id | IN($$ids[]))], \
224-
project: { \
225-
id: 0, \
226-
name: .project.name, \
227-
hide_disabled_flags: .project.hide_disabled_flags, \
228-
segments: [], \
229-
organisation: { \
230-
id: 0, \
231-
name: .project.organisation.name, \
232-
feature_analytics: .project.organisation.feature_analytics, \
233-
stop_serving_flags: .project.organisation.stop_serving_flags, \
234-
persist_trait_data: .project.organisation.persist_trait_data \
235-
} \
236-
} \
237-
}' > $(FLAGSMITH_DOCUMENT_PATH)
244+
flagsmith environment document --no-input \
245+
| jq --argjson ids "$$ids" "$$MASK_ENVIRONMENT_DOCUMENT_JQ" \
246+
> $(FLAGSMITH_DOCUMENT_PATH)

0 commit comments

Comments
 (0)