Skip to content

Commit

Permalink
daemon: Add commit metadata to deployment properties
Browse files Browse the repository at this point in the history
In another PR I did the manual bridging of commit metadata to deployment
property, but that's annoying. Let's just bridge all commit metadata.

Closes: #1069
Approved by: jlebon
  • Loading branch information
cgwalters authored and rh-atomic-bot committed Oct 25, 2017
1 parent cdfba8e commit 9ec45d3
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 10 deletions.
22 changes: 15 additions & 7 deletions src/daemon/rpmostreed-deployment-utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -231,28 +231,36 @@ rpmostreed_deployment_generate_variant (OstreeSysroot *sysroot,
&replaced_base_pkgs, error))
return NULL;

g_autoptr(GVariant) base_commit = NULL;
if (is_layered)
{
g_autoptr(GVariant) base_commit = NULL;

if (!ostree_repo_load_variant (repo,
OSTREE_OBJECT_TYPE_COMMIT,
base_checksum,
&base_commit,
error))
if (!ostree_repo_load_variant (repo, OSTREE_OBJECT_TYPE_COMMIT,
base_checksum, &base_commit, error))
return NULL;

g_variant_dict_insert (&dict, "base-checksum", "s", base_checksum);
variant_add_commit_details (&dict, "base-", base_commit);
/* for layered commits, check if their base commit has end of life attribute */
variant_add_metadata_attribute (&dict, OSTREE_COMMIT_META_KEY_ENDOFLIFE, "endoflife", base_commit);

/* See below for base commit metadata */
g_autoptr(GVariant) layered_metadata = g_variant_get_child_value (commit, 0);
g_variant_dict_insert (&dict, "layered-commit-meta", "@a{sv}", layered_metadata);
}
else
{
base_commit = g_variant_ref (commit);
base_checksum = g_strdup (csum);
variant_add_metadata_attribute (&dict, OSTREE_COMMIT_META_KEY_ENDOFLIFE, "endoflife", commit);
}

/* We used to bridge individual keys, but that was annoying; just pass through all
* of the commit metadata.
*/
{ g_autoptr(GVariant) base_meta = g_variant_get_child_value (commit, 0);
g_variant_dict_insert (&dict, "base-commit-meta", "@a{sv}", base_meta);
}

sigs = rpmostreed_deployment_gpg_results (repo, refspec, base_checksum, &gpg_enabled);
variant_add_commit_details (&dict, NULL, commit);

Expand Down
6 changes: 4 additions & 2 deletions tests/vmcheck/test-basic.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,10 @@ vm_assert_status_jq \
'.deployments[0]["requested-packages"]' \
'.deployments[0]["requested-local-packages"]' \
'.deployments[0]["base-removals"]' \
'.deployments[0]["requested-base-removals"]'
echo "ok empty pkg arrays in status json"
'.deployments[0]["requested-base-removals"]' \
'.deployments[0]["base-commit-meta"]' \
'.deployments[0]["layered-commit-meta"]|not'
echo "ok empty pkg arrays, and commit meta correct in status json"

# Be sure an unprivileged user exists and that we can SSH into it. This is a bit
# underhanded, but we need a bona fide user session to verify non-priv status,
Expand Down
4 changes: 3 additions & 1 deletion tests/vmcheck/test-layering-basic.sh
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ echo "ok pkg-add foo"
vm_reboot
vm_assert_status_jq \
'.deployments[0]["base-checksum"]' \
'.deployments[0]["pending-base-checksum"]|not'
'.deployments[0]["pending-base-checksum"]|not' \
'.deployments[0]["base-commit-meta"]' \
'.deployments[0]["layered-commit-meta"]["rpmostree.clientlayer_version"] == 2'

vm_assert_layered_pkg foo-1.0 present
echo "ok pkg foo added"
Expand Down

0 comments on commit 9ec45d3

Please sign in to comment.