-
Notifications
You must be signed in to change notification settings - Fork 908
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
Deb822 default sources list d #4437
Changes from 1 commit
5cbf17d
0af28d3
fda98cc
39c5c06
383193d
203d04f
c7ac464
b56fb0c
64b095b
38cfd5d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,8 +18,6 @@ | |
from textwrap import dedent, indent | ||
from typing import Dict | ||
|
||
import apt_pkg | ||
|
||
from cloudinit import features, gpg, subp, templater, util | ||
from cloudinit.cloud import Cloud | ||
from cloudinit.config import Config | ||
|
@@ -511,7 +509,7 @@ def disable_suites(disabled, src, release) -> str: | |
return src | ||
|
||
retsrc = src | ||
if is_deb822_format(src): | ||
if is_deb822_sources_format(src): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why are we renaming a function that is introduced in this commit series? To avoid unnecessary code churn / review burden (reviewing the "same code" multiple times), it would be better to name it as you want it in the commit that introduces the function. |
||
return disable_suites_deb822(disabled, src, release) | ||
for suite in disabled: | ||
suite = map_known_suites(suite) | ||
|
@@ -551,7 +549,7 @@ def add_mirror_keys(cfg, cloud, target): | |
add_apt_key(mirror, cloud, target, file_name=key) | ||
|
||
|
||
def is_deb822_format(apt_src_content: str) -> bool: | ||
def is_deb822_sources_format(apt_src_content: str) -> bool: | ||
"""Simple check for deb822 format for apt source content | ||
|
||
Only validates that minimal required keys are present in the file, which | ||
|
@@ -562,16 +560,18 @@ def is_deb822_format(apt_src_content: str) -> bool: | |
Return True if content looks like it is deb822 formatted APT source. | ||
""" | ||
# TODO(At jammy EOL: use aptsources.sourceslist.Deb822SourceEntry.invalid) | ||
try: | ||
apt_src = safeyaml.load(apt_src_content) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is more refactoring within the series that we don't need in the commit history. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. +1 on these points here @holman. I had actually squash merged this PR during merge instead of a rebase merge because of the way I had dealt with review comments and refactoring code after the fact. When I handle some of the review comments, I didn't squash the content into the correct commit in some cases and rather that presenting 10 separate commits for this effort, I thought it was going to be more appropriate to squash merge and represent the set of changes in the single commit message. |
||
except (safeyaml.YAMLError, TypeError, ValueError): | ||
if re.findall(r"^(deb |deb-src )", apt_src_content, re.M): | ||
return False | ||
if not isinstance(apt_src, dict): | ||
return False | ||
|
||
# Are all required deb822 keys present | ||
required_keys = set(["Types", "Suites", "Components", "URIs"]) | ||
return required_keys == required_keys.intersection(apt_src.keys()) | ||
if re.findall( | ||
r"^(Types: |Suites: |Components: |URIs: )", apt_src_content, re.M | ||
): | ||
return True | ||
# Did not match any required deb822 format keys | ||
LOG.warning( | ||
"apt.sources_list value does not match either deb822 source keys or" | ||
" deb/deb-src list keys. Assuming APT deb/deb-src list format." | ||
) | ||
return False | ||
TheRealFalcon marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
|
||
DEFAULT_APT_CFG = { | ||
|
@@ -656,7 +656,7 @@ def generate_sources_list(cfg, release, mirrors, cloud): | |
|
||
rendered = templater.render_string(tmpl, params) | ||
if tmpl: | ||
if is_deb822_format(rendered): | ||
if is_deb822_sources_format(rendered): | ||
if aptsrc_file == apt_sources_list: | ||
TheRealFalcon marked this conversation as resolved.
Show resolved
Hide resolved
|
||
LOG.debug( | ||
"Provided 'sources_list' user-data is deb822 format," | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This import removal doesn't belong in this commit if we are merging these commits individually.