remote-add: Add a --collection-id argument to the built-in add command
authorPhilip Withnall <withnall@endlessm.com>
Wed, 7 Jun 2017 13:50:51 +0000 (14:50 +0100)
committerAtomic Bot <atomic-devel@projectatomic.io>
Mon, 26 Jun 2017 15:56:07 +0000 (15:56 +0000)
This allows newly configured remotes to have their collection ID specified,
so that refs from them can be downloaded from peers as well as the
upstream collection, using the remote’s configuration.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
Closes: #924
Approved by: cgwalters

man/ostree-remote.xml
src/ostree/ot-remote-builtin-add.c

index 88e61ac0f04f8d6153ebcf041341f70f3270a01c..2bb8aa71c279d4b2d66ee6148860bc5e7cd217de 100644 (file)
@@ -137,6 +137,16 @@ Boston, MA 02111-1307, USA.
                   <command>ostree remote gpg-import --keyring=FILE</command>.
                 </para></listitem>
             </varlistentry>
+
+            <varlistentry>
+                <term><option>--collection-id</option>=COLLECTION-ID</term>
+
+                <listitem><para>
+                  Set the collection ID for the remote to a value provided by
+                  the repository owner, which allows refs from this remote to be
+                  shared peer to peer.
+                </para></listitem>
+            </varlistentry>
         </variablelist>
     </refsect1>
 
index 3e3aeda9784e3cf3806740bdcab3975cdce21aa0..db115efd4c29ec8ac30156c8c8900681f1fa24f8 100644 (file)
@@ -31,6 +31,9 @@ static gboolean opt_no_gpg_verify;
 static gboolean opt_if_not_exists;
 static char *opt_gpg_import;
 static char *opt_contenturl;
+#ifdef OSTREE_ENABLE_EXPERIMENTAL_API
+static char *opt_collection_id;
+#endif  /* OSTREE_ENABLE_EXPERIMENTAL_API */
 
 static GOptionEntry option_entries[] = {
   { "set", 0, 0, G_OPTION_ARG_STRING_ARRAY, &opt_set, "Set config option KEY=VALUE for remote", "KEY=VALUE" },
@@ -38,6 +41,10 @@ static GOptionEntry option_entries[] = {
   { "if-not-exists", 0, 0, G_OPTION_ARG_NONE, &opt_if_not_exists, "Do nothing if the provided remote exists", NULL },
   { "gpg-import", 0, 0, G_OPTION_ARG_FILENAME, &opt_gpg_import, "Import GPG key from FILE", "FILE" },
   { "contenturl", 0, 0, G_OPTION_ARG_STRING, &opt_contenturl, "Use URL when fetching content", "URL" },
+#ifdef OSTREE_ENABLE_EXPERIMENTAL_API
+  { "collection-id", 0, 0, G_OPTION_ARG_STRING, &opt_collection_id,
+    "Globally unique ID for this repository as an collection of refs for redistribution to other repositories", "COLLECTION-ID" },
+#endif  /* OSTREE_ENABLE_EXPERIMENTAL_API */
   { NULL }
 };
 
@@ -110,6 +117,12 @@ ot_remote_builtin_add (int argc, char **argv, GCancellable *cancellable, GError
                            "gpg-verify",
                            g_variant_new_variant (g_variant_new_boolean (FALSE)));
 
+#ifdef OSTREE_ENABLE_EXPERIMENTAL_API
+  if (opt_collection_id != NULL)
+    g_variant_builder_add (optbuilder, "{s@v}", "collection-id",
+                           g_variant_new_variant (g_variant_new_take_string (g_steal_pointer (&opt_collection_id))));
+#endif  /* OSTREE_ENABLE_EXPERIMENTAL_API */
+
   options = g_variant_ref_sink (g_variant_builder_end (optbuilder));
 
   if (!ostree_repo_remote_change (repo, NULL,