-
Notifications
You must be signed in to change notification settings - Fork 16
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
Implement autonaming configuration protocol #1919
Merged
mikhailshilkov
merged 4 commits into
master
from
mikhailshilkov/autonaming-configuration
Jan 7, 2025
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
7a4a29f
Implement autonaming configuration protocol
mikhailshilkov 7841fba
Simplify getDefaultName signature
mikhailshilkov cb51b7f
Conflict if both engine and provider config are specified. Also, unif…
mikhailshilkov d3f09bc
Skip e2e test if short
mikhailshilkov File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a way that we can get the new engine autonaming to work with the existing autoNaming config? It seems like it could work with
EngineAutonamingModePropose
. And then maybe we should throw errors if you try to configure it withEnforce
orDisable
?pulumi-aws-native/provider/pkg/schema/gen.go
Lines 188 to 191 in 11ac7b3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My original take was a no, but now I think I misunderstood
autoTrim
. It could potentially apply to the Propose mode.randomSuffixMinLength
won't work because the suffix (or prefix, or whatever format) is already baked into the proposed name.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, I'm still not sure about
autoTrim
. Do we have any docs about what its supposed to do exactly? Reading the code, its semantics is roughly "if a random suffix makes the generated name too long, we can trim that random suffix down to N characters, where N is either 1 or whatever the user configured". I don't think there is any way to apply that to the proposed name, given it has an unknown structure. I assume we don't want to be trimming non-random portions of the name, and there is no way to ensure the min suffix length rule.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Without/pre
autoTrim
the behavior was to allow the random suffix to be as little as 1 character if that allowed the name to fit within the maxLength requirements.autoTrim
introduced a couple of new behaviors.randomSuffixMinLength
could be used to enforce a minimum length of the random suffixautoTrim: true
. If the length of the name exceeded the maxLength (including the random suffix) then the name would be trimmed to fix within the maxLength. The part of the name that is trimmed is taken from the middle of the name in order to keep uniqueness.It sounds like the
randomSuffixMinLength
might conflict with the new engine functionality. In that case we should throw an error if both are used. SinceautoTrim
removes from the middle it's possible it could work with the new engine behavior, but I think it would also be fine if these two features are mutually exclusive for now (especially if the autotrim behavior could be added to the engine)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 to what Cory said.
Are we able to make a distinction between whether engine level autonaming is configured for the stack/provider or only for a certain resource.
I feel like
autoTrim
+ stack/provider level autonaming config should be an invalid case, butautoTrim
+ resource level autonaming config should be valid because it is essentially an escape hatch.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No
Could you please explain why this distinction? If a user configures a pattern like
${stack}-${name}-${hex(6)}
on the provider level for all AWS Native resources vs. does so for a giveaws-native:foo:Bar
- how does that change the expectation of the user of whether some middle part of the generated name will be trimmed or not?In any case, the question is a bit hypothetical because the provider can't tell the difference with the current design. I think I'm inclined to do the following for
Propose
mode:RandomSuffixMinLength
is configured, throw an error, we can't do anything with it.AutoTrim
is true andautoNamingSpec.MaxLength
is defined, calltrimName(ProposedName, autoNamingSpec.MaxLength)
and hope it does what the user wanted.But we can also keep it simple and throw an error for now.
Thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's fine for now to just say that you can't configure both the engine autonaming and the provider autoName config and throw an error/warning if you have explicitly configured both.
I can create an issue for supporting a
autoTrim
type feature in the engine, would that be in pu/pu?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added returning an error if both engine and provider configs are specified. Also, renamed a few types and variables to make it consistent and more clear.
yes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My reasoning is that users might want to apply the trimming by default to ensure their resources fit AWS limitations, but then overwrite it for a particular resource type as an escape hatch (e.g. Bucket only allowing lowercase chars).
But it's fine for now because the provider can't detect this atm.