image_service: update BuildConfig to be NamedTuple
Update BuildConfig to be a NamedTuple and update it's usage. Add
additional unit tests to verify all the arguments.
BUG=b:232440963
TEST=run_tests
Change-Id: I5c58eafc3c308ea9bfa2f068b1a9f585b8ffbd8e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/chromite/+/3665283
Reviewed-by: Cindy Lin <xcl@google.com>
Tested-by: Ram Chandrasekar <rchandrasekar@google.com>
Auto-Submit: Ram Chandrasekar <rchandrasekar@google.com>
Commit-Queue: Ram Chandrasekar <rchandrasekar@google.com>
diff --git a/api/controller/image.py b/api/controller/image.py
index 9572b4a..7c94856 100644
--- a/api/controller/image.py
+++ b/api/controller/image.py
@@ -7,7 +7,6 @@
The image related API endpoints should generally be found here.
"""
-import copy
import functools
import logging
import os
@@ -229,10 +228,8 @@
image_types = _ParseImagesToCreate(to_build)
build_config = _ParseCreateBuildConfig(input_proto)
- factory_build_config = copy.copy(build_config)
- build_config.symlink = LOCATION_CORE
- factory_build_config.symlink = LOCATION_FACTORY
- factory_build_config.output_dir_suffix = LOCATION_FACTORY
+ factory_build_config = build_config._replace(
+ symlink=LOCATION_FACTORY, output_dir_suffix=LOCATION_FACTORY)
# Try building the core and factory images.
# Sorted isn't really necessary here, but it's much easier to test.
@@ -364,6 +361,7 @@
version=version,
disk_layout=disk_layout,
builder_path=builder_path,
+ symlink=LOCATION_CORE,
)