1
0
mirror of https://github.com/projectatomic/atomic.git synced 2026-02-05 09:44:59 +01:00

update: support update to a different image via --rebase

It allows to override the image to use for the update.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>

Closes: #883
Approved by: rhatdan
This commit is contained in:
Giuseppe Scrivano
2017-02-09 14:22:13 +01:00
committed by Atomic Bot
parent fc1b912768
commit 15db71aec7
5 changed files with 13 additions and 5 deletions

View File

@@ -73,6 +73,8 @@ def cli(subparser):
updatep.set_defaults(_class=Containers, func='update')
updatep.add_argument("container",
help=_("Specify one or more containers. Must be final arguments."))
updatep.add_argument("--rebase", dest="rebase", default=None,
help=_("Rebase to a different image (useful for upgrading to a different tag)"))
if OSTREE_PRESENT:
updatep.add_argument("--set", dest="setvalues",
action='append',
@@ -263,9 +265,9 @@ class Containers(Atomic):
if con.id in vulnerable_uuids:
con.vulnerable = True
def update(self, to=None):
def update(self):
if self.syscontainers.get_checkout(self.args.container):
return self.syscontainers.update_container(self.args.container, self.args.setvalues)
return self.syscontainers.update_container(self.args.container, self.args.setvalues, self.args.rebase)
raise ValueError("System container '%s' is not installed" % self.args.container)
def rollback(self):

View File

@@ -586,7 +586,7 @@ class SystemContainers(object):
return [image_inspect]
return None
def update_container(self, name, setvalues=None):
def update_container(self, name, setvalues=None, rebase=None):
repo = self._get_ostree_repo()
if not repo:
raise ValueError("Cannot find a configured OSTree repo")
@@ -605,7 +605,7 @@ class SystemContainers(object):
with open(os.path.join(self._get_system_checkout_path(), name, "info"), "r") as info_file:
info = json.loads(info_file.read())
image = info["image"]
image = rebase or info["image"]
values = info["values"]
revision = info["revision"] if "revision" in info else None

View File

@@ -578,7 +578,7 @@ _atomic_containers_trim() {
_atomic_containers_update() {
case "$cur" in
-*)
COMPREPLY=( $( compgen -W "--help --set" -- "$cur" ) )
COMPREPLY=( $( compgen -W "--help --set --rebase" -- "$cur" ) )
;;
*)
__atomic_system_containers_containers

View File

@@ -87,6 +87,9 @@ Can use --set to update environment variables.
Only display container IDs
# update OPTIONS:
**--rebase=IMAGE**
Rebase to a different image. If not specified, the same image used to install the container will be used.
**--set=NAME=VALUE**
Set a value that is going to be used by a system container for its configuration and can be specified multiple times. OSTree is required for this feature to be available.

View File

@@ -176,6 +176,9 @@ assert_matches 8081 ${ATOMIC_OSTREE_CHECKOUT_PATH}/${NAME}.0/config.json
${ATOMIC} containers update ${NAME} > update.out
assert_matches "Latest version already installed" update.out
${ATOMIC} containers update ${NAME} --rebase oci:atomic-test-system > update.out
assert_matches "Latest version already installed" update.out
${ATOMIC} containers update --set=PORT=8082 ${NAME}
test -e ${ATOMIC_OSTREE_CHECKOUT_PATH}/${NAME}.1/${NAME}.service
test -e ${ATOMIC_OSTREE_CHECKOUT_PATH}/${NAME}.1/tmpfiles-${NAME}.conf