Resource Naming
cloudspells.core.naming
Resource naming utilities for CloudSpells.
Provides ResourceNamer, which generates consistent, predictable names
for every OCI resource created by a CloudSpells component. All names follow
the pattern:
{stack_name}-{resource_name}-{suffix}
DNS labels are built by concatenating a short prefix with the stack name, keeping them within OCI's 15-character alphanumeric limit.
ResourceNamer
Generate standardised resource names and DNS labels.
Every BaseResource owns a ResourceNamer instance and delegates naming
to it via BaseResource.create_resource_name and
BaseResource.create_dns_label.
Attributes:
| Name | Type | Description |
|---|---|---|
stack_name |
str
|
Pulumi stack name (e.g. |
resource_name |
str
|
Logical name of the spell (e.g. |
Source code in packages/cloudspells-core/src/cloudspells/core/naming.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 | |
__init__(stack_name: str, resource_name: str) -> None
Initialise a namer for a specific resource.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
stack_name
|
str
|
Pulumi stack name (e.g. |
required |
resource_name
|
str
|
Logical name of the spell (e.g. |
required |
Source code in packages/cloudspells-core/src/cloudspells/core/naming.py
31 32 33 34 35 36 37 38 39 | |
create_resource_name(suffix: str) -> str
Build a standardised OCI resource name.
Combines the stack name, resource name, and a type suffix into the
canonical CloudSpells naming pattern: {stack_name}-{resource_name}-{suffix}.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
suffix
|
str
|
Resource type suffix (e.g. |
required |
Returns:
| Type | Description |
|---|---|
str
|
Fully-qualified resource name string. |
Example
namer = ResourceNamer("prod", "lab") namer.create_resource_name("vcn") 'prod-lab-vcn'
Source code in packages/cloudspells-core/src/cloudspells/core/naming.py
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | |
create_dns_label(prefix: str) -> str
Build a DNS-safe label for OCI networking resources.
OCI requires DNS labels to be alphanumeric, start with a letter, and
be at most 15 characters. Concatenates prefix and stack_name to
form the label — keep both values short to stay within the limit.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
prefix
|
str
|
Short alphanumeric prefix (e.g. |
required |
Returns:
| Type | Description |
|---|---|
str
|
DNS label string formed by |
Example
namer = ResourceNamer("mystack", "lab") namer.create_dns_label("vcn") 'vcnmystack'
Source code in packages/cloudspells-core/src/cloudspells/core/naming.py
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 | |