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

chore: enable rest plugin only if in config or if --rest-http-port is set #1593

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

gabrik
Copy link
Contributor

@gabrik gabrik commented Nov 13, 2024

Currently the rest plugin is enabled by default for zenohd, which means that its a required dependency when running a simple zenoh router without configuration.

This PR changes the behaviour by enabling the rest plugin only if the --rest-http-port is passed.

… passed

Signed-off-by: Gabriele Baldoni <gabriele.baldoni@gmail.com>
Copy link

PR missing one of the required labels: {'bug', 'breaking-change', 'enhancement', 'internal', 'documentation', 'dependencies', 'new feature'}

@gabrik gabrik added breaking-change Indicates that the issue implies a breaking change (be it at compile time or at runtime) internal Changes not included in the changelog labels Nov 13, 2024
@gabrik gabrik self-assigned this Nov 13, 2024
@OlivierHecart
Copy link
Contributor

OlivierHecart commented Nov 13, 2024

Should be:

    // apply '--rest-http-port' to config only if explicitly set (overwriting config)
    // or if no config file is set (to apply its default value)
    if args.rest_http_port.is_some() || args.config.is_none() {
        match args.rest_http_port.as_deref() {
            Some(value) => {
                if !value.eq_ignore_ascii_case("none") {
                    config
                        .insert_json5("plugins/rest/http_port", &format!(r#""{value}""#))
                        .unwrap();
                    config
                        .insert_json5("plugins/rest/__required__", "true")
                        .unwrap();
                }
            }
            None => {
                config
                    .insert_json5("plugins/rest/http_port", "8000")
                    .unwrap();
            }
        }
    }

@gabrik
Copy link
Contributor Author

gabrik commented Nov 13, 2024

shouldn't the || args.config.is_none() be removed to load only if the argument passed?

@OlivierHecart
Copy link
Contributor

shouldn't the || args.config.is_none() be removed to load only if the argument passed?

Well the point is that we want rest to start on port 8000 by default if nothing is specified.

@gabrik
Copy link
Contributor Author

gabrik commented Nov 13, 2024

shouldn't the || args.config.is_none() be removed to load only if the argument passed?

Well the point is that we want rest to start on port 8000 by default if nothing is specified.

the point of my PR is not not have it unless --rest-http-port is specified

@OlivierHecart
Copy link
Contributor

shouldn't the || args.config.is_none() be removed to load only if the argument passed?

Well the point is that we want rest to start on port 8000 by default if nothing is specified.

the point of my PR is not not have it unless --rest-http-port is specified

I believed the point of the PR was to not fail if rest was not available but still start it on port 8000 by default if available.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking-change Indicates that the issue implies a breaking change (be it at compile time or at runtime) internal Changes not included in the changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants