Skip to content

Commit 64066fc

Browse files
committed
feat: add support for more detailed owner schema in flagpole
1 parent aa58e30 commit 64066fc

File tree

2 files changed

+44
-6
lines changed

2 files changed

+44
-6
lines changed

src/flagpole/__init__.py

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,13 +87,22 @@ def load_json_schema() -> dict[str, Any]:
8787
return data
8888

8989

90+
@dataclasses.dataclass(frozen=True)
91+
class OwnerInfo:
92+
team: str
93+
"The team that owns this feature."
94+
95+
email: str | None = None
96+
"The email address of the owner."
97+
98+
9099
@dataclasses.dataclass(frozen=True)
91100
class Feature:
92101
name: str
93102
"The feature name."
94103

95-
owner: str
96-
"The owner of this feature. Either an email address or team name, preferably."
104+
owner: str | OwnerInfo
105+
"The owner of this feature."
97106

98107
enabled: bool = dataclasses.field(default=True)
99108
"Whether or not the feature is enabled."
@@ -133,9 +142,19 @@ def from_feature_dictionary(cls, name: str, config_dict: dict[str, Any]) -> Feat
133142
raise InvalidFeatureFlagConfiguration("Feature has no segments defined")
134143
try:
135144
segments = [Segment.from_dict(segment) for segment in segment_data]
145+
146+
raw_owner = config_dict.get("owner", "")
147+
if isinstance(raw_owner, dict):
148+
owner = OwnerInfo(
149+
team=raw_owner["team"],
150+
email=raw_owner.get("email"),
151+
)
152+
else:
153+
owner = str(raw_owner)
154+
136155
feature = cls(
137156
name=name,
138-
owner=str(config_dict.get("owner", "")),
157+
owner=owner,
139158
enabled=bool(config_dict.get("enabled", True)),
140159
created_at=str(config_dict.get("created_at")),
141160
segments=segments,

src/flagpole/flagpole-schema.json

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,28 @@
1010
},
1111
"owner": {
1212
"title": "Owner",
13-
"description": "The owner of this feature. Either an email address or team name, preferably.",
14-
"minLength": 1,
15-
"type": "string"
13+
"description": "The owner of this feature.",
14+
"oneOf": [
15+
{
16+
"type": "string",
17+
"minLength": 1
18+
},
19+
{
20+
"type": "object",
21+
"properties": {
22+
"team": {
23+
"type": "string",
24+
"description": "The team that owns this feature."
25+
},
26+
"email": {
27+
"type": "string",
28+
"description": "The email address of the owner. Not required."
29+
}
30+
},
31+
"required": ["team"],
32+
"additionalProperties": false
33+
}
34+
]
1635
},
1736
"segments": {
1837
"title": "Segments",

0 commit comments

Comments
 (0)