Skip to content
This repository was archived by the owner on Nov 6, 2025. It is now read-only.

Parsing a config file with Config#130

Merged
danbi2990 merged 1 commit intomainfrom
pott/settings
May 28, 2025
Merged

Parsing a config file with Config#130
danbi2990 merged 1 commit intomainfrom
pott/settings

Conversation

@pott-cho
Copy link
Copy Markdown
Contributor

Close: #106

@sophie-cluml sophie-cluml requested a review from danbi2990 April 22, 2025 14:39
Copy link
Copy Markdown
Contributor

@danbi2990 danbi2990 left a comment

Choose a reason for hiding this comment

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

Changelog needs to be updated.

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 28, 2025

Codecov Report

Attention: Patch coverage is 0% with 24 lines in your changes missing coverage. Please review.

Project coverage is 30.13%. Comparing base (c2b2c2c) to head (875cee9).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/main.rs 0.00% 13 Missing ⚠️
src/settings.rs 0.00% 10 Missing ⚠️
src/web.rs 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #130      +/-   ##
==========================================
+ Coverage   28.42%   30.13%   +1.71%     
==========================================
  Files          10       10              
  Lines         387      365      -22     
==========================================
  Hits          110      110              
+ Misses        277      255      -22     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@danbi2990
Copy link
Copy Markdown
Contributor

danbi2990 commented Apr 29, 2025

The changelog needs to be updated to reflect the CLI and config changes.

CHANGELOG.md Outdated
nor `last` is specified.
- GraphQL API `issues` and `pullRequests` return an error if conflicting
pagination arguments (e.g., `first` and `before`) are provided simultaneously.
- Changed from file-based configuration loading to Config-based loading,
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I don't think "Config-based" clearly conveys what we intended, since it doesn't specify that "Config" refers to the crate. It would be better to use a more explicit form, such as the config crate, or the config crate, or config-based.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Its official site refers to it as config, not Config.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

In addition to Kone's comment, I believe the following three key changes should be included (with better wording):

  • Added CLI arguments: --key, --cert
  • Changed CLI format: -c <CONFIG_PATH>
  • Removed configuration file options for key and cert

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Based on your feedback, I removed the phrases "Config-based" and "resulting in changes to the CLI execution method," and provided a more detailed description of the CLI changes. Please let me know if any further revisions are needed; otherwise, I’ll proceed with this version. Thank you!

- Replaced file-based config loading with the `config` crate.
- Config file must now be specified with `-c <CONFIG_PATH>`
- `--key` and `--cert` are now required as CLI options instead of being set in the config file

@sehkone
Copy link
Copy Markdown

sehkone commented Apr 30, 2025

The title now says Config, but that's not quite right. First, the official name is config, not Config. Second, Config looks like it refers to the Config struct provided by the config crate. We need to be careful when capitalizing the names of software or libraries. Some start with a capital letter, but others don't.

Cc. @danbi2990 @sophie-cluml

src/settings.rs Outdated
}

impl Database {
pub(crate) fn get_path(&self) -> &Path {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm not sure this method is necessary.
If it is, the method name should be something other than get_path, in accordance with our naming guidelines. You can find details in Notion by searching for "get".

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thank you. I removed this function.

src/settings.rs Outdated
pub(crate) key: PathBuf,
}

#[derive(Clone, Debug, Serialize, Deserialize)]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

All Clone traits in this file are unnecessary.

src/settings.rs Outdated
Comment on lines +68 to +73
let config_path_str = config_path
.to_str()
.ok_or_else(|| ConfigError::Message("Invalid config path".into()))?;

let settings = default_config_builder()
.add_source(File::with_name(config_path_str))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

#130 (comment)
As I suggested, the conversion from &Path to &str is unnecessary if we use File::from method.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'm sorry for overlooking that. Thank you for your meticulous code review.

{
let addr = String::deserialize(deserializer)?;
addr.parse()
.map_err(|e| D::Error::custom(format!("invalid address \"{addr}\": {e}")))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Let's maintain consistency in error messages by capitalizing the first letter.

@pott-cho pott-cho force-pushed the pott/settings branch 2 times, most recently from f626cd5 to 8d59ec8 Compare April 30, 2025 04:53
src/settings.rs Outdated
pub(crate) address: SocketAddr,
}

#[derive(Clone, Debug, Serialize, Deserialize)]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Clone trait seems unnecessary.

@danbi2990
Copy link
Copy Markdown
Contributor

How about making commit message a bit more meaningful?
The current message does not seem to clearly reflect the intent of the commit.
Using the PR title as the commit message (with lower case config, as Kone mentioned) might be sufficient and more descriptive.
Additionally, it would be helpful to include "Closes #{issue_number}" in the commit body for better traceability.

src/settings.rs Outdated
config::Config::builder()
.set_default("address", DEFAULT_ADDR)
.expect("valid default address")
.set_default("database", DEFAULT_DATABASE_NAME)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The default value for the database does not work. It should be set using "database.db_path".

README.md Outdated
@@ -30,8 +28,6 @@ db_path = "db_path"
```

- `address`: The address of web server.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Maybe we could add a bit more detail about what the default value is and how it works?
The same applies to db_path.

@pott-cho pott-cho force-pushed the pott/settings branch 2 times, most recently from 2480f37 to c5503a1 Compare May 12, 2025 04:59
- To provide an SSH passphrase, set the `SSH_PASSPHRASE` environment variable.
- `db_path`: The path to the database for creation/connection.
- `db_path`: Folder where the sled database files are stored. Created
automatically if it doesn’t exist. (Default: github-dashboard)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I believe the default value for db_path should be absolute path - or it might be better not to provide a default at all.
It's not a big issue in debug builds since we typically run the program from the project root. However, in release builds, the working directory is not guaranteed, which can lead to the database being created in arbitrary locations.

Copy link
Copy Markdown

@sehkone sehkone May 13, 2025

Choose a reason for hiding this comment

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

I believe the default value for db_path should be absolute path - or it might be better not to provide a default at all.

@danbi2990, could you explain why db_path needs to be an absolute path?

Our software—like any other—should work with both absolute and relative paths. Software generally does not assume that a path is always absolute.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm not saying that db_path must be an absolute path in all cases, but I believe the default value for db_path should be an absolute path.

The reason is to ensure a consistent and predictable database location. If the default is relative to the working directory, a new database might be created in different locations depending on where the program is run. I'd appreciate your thoughts on this.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I still disagree with the idea that default paths should be absolute.

Of course, using absolute paths is preferable during deployment to avoid unexpected outcomes. However, when software suggests default path values, they are typically not absolute. Using absolute paths belongs to the domain of deployment and operations—not the software codebase itself.

For that reason, general documentation such as README.md tends to use relative paths as defaults, unless the path has a specific or special meaning. This also aligns with the decoupling principle: the software should not assume or be tightly bound to specific environments or file system layouts.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Okay, I see your point. Let's keep it as a relative path. Thank you.

Copy link
Copy Markdown
Contributor

@danbi2990 danbi2990 left a comment

Choose a reason for hiding this comment

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

@pott-cho
Could you rebase this onto the main branch?

@pott-cho
Copy link
Copy Markdown
Contributor Author

@danbi2990
I've completed the rebase.

@danbi2990 danbi2990 requested a review from sophie-cluml May 14, 2025 08:15
@danbi2990
Copy link
Copy Markdown
Contributor

@sophie-cluml Could you also review this PR?

README.md Outdated
- `address`: The address of web server.
- `key`: The TLS key path for the web server.
- `cert`: The TLS certificate path for the web server.
- `address`: IP address and port the web server listens on. (Default: 127.0.0.1:8000)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

마크다운파일에 대한 VS code 포매팅 세팅이 최신이 아닌 것 같습니다. 확인 부탁드립니다.

Copy link
Copy Markdown
Contributor Author

@pott-cho pott-cho May 19, 2025

Choose a reason for hiding this comment

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

I fixed it.

use tracing::{error, info};

use crate::conf::RepoInfo;
use crate::settings::Repository as RepoInfo;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

굳이 alias로 use 할 이유가 없는 상황 같아서 alias 없애면 어떨까요?

Copy link
Copy Markdown
Contributor Author

@pott-cho pott-cho May 19, 2025

Choose a reason for hiding this comment

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

If I remove the alias, a conflict will occur between git2::{Cred, FetchOptions, RemoteCallbacks, Repository} and crate::settings::Repository.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Thank you for clarification, certainly I overlooked that conflict.

src/settings.rs Outdated
}
}

/// Creates a new `ConfigBuilder` instance with the default configuration.
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

/// 는 rustdoc comment 이므로, private function에는 사실상 ineffective한 효과를 발생시킬 것 같습니다. 이 함수를 설명해주고 싶다면 단순 // comment로 하는 것을 제안드리고 싶습니다. 한편, 코드로 충분히 다 전달이 되는 내용을 반복할 뿐이라면 주석이 없는 것도 하나의 방향일 것 같습니다.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I removed this.

CHANGELOG.md Outdated
Comment on lines +24 to +26
- Config file must now be specified with `-c <CONFIG_PATH>`
- `--key` and `--cert` are now required as CLI options instead of being set in
the config file
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

문장 뒤에 마침표 부탁드립니다.

README.md Outdated

To run the application without specifying the configuration file path, save the
file to one of the following locations:
<!-- markdownlint-disable -->
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

요거 꼭 필요한가요?

@danbi2990
Copy link
Copy Markdown
Contributor

@pott-cho Could you rebase it onto main please?

@danbi2990 danbi2990 merged commit 803a0a6 into main May 28, 2025
11 of 12 checks passed
@danbi2990 danbi2990 deleted the pott/settings branch May 28, 2025 04:37
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

config로 설정 파일 파싱

4 participants