-
Notifications
You must be signed in to change notification settings - Fork 1
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
Add AutoAliasing code migration #39
Conversation
upgrade/migrations_test.go
Outdated
` | ||
|
||
// Write original program to temporary file | ||
orig, err := os.Create("original.go") |
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.
If we need to write to a temp file, at least put it in temporary directory. Ideally, we would be able to do the test in memory though.
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestAutoAliasingMigration(t *testing.T) { |
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.
Let's make sure we can run AutoAliasing
multiple times on a file without changes. We should write migrations with the expectation that they will be run on every provider every time.
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.
It looks like that is handled by another part of the migration. Can we get a test for that part as well?
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.
A couple nits, but otherwise LGTM
@@ -197,6 +216,30 @@ func UpgradeProvider(ctx Context, name string) error { | |||
In(repo.providerDir())) | |||
} | |||
|
|||
if ctx.UpgradeCodeMigration { | |||
applied := make(map[string]struct{}) | |||
for _, opt := range ctx.MigrationOpts { |
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.
We should make sure this is sorted so we get the same output however the user specifies the migrations.
This PR adds an option to perform code migrations on providers, either alongside a normal provider updates (by default or if --kind=all), or by itself (if --kind=code).
If --kind=all, all available code migrations options will be performed.
If --kind=code, a list of options must be specified via --migration-opts.
Currently the only option is to add AutoAliasing.