Skip to content
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

[MM-61280] disable init data if providing external database #870

Merged
merged 5 commits into from
Dec 16, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmd/ltctl/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func RunCreateCmdF(cmd *cobra.Command, args []string) error {
return fmt.Errorf("failed to create SSH agent: %w", err)
}

initData := config.DBDumpURI == ""
initData := config.DBDumpURI == "" || config.ExternalDBSettings.DataSource != ""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wondering if this should be an invalid case at the config level. Does having both defined make sense?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, because it will try to upload the dump to the database using the TerraformDBSettings credentials and getting the database URL from terraform's output DBWriter.

Copy link
Member

@agarciamontoro agarciamontoro Dec 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand this either. With this change, if both DBDumpURI and DataSource are non-empty, initData is true, right? Shouldn't this be

Suggested change
initData := config.DBDumpURI == "" || config.ExternalDBSettings.DataSource != ""
initData := config.DBDumpURI == "" && config.ExternalDBSettings.DataSource == ""

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That looks better 👍

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd still welcome an addition to func (c *Config) IsValid() if having both set is a clear invalid case to avoid unexpected side effects. Not blocking though.

Copy link
Contributor Author

@fmartingr fmartingr Dec 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather do it now than forget later: 9aa44f4

if err = t.Create(extAgent, initData); err != nil {
return fmt.Errorf("failed to create terraform env: %w", err)
}
Expand Down
Loading