dnephin / dobi

A build automation tool for Docker applications
https://dnephin.github.io/dobi/
Apache License 2.0
309 stars 36 forks source link

add SLUG versions for all the config variables #138

Open Enteee opened 6 years ago

Enteee commented 6 years ago

Gitlab defines for some of their variables a SLUG version:

from GitLab CI/CD Variables (example):

CI_PROJECT_PATH_SLUG: $CI_PROJECT_PATH lowercased and with everything except 0-9 and a-z replaced with -. Use in URLs and domain names.

This is super useful when using those variables in combination with docker images names and tags. dobi should provide a SLUG version for all it's config variables.

dnephin commented 6 years ago

I don't think I understand how this would work. Do you mean all the values here would have slug versions?

Are there any in particular that you think would be used as a slug? Is it primarily the env variables?

Enteee commented 6 years ago

Maybe I should explain my use case for this.

I am currently using something like:

image=image:
 [...]
  tags: [ 
    "{git.branch}" 
  ]

which fails when users decide to create a branch with a non docker compatible name. For example: feature/awesome-thing, which is not an uncommon branch name.

image=image:
 [...]
  tags: [ 
    "{slug(git.branch)}" 
  ]

or

image=image:
 [...]
  tags: [ 
    "{git.branch.slug}" 
  ]

should convert feature/awesome-thing to feature-awesome-thing. According to slug rules.

dnephin commented 5 years ago

Cool, that makes sense. I think this would be a cool feature. Maybe something like {git.branch|slug}, which is similar to some other template languages I've seen. The only prefix that could contain a | would be time, but I think that's unlikely.