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

Emit database names in manifest. #98

Closed
wants to merge 3 commits into from
Closed

Emit database names in manifest. #98

wants to merge 3 commits into from

Conversation

mitchdenny
Copy link
Member

@mitchdenny mitchdenny commented Oct 6, 2023

Minimal implementation of emitting the database names postgres components. This should go in AFTER #84 (will need to react to changes there).

Fix #104

return builder.WithEnvironment((context) =>
{
if (context.PublisherName == "manifest")
{
context.EnvironmentVariables[$"{ConnectionStringEnvironmentName}{connectionName}"] = $"{{{postgresBuilder.Component.Name}.connectionString}}";
var manifestConnectionString = databaseName == null ? $"{{{postgresBuilder.Component.Name}.connectionString}}" : $"{{{postgresBuilder.Component.Name}.databases.{databaseName}.connectionString}}";
Copy link
Member

Choose a reason for hiding this comment

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

IMO - I wouldn't make it this complicated. I would think this should be good enough:

            "env": {
                "ConnectionStrings__postgres": "{postgres.connectionString};Database=catalogdb"
            },

That way there's no need for a new annotation, and no need to write the list of databases into the "type", "postgres.v1" object.

@ellismg - will string interpolation like I have above work correctly in azd? Get the connectionString from the postgres resource, and then append ;Database=catalogdb to it.

Copy link

Choose a reason for hiding this comment

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

@ellismg - will string interpolation like I have above work correctly in azd? Get the connectionString from the postgres resource, and then append ;Database=catalogdb to it.

Not today - but we could make it work. The reason we didn't allow this was because we felt we'd need to come up with a way to escape the {. If we want to say you put in a literal { or } with a \{ or \} and escape a literal \ with \\, it would be easy enough to implement.

Copy link
Member Author

Choose a reason for hiding this comment

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

There are two parts to making this emission work. One part is emitting the connection string, but the other part is emitting the list of databases on the postgres component.

Copy link
Member

Choose a reason for hiding this comment

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

but the other part is emitting the list of databases on the postgres component.

why do we need that?

Copy link
Member Author

Choose a reason for hiding this comment

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

So that the thing that uses the manifest can create the database. You don't generally give apps that level of privs to the database server. In fact even DDL access is a bit too much.

@mitchdenny
Copy link
Member Author

Yeeting this PR into void due to some upcoming changes in the way we are going to model sub database resources.

@mitchdenny mitchdenny closed this Oct 9, 2023
@github-actions github-actions bot locked and limited conversation to collaborators May 1, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Database names are not written to manifest file
4 participants