Skip to content

Commit 5341acf

Browse files
committed
Replace "whitelist" with allowed_build_names
This change is implemented only in internal variable names. Specification and public functions were left intact. We could deprecate the function names, but then they would not match a keyword from the specification and that would be confusing.
1 parent 44fc186 commit 5341acf

File tree

3 files changed

+87
-87
lines changed

3 files changed

+87
-87
lines changed

modulemd/modulemd-buildopts.c

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ struct _ModulemdBuildopts
2828

2929
gchar *rpm_macros;
3030

31-
GHashTable *whitelist;
31+
GHashTable *allowed_build_names;
3232
GHashTable *arches;
3333
};
3434

@@ -68,8 +68,8 @@ modulemd_buildopts_equals (ModulemdBuildopts *self_1,
6868
return FALSE;
6969
}
7070

71-
if (!modulemd_hash_table_sets_are_equal (self_1->whitelist,
72-
self_2->whitelist))
71+
if (!modulemd_hash_table_sets_are_equal (self_1->allowed_build_names,
72+
self_2->allowed_build_names))
7373
{
7474
return FALSE;
7575
}
@@ -112,8 +112,8 @@ modulemd_buildopts_compare (ModulemdBuildopts *self_1,
112112
return cmp;
113113
}
114114

115-
cmp =
116-
modulemd_hash_table_compare (self_1->whitelist, self_2->whitelist, NULL);
115+
cmp = modulemd_hash_table_compare (
116+
self_1->allowed_build_names, self_2->allowed_build_names, NULL);
117117
if (cmp != 0)
118118
{
119119
return cmp;
@@ -147,7 +147,7 @@ modulemd_buildopts_copy (ModulemdBuildopts *self)
147147
modulemd_buildopts_set_rpm_macros (copy,
148148
modulemd_buildopts_get_rpm_macros (self));
149149

150-
MODULEMD_REPLACE_SET (copy->whitelist, self->whitelist);
150+
MODULEMD_REPLACE_SET (copy->allowed_build_names, self->allowed_build_names);
151151
MODULEMD_REPLACE_SET (copy->arches, self->arches);
152152

153153
return g_steal_pointer (&copy);
@@ -160,7 +160,7 @@ modulemd_buildopts_finalize (GObject *object)
160160
ModulemdBuildopts *self = (ModulemdBuildopts *)object;
161161

162162
g_clear_pointer (&self->rpm_macros, g_free);
163-
g_clear_pointer (&self->whitelist, g_hash_table_unref);
163+
g_clear_pointer (&self->allowed_build_names, g_hash_table_unref);
164164
g_clear_pointer (&self->arches, g_hash_table_unref);
165165

166166
G_OBJECT_CLASS (modulemd_buildopts_parent_class)->finalize (object);
@@ -194,7 +194,7 @@ modulemd_buildopts_add_rpm_to_whitelist (ModulemdBuildopts *self,
194194
const gchar *rpm)
195195
{
196196
g_return_if_fail (MODULEMD_IS_BUILDOPTS (self));
197-
g_hash_table_add (self->whitelist, g_strdup (rpm));
197+
g_hash_table_add (self->allowed_build_names, g_strdup (rpm));
198198
}
199199

200200

@@ -203,14 +203,14 @@ modulemd_buildopts_remove_rpm_from_whitelist (ModulemdBuildopts *self,
203203
const gchar *rpm)
204204
{
205205
g_return_if_fail (MODULEMD_IS_BUILDOPTS (self));
206-
g_hash_table_remove (self->whitelist, rpm);
206+
g_hash_table_remove (self->allowed_build_names, rpm);
207207
}
208208

209209
void
210210
modulemd_buildopts_clear_rpm_whitelist (ModulemdBuildopts *self)
211211
{
212212
g_return_if_fail (MODULEMD_IS_BUILDOPTS (self));
213-
g_hash_table_remove_all (self->whitelist);
213+
g_hash_table_remove_all (self->allowed_build_names);
214214
}
215215

216216

@@ -219,7 +219,7 @@ modulemd_buildopts_get_rpm_whitelist_as_strv (ModulemdBuildopts *self)
219219
{
220220
g_return_val_if_fail (MODULEMD_IS_BUILDOPTS (self), NULL);
221221

222-
return modulemd_ordered_str_keys_as_strv (self->whitelist);
222+
return modulemd_ordered_str_keys_as_strv (self->allowed_build_names);
223223
}
224224

225225

@@ -316,7 +316,7 @@ modulemd_buildopts_class_init (ModulemdBuildoptsClass *klass)
316316
static void
317317
modulemd_buildopts_init (ModulemdBuildopts *self)
318318
{
319-
self->whitelist =
319+
self->allowed_build_names =
320320
g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
321321
self->arches = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
322322
}
@@ -450,10 +450,10 @@ modulemd_buildopts_parse_rpm_buildopts (yaml_parser_t *parser,
450450
if (g_str_equal ((const gchar *)event.data.scalar.value,
451451
"whitelist"))
452452
{
453-
g_hash_table_unref (buildopts->whitelist);
454-
buildopts->whitelist =
453+
g_hash_table_unref (buildopts->allowed_build_names);
454+
buildopts->allowed_build_names =
455455
modulemd_yaml_parse_string_set (parser, &nested_error);
456-
if (buildopts->whitelist == NULL)
456+
if (buildopts->allowed_build_names == NULL)
457457
{
458458
MMD_YAML_ERROR_EVENT_EXIT_BOOL (
459459
error,
@@ -559,7 +559,7 @@ modulemd_buildopts_emit_yaml (ModulemdBuildopts *self,
559559
}
560560
}
561561

562-
if (g_hash_table_size (self->whitelist) != 0)
562+
if (g_hash_table_size (self->allowed_build_names) != 0)
563563
{
564564
ret = mmd_emitter_scalar (
565565
emitter, "whitelist", YAML_PLAIN_SCALAR_STYLE, &nested_error);

modulemd/tests/test-modulemd-buildopts.c

Lines changed: 62 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,17 @@ static void
3030
buildopts_test_construct (void)
3131
{
3232
g_autoptr (ModulemdBuildopts) b = NULL;
33-
g_auto (GStrv) whitelist = NULL;
33+
g_auto (GStrv) allowed_build_names = NULL;
3434
g_auto (GStrv) arches = NULL;
3535

3636
/* Test that the new() function works */
3737
b = modulemd_buildopts_new ();
3838
g_assert_nonnull (b);
3939
g_assert_true (MODULEMD_IS_BUILDOPTS (b));
4040
g_assert_null (modulemd_buildopts_get_rpm_macros (b));
41-
whitelist = modulemd_buildopts_get_rpm_whitelist_as_strv (b);
42-
g_assert_nonnull (whitelist);
43-
g_assert_cmpint (g_strv_length (whitelist), ==, 0);
41+
allowed_build_names = modulemd_buildopts_get_rpm_whitelist_as_strv (b);
42+
g_assert_nonnull (allowed_build_names);
43+
g_assert_cmpint (g_strv_length (allowed_build_names), ==, 0);
4444
arches = modulemd_buildopts_get_arches_as_strv (b);
4545
g_assert_nonnull (arches);
4646
g_assert_cmpint (g_strv_length (arches), ==, 0);
@@ -230,17 +230,17 @@ buildopts_test_copy (void)
230230
{
231231
g_autoptr (ModulemdBuildopts) b = NULL;
232232
g_autoptr (ModulemdBuildopts) b_copy = NULL;
233-
g_auto (GStrv) whitelist = NULL;
233+
g_auto (GStrv) allowed_build_names = NULL;
234234
g_auto (GStrv) arches = NULL;
235235

236236
b = modulemd_buildopts_new ();
237237
g_assert_nonnull (b);
238238
g_assert_true (MODULEMD_IS_BUILDOPTS (b));
239239
g_assert_null (modulemd_buildopts_get_rpm_macros (b));
240-
whitelist = modulemd_buildopts_get_rpm_whitelist_as_strv (b);
241-
g_assert_nonnull (whitelist);
242-
g_assert_cmpint (g_strv_length (whitelist), ==, 0);
243-
g_clear_pointer (&whitelist, g_strfreev);
240+
allowed_build_names = modulemd_buildopts_get_rpm_whitelist_as_strv (b);
241+
g_assert_nonnull (allowed_build_names);
242+
g_assert_cmpint (g_strv_length (allowed_build_names), ==, 0);
243+
g_clear_pointer (&allowed_build_names, g_strfreev);
244244
arches = modulemd_buildopts_get_arches_as_strv (b);
245245
g_assert_nonnull (arches);
246246
g_assert_cmpint (g_strv_length (arches), ==, 0);
@@ -250,10 +250,10 @@ buildopts_test_copy (void)
250250
g_assert_nonnull (b_copy);
251251
g_assert_true (MODULEMD_IS_BUILDOPTS (b_copy));
252252
g_assert_null (modulemd_buildopts_get_rpm_macros (b_copy));
253-
whitelist = modulemd_buildopts_get_rpm_whitelist_as_strv (b_copy);
254-
g_assert_nonnull (whitelist);
255-
g_assert_cmpint (g_strv_length (whitelist), ==, 0);
256-
g_clear_pointer (&whitelist, g_strfreev);
253+
allowed_build_names = modulemd_buildopts_get_rpm_whitelist_as_strv (b_copy);
254+
g_assert_nonnull (allowed_build_names);
255+
g_assert_cmpint (g_strv_length (allowed_build_names), ==, 0);
256+
g_clear_pointer (&allowed_build_names, g_strfreev);
257257
arches = modulemd_buildopts_get_arches_as_strv (b_copy);
258258
g_assert_nonnull (arches);
259259
g_assert_cmpint (g_strv_length (arches), ==, 0);
@@ -267,10 +267,10 @@ buildopts_test_copy (void)
267267
g_assert_nonnull (b);
268268
g_assert_true (MODULEMD_IS_BUILDOPTS (b));
269269
g_assert_cmpstr (modulemd_buildopts_get_rpm_macros (b), ==, "a test");
270-
whitelist = modulemd_buildopts_get_rpm_whitelist_as_strv (b);
271-
g_assert_nonnull (whitelist);
272-
g_assert_cmpint (g_strv_length (whitelist), ==, 0);
273-
g_clear_pointer (&whitelist, g_strfreev);
270+
allowed_build_names = modulemd_buildopts_get_rpm_whitelist_as_strv (b);
271+
g_assert_nonnull (allowed_build_names);
272+
g_assert_cmpint (g_strv_length (allowed_build_names), ==, 0);
273+
g_clear_pointer (&allowed_build_names, g_strfreev);
274274
arches = modulemd_buildopts_get_arches_as_strv (b);
275275
g_assert_nonnull (arches);
276276
g_assert_cmpint (g_strv_length (arches), ==, 0);
@@ -280,10 +280,10 @@ buildopts_test_copy (void)
280280
g_assert_nonnull (b_copy);
281281
g_assert_true (MODULEMD_IS_BUILDOPTS (b_copy));
282282
g_assert_cmpstr (modulemd_buildopts_get_rpm_macros (b_copy), ==, "a test");
283-
whitelist = modulemd_buildopts_get_rpm_whitelist_as_strv (b_copy);
284-
g_assert_nonnull (whitelist);
285-
g_assert_cmpint (g_strv_length (whitelist), ==, 0);
286-
g_clear_pointer (&whitelist, g_strfreev);
283+
allowed_build_names = modulemd_buildopts_get_rpm_whitelist_as_strv (b_copy);
284+
g_assert_nonnull (allowed_build_names);
285+
g_assert_cmpint (g_strv_length (allowed_build_names), ==, 0);
286+
g_clear_pointer (&allowed_build_names, g_strfreev);
287287
arches = modulemd_buildopts_get_arches_as_strv (b_copy);
288288
g_assert_nonnull (arches);
289289
g_assert_cmpint (g_strv_length (arches), ==, 0);
@@ -297,11 +297,11 @@ buildopts_test_copy (void)
297297
g_assert_nonnull (b);
298298
g_assert_true (MODULEMD_IS_BUILDOPTS (b));
299299
g_assert_null (modulemd_buildopts_get_rpm_macros (b));
300-
whitelist = modulemd_buildopts_get_rpm_whitelist_as_strv (b);
301-
g_assert_nonnull (whitelist);
302-
g_assert_cmpint (g_strv_length (whitelist), ==, 1);
303-
g_assert_cmpstr (whitelist[0], ==, "testrpm");
304-
g_clear_pointer (&whitelist, g_strfreev);
300+
allowed_build_names = modulemd_buildopts_get_rpm_whitelist_as_strv (b);
301+
g_assert_nonnull (allowed_build_names);
302+
g_assert_cmpint (g_strv_length (allowed_build_names), ==, 1);
303+
g_assert_cmpstr (allowed_build_names[0], ==, "testrpm");
304+
g_clear_pointer (&allowed_build_names, g_strfreev);
305305
arches = modulemd_buildopts_get_arches_as_strv (b);
306306
g_assert_nonnull (arches);
307307
g_assert_cmpint (g_strv_length (arches), ==, 0);
@@ -311,11 +311,11 @@ buildopts_test_copy (void)
311311
g_assert_nonnull (b_copy);
312312
g_assert_true (MODULEMD_IS_BUILDOPTS (b_copy));
313313
g_assert_null (modulemd_buildopts_get_rpm_macros (b_copy));
314-
whitelist = modulemd_buildopts_get_rpm_whitelist_as_strv (b_copy);
315-
g_assert_nonnull (whitelist);
316-
g_assert_cmpint (g_strv_length (whitelist), ==, 1);
317-
g_assert_cmpstr (whitelist[0], ==, "testrpm");
318-
g_clear_pointer (&whitelist, g_strfreev);
314+
allowed_build_names = modulemd_buildopts_get_rpm_whitelist_as_strv (b_copy);
315+
g_assert_nonnull (allowed_build_names);
316+
g_assert_cmpint (g_strv_length (allowed_build_names), ==, 1);
317+
g_assert_cmpstr (allowed_build_names[0], ==, "testrpm");
318+
g_clear_pointer (&allowed_build_names, g_strfreev);
319319
arches = modulemd_buildopts_get_arches_as_strv (b_copy);
320320
g_assert_nonnull (arches);
321321
g_assert_cmpint (g_strv_length (arches), ==, 0);
@@ -329,10 +329,10 @@ buildopts_test_copy (void)
329329
g_assert_nonnull (b);
330330
g_assert_true (MODULEMD_IS_BUILDOPTS (b));
331331
g_assert_null (modulemd_buildopts_get_rpm_macros (b));
332-
whitelist = modulemd_buildopts_get_rpm_whitelist_as_strv (b);
333-
g_assert_nonnull (whitelist);
334-
g_assert_cmpint (g_strv_length (whitelist), ==, 0);
335-
g_clear_pointer (&whitelist, g_strfreev);
332+
allowed_build_names = modulemd_buildopts_get_rpm_whitelist_as_strv (b);
333+
g_assert_nonnull (allowed_build_names);
334+
g_assert_cmpint (g_strv_length (allowed_build_names), ==, 0);
335+
g_clear_pointer (&allowed_build_names, g_strfreev);
336336
arches = modulemd_buildopts_get_arches_as_strv (b);
337337
g_assert_nonnull (arches);
338338
g_assert_cmpint (g_strv_length (arches), ==, 1);
@@ -343,10 +343,10 @@ buildopts_test_copy (void)
343343
g_assert_nonnull (b_copy);
344344
g_assert_true (MODULEMD_IS_BUILDOPTS (b_copy));
345345
g_assert_null (modulemd_buildopts_get_rpm_macros (b_copy));
346-
whitelist = modulemd_buildopts_get_rpm_whitelist_as_strv (b_copy);
347-
g_assert_nonnull (whitelist);
348-
g_assert_cmpint (g_strv_length (whitelist), ==, 0);
349-
g_clear_pointer (&whitelist, g_strfreev);
346+
allowed_build_names = modulemd_buildopts_get_rpm_whitelist_as_strv (b_copy);
347+
g_assert_nonnull (allowed_build_names);
348+
g_assert_cmpint (g_strv_length (allowed_build_names), ==, 0);
349+
g_clear_pointer (&allowed_build_names, g_strfreev);
350350
arches = modulemd_buildopts_get_arches_as_strv (b_copy);
351351
g_assert_nonnull (arches);
352352
g_assert_cmpint (g_strv_length (arches), ==, 1);
@@ -390,37 +390,37 @@ static void
390390
buildopts_test_whitelist (void)
391391
{
392392
g_autoptr (ModulemdBuildopts) b = NULL;
393-
g_auto (GStrv) whitelist = NULL;
393+
g_auto (GStrv) allowed_build_names = NULL;
394394

395395
b = modulemd_buildopts_new ();
396396
g_assert_nonnull (b);
397397
g_assert_true (MODULEMD_IS_BUILDOPTS (b));
398398

399399
/* Assert we start with 0 rpms */
400-
whitelist = modulemd_buildopts_get_rpm_whitelist_as_strv (b);
401-
g_assert_cmpint (g_strv_length (whitelist), ==, 0);
402-
g_clear_pointer (&whitelist, g_strfreev);
400+
allowed_build_names = modulemd_buildopts_get_rpm_whitelist_as_strv (b);
401+
g_assert_cmpint (g_strv_length (allowed_build_names), ==, 0);
402+
g_clear_pointer (&allowed_build_names, g_strfreev);
403403

404-
/* Whitelist some rpms */
404+
/* Allow some rpms */
405405
modulemd_buildopts_add_rpm_to_whitelist (b, "test2");
406406
modulemd_buildopts_add_rpm_to_whitelist (b, "test3");
407407
modulemd_buildopts_add_rpm_to_whitelist (b, "test1");
408-
whitelist = modulemd_buildopts_get_rpm_whitelist_as_strv (b);
409-
g_assert_cmpint (g_strv_length (whitelist), ==, 3);
408+
allowed_build_names = modulemd_buildopts_get_rpm_whitelist_as_strv (b);
409+
g_assert_cmpint (g_strv_length (allowed_build_names), ==, 3);
410410
// They should be sorted
411-
g_assert_cmpstr (whitelist[0], ==, "test1");
412-
g_assert_cmpstr (whitelist[1], ==, "test2");
413-
g_assert_cmpstr (whitelist[2], ==, "test3");
414-
g_clear_pointer (&whitelist, g_strfreev);
411+
g_assert_cmpstr (allowed_build_names[0], ==, "test1");
412+
g_assert_cmpstr (allowed_build_names[1], ==, "test2");
413+
g_assert_cmpstr (allowed_build_names[2], ==, "test3");
414+
g_clear_pointer (&allowed_build_names, g_strfreev);
415415

416416
/* Remove some rpms */
417417
modulemd_buildopts_remove_rpm_from_whitelist (b, "test2");
418-
whitelist = modulemd_buildopts_get_rpm_whitelist_as_strv (b);
419-
g_assert_cmpint (g_strv_length (whitelist), ==, 2);
418+
allowed_build_names = modulemd_buildopts_get_rpm_whitelist_as_strv (b);
419+
g_assert_cmpint (g_strv_length (allowed_build_names), ==, 2);
420420
// They should be sorted
421-
g_assert_cmpstr (whitelist[0], ==, "test1");
422-
g_assert_cmpstr (whitelist[1], ==, "test3");
423-
g_clear_pointer (&whitelist, g_strfreev);
421+
g_assert_cmpstr (allowed_build_names[0], ==, "test1");
422+
g_assert_cmpstr (allowed_build_names[1], ==, "test3");
423+
g_clear_pointer (&allowed_build_names, g_strfreev);
424424
}
425425

426426
static void
@@ -468,7 +468,7 @@ buildopts_test_parse_yaml (void)
468468
g_autoptr (GError) error = NULL;
469469
MMD_INIT_YAML_PARSER (parser);
470470
g_autofree gchar *yaml_path = NULL;
471-
g_auto (GStrv) whitelist = NULL;
471+
g_auto (GStrv) allowed_build_names = NULL;
472472
g_auto (GStrv) arches = NULL;
473473
g_autoptr (FILE) yaml_stream = NULL;
474474
yaml_path = g_strdup_printf ("%s/b.yaml", g_getenv ("TEST_DATA_PATH"));
@@ -488,12 +488,12 @@ buildopts_test_parse_yaml (void)
488488
==,
489489
"%demomacro 1\n"
490490
"%demomacro2 %{demomacro}23\n");
491-
whitelist = modulemd_buildopts_get_rpm_whitelist_as_strv (b);
492-
g_assert_cmpint (g_strv_length (whitelist), ==, 4);
493-
g_assert_cmpstr (whitelist[0], ==, "fooscl-1-bar");
494-
g_assert_cmpstr (whitelist[1], ==, "fooscl-1-baz");
495-
g_assert_cmpstr (whitelist[2], ==, "xxx");
496-
g_assert_cmpstr (whitelist[3], ==, "xyz");
491+
allowed_build_names = modulemd_buildopts_get_rpm_whitelist_as_strv (b);
492+
g_assert_cmpint (g_strv_length (allowed_build_names), ==, 4);
493+
g_assert_cmpstr (allowed_build_names[0], ==, "fooscl-1-bar");
494+
g_assert_cmpstr (allowed_build_names[1], ==, "fooscl-1-baz");
495+
g_assert_cmpstr (allowed_build_names[2], ==, "xxx");
496+
g_assert_cmpstr (allowed_build_names[3], ==, "xyz");
497497
arches = modulemd_buildopts_get_arches_as_strv (b);
498498
g_assert_cmpint (g_strv_length (arches), ==, 2);
499499
g_assert_cmpstr (arches[0], ==, "ppc64le");

modulemd/tests/test-modulemd-modulestream.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -678,7 +678,7 @@ module_stream_test_v2_yaml (void)
678678

679679
ModulemdBuildopts *buildopts = NULL;
680680
g_autofree gchar *buildopts_rpm_macros_prop = NULL;
681-
g_auto (GStrv) buildopts_rpm_whitelist = NULL;
681+
g_auto (GStrv) buildopts_rpm_allowed_build_names = NULL;
682682
g_auto (GStrv) buildopts_arches = NULL;
683683

684684
GVariant *tmp_variant = NULL;
@@ -940,18 +940,18 @@ module_stream_test_v2_yaml (void)
940940
==,
941941
"%demomacro 1\n%demomacro2 %{demomacro}23\n");
942942

943-
buildopts_rpm_whitelist =
943+
buildopts_rpm_allowed_build_names =
944944
modulemd_buildopts_get_rpm_whitelist_as_strv (buildopts);
945945
buildopts_arches = modulemd_buildopts_get_arches_as_strv (buildopts);
946946

947947
g_assert_true (g_strv_contains (
948-
(const gchar *const *)buildopts_rpm_whitelist, "fooscl-1-bar"));
948+
(const gchar *const *)buildopts_rpm_allowed_build_names, "fooscl-1-bar"));
949949
g_assert_true (g_strv_contains (
950-
(const gchar *const *)buildopts_rpm_whitelist, "fooscl-1-baz"));
951-
g_assert_true (
952-
g_strv_contains ((const gchar *const *)buildopts_rpm_whitelist, "xxx"));
953-
g_assert_true (
954-
g_strv_contains ((const gchar *const *)buildopts_rpm_whitelist, "xyz"));
950+
(const gchar *const *)buildopts_rpm_allowed_build_names, "fooscl-1-baz"));
951+
g_assert_true (g_strv_contains (
952+
(const gchar *const *)buildopts_rpm_allowed_build_names, "xxx"));
953+
g_assert_true (g_strv_contains (
954+
(const gchar *const *)buildopts_rpm_allowed_build_names, "xyz"));
955955
g_assert_true (
956956
g_strv_contains ((const gchar *const *)buildopts_arches, "i686"));
957957
g_assert_true (
@@ -1051,7 +1051,7 @@ module_stream_test_v2_yaml (void)
10511051
g_clear_pointer (&profile_names, g_strfreev);
10521052

10531053
g_clear_pointer (&buildopts_rpm_macros_prop, g_free);
1054-
g_clear_pointer (&buildopts_rpm_whitelist, g_strfreev);
1054+
g_clear_pointer (&buildopts_rpm_allowed_build_names, g_strfreev);
10551055
g_clear_pointer (&buildopts_arches, g_strfreev);
10561056

10571057

0 commit comments

Comments
 (0)