From 3ae9311dd7961756f6e22c2a77dd3f5690208148 Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Sat, 7 Dec 2024 18:07:45 -0500 Subject: Add get_docker_images() helper function --- src/cli/stasis_indexer/helpers.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/cli/stasis_indexer/helpers.c') diff --git a/src/cli/stasis_indexer/helpers.c b/src/cli/stasis_indexer/helpers.c index f67292f..6d2fdd0 100644 --- a/src/cli/stasis_indexer/helpers.c +++ b/src/cli/stasis_indexer/helpers.c @@ -255,6 +255,23 @@ int get_files(struct StrList **out, const char *path, const char *pattern, ...) return 0; } +struct StrList *get_docker_images(struct Delivery *ctx, char *pattern) { + char *tarball = NULL; + asprintf(&tarball, "%s*.tar*", pattern); + if (!tarball) { + SYSERROR("%s", "Unable to allocate bytes for docker image wildcard pattern"); + return NULL; + } + tolower_s(tarball); + replace_text(tarball, "+", "-", 0); + + struct StrList *files = NULL; + get_files(&files, ctx->storage.docker_artifact_dir, tarball); + guard_free(tarball); + + return files; +} + int load_metadata(struct Delivery *ctx, const char *filename) { char line[STASIS_NAME_MAX] = {0}; -- cgit