Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .github/workflows/api-deploy-production-ecs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ jobs:
run: |
echo "https://${{ secrets.GH_PRIVATE_ACCESS_TOKEN }}:@github.com" > ${HOME}/.git-credentials
git config --global credential.helper store
make install-packages opts="--extra private --extra auth-controller --extra workflows"
make install-private-modules
make install-packages opts="--extra private --extra auth-controller"
rm -rf ${HOME}/.git-credentials
- name: Generate MCP schema
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/api-tests-with-private-packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ jobs:
run: |
echo "https://${{ secrets.GH_PRIVATE_ACCESS_TOKEN }}:@github.com" > ${HOME}/.git-credentials
git config --global credential.helper store
make install-packages opts="--extra dev --extra private --extra auth-controller --extra workflows"
make install-private-modules
make install-packages opts="--extra dev --extra private --extra auth-controller"
make integrate-private-tests
rm -rf ${HOME}/.git-credentials
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ repos:
- id: flagsmith-lint-tests

- repo: https://github.com/astral-sh/uv-pre-commit
rev: 0.11.8 # Ensure this matches the version in api/pyproject.toml
rev: 0.11.14 # Ensure this matches the version in api/pyproject.toml
hooks:
- id: uv-lock
args: ["--project", "api", "--check"]
Expand Down
11 changes: 4 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -106,19 +106,16 @@ RUN --mount=type=cache,target=/root/.cache/uv \
# * build-python-private [build-python]
FROM build-python AS build-python-private

# Authenticate git with token, install private Python dependencies,
# and integrate private modules
ARG RBAC_REVISION
ARG EXTRAS="--extra private --extra auth-controller --extra ldap --extra workflows --extra licensing"
# Authenticate git with token and install private Python dependencies
ARG EXTRAS="--extra private --extra auth-controller --extra ldap --extra licensing"
RUN --mount=type=secret,id=github_private_cloud_token \
--mount=type=secret,id=codeartifact_token \
--mount=type=cache,target=/root/.cache/uv \
echo "https://$(cat /run/secrets/github_private_cloud_token):@github.com" > ${HOME}/.git-credentials && \
git config --global credential.helper store && \
UV_INDEX_FLAGSMITH_PYPI_PRODUCTION_USERNAME=aws \
UV_INDEX_FLAGSMITH_PYPI_PRODUCTION_PASSWORD="$(cat /run/secrets/codeartifact_token)" \
make install-packages opts="--no-install-project ${EXTRAS}" && \
make install-private-modules
make install-packages opts="--no-install-project ${EXTRAS}"

# * api-runtime
FROM wolfi-base AS api-runtime
Expand Down Expand Up @@ -179,7 +176,7 @@ RUN --mount=type=secret,id=codeartifact_token \
--mount=type=cache,target=/root/.cache/uv \
UV_INDEX_FLAGSMITH_PYPI_PRODUCTION_USERNAME=aws \
UV_INDEX_FLAGSMITH_PYPI_PRODUCTION_PASSWORD="$(cat /run/secrets/codeartifact_token)" \
make install-packages opts='--extra dev --extra private --extra auth-controller --extra ldap --extra workflows --extra licensing' && \
make install-packages opts='--extra dev --extra private --extra auth-controller --extra ldap --extra licensing' && \
make integrate-private-tests && \
git config --global --unset credential.helper && \
rm -f ${HOME}/.git-credentials
Expand Down
18 changes: 5 additions & 13 deletions api/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ DOTENV_OVERRIDE_FILE ?= .env

UV_VERSION ?= $(shell python -c 'import tomllib; print(tomllib.load(open("pyproject.toml","rb"))["tool"]["uv"]["required-version"].lstrip("="))')

RBAC_REVISION ?= v0.13.0

OPENAPI_FORMAT_VERSION ?= 1.23.0

-include .env-local
Expand All @@ -37,13 +35,6 @@ install-uv:
install-packages:
uv sync --frozen $(opts)

.PHONY: install-private-modules
install-private-modules:
$(eval SITE_PACKAGES_DIR := $(shell uv run python -c 'import site; print(site.getsitepackages()[0])'))
rm -rf $(SITE_PACKAGES_DIR)/rbac
git clone https://github.com/flagsmith/flagsmith-rbac --depth 1 --branch ${RBAC_REVISION} && mv ./flagsmith-rbac/rbac $(SITE_PACKAGES_DIR)
rm -rf ./flagsmith-rbac

.PHONY: install
install: install-pip install-uv install-packages

Expand Down Expand Up @@ -160,13 +151,14 @@ generate-grafana-client-types:

