Skip to content

Commit 77b9eb8

Browse files
committed
Merge remote-tracking branch 'upstream/main' into feat/grpc-sync-addition
Signed-off-by: Simon Schrottner <[email protected]>
2 parents a37e5a3 + 9dcb6a5 commit 77b9eb8

27 files changed

+435
-298
lines changed

.github/workflows/build.yml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@ jobs:
3232
- "providers/openfeature-provider-ofrep"
3333

3434
steps:
35-
- uses: actions/checkout@v4
35+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
3636
with:
3737
submodules: recursive
3838

3939
- name: Set up Python ${{ matrix.python-version }}
40-
uses: actions/setup-python@v5
40+
uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5
4141
with:
4242
python-version: ${{ matrix.python-version }}
4343
cache: "pip"
@@ -60,7 +60,7 @@ jobs:
6060

6161
- if: matrix.python-version == '3.11'
6262
name: Upload coverage to Codecov
63-
uses: codecov/codecov-action@v4.5.0
63+
uses: codecov/codecov-action@1e68e06f1dbfde0e4cefc87efeba9e4643565303 # v5.1.2
6464
with:
6565
name: Code Coverage for ${{ matrix.package }} on Python ${{ matrix.python-version }}
6666
directory: ${{ matrix.package }}
@@ -72,14 +72,14 @@ jobs:
7272
runs-on: ubuntu-latest
7373

7474
steps:
75-
- uses: actions/checkout@v4
76-
- uses: actions/setup-python@v5
75+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
76+
- uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5
7777
with:
7878
python-version: "3.11"
7979
cache: "pip"
8080

8181
- name: Run pre-commit
82-
uses: pre-commit/[email protected]
82+
uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # v3.0.1
8383

8484
sast:
8585
runs-on: ubuntu-latest
@@ -88,13 +88,13 @@ jobs:
8888
contents: read
8989
security-events: write
9090
steps:
91-
- uses: actions/checkout@v4
91+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
9292

9393
- name: Initialize CodeQL
94-
uses: github/codeql-action/init@v3
94+
uses: github/codeql-action/init@48ab28a6f5dbc2a99bf1e0131198dd8f1df78169 # v3
9595
with:
9696
languages: python
9797
config-file: ./.github/codeql-config.yml
9898

9999
- name: Perform CodeQL Analysis
100-
uses: github/codeql-action/analyze@v3
100+
uses: github/codeql-action/analyze@48ab28a6f5dbc2a99bf1e0131198dd8f1df78169 # v3

.github/workflows/lint-pr.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ jobs:
2020
name: Validate PR title
2121
runs-on: ubuntu-latest
2222
steps:
23-
- uses: amannn/action-semantic-pull-request@v5
23+
- uses: amannn/action-semantic-pull-request@0723387faaf9b38adef4775cd42cfd5155ed6017 # v5
2424
id: lint_pr_title
2525
env:
2626
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2727

28-
- uses: marocchino/sticky-pull-request-comment@v2
28+
- uses: marocchino/sticky-pull-request-comment@331f8f5b4215f0445d3c07b4967662a32a2d3e31 # v2
2929
# When the previous steps fails, the workflow would stop. By adding this
3030
# condition you can continue the execution with the populated error message.
3131
if: always() && (steps.lint_pr_title.outputs.error_message != null)
@@ -44,7 +44,7 @@ jobs:
4444
4545
# Delete a previous comment when the issue has been resolved
4646
- if: ${{ steps.lint_pr_title.outputs.error_message == null }}
47-
uses: marocchino/sticky-pull-request-comment@v2
47+
uses: marocchino/sticky-pull-request-comment@331f8f5b4215f0445d3c07b4967662a32a2d3e31 # v2
4848
with:
4949
header: pr-title-lint-error
5050
delete: true

.github/workflows/release.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
pull-requests: write # for googleapis/release-please-action to create release PR
2020
# Release-please creates a PR that tracks all changes
2121
steps:
22-
- uses: googleapis/release-please-action@v4
22+
- uses: googleapis/release-please-action@7987652d64b4581673a76e33ad5e98e3dd56832f # v4
2323
id: release
2424
with:
2525
token: ${{secrets.GITHUB_TOKEN}}
@@ -46,10 +46,10 @@ jobs:
4646
# IMPORTANT: this permission is mandatory for trusted publishing to pypi
4747
id-token: write
4848
container:
49-
image: "python:3.12"
49+
image: "python:3.13"
5050

5151
steps:
52-
- uses: actions/checkout@v4
52+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
5353
with:
5454
submodules: recursive
5555

.gitmodules

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
[submodule "providers/openfeature-provider-flagd/test-harness"]
55
path = providers/openfeature-provider-flagd/openfeature/test-harness
66
url = [email protected]:open-feature/flagd-testbed.git
7+
branch = v0.5.18
78
[submodule "providers/openfeature-provider-flagd/spec"]
89
path = providers/openfeature-provider-flagd/openfeature/spec
910
url = https://github.com/open-feature/spec

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
default_stages: [commit]
22
repos:
33
- repo: https://github.com/astral-sh/ruff-pre-commit
4-
rev: v0.6.3
4+
rev: v0.8.4
55
hooks:
66
- id: ruff
77
args: [--fix]
88
- id: ruff-format
99

1010
- repo: https://github.com/pre-commit/pre-commit-hooks
11-
rev: v4.6.0
11+
rev: v5.0.0
1212
hooks:
1313
- id: check-toml
1414
- id: check-yaml

providers/openfeature-provider-flagd/README.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,12 @@ This mode is useful for local development, tests and offline applications.
7979
The default options can be defined in the FlagdProvider constructor.
8080

8181
| Option name | Environment variable name | Type & Values | Default | Compatible resolver |
82-
| ------------------------ | ------------------------------ | -------------------------- | ----------------------------- | ------------------- |
82+
|--------------------------|--------------------------------|----------------------------|-------------------------------|---------------------|
8383
| resolver_type | FLAGD_RESOLVER | enum - `rpc`, `in-process` | rpc | |
8484
| host | FLAGD_HOST | str | localhost | rpc & in-process |
8585
| port | FLAGD_PORT | int | 8013 (rpc), 8015 (in-process) | rpc & in-process |
8686
| tls | FLAGD_TLS | bool | false | rpc & in-process |
87+
| cert_path | FLAGD_SERVER_CERT_PATH | String | null | rpc & in-process |
8788
| deadline | FLAGD_DEADLINE_MS | int | 500 | rpc & in-process |
8889
| stream_deadline_ms | FLAGD_STREAM_DEADLINE_MS | int | 600000 | rpc & in-process |
8990
| keep_alive_time | FLAGD_KEEP_ALIVE_TIME_MS | int | 0 | rpc & in-process |
@@ -96,8 +97,6 @@ The default options can be defined in the FlagdProvider constructor.
9697
<!-- not implemented
9798
| target_uri | FLAGD_TARGET_URI | alternative to host/port, supporting custom name resolution | string | null | rpc & in-process |
9899
| socket_path | FLAGD_SOCKET_PATH | alternative to host port, unix socket | String | null | rpc & in-process |
99-
| cert_path | FLAGD_SERVER_CERT_PATH | tls cert path | String | null | rpc & in-process |
100-
| max_event_stream_retries | FLAGD_MAX_EVENT_STREAM_RETRIES | int | 5 | rpc |
101100
| context_enricher | - | sync-metadata to evaluation context mapping function | function | identity function | in-process |
102101
| offline_pollIntervalMs | FLAGD_OFFLINE_POLL_MS | poll interval for reading offlineFlagSourcePath | int | 5000 | in-process |
103102
-->
@@ -132,17 +131,18 @@ and the evaluation will default.
132131

133132
TLS is available in situations where flagd is running on another host.
134133

135-
<!--
134+
136135
You may optionally supply an X.509 certificate in PEM format. Otherwise, the default certificate store will be used.
137-
```java
138-
FlagdProvider flagdProvider = new FlagdProvider(
139-
FlagdOptions.builder()
140-
.host("myflagdhost")
141-
.tls(true) // use TLS
142-
.certPath("etc/cert/ca.crt") // PEM cert
143-
.build());
136+
137+
```python
138+
from openfeature import api
139+
from openfeature.contrib.provider.flagd import FlagdProvider
140+
141+
api.set_provider(FlagdProvider(
142+
tls=True, # use TLS
143+
cert_path="etc/cert/ca.crt" # PEM cert
144+
))
144145
```
145-
-->
146146

147147
## License
148148

providers/openfeature-provider-flagd/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ dependencies = [
4040
"pytest-bdd",
4141
"testcontainers",
4242
"asserts",
43-
"grpcio-health-checking==1.60.0",
43+
"grpcio-health-checking==1.68.1",
4444
]
4545
pre-install-commands = [
4646
"hatch build",

providers/openfeature-provider-flagd/src/openfeature/contrib/provider/flagd/config.py

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,10 @@ class CacheType(Enum):
2626
DEFAULT_RESOLVER_TYPE = ResolverType.RPC
2727
DEFAULT_RETRY_BACKOFF = 1000
2828
DEFAULT_RETRY_BACKOFF_MAX = 120000
29-
DEFAULT_RETRY_GRACE_ATTEMPTS = 5
29+
DEFAULT_RETRY_GRACE_PERIOD_SECONDS = 5
3030
DEFAULT_STREAM_DEADLINE = 600000
3131
DEFAULT_TLS = False
32+
DEFAULT_TLS_CERT: typing.Optional[str] = None
3233

3334
ENV_VAR_CACHE_SIZE = "FLAGD_MAX_CACHE_SIZE"
3435
ENV_VAR_CACHE_TYPE = "FLAGD_CACHE"
@@ -41,10 +42,11 @@ class CacheType(Enum):
4142
ENV_VAR_RESOLVER_TYPE = "FLAGD_RESOLVER"
4243
ENV_VAR_RETRY_BACKOFF_MS = "FLAGD_RETRY_BACKOFF_MS"
4344
ENV_VAR_RETRY_BACKOFF_MAX_MS = "FLAGD_RETRY_BACKOFF_MAX_MS"
44-
ENV_VAR_RETRY_GRACE_ATTEMPTS = "FLAGD_RETRY_GRACE_ATTEMPTS"
45-
ENV_VAR_SELECTOR = "FLAGD_SELECTOR"
45+
ENV_VAR_RETRY_GRACE_PERIOD_SECONDS = "FLAGD_RETRY_GRACE_PERIOD"
46+
ENV_VAR_SELECTOR = "FLAGD_SOURCE_SELECTOR"
4647
ENV_VAR_STREAM_DEADLINE_MS = "FLAGD_STREAM_DEADLINE_MS"
4748
ENV_VAR_TLS = "FLAGD_TLS"
49+
ENV_VAR_TLS_CERT = "FLAGD_SERVER_CERT_PATH"
4850

4951
T = typing.TypeVar("T")
5052

@@ -83,12 +85,13 @@ def __init__( # noqa: PLR0913
8385
offline_poll_interval_ms: typing.Optional[int] = None,
8486
retry_backoff_ms: typing.Optional[int] = None,
8587
retry_backoff_max_ms: typing.Optional[int] = None,
86-
retry_grace_attempts: typing.Optional[int] = None,
88+
retry_grace_period: typing.Optional[int] = None,
8789
deadline_ms: typing.Optional[int] = None,
8890
stream_deadline_ms: typing.Optional[int] = None,
8991
keep_alive_time: typing.Optional[int] = None,
9092
cache: typing.Optional[CacheType] = None,
9193
max_cache_size: typing.Optional[int] = None,
94+
cert_path: typing.Optional[str] = None,
9295
):
9396
self.host = env_or_default(ENV_VAR_HOST, DEFAULT_HOST) if host is None else host
9497

@@ -117,14 +120,16 @@ def __init__( # noqa: PLR0913
117120
else retry_backoff_max_ms
118121
)
119122

120-
self.retry_grace_attempts: int = (
123+
self.retry_grace_period: int = (
121124
int(
122125
env_or_default(
123-
ENV_VAR_RETRY_GRACE_ATTEMPTS, DEFAULT_RETRY_GRACE_ATTEMPTS, cast=int
126+
ENV_VAR_RETRY_GRACE_PERIOD_SECONDS,
127+
DEFAULT_RETRY_GRACE_PERIOD_SECONDS,
128+
cast=int,
124129
)
125130
)
126-
if retry_grace_attempts is None
127-
else retry_grace_attempts
131+
if retry_grace_period is None
132+
else retry_grace_period
128133
)
129134

130135
self.resolver = (
@@ -201,6 +206,12 @@ def __init__( # noqa: PLR0913
201206
else max_cache_size
202207
)
203208

209+
self.cert_path = (
210+
env_or_default(ENV_VAR_TLS_CERT, DEFAULT_TLS_CERT)
211+
if cert_path is None
212+
else cert_path
213+
)
214+
204215
self.selector = (
205216
env_or_default(ENV_VAR_SELECTOR, None) if selector is None else selector
206217
)

0 commit comments

Comments
 (0)