David Boreham
da1ff609fe
All checks were successful
Lint Checks / Run linter (push) Successful in 35s
Publish / Build and publish (push) Successful in 1m33s
Webapp Test / Run webapp test suite (push) Successful in 3m44s
Smoke Test / Run basic test suite (push) Successful in 4m9s
Deploy Test / Run deploy test suite (push) Successful in 7m3s
Implementation of a command to fetch pre-built images from a remote registry, complementing the --push-images option already present on build-containers. The two subcommands used together allow a stack to be deployed without needing to built its images, provided they have been already built and pushed to the specified container image registry. This implementation simply picks the newest image with the right name and platform (matches against the platform Python is running on, so watch out for scenarios where Python is an x86 binary on M1 macs). Reviewed-on: #768 Co-authored-by: David Boreham <david@bozemanpass.com> Co-committed-by: David Boreham <david@bozemanpass.com>
43 lines
1.6 KiB
Python
43 lines
1.6 KiB
Python
# Copyright © 2024 Vulcanize
|
|
|
|
# This program is free software: you can redistribute it and/or modify
|
|
# it under the terms of the GNU Affero General Public License as published by
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
# (at your option) any later version.
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU Affero General Public License for more details.
|
|
|
|
# You should have received a copy of the GNU Affero General Public License
|
|
# along with this program. If not, see <http:#www.gnu.org/licenses/>.
|
|
|
|
import importlib.resources
|
|
|
|
from stack_orchestrator.opts import opts
|
|
from stack_orchestrator.util import get_parsed_stack_config, warn_exit
|
|
|
|
|
|
def get_containers_in_scope(stack: str):
|
|
|
|
# See: https://stackoverflow.com/a/20885799/1701505
|
|
from stack_orchestrator import data
|
|
with importlib.resources.open_text(data, "container-image-list.txt") as container_list_file:
|
|
all_containers = container_list_file.read().splitlines()
|
|
|
|
containers_in_scope = []
|
|
if stack:
|
|
stack_config = get_parsed_stack_config(stack)
|
|
if "containers" not in stack_config or stack_config["containers"] is None:
|
|
warn_exit(f"stack {stack} does not define any containers")
|
|
containers_in_scope = stack_config['containers']
|
|
else:
|
|
containers_in_scope = all_containers
|
|
|
|
if opts.o.verbose:
|
|
print(f'Containers: {containers_in_scope}')
|
|
if stack:
|
|
print(f"Stack: {stack}")
|
|
|
|
return containers_in_scope |