-
Notifications
You must be signed in to change notification settings - Fork 87
feat(provider): align attributes schema with audit requirements #3284
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 2 commits
ef530d5
2506e94
8e45e00
6d919d5
5cb7f61
575b704
a0f281c
162d6d0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -82,7 +82,7 @@ export const mapProviderToList = ( | |
| host: getStringAttribute("host", attrMap, providerAttributeSchema), | ||
| organization: getStringAttribute("organization", attrMap, providerAttributeSchema), | ||
| statusPage: getStringAttribute("status-page", attrMap, providerAttributeSchema), | ||
| locationRegion: getStringAttribute("location-region", attrMap, providerAttributeSchema), | ||
| locationRegion: getLocationRegion(attrMap, providerAttributeSchema), | ||
| country: getStringAttribute("country", attrMap, providerAttributeSchema), | ||
| city: getStringAttribute("city", attrMap, providerAttributeSchema), | ||
| timezone: getStringAttribute("timezone", attrMap, providerAttributeSchema), | ||
|
|
@@ -92,17 +92,19 @@ export const mapProviderToList = ( | |
| hardwareCpuArch: getStringAttribute("hardware-cpu-arch", attrMap, providerAttributeSchema), | ||
| hardwareGpuVendor: getStringAttribute("hardware-gpu", attrMap, providerAttributeSchema), | ||
| hardwareGpuModels: getStringArrayAttribute("hardware-gpu-model", provider, providerAttributeSchema), | ||
| hardwareDisk: getStringArrayAttribute("hardware-disk", provider, providerAttributeSchema), | ||
| featPersistentStorage: getBooleanAttribute("feat-persistent-storage", attrMap, providerAttributeSchema), | ||
| featPersistentStorageType: getStringArrayAttribute("feat-persistent-storage-type", provider, providerAttributeSchema), | ||
| hardwareGpuCapabilities: getStringArrayAttribute("hardware-gpu-capability", provider, providerAttributeSchema), | ||
| hardwarePersistentStorageClass: getStringAttribute("hardware-persistent-storage-class", attrMap, providerAttributeSchema), | ||
| featPersistentStorage: getPersistentStorageSupport(attrMap, providerAttributeSchema), | ||
| featShm: getShmSupport(attrMap, providerAttributeSchema), | ||
| hardwareShm: getStringArrayAttribute("hardware-shm", provider, providerAttributeSchema), | ||
| hardwareCuda: getStringAttribute("hardware-cuda", attrMap, providerAttributeSchema), | ||
| datacenter: getStringAttribute("datacenter", attrMap, providerAttributeSchema), | ||
| hardwareMemory: getStringAttribute("hardware-memory", attrMap, providerAttributeSchema), | ||
| networkProvider: getStringAttribute("network-provider", attrMap, providerAttributeSchema), | ||
| networkSpeedDown: getNumberAttribute("network-speed-down", attrMap, providerAttributeSchema), | ||
| networkSpeedUp: getNumberAttribute("network-speed-up", attrMap, providerAttributeSchema), | ||
| tier: getStringAttribute("tier", attrMap, providerAttributeSchema), | ||
| featEndpointCustomDomain: getBooleanAttribute("feat-endpoint-custom-domain", attrMap, providerAttributeSchema), | ||
| workloadSupportChia: getBooleanAttribute("workload-support-chia", attrMap, providerAttributeSchema), | ||
| workloadSupportChiaCapabilities: getStringArrayAttribute("workload-support-chia-capabilities", provider, providerAttributeSchema), | ||
| featEndpointIp: getBooleanAttribute("feat-endpoint-ip", attrMap, providerAttributeSchema) | ||
| }; | ||
| }; | ||
|
|
@@ -125,12 +127,52 @@ function getStringAttribute(key: keyof ProviderAttributesSchema, attrMap: Map<st | |
| return attrMap.get(schemaKey) || null; | ||
| } | ||
|
|
||
| function getLocationRegion(attrMap: Map<string, string>, schema: ProviderAttributesSchema): string | null { | ||
| const locationRegion = getStringAttribute("location-region", attrMap, schema); | ||
| if (locationRegion) { | ||
| return locationRegion; | ||
| } | ||
|
|
||
| // Legacy providers may still have `region` on-chain; console expects `location-region`. | ||
| return attrMap.get("region") || null; | ||
|
Zblocker64 marked this conversation as resolved.
Outdated
|
||
| } | ||
|
Comment on lines
+131
to
+133
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Normalize legacy region values in the fallback path. Line 137 returns the old 🤖 Prompt for AI Agents |
||
|
|
||
| function getBooleanAttribute(key: keyof ProviderAttributesSchema, attrMap: Map<string, string>, schema: ProviderAttributesSchema): boolean { | ||
| const schemaKey = schema[key].key; | ||
| const value = attrMap.get(schemaKey); | ||
| return value === "true"; | ||
| } | ||
|
|
||
| function hasShmCapability(attrMap: Map<string, string>): boolean { | ||
| for (const [key, value] of attrMap.entries()) { | ||
| if (/^capabilities\/storage\/\d+\/class$/.test(key) && value === "ram") { | ||
| return true; | ||
| } | ||
| } | ||
|
|
||
| return false; | ||
| } | ||
|
|
||
| function getShmSupport(attrMap: Map<string, string>, schema: ProviderAttributesSchema): boolean { | ||
| if (getBooleanAttribute("feat-shm", attrMap, schema)) { | ||
| return true; | ||
| } | ||
|
|
||
| return hasShmCapability(attrMap); | ||
| } | ||
|
|
||
| function getPersistentStorageSupport(attrMap: Map<string, string>, schema: ProviderAttributesSchema): boolean { | ||
| if (getBooleanAttribute("feat-persistent-storage", attrMap, schema)) { | ||
| return true; | ||
| } | ||
|
|
||
| if (getBooleanAttribute("hardware-persistent-storage-capability", attrMap, schema)) { | ||
| return true; | ||
| } | ||
|
|
||
| return attrMap.get("capabilities/storage/1/persistent") === "true"; | ||
| } | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
|
|
||
| function getNumberAttribute(key: keyof ProviderAttributesSchema, attrMap: Map<string, string>, schema: ProviderAttributesSchema): number { | ||
| const schemaKey = schema[key].key; | ||
| const value = attrMap.get(schemaKey); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.