.PHONY: integrate-private-tests
integrate-private-tests:
$(eval WORKFLOW_REVISION := $(shell uv run python -c 'import tomllib; d=tomllib.load(open("pyproject.toml","rb")); s=d.get("tool",{}).get("uv",{}).get("sources",{}).get("workflows-logic",{}); print(s.get("tag") or s.get("rev") or "")'))
$(eval FLAGSMITH_PRIVATE_REVISION := v$(shell uv run python -c 'import importlib.metadata; print(importlib.metadata.version("flagsmith-private"))'))
Comment thread
khvn26 marked this conversation as resolved.
$(eval AUTH_CONTROLLER_REVISION := $(shell uv run python -c 'import tomllib; d=tomllib.load(open("pyproject.toml","rb")); s=d.get("tool",{}).get("uv",{}).get("sources",{}).get("auth-controller",{}); print(s.get("tag") or s.get("rev") or "")'))

git clone https://github.com/flagsmith/flagsmith-rbac --depth 1 --branch ${RBAC_REVISION} && mv ./flagsmith-rbac/tests tests/rbac_tests
git clone https://github.com/flagsmith/flagsmith-workflows --depth 1 --branch ${WORKFLOW_REVISION} && mv ./flagsmith-workflows/tests tests/workflow_tests
git clone https://github.com/Flagsmith/flagsmith-private --depth 1 --branch ${FLAGSMITH_PRIVATE_REVISION} \
&& mv ./flagsmith-private/integration_tests/rbac tests/rbac_tests \
&& mv ./flagsmith-private/integration_tests/workflows_logic tests/workflow_tests
git clone https://github.com/flagsmith/flagsmith-auth-controller --depth 1 --branch ${AUTH_CONTROLLER_REVISION} && mv ./flagsmith-auth-controller/tests tests/auth_controller_tests
rm -rf ./flagsmith-rbac ./flagsmith-workflows ./flagsmith-auth-controller
rm -rf ./flagsmith-private ./flagsmith-auth-controller

