I can take a stab at this, but could someone point...
# development
c
I can take a stab at this, but could someone point to me to a historical example where we changed the type of a field? (ex: from str to list[str]) I'm grepped around before and feel like I'm missing something obvious? https://pantsbuild.slack.com/archives/C046T6T9U/p1708710290210289
b
I don’t know of an example… But, potentially side stepping the question, I’d be wondering about adding list as a possibility in addition to existing behaviour, rather than switching to only a list. Thoughts? (Also, I’ve asked to see if Tyler is interested in contributing, before I saw this, sorry about that.)
c
hmm, like a
StrListOrMaybeJustStrOption
? No problem, we virtually sit next to each other.
😅 1
b
Yeah, something like that; I don’t know if we have existing examples though. Like, physically sit? Cool
n
Hmm, i'd forgotten that cache-from supports multiple image sources when I added it. To be fair, it's not well documented. I think changing to a list makes sense. Though I also can't find an example of an existing target field like that - should we add a new one
ListOfDictStringToStringField
?
h
A list-valued option supports
--option=foo
as shorthand for
--option="+['foo']"
(and similarly for config and env vars), so switching to a list-valued option usually doesn't break existing configs or cmd-lines that assumed a scalar of the same type
unless the default list value is not empty, or if you try and override a value with another value (because override will now become append)
b
(I think this is a BUILD field)
n
We'd want something like this:
Copy code
docker_image(
    name="with-local-cache-backend",
    cache_to={
        "type": "local",
        "dest": "/tmp/docker-cache/pants-example"
    },
    cache_from=[
    {
        "type": "local",
        "src": "/tmp/docker-cache/pants-example"
    },
    {
        "type": "local",
        "src": "/tmp/docker-cache/pants-example2"
    },
]
)
I took a very rough stab at this - test works, but there may be some mypy issues. https://github.com/pantsbuild/pants/pull/20600
Sorry not trying to take away from anyone's contributions - just thought it might help the docker backend is a little involved with the mixins.
👍 2