Skip to content

Commit

Permalink
Drop requirement for profile map to list default stream
Browse files Browse the repository at this point in the history
Fixes: #43

Signed-off-by: Stephen Gallagher <[email protected]>
  • Loading branch information
sgallagher committed Apr 18, 2018
1 parent 3b86e94 commit 0115c5f
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 90 deletions.
14 changes: 0 additions & 14 deletions mod-defaults/bad-missing-default-stream.yaml

This file was deleted.

2 changes: 0 additions & 2 deletions mod-defaults/spec.v1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ data:
# Module profiles indexed by the stream name, optional
# This is a dictionary of stream names to a list of default profiles to be
# installed.
# You need to specify an entry for at least the default stream, the empty
# list is valid.
profiles:
'x.y': []
bar: [baz, snafu]
Expand Down
25 changes: 0 additions & 25 deletions modulemd/modulemd-yaml-emitter-defaults.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,6 @@ _emit_defaults_root (yaml_emitter_t *emitter,
yaml_event_t event;
guint64 mdversion = modulemd_defaults_peek_version (defaults);
const gchar *module_name = modulemd_defaults_peek_module_name (defaults);
const gchar *default_stream =
modulemd_defaults_peek_default_stream (defaults);
GHashTable *profile_defaults =
modulemd_defaults_peek_profile_defaults (defaults);
gchar *name = NULL;
gchar *value = NULL;

Expand All @@ -109,27 +105,6 @@ _emit_defaults_root (yaml_emitter_t *emitter,
MMD_YAML_EMITTER_ERROR_RETURN (error, "Module name is missing");
}

if (default_stream && !(default_stream[0]))
{
/* Ensure that the default profile is references in the profiles
* section
*/
profile_defaults = modulemd_defaults_peek_profile_defaults (defaults);
if (!g_hash_table_contains (profile_defaults, default_stream))
{
MMD_YAML_EMITTER_ERROR_RETURN (
error, "Default stream missing from profile defaults");
}
}

if (default_stream &&
!(g_hash_table_contains (profile_defaults, default_stream)))
{
/* Profile defaults are missing the default stream */
MMD_YAML_EMITTER_ERROR_RETURN (
error, "Module default stream is missing from profile defaults");
}

yaml_mapping_start_event_initialize (
&event, NULL, NULL, 1, YAML_BLOCK_MAPPING_STYLE);

Expand Down
18 changes: 1 addition & 17 deletions modulemd/modulemd-yaml-parser-defaults.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,7 @@ _parse_defaults (yaml_parser_t *parser,
gboolean done = FALSE;
gboolean result = FALSE;
const gchar *module_name = NULL;
const gchar *default_stream = NULL;
guint64 mdversion;
GHashTable *profile_defaults = NULL;
ModulemdDefaults *defaults = NULL;

g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
Expand Down Expand Up @@ -182,27 +180,13 @@ _parse_defaults (yaml_parser_t *parser,
* imported
*/

/* Ensure that the module name and default stream are set */
/* Ensure that the module name is set */
module_name = modulemd_defaults_peek_module_name (defaults);
if (!module_name || !(module_name[0]))
{
MMD_YAML_ERROR_RETURN (error, "Module name not specified");
}

default_stream = modulemd_defaults_peek_default_stream (defaults);
if (default_stream && default_stream[0])
{
/* Ensure that the default profile is references in the profiles
* section
*/
profile_defaults = modulemd_defaults_peek_profile_defaults (defaults);
if (!g_hash_table_contains (profile_defaults, default_stream))
{
MMD_YAML_ERROR_RETURN (
error, "Default stream missing from profile defaults");
}
}

*object = g_object_ref (G_OBJECT (defaults));
result = TRUE;

Expand Down
32 changes: 0 additions & 32 deletions modulemd/test-modulemd-defaults.c
Original file line number Diff line number Diff line change
Expand Up @@ -411,29 +411,6 @@ modulemd_defaults_test_good_ex4 (DefaultsFixture *fixture,
}


static void
modulemd_defaults_test_missing_default_from_profile (DefaultsFixture *fixture,
gconstpointer user_data)
{
gboolean result = FALSE;
gchar *yaml_path = NULL;
GPtrArray *objects = NULL;
GError *error = NULL;

yaml_path =
g_strdup_printf ("%s/mod-defaults/bad-missing-default-stream.yaml",
g_getenv ("MESON_SOURCE_ROOT"));
g_assert_nonnull (yaml_path);

result = parse_yaml_file (yaml_path, &objects, &error);
g_free (yaml_path);
g_assert_true (result);

g_assert_cmpint (objects->len, ==, 0);
g_clear_pointer (&objects, g_ptr_array_unref);
}


static void
modulemd_defaults_test_copy (DefaultsFixture *fixture, gconstpointer user_data)
{
Expand Down Expand Up @@ -948,14 +925,5 @@ main (int argc, char *argv[])
modulemd_regressions_issue45,
NULL);

g_test_add (
"/modulemd/defaults/modulemd_defaults_test_bad_examples/"
"default_stream_profile",
DefaultsFixture,
NULL,
NULL,
modulemd_defaults_test_missing_default_from_profile,
NULL);

return g_test_run ();
};

0 comments on commit 0115c5f

Please sign in to comment.