diff options
| -rw-r--r-- | include/docker.h | 1 | ||||
| -rw-r--r-- | src/deliverable.c | 8 | ||||
| -rw-r--r-- | src/docker.c | 12 | 
3 files changed, 18 insertions, 3 deletions
| diff --git a/include/docker.h b/include/docker.h index 413bf6d..33726e6 100644 --- a/include/docker.h +++ b/include/docker.h @@ -83,5 +83,6 @@ int docker_exec(const char *args, unsigned flags);  int docker_build(const char *dirpath, const char *args, int engine);  int docker_script(const char *image, char *data, unsigned flags);  int docker_save(const char *image, const char *destdir, const char *compression_program); +void docker_sanitize_tag(char *str);  #endif //OMC_DOCKER_H diff --git a/src/deliverable.c b/src/deliverable.c index 09b30f1..9b20a63 100644 --- a/src/deliverable.c +++ b/src/deliverable.c @@ -1758,7 +1758,9 @@ int delivery_docker(struct Delivery *ctx) {      // Append image tags to command      for (size_t i = 0; i < total_tags; i++) { -        char *tag = strlist_item(ctx->deploy.docker.tags, i); +        char *tag_orig = strlist_item(ctx->deploy.docker.tags, i); +        strcpy(tag, tag_orig); +        docker_sanitize_tag(tag);          sprintf(args + strlen(args), " -t \"%s\" ", tag);      } @@ -1795,8 +1797,8 @@ int delivery_docker(struct Delivery *ctx) {      // Test the image      // All tags point back to the same image so test the first one we see      // regardless of how many are defined -    char *tag = NULL; -    tag = strlist_item(ctx->deploy.docker.tags, 0); +    strcpy(tag, strlist_item(ctx->deploy.docker.tags, 0)); +    docker_sanitize_tag(tag);      msg(OMC_MSG_L2, "Executing image test script for %s\n", tag);      if (ctx->deploy.docker.test_script) { diff --git a/src/docker.c b/src/docker.c index d5cffd9..e2a392b 100644 --- a/src/docker.c +++ b/src/docker.c @@ -168,3 +168,15 @@ int docker_capable(struct DockerCapabilities *result) {      result->usable = true;      return true;  } + +void docker_sanitize_tag(char *str) { +    char *pos = str; +    while (*pos != 0) { +        if (!isalnum(*pos)) { +            if (*pos != '.' && *pos != ':' && *pos != '/') { +                *pos = '-'; +            } +        } +        pos++; +    } +} | 