.PHONY: generate-docs
generate-docs: generate-flagsmith-sdk-openapi
Expand Down
8 changes: 2 additions & 6 deletions api/environments/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,8 @@
type=int,
)
],
extensions={
"x-gram": {
"name": "list_environments",
"description": "Lists all environments the user has access to",
},
},
operation_id="list_environments",
description="Lists all environments the user has access to",
),
)
class EnvironmentViewSet(viewsets.ModelViewSet): # type: ignore[type-arg]
Expand Down
8 changes: 2 additions & 6 deletions api/features/feature_external_resources/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,8 @@
name="list",
decorator=extend_schema(
tags=["mcp"],
extensions={
"x-gram": {
"name": "get_feature_external_resources",
"description": "Retrieves external resources linked to the feature flag.",
},
},
operation_id="get_feature_external_resources",
description="Retrieves external resources linked to the feature flag.",
),
)
class FeatureExternalResourceViewSet(viewsets.ModelViewSet): # type: ignore[type-arg]
Expand Down
8 changes: 2 additions & 6 deletions api/features/feature_health/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,8 @@
name="list",
decorator=extend_schema(
tags=["mcp"],
extensions={
"x-gram": {
"name": "get_feature_health_events",
"description": "Retrieves feature health monitoring events and metrics for the project.",
},
},
operation_id="get_feature_health_events",
description="Retrieves feature health monitoring events and metrics for the project.",
),
)
class FeatureHealthEventViewSet(
Expand Down
16 changes: 4 additions & 12 deletions api/features/feature_segments/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,24 +30,16 @@
decorator=extend_schema(
tags=["mcp"],
parameters=[FeatureSegmentQuerySerializer],
extensions={
"x-gram": {
"name": "list_feature_segments",
"description": "Lists segment overrides for a feature in an environment.",
},
},
operation_id="list_feature_segments",
description="Lists segment overrides for a feature in an environment.",
),
)
@method_decorator(
name="destroy",
decorator=extend_schema(
tags=["mcp"],
extensions={
"x-gram": {
"name": "delete_feature_segment",
"description": "Deletes a segment override. Use this tool for environments without v2 feature versioning (use_v2_feature_versioning: false).",
},
},
operation_id="delete_feature_segment",
description="Deletes a segment override. Applies to environments without v2 feature versioning (use_v2_feature_versioning: false).",
),
)
class FeatureSegmentViewSet(
Expand Down
32 changes: 8 additions & 24 deletions api/features/multivariate/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,48 +20,32 @@
name="list",
decorator=extend_schema(
tags=["mcp"],
extensions={
"x-gram": {
"name": "list_feature_multivariate_options",
"description": "Retrieves all multivariate options for a feature flag.",
},
},
operation_id="list_feature_multivariate_options",
description="Retrieves all multivariate options for a feature flag.",
),
)
@method_decorator(
name="create",
decorator=extend_schema(
tags=["mcp"],
extensions={
"x-gram": {
"name": "create_feature_multivariate_option",
"description": "Creates a new multivariate option for a feature flag.",
},
},
operation_id="create_feature_multivariate_option",
description="Creates a new multivariate option for a feature flag.",
),
)
@method_decorator(
name="update",
decorator=extend_schema(
tags=["mcp"],
extensions={
"x-gram": {
"name": "update_feature_multivariate_option",
"description": "Updates an existing multivariate option.",
},
},
operation_id="update_feature_multivariate_option",
description="Updates an existing multivariate option.",
),
)
@method_decorator(
name="destroy",
decorator=extend_schema(
tags=["mcp"],
extensions={
"x-gram": {
"name": "delete_feature_multivariate_option",
"description": "Deletes a multivariate option.",
},
},
operation_id="delete_feature_multivariate_option",
description="Deletes a multivariate option.",
),
)
class MultivariateFeatureOptionViewSet(viewsets.ModelViewSet): # type: ignore[type-arg]
Expand Down
48 changes: 12 additions & 36 deletions api/features/versioning/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,24 +51,16 @@
name="list",
decorator=extend_schema(
tags=["mcp"],
extensions={
"x-gram": {
"name": "get_environment_feature_versions",
"description": "Retrieves version information for a feature flag in a specific environment. Use this tool for environments with v2 feature versioning (use_v2_feature_versioning: true).",
},
},
operation_id="get_environment_feature_versions",
description="Retrieves version information for a feature flag in a specific environment. Applies to environments with v2 feature versioning (use_v2_feature_versioning: true).",
),
)
@method_decorator(
name="create",
decorator=extend_schema(
tags=["mcp"],
extensions={
"x-gram": {
"name": "create_environment_feature_version",
"description": "Creates a new version for a feature flag in a specific environment. Use this tool for environments with v2 feature versioning (use_v2_feature_versioning: true).",
},
},
operation_id="create_environment_feature_version",
description="Creates a new version for a feature flag in a specific environment. Applies to environments with v2 feature versioning (use_v2_feature_versioning: true).",
),
)
class EnvironmentFeatureVersionViewSet(
Expand Down Expand Up @@ -160,12 +152,8 @@ def perform_destroy(self, instance: EnvironmentFeatureVersion) -> None:

@extend_schema(
tags=["mcp"],
extensions={
"x-gram": {
"name": "publish_environment_feature_version",
"description": "Publishes a feature version to make it live in the environment. Use this tool for environments with v2 feature versioning (use_v2_feature_versioning: true).",
},
},
operation_id="publish_environment_feature_version",
description="Publishes a feature version to make it live in the environment. Applies to environments with v2 feature versioning (use_v2_feature_versioning: true).",
)
@action(detail=True, methods=["POST"])
def publish(self, request: Request, **kwargs) -> Response: # type: ignore[no-untyped-def]
Expand Down Expand Up @@ -223,36 +211,24 @@ def get_queryset(self): # type: ignore[no-untyped-def]
name="list",
decorator=extend_schema(
tags=["mcp"],
extensions={
"x-gram": {
"name": "get_environment_feature_version_states",
"description": "Retrieves feature state information for a specific version in an environment. Use this tool for environments with v2 feature versioning (use_v2_feature_versioning: true).",
},
},
operation_id="get_environment_feature_version_states",
description="Retrieves feature state information for a specific version in an environment. Applies to environments with v2 feature versioning (use_v2_feature_versioning: true).",
),
)
@method_decorator(
name="create",
decorator=extend_schema(
tags=["mcp"],
extensions={
"x-gram": {
"name": "create_environment_feature_version_state",
"description": "Creates a new feature state for a specific version in an environment. Use this tool for environments with v2 feature versioning (use_v2_feature_versioning: true).",
},
},
operation_id="create_environment_feature_version_state",
description="Creates a new feature state for a specific version in an environment. Applies to environments with v2 feature versioning (use_v2_feature_versioning: true).",
),
)
@method_decorator(
name="update",
decorator=extend_schema(
tags=["mcp"],
extensions={
"x-gram": {
"name": "update_environment_feature_version_state",
"description": "Updates an existing feature state for a specific version in an environment. Use this tool for environments with v2 feature versioning (use_v2_feature_versioning: true).",
},
},
operation_id="update_environment_feature_version_state",
description="Updates an existing feature state for a specific version in an environment. Applies to environments with v2 feature versioning (use_v2_feature_versioning: true).",
),
)
class EnvironmentFeatureVersionFeatureStatesViewSet(
Expand Down
Loading
Loading