modules/mu/mommacat/naming.rb in cloud-mu-3.4.0 vs modules/mu/mommacat/naming.rb in cloud-mu-3.5.0
- old
+ new
@@ -162,11 +162,11 @@
# @param max_length [Integer]: The maximum length of the resulting resource name.
# @param need_unique_string [Boolean]: Whether to forcibly append a random three-character string to the name to ensure it's unique. Note that this behavior will be automatically invoked if the name must be truncated.
# @param scrub_mu_isms [Boolean]: Don't bother with generating names specific to this deployment. Used to generate generic CloudFormation templates, amongst other purposes.
# @param disallowed_chars [Regexp]: A pattern of characters that are illegal for this resource name, such as +/[^a-zA-Z0-9-]/+
# @return [String]: A full name string for this resource
- def getResourceName(name, max_length: 255, need_unique_string: false, use_unique_string: nil, reuse_unique_string: false, scrub_mu_isms: @original_config['scrub_mu_isms'], disallowed_chars: nil)
+ def getResourceName(name, max_length: 255, need_unique_string: false, use_unique_string: nil, reuse_unique_string: false, scrub_mu_isms: @original_config['scrub_mu_isms'], disallowed_chars: nil, never_gen_unique: false)
if name.nil?
raise MuError, "Got no argument to MU::MommaCat.getResourceName"
end
if @appname.nil? or @environment.nil? or @timestamp.nil? or @seed.nil?
MU.log "getResourceName: Missing global deploy variables in thread #{Thread.current.object_id}, using bare name '#{name}' (appname: #{@appname}, environment: #{@environment}, timestamp: #{@timestamp}, seed: #{@seed}, deploy_id: #{@deploy_id}", MU::WARN, details: caller
@@ -217,10 +217,10 @@
basename = basename + "-" + @seed.upcase
basename.gsub!(disallowed_chars, subchar) if disallowed_chars
else
# If we have to strip anything, assume we've lost uniqueness and
# will have to compensate with #genUniquenessString.
- need_unique_string = true
+ need_unique_string = true if !never_gen_unique
reserved = 4
basename.sub!(/-[^-]+-#{@seed.upcase}-#{Regexp.escape(name.upcase)}$/, "")
basename = basename + "-" + @seed.upcase + "-" + name.upcase
basename.gsub!(disallowed_chars, subchar) if disallowed_chars
end