Skip to content

Commit 1667513

Browse files
authored
Merge pull request #266 from launchdarkly-labs/cko_2025
CKO 2025
2 parents fa8a8f1 + 0f32844 commit 1667513

File tree

84 files changed

+5073
-2150
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+5073
-2150
lines changed

Diff for: .github/workflows/demo_provisioning_scripts/DemoBuilder.py

+1,172-134
Large diffs are not rendered by default.

Diff for: .github/workflows/demo_provisioning_scripts/LDPlatform.py

+183-13
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ def create_flag(
150150
tags=[],
151151
migration_stages=0,
152152
prerequisites=[],
153+
temporary=False,
153154
):
154155
if self.flag_exists(flag_key):
155156
return
@@ -162,6 +163,7 @@ def create_flag(
162163
"usingEnvironmentId": True,
163164
"usingMobileKey": True,
164165
},
166+
"temporary": temporary,
165167
}
166168

167169
if len(variations) > 0:
@@ -201,6 +203,28 @@ def create_flag(
201203
if "message" in data:
202204
print("Error creating flag: " + data["message"])
203205
return response
206+
207+
##################################################
208+
# Update a flag
209+
##################################################
210+
def update_flag_client_side_availability(self, flag_key):
211+
212+
payload = {
213+
"instructions": [
214+
{
215+
"kind": "turnOnClientSideAvailability", "value": "usingEnvironmentId"
216+
}
217+
]
218+
}
219+
220+
headers = {
221+
"Authorization": self.api_key,
222+
"Content-Type": "application/json; domain-model=launchdarkly.semanticpatch",
223+
}
224+
225+
url = "https://app.launchdarkly.com/api/v2/flags/" + self.project_key + "/" + flag_key
226+
res = self.getrequest("PATCH", url, headers=headers, json=payload)
227+
return res
204228

205229
##################################################
206230
# Copy a flag
@@ -262,7 +286,6 @@ def create_ai_config(self, config_key, config_name, description, tags):
262286
headers=headers,
263287
)
264288
data = json.loads(response.text)
265-
print(response.text)
266289
if "message" in data:
267290
print("Error creating AI Config: " + data["message"])
268291
return response
@@ -272,13 +295,14 @@ def create_ai_config(self, config_key, config_name, description, tags):
272295
# Create AI Config Versions
273296
##################################################
274297

275-
def create_ai_config_versions(self, ai_config_key, ai_config_version_key, ai_config_version_name, model, messages):
298+
def create_ai_config_versions(self, ai_config_key, ai_config_version_key, ai_model_config_key, ai_config_version_name, model, messages):
276299

277300
payload = {
278301
"key": ai_config_version_key,
279302
"name": ai_config_version_name,
280303
"messages": messages,
281-
"model": model
304+
"model": model,
305+
"modelConfigKey": ai_model_config_key
282306
}
283307

284308
headers = {
@@ -614,6 +638,14 @@ def create_experiment(
614638
print("Error creating experiment: " + data["message"])
615639
return response
616640

641+
##################################################
642+
# Create a holdout
643+
##################################################
644+
645+
##################################################
646+
# Create a layer
647+
##################################################
648+
617649
##################################################
618650
# Create a release pipeline
619651
##################################################
@@ -692,18 +724,24 @@ def create_release_pipeline(self, pipeline_key, pipeline_name):
692724
print("Error creating release pipeline: " + data["message"])
693725
return response
694726

695-
def create_shortcut(self):
727+
def create_shortcut(self, name, key, icon, tags, env_key, sort_by="name"):
696728
payload = {
697-
"name": "another",
698-
"key": "another",
699-
"icon": "bolt",
729+
"name": name,
730+
"key": key,
731+
"icon": icon,
700732
"type": "flags",
701733
"context": {
702734
"projectKey": self.project_key,
703-
"environmentKeys": ["production", "test"],
704-
"selectedEnvironmentKey": "production",
735+
"environmentKeys": ["production"],
736+
"selectedEnvironmentKey": env_key,
705737
},
706-
"filters": {"filter": {"tags": ["AI"]}},
738+
"filters": {
739+
"filter": {
740+
"tags": tags
741+
},
742+
"state": "live",
743+
"sort": sort_by
744+
},
707745
"visibility": "me",
708746
}
709747
headers = {
@@ -735,7 +773,7 @@ def create_shortcut(self):
735773
def get_user_id(self, email):
736774
if email is None:
737775
return None
738-
776+
739777
filter = "email:" + email
740778
if email == "":
741779
filter = "role:owner"
@@ -1029,11 +1067,16 @@ def add_guarded_rollout(
10291067
rollback=True,
10301068
weight=50000,
10311069
notify=True,
1070+
days=1,
10321071
):
10331072
vars, defaults = self.get_flag_variation_values(flag_key)
10341073

10351074
control_var = ""
10361075
test_var = ""
1076+
stagesWindow = 17280000
1077+
1078+
if days == 7:
1079+
stagesWindow = 120960000
10371080

10381081
for v in vars:
10391082
if v["value"] == False:
@@ -1051,21 +1094,148 @@ def add_guarded_rollout(
10511094
headers = {
10521095
"Authorization": self.api_key,
10531096
"Content-Type": "application/json; domain-model=launchdarkly.semanticpatch",
1054-
"LD-API-Version": "beta",
10551097
}
10561098
payload = {
10571099
"comment": "",
10581100
"environmentKey": env_key,
10591101
"instructions": [
10601102
{
1061-
"kind": "updateFallthroughWithMeasuredRollout",
1103+
"kind": "turnFlagOn"
1104+
},
1105+
{
1106+
"kind": "updateFallthroughWithMeasuredRolloutV2",
10621107
"testVariationId": test_var,
10631108
"controlVariationId": control_var,
10641109
"randomizationUnit": "user",
10651110
"onRegression": {"notify": notify, "rollback": rollback},
10661111
"onProgression": {"notify": notify, "rollForward": True},
10671112
"monitoringWindowMilliseconds": timeout,
10681113
"rolloutWeight": weight,
1114+
"stages": [
1115+
{
1116+
"rolloutWeight": 1000,
1117+
"monitoringWindowMilliseconds": stagesWindow
1118+
},
1119+
{
1120+
"rolloutWeight": 5000,
1121+
"monitoringWindowMilliseconds": stagesWindow
1122+
},
1123+
{
1124+
"rolloutWeight": 10000,
1125+
"monitoringWindowMilliseconds": stagesWindow
1126+
},
1127+
{
1128+
"rolloutWeight": 25000,
1129+
"monitoringWindowMilliseconds": stagesWindow
1130+
},
1131+
{
1132+
"rolloutWeight": 50000,
1133+
"monitoringWindowMilliseconds": stagesWindow
1134+
},
1135+
]
1136+
}
1137+
],
1138+
}
1139+
res = self.getrequest("PATCH", url, headers=headers, json=payload)
1140+
return res
1141+
1142+
##################################################
1143+
# Add a guarded rollout to a flag
1144+
##################################################
1145+
def add_progressive_rollout(
1146+
self,
1147+
flag_key,
1148+
env_key,
1149+
timeout=604800000,
1150+
rollback=True,
1151+
weight=50000,
1152+
notify=True,
1153+
):
1154+
vars, defaults = self.get_flag_variation_values(flag_key)
1155+
1156+
control_var = ""
1157+
end_var = ""
1158+
1159+
for v in vars:
1160+
if v["value"] == False:
1161+
control_var = v["id"]
1162+
else:
1163+
end_var = v["id"]
1164+
1165+
url = (
1166+
"https://app.launchdarkly.com/api/v2/flags/"
1167+
+ self.project_key
1168+
+ "/"
1169+
+ flag_key
1170+
+ "?ignoreConflicts=true"
1171+
)
1172+
headers = {
1173+
"Authorization": self.api_key,
1174+
"Content-Type": "application/json; domain-model=launchdarkly.semanticpatch",
1175+
}
1176+
payload = {
1177+
"comment": "",
1178+
"environmentKey": env_key,
1179+
"instructions": [
1180+
{
1181+
"kind": "turnFlagOn"
1182+
},
1183+
{
1184+
"kind": "updateFallthroughVariationOrRollout",
1185+
"rolloutContextKind": "user",
1186+
"progressiveRolloutConfiguration": {
1187+
"controlVariationId": control_var,
1188+
"endVariationId": end_var,
1189+
"stages": [
1190+
{
1191+
"displayUnit": "day",
1192+
"durationMs": timeout,
1193+
"rollout": {
1194+
end_var: 1000,
1195+
control_var: 99000,
1196+
}
1197+
},
1198+
{
1199+
"displayUnit": "day",
1200+
"durationMs": timeout,
1201+
"rollout": {
1202+
end_var: 5000,
1203+
control_var: 95000,
1204+
}
1205+
},
1206+
{
1207+
"displayUnit": "day",
1208+
"durationMs": timeout,
1209+
"rollout": {
1210+
end_var: 10000,
1211+
control_var: 90000,
1212+
}
1213+
},
1214+
{
1215+
"displayUnit": "day",
1216+
"durationMs": timeout,
1217+
"rollout": {
1218+
end_var: 25000,
1219+
control_var: 75000,
1220+
}
1221+
},
1222+
{
1223+
"displayUnit": "day",
1224+
"durationMs": timeout,
1225+
"rollout": {
1226+
end_var: 50000,
1227+
control_var: 50000,
1228+
}
1229+
},
1230+
{
1231+
"displayUnit": "day",
1232+
"rollout": {
1233+
end_var: 100000,
1234+
control_var: 0,
1235+
}
1236+
}
1237+
]
1238+
}
10691239
}
10701240
],
10711241
}

Diff for: .github/workflows/ld-add-code-references.yaml

-35
This file was deleted.

0 commit comments

Comments
 (0)