Skip to content

Commit b8626e9

Browse files
committed
refactor(config): move AWS-shaped naming defaults out of shared config
Follow-up to the earlier ec2_instance/region migration. The shared NamingConfig still carried AWS-only vocabulary that non-AWS providers would never use: - naming.patterns: dropped spot_fleet / ec2_fleet / asg regexes (no shared reader consumes them — only AWS validators do; confirmed via grep). They belong on AWSNamingConfig. - naming.fleet_types (instant/request/maintain) and naming.price_types (ondemand/spot/heterogeneous): removed from the shared schema — these are AWS EC2 fleet/pricing concepts, read only by AWS provider code. Both default_config.json files (packaged + repo sample) updated to match. Deferred (documented with TODO): the AWS-specific *prefix* keys (launch_template/instance/fleet/spot_fleet/asg) remain on the shared prefix schemas because ConfigurationAdapter.get_resource_prefix dispatches through hasattr() on those field names; removing them needs an AWS-specific accessor first. performance.caching.ami_resolution likewise stays for now — it is entangled in the shared performance schema and is a cosmetic leak (non-AWS providers simply ignore it), not a functional one.
1 parent 205d446 commit b8626e9

3 files changed

Lines changed: 33 additions & 69 deletions

File tree

config/default_config.json

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,6 @@
4141
"audit_logs": "audit_logs",
4242
"metrics_logs": "metrics_logs"
4343
},
44-
"fleet_types": {
45-
"instant": "instant",
46-
"request": "request",
47-
"maintain": "maintain"
48-
},
49-
"price_types": {
50-
"ondemand": "ondemand",
51-
"spot": "spot",
52-
"heterogeneous": "heterogeneous"
53-
},
5444
"statuses": {
5545
"request": {
5646
"pending": "pending",
@@ -80,19 +70,14 @@
8070
}
8171
},
8272
"patterns": {
83-
"spot_fleet": "^sfr-[a-f0-9]+$",
84-
"ec2_fleet": "^fleet-[a-f0-9]+$",
85-
"asg": "^[a-zA-Z0-9_-]+$",
86-
"request_id": "^(req|ret)-[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"
73+
"request_id": "^(req|ret)-[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$",
74+
"tag_key": "^[\\w\\s+=.@-]+$",
75+
"cidr_block": "^(\\d{1,3}\\.){3}\\d{1,3}/\\d{1,2}$"
8776
},
8877
"prefixes": {
8978
"default": "",
9079
"request": "req-",
9180
"return_prefix": "ret-",
92-
"launch_template": "",
93-
"instance": "",
94-
"fleet": "",
95-
"asg": "",
9681
"tag": ""
9782
}
9883
},
@@ -268,11 +253,6 @@
268253
"default": "",
269254
"request": "req-",
270255
"return_prefix": "ret-",
271-
"launch_template": "",
272-
"instance": "",
273-
"fleet": "",
274-
"spot_fleet": "",
275-
"asg": "",
276256
"tag": ""
277257
}
278258
}

src/orb/config/default_config.json

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,6 @@
3333
"audit_logs": "audit_logs",
3434
"metrics_logs": "metrics_logs"
3535
},
36-
"fleet_types": {
37-
"instant": "instant",
38-
"request": "request",
39-
"maintain": "maintain"
40-
},
41-
"price_types": {
42-
"ondemand": "ondemand",
43-
"spot": "spot",
44-
"heterogeneous": "heterogeneous"
45-
},
4636
"statuses": {
4737
"request": {
4838
"pending": "pending",
@@ -72,19 +62,14 @@
7262
}
7363
},
7464
"patterns": {
75-
"spot_fleet": "^sfr-[a-f0-9]+$",
76-
"ec2_fleet": "^fleet-[a-f0-9]+$",
77-
"asg": "^[a-zA-Z0-9_-]+$",
78-
"request_id": "^(req|ret)-[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"
65+
"request_id": "^(req|ret)-[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$",
66+
"tag_key": "^[\\w\\s+=.@-]+$",
67+
"cidr_block": "^(\\d{1,3}\\.){3}\\d{1,3}/\\d{1,2}$"
7968
},
8069
"prefixes": {
8170
"default": "",
8271
"request": "req-",
8372
"return_prefix": "ret-",
84-
"launch_template": "",
85-
"instance": "",
86-
"fleet": "",
87-
"asg": "",
8873
"tag": ""
8974
}
9075
},
@@ -260,11 +245,6 @@
260245
"default": "",
261246
"request": "req-",
262247
"return_prefix": "ret-",
263-
"launch_template": "",
264-
"instance": "",
265-
"fleet": "",
266-
"spot_fleet": "",
267-
"asg": "",
268248
"tag": ""
269249
}
270250
}

src/orb/config/schemas/common_schema.py

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,18 @@
66

77

88
class ResourcePrefixConfig(BaseModel):
9-
"""Resource prefix configuration."""
9+
"""Resource prefix configuration.
10+
11+
The generic keys (default, request, return_prefix, tag) are provider-agnostic.
12+
The AWS-specific keys (launch_template, instance, fleet, spot_fleet, asg) are
13+
kept here because ``ConfigurationAdapter.get_resource_prefix(key)`` dispatches
14+
through ``hasattr(prefixes, key)`` and AWS handler code passes AWS resource-type
15+
strings. Their default values are empty strings and they are absent from the
16+
packaged default_config.json.
17+
TODO: move launch_template/instance/fleet/spot_fleet/asg to AWSNamingConfig
18+
and replace ``get_resource_prefix`` with an AWS-specific accessor so this
19+
shared schema is free of AWS vocabulary.
20+
"""
1021

1122
default: str = Field("", description="Default prefix for all resources")
1223
request: str = Field("req-", description="Prefix for acquire request IDs")
@@ -34,7 +45,17 @@ def set_default_prefix(self) -> "ResourceConfig":
3445

3546

3647
class PrefixConfig(BaseModel):
37-
"""Prefix configuration."""
48+
"""Naming prefix configuration used by the shared NamingConfig.
49+
50+
The generic keys (default, request, return_prefix, tag) are provider-agnostic.
51+
The AWS-specific keys (launch_template, instance, fleet, asg) are kept for the
52+
same reason as ResourcePrefixConfig: the hasattr-based dispatch in
53+
ConfigurationAdapter.get_resource_prefix requires them as typed fields.
54+
Their default values are empty strings and they are absent from the packaged
55+
default_config.json.
56+
TODO: remove launch_template/instance/fleet/asg once get_resource_prefix
57+
gains an AWS-specific code path.
58+
"""
3859

3960
default: str = Field("", description="Default prefix for all resources")
4061
request: str = Field("req-", description="Prefix for acquire request IDs")
@@ -110,39 +131,22 @@ class NamingConfig(BaseModel):
110131
},
111132
description="Table names for SQL databases",
112133
)
113-
fleet_types: dict[str, str] = Field(
114-
default_factory=lambda: {
115-
"instant": "instant",
116-
"request": "request",
117-
"maintain": "maintain",
118-
},
119-
description="Fleet types for EC2 Fleet and Spot Fleet",
120-
)
121-
price_types: dict[str, str] = Field(
122-
default_factory=lambda: {
123-
"ondemand": "ondemand",
124-
"spot": "spot",
125-
"heterogeneous": "heterogeneous",
126-
},
127-
description="Price types for templates",
128-
)
129134
statuses: StatusValuesConfig = Field(default_factory=lambda: StatusValuesConfig())
130135
patterns: dict[str, str] = Field(
131136
default_factory=lambda: {
132-
"spot_fleet": r"^sfr-[a-f0-9]+$",
133-
"ec2_fleet": r"^fleet-[a-f0-9]+$",
134-
"asg": r"^[a-zA-Z0-9_-]+$",
135137
# No shared "region" pattern: region format varies by provider
136138
# (AWS: us-east-1, GCP: us-central1, Azure: eastus).
137139
# Providers that need region validation contribute their own pattern.
138140
"request_id": r"^(req|ret)-[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$",
139141
"tag_key": r"^[\w\s+=.@-]+$",
140142
"cidr_block": r"^(\d{1,3}\.){3}\d{1,3}/\d{1,2}$",
143+
# AWS-specific patterns (spot_fleet, ec2_fleet, asg, ec2_instance,
144+
# instance_type) belong on AWSNamingConfig, not here.
141145
},
142146
description=(
143147
"Provider-agnostic validation patterns for shared resource identifiers. "
144-
"AWS-specific patterns (ec2_instance, instance_type) belong on the AWS "
145-
"provider's AWSNamingConfig / get_resource_id_pattern() classmethod, not here."
148+
"AWS-specific patterns (spot_fleet, ec2_fleet, asg, ec2_instance, "
149+
"instance_type) belong on the AWS provider's AWSNamingConfig, not here."
146150
),
147151
)
148152
prefixes: PrefixConfig = Field(default_factory=lambda: PrefixConfig()) # type: ignore[call-arg]

0 commit comments

Comments
 (0)