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

autoinstall: reject null values in autoinstall top level sections #1377

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion subiquity/server/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ def __init__(self, app):
def setup_autoinstall(self):
if not self.app.autoinstall_config:
return
validate = True
with self.context.child("load_autoinstall_data"):
key_candidates = [self.autoinstall_key]
if self.autoinstall_key_alias is not None:
Expand All @@ -63,8 +64,9 @@ def setup_autoinstall(self):
pass
else:
ai_data = self.autoinstall_default
validate = False

if ai_data is not None and self.autoinstall_schema is not None:
if validate and self.autoinstall_schema is not None:
jsonschema.validate(ai_data, self.autoinstall_schema)
self.load_autoinstall_data(ai_data)

Expand Down
2 changes: 1 addition & 1 deletion subiquity/server/controllers/drivers.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def make_autoinstall(self):
}

def load_autoinstall_data(self, data):
if data is not None and "install" in data:
if "install" in data:
self.model.do_install = data["install"]

def start(self):
Expand Down
5 changes: 0 additions & 5 deletions subiquity/server/controllers/source.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,6 @@ def make_autoinstall(self):
return {"search_drivers": self.model.search_drivers}

def load_autoinstall_data(self, data: Any) -> None:
if data is None:
# For some reason, the schema validator does not reject
# "source: null" despite "type" being "object"
data = self.autoinstall_default

# search_drivers is marked required so the schema validator should
# reject any missing data.
assert "search_drivers" in data
Expand Down
3 changes: 1 addition & 2 deletions subiquity/server/controllers/ubuntu_pro.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ class UbuntuProController(SubiquityController):
},
},
}
autoinstall_default = {}

def __init__(self, app) -> None:
""" Initializer for server-side Ubuntu Pro controller. """
Expand All @@ -79,8 +80,6 @@ def __init__(self, app) -> None:

def load_autoinstall_data(self, data: dict) -> None:
""" Load autoinstall data and update the model. """
if data is None:
return
self.model.token = data.get("token", "")

def make_autoinstall(self) -> dict:
Expand Down