Coder Social home page Coder Social logo

URL Variables as Docker Labels? about traefik HOT 5 CLOSED

polds avatar polds commented on May 17, 2024
URL Variables as Docker Labels?

from traefik.

Comments (5)

polds avatar polds commented on May 17, 2024

Looked into it a little more when trying to pass that as a Docker label the toml package throws the following error:

Error creating docker configuration Near line 8, key 'frontends': Near line 8: Table names cannot contain '[' or ']'.

Looks like because the entire frontend name is being used as per docker.tmpl it's attempting also inject the regex into the table name.

Please see the referenced commit for my fixes. If you think these are inline I can make a PR. I'm not exactly sure what to return with if the parsing failed. Right now it returns the original string (Don't like this)

from traefik.

emilevauge avatar emilevauge commented on May 17, 2024

Hi @polds, thank you for reporting. This is an issue. We have to find a smart way to do that. I'm not sure to understand what does:

"makeParsedUrl": func(s1 string) string {
            if u, err := url.Parse(s1); err == nil {
                return u.String()
            }
            return s1
        },

Could you explain a little bit ?

from traefik.

polds avatar polds commented on May 17, 2024

@emilevauge it converts the string to their html entities counterparts. Going in the string is {subdomain: [a-z]+}.example.com and coming back it is converted to an ugly, but safe: %7Bsubdomain:%20%5Ba-z%5D+%7D.example.com but still parsed correctly by Traefik.

My biggest concern is if the url.Parse() fails I have it returning the same string which would inevitably cause issues if url.Parse() can't handle it. I'm wondering if just returning the string "error" would be better.

Edit: The TOML parser was only specifically complaining about the [ ] so perhaps instead of introducing a new template function we use the already available replace function and do something like so:

{{$frontend | replace "[" "" | replace "]" ""}}

from traefik.

emilevauge avatar emilevauge commented on May 17, 2024

@polds, OK I get it. I definitely prefer the second solution to reuse the replace template function. Would you make a PR on that point?

from traefik.

emilevauge avatar emilevauge commented on May 17, 2024

Or even better, should be added directly here: https://github.com/emilevauge/traefik/blob/master/provider/docker.go#L209

from traefik.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.