Update resource_prefix
syntax for ansible-test.
This commit is contained in:
parent
1d5110db6f
commit
15064c7a42
4 changed files with 9 additions and 5 deletions
4
changelogs/fragments/ansible-test-resource-prefix.yml
Normal file
4
changelogs/fragments/ansible-test-resource-prefix.yml
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
minor_changes:
|
||||||
|
- ansible-test - The generated ``resource_prefix`` variable now meets the host name syntax requirements specified in RFC 1123 and RFC 952.
|
||||||
|
The value used for local tests now places the random number before the hostname component, rather than after.
|
||||||
|
If the resulting value is too long, it will be truncated.
|
|
@ -73,8 +73,6 @@ class AzurePipelines(CIProvider):
|
||||||
except KeyError as ex:
|
except KeyError as ex:
|
||||||
raise MissingEnvironmentVariable(name=ex.args[0])
|
raise MissingEnvironmentVariable(name=ex.args[0])
|
||||||
|
|
||||||
prefix = re.sub(r'[^a-zA-Z0-9]+', '-', prefix).lower()
|
|
||||||
|
|
||||||
return prefix
|
return prefix
|
||||||
|
|
||||||
def get_base_branch(self): # type: () -> str
|
def get_base_branch(self): # type: () -> str
|
||||||
|
|
|
@ -58,9 +58,10 @@ class Local(CIProvider):
|
||||||
|
|
||||||
def generate_resource_prefix(self): # type: () -> str
|
def generate_resource_prefix(self): # type: () -> str
|
||||||
"""Return a resource prefix specific to this CI provider."""
|
"""Return a resource prefix specific to this CI provider."""
|
||||||
node = re.sub(r'[^a-zA-Z0-9]+', '-', platform.node().split('.')[0]).lower()
|
prefix = 'ansible-test-%d-%s' % (
|
||||||
|
random.randint(10000000, 99999999),
|
||||||
prefix = 'ansible-test-%s-%d' % (node, random.randint(10000000, 99999999))
|
platform.node().split('.')[0],
|
||||||
|
)
|
||||||
|
|
||||||
return prefix
|
return prefix
|
||||||
|
|
||||||
|
|
|
@ -313,6 +313,7 @@ class CloudProvider(CloudBase):
|
||||||
def setup(self):
|
def setup(self):
|
||||||
"""Setup the cloud resource before delegation and register a cleanup callback."""
|
"""Setup the cloud resource before delegation and register a cleanup callback."""
|
||||||
self.resource_prefix = self.ci_provider.generate_resource_prefix()
|
self.resource_prefix = self.ci_provider.generate_resource_prefix()
|
||||||
|
self.resource_prefix = re.sub(r'[^a-zA-Z0-9]+', '-', self.resource_prefix)[:63].lower().rstrip('-')
|
||||||
|
|
||||||
atexit.register(self.cleanup)
|
atexit.register(self.cleanup)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue