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

Enhance httpd spec include #3977

Merged
merged 6 commits into from
Jan 3, 2024
Merged

Enhance httpd spec include #3977

merged 6 commits into from
Jan 3, 2024

Conversation

wushiqinlou
Copy link
Contributor

All Pull Requests:

Check all that apply:

  • Have you followed the guidelines in our Contributing document, including the instructions about commit messages?
  • Is this PR to correct an issue?
  • Is this PR an enhancement?

Complete Description of Additions/Changes:

This PR is used to enhance httpd_conf spec so that it can handle Include situation.

insights/specs/datasources/httpd.py Outdated Show resolved Hide resolved
# "/etc/httpd/conf.d/*/*.conf",
# "/etc/httpd/conf.modules.d/*.conf"
# ]
# )
httpd_conf_scl_httpd24 = glob_file(
Copy link
Contributor

Choose a reason for hiding this comment

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

Better update the httpd_conf_scl_httpd24 and httpd_conf_scl_jbcs_httpd24 as well.

insights/specs/default.py Outdated Show resolved Hide resolved
with open(conf) as cfp:
_includes = None
for line in cfp.readlines()[::-1]:
if ("Include" in line or "IncludeOptional" in line) and (line.strip().startswith("Include") or line.strip().startswith("IncludeOptional")):
Copy link
Contributor

Choose a reason for hiding this comment

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

If startswith is must-be-checked, better only keep it in the condition, since the in is overlapped by startswith

line = line.strip()
if line.startswith(("Include, "IncludeOptional")):   # --> it seems `line.startswith("Include")`: is enough, right?

for line in cfp.readlines()[::-1]:
if "ServerRoot" in line and line.strip().startswith("ServerRoot"):
server_root = line.strip().split()[-1].strip().strip('"\'')
elif ("Include" in line or "IncludeOptional" in line) and (line.strip().startswith("Include") or line.strip().startswith("IncludeOptional")):
Copy link
Contributor

Choose a reason for hiding this comment

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

The same comment as above.

# Add it only when it exists
all_paths.add(main_httpd_conf)
for line in cfp.readlines()[::-1]:
if "ServerRoot" in line and line.strip().startswith("ServerRoot"):
Copy link
Contributor

Choose a reason for hiding this comment

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

The same comment as above

line = line.strip()
if line.startswith("ServerRoot"):

server_root = line.strip().split()[-1].strip().strip('"\'')
elif ("Include" in line or "IncludeOptional" in line) and (line.strip().startswith("Include") or line.strip().startswith("IncludeOptional")):
includes = line.strip().split()[-1].strip('"\'')
all_paths.update(_get_all_include_conf(server_root, includes))
Copy link
Contributor

@xiangce xiangce Dec 20, 2023

Choose a reason for hiding this comment

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

Would you mind adding a comment about, e.g.: For multiple "Include" directives, all of them will be included

insights/specs/datasources/httpd.py Show resolved Hide resolved
_paths.add(conf)
with open(conf) as cfp:
_includes = None
for line in cfp.readlines()[::-1]:
Copy link
Contributor

Choose a reason for hiding this comment

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

If all multiple "Include" directives will be included, the [::-1] operation is not required, please remove it.

_paths.add(conf)
with open(conf) as cfp:
_includes = None
for line in cfp.readlines()[::-1]:
Copy link
Contributor

Choose a reason for hiding this comment

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

If all multiple "Include" directives will be included, the [::-1] operation is not required, please remove it.

Signed-off-by: jiazhang <[email protected]>
Signed-off-by: jiazhang <[email protected]>
Signed-off-by: jiazhang <[email protected]>
Signed-off-by: jiazhang <[email protected]>
Signed-off-by: jiazhang <[email protected]>
@xiangce xiangce merged commit 3d3eefe into RedHatInsights:master Jan 3, 2024
7 of 11 checks passed
xiangce pushed a commit that referenced this pull request Jan 4, 2024
Signed-off-by: jiazhang <[email protected]>
(cherry picked from commit 3d3eefe)
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.

2 participants