[go: nahoru, domu]

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

Move 'location' from firebase.json to dataconnect.yaml #7373

Merged
merged 10 commits into from
Jun 25, 2024

Conversation

joehan
Copy link
Contributor
@joehan joehan commented Jun 24, 2024

Description

Previously, location was provided as part of firebase.json:

## firebase.json
dataconnect: {
  source: 'dataconnect',
  location: 'us-east4',
}

Now, it is provided via dataconnect.yaml

specVersion: "v1alpha"
serviceId: "other-other-dataconnect"
location: "us-east4"

Scenarios Tested

Tested the following cases using an emulator built from HEAD:

  • Deployed dataconnect, and confirmed that it uses the right location
  • firebase init dataconnect writes location to dataconnect.yaml, not firebase.json
  • Ran SDK generation (via dataconnect:sdk:generate and via emulator:start), and confirmed that the correct location is passed through to the generated SDKs by searching the generated code.

I also tested the cases where someone still has the old way of setting location - we show a warning if location is set in firebase.json, and error out if it is missing in dataconnect.yaml:
Screenshot 2024-06-24 at 3 10 49 PM

@joehan joehan requested a review from fredzqm June 24, 2024 22:53
@@ -43,6 +40,9 @@ export async function readDataConnectYaml(sourceDirectory: string): Promise<Data

function validateDataConnectYaml(unvalidated: any): DataConnectYaml {
// TODO: Add validation
if (!unvalidated["location"]) {
throw new FirebaseError("Missing required field 'location' in dataconnect.yaml");
}
return unvalidated as DataConnectYaml;
Copy link
Contributor

Choose a reason for hiding this comment

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

OOC, Q: do we want to validate other fields as well?

Is there a way to make json schema do it for us?

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's a good point, and we defiitely should leverage the json schema here. Adding a todo for now.

@@ -21,3 +21,10 @@ export async function promptDeleteConnector(
utils.logLabeledSuccess("dataconnect", `Connector ${connectorName} deleted`);
}
}

export function locationInFirebaseJsonWarning() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this used? I saw the same string in src/config.ts

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oops, this was accidentally left in, removing.

`--config_dir=${args.configDir}`,
`--connector_id=${args.connectorId}`,
];
const res = childProcess.spawnSync(commandInfo.binary, cmd, { encoding: "utf-8" });

logger.debug(res.stderr);
if (res.error) {
Copy link
Contributor
@fredzqm fredzqm Jun 24, 2024

Choose a reason for hiding this comment

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

I think we would want to remove this check.
--logtostderr above will re-direct all logs to stderr. Probably negligence on my end.

Have we tested it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This does pipe all logs to stderr - however, it is the stderr of the childprocess, so it is not visible to the end user unless we do this.. This pipes that to the main logger at debug level, so that we can at least use it for debugging issues.
We could alternatively log at info level if we want these to always be displayed, which looks like:
Screenshot 2024-06-24 at 6 28 19 PM
Its a bit noisy, but not too bad overall.

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, thanks for the test run!

The info logs here looks helpful~ I was worrying if if (res.error) would be true in case of any stderror. Doesn't seem to be that case.

config.set("dataconnect.location", info.locationId);
} else {
// Remove location if it was previously set.
config.set("dataconnect", { source: dir });
Copy link
Contributor

Choose a reason for hiding this comment

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

Q: why this branch?

Isn't this equivalent to always do config.set("dataconnect", { source: dir });?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point. Fixed.

@joehan joehan requested a review from fredzqm June 25, 2024 16:17
`--config_dir=${args.configDir}`,
`--connector_id=${args.connectorId}`,
];
const res = childProcess.spawnSync(commandInfo.binary, cmd, { encoding: "utf-8" });

logger.debug(res.stderr);
if (res.error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, thanks for the test run!

The info logs here looks helpful~ I was worrying if if (res.error) would be true in case of any stderror. Doesn't seem to be that case.

@joehan joehan merged commit f3156d1 into master Jun 25, 2024
41 checks passed
@joehan joehan deleted the jh-location-location-location branch June 25, 2024 17:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants