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

feat(server): YAML config file support #7894

Merged
merged 4 commits into from Mar 12, 2024
Merged

feat(server): YAML config file support #7894

merged 4 commits into from Mar 12, 2024

Conversation

bo0tzz
Copy link
Member

@bo0tzz bo0tzz commented Mar 12, 2024

No description provided.

@@ -341,19 +342,19 @@ export class SystemConfigCore {
if (force || !this.configCache) {
try {
const file = await this.repository.readFile(filepath);
const json = JSON.parse(file.toString());
const config = loadYaml(file.toString()) as any;
Copy link
Member Author

Choose a reason for hiding this comment

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

js-yaml has this option:

json (default: false) - compatibility with JSON.parse behaviour. If true, then duplicate keys in a mapping will override values rather than throwing an error.

I don't think we need it, right?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, that probably doesn't matter. I don't think it matters how exactly the parser works, just that it will still have to pass validation with class-transformer/class-validator either way. This seems like a more edge-case for parsing that we don't care about. Although, it would be great to add an e2e test for this too. I can probably do that if you don't want to both with it.

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh I didn't realize you could unit test it so easily, but that works too.

if (!_.isEmpty(json)) {
this.logger.warn(`Unknown keys found: ${JSON.stringify(json, null, 2)}`);
if (!_.isEmpty(config)) {
this.logger.warn(`Unknown keys found: ${JSON.stringify(config, null, 2)}`);
Copy link
Member Author

Choose a reason for hiding this comment

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

I left this as just JSON output rather than trying to format based on what the input was, to keep the code simple.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think that's fine, it is just a warning anyways and the user should be able to map it back themselves.

Copy link

cloudflare-pages bot commented Mar 12, 2024

Deploying with  Cloudflare Pages  Cloudflare Pages

Latest commit: 26984e5
Status: ✅  Deploy successful!
Preview URL: https://b7c27d26.immich.pages.dev
Branch Preview URL: https://feat-yaml-config.immich.pages.dev

View logs

Copy link
Contributor

@jrasm91 jrasm91 left a comment

Choose a reason for hiding this comment

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

Noice.

@bo0tzz bo0tzz merged commit 72f9295 into main Mar 12, 2024
25 checks passed
@bo0tzz bo0tzz deleted the feat/yaml-config branch March 12, 2024 15:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants