| 
13 | 13 | registries_t registry_manager_init_registries(list_t* registry_urls, clib_secrets_t secrets) {  | 
14 | 14 |   list_t* registries = list_new();  | 
15 | 15 | 
 
  | 
16 |  | -  // Add all the registries that were provided.  | 
17 |  | -  list_iterator_t *registry_iterator = list_iterator_new(registry_urls, LIST_HEAD);  | 
18 |  | -  list_node_t *node;  | 
19 |  | -  while ((node = list_iterator_next(registry_iterator))) {  | 
20 |  | -    char* url = node->val;  | 
21 |  | -    url_data_t *parsed = url_parse(url);  | 
22 |  | -    char* hostname = strdup(parsed->hostname);  | 
23 |  | -    url_free(parsed);  | 
24 |  | -    char* secret = clib_secret_find_for_hostname(secrets, hostname);  | 
25 |  | -    registry_ptr_t registry = registry_create(url, secret);  | 
26 |  | -    list_rpush(registries, list_node_new(registry));  | 
 | 16 | +  if (registry_urls != NULL) {  | 
 | 17 | +    // Add all the registries that were provided.  | 
 | 18 | +    list_iterator_t *registry_iterator = list_iterator_new(registry_urls, LIST_HEAD);  | 
 | 19 | +    list_node_t *node;  | 
 | 20 | +    while ((node = list_iterator_next(registry_iterator))) {  | 
 | 21 | +      char *url = node->val;  | 
 | 22 | +      url_data_t *parsed = url_parse(url);  | 
 | 23 | +      char *secret = clib_secret_find_for_hostname(secrets, parsed->hostname);  | 
 | 24 | +      url_free(parsed);  | 
 | 25 | +      registry_ptr_t registry = registry_create(url, secret);  | 
 | 26 | +      if (registry != NULL) {  | 
 | 27 | +        list_rpush(registries, list_node_new(registry));  | 
 | 28 | +      }  | 
 | 29 | +    }  | 
 | 30 | +    list_iterator_destroy(registry_iterator);  | 
27 | 31 |   }  | 
28 |  | -  list_iterator_destroy(registry_iterator);  | 
29 | 32 | 
 
  | 
30 | 33 |   // And add the default registry.  | 
31 | 34 |   registry_ptr_t registry = registry_create(CLIB_WIKI_URL, NULL);  | 
 | 
0 commit comments