You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Nov 19, 2026. It is now read-only.
Repository navigation
This repository was archived by the owner on Nov 19, 2026. It is now read-only.
transports.ImageName would be trivial to separate, but the transport.KnownTransports[key] reference in signature/policy_config.go is not so easy (we could get rid of it in principle, at the cost of noticeably worse diagnostics; not an easy decision). And the Docker code uses the signature package…
We could perhaps split it to have KnownTransports in one subpackage, always available, but empty by default (this would be used by Docker, which would explicitly register the single needed transport into KnownTransports), and a separate subpackage which would register all transports (perhaps a package with the current transports.ParseImageName would contain the list of all transports, assuming that any code generic enough to use transports.ParseImageName wants all transports).
That would still require policy_config.go changes to silently allow configuration which contains unrecognized transports (but to refuse to accept any image from unrecognized transports, I suppose). That’s still a bit risky and pretty ugly, but doable in principle.
That’s elegant in a way, (and non-obvious in a way), but there should still be a single thing to import for decoupled consumers like skopeo.
When we add a new transport to containers/image, not a single line should need to be updated in skopeo (beyond revendoring).
That can of course be done by having each transport register itself, and then having a subpackage which just includes all of them without doing anything else with them.
There's no need to have another package doing that (ofc you need to change skopeo to add a new transport and I'm fine with that). It's go idiomatic to have a package imported with _ (the underscore) to just call its init function (to register the transport in this case), another package to register everything isn't good to me instead since we need to leave to users the option and adding a single line in skopeo when a new transport is added isn't a big deal to me.
It's go idiomatic to have a package imported with _ (the underscore) to just call its init function
ACK.
ofc you need to change skopeo to add a new transport and I'm fine with that
I’d rather not. It is fine to give callers flexibility, but there should be a default and easy way to consume everything without having to keep up and risking divergence. We don’t want to end up with 3 different CLIs which all accept docker://busybox but only two accept dir: and only one accepts oci:. … I guess it makes sense to me to tie this to transports.ParseImageName; callers of an individual somepackage.NewReference can do whatever they want, but anything which exposes the name syntax should support everything.
(Of course anyone can still explicitly opt out, or, well, import everything and then edit KnownTransports to drop something, or just do string filtering on input, or… But the easy way to use this package should consume everything I think.)
I’d rather not. It is fine to give callers flexibility, but there should be a default and easy way to consume everything without having to keep up and risking divergence. We don’t want to end up with 3 different CLIs which all accept docker://busybox but only two accept dir: and only one accepts oci:. …
Isn't this the whole point of this being a library and that we have subpackages? Docker being the example here were it only needs the docker transport.
Maybe we need to refactor the library to be more flexible in this scenario?
containers/image/registeredtransports contains KnownTransports, which starts empty
containers/image/docker usable independently, registers itself into registeredtransports
containers/image/openshift usable independently, registers itself into registeredtransports
containers/image/image usable with any ImageSource
containers/image/signature uses KnownTransports
containers/image/copy gets ImageReference instances, uses signature and its KnownTransports
containers/image/transports imports all transports to register them, provides ParseImageName
Then,
Callers have perfect flexibility to import a single transport and use it to read/store blobs or whatever, starting with sometransport.{New,Parse}Reference.
Callers can import containers/image/image + a single transport and read information about the image.
Callers can import copy + any two transports (only) and copy stuff, again starting with sometransport.{New,Parse}Reference.
A caller like skopeo, which uses ParseImageName, will always support all transfers.
(I didn’t actually check that they packages are that independent right now. I think they are, or can be.)
Does this make sense? It seems quite flexible to me, except for the ParseImageName bit which is all or nothing.
marking this as enhancement - I plan to work on this after projectatomic/docker#200 since this is just nice to have when I'll open that same PR upstream in docker/docker
Activity
mtrmac commentedon Oct 11, 2016
transports.ImageNamewould be trivial to separate, but thetransport.KnownTransports[key]reference insignature/policy_config.gois not so easy (we could get rid of it in principle, at the cost of noticeably worse diagnostics; not an easy decision). And the Docker code uses thesignaturepackage…We could perhaps split it to have
KnownTransportsin one subpackage, always available, but empty by default (this would be used by Docker, which would explicitly register the single needed transport intoKnownTransports), and a separate subpackage which would register all transports (perhaps a package with the currenttransports.ParseImageNamewould contain the list of all transports, assuming that any code generic enough to usetransports.ParseImageNamewants all transports).That would still require
policy_config.gochanges to silently allow configuration which contains unrecognized transports (but to refuse to accept any image from unrecognized transports, I suppose). That’s still a bit risky and pretty ugly, but doable in principle.runcom commentedon Oct 11, 2016
Something like
transports.Registershould do the job I guess.runcom commentedon Oct 11, 2016
And each transport registers itself when imported? This seems cleaner.
mtrmac commentedon Oct 11, 2016
That’s elegant in a way, (and non-obvious in a way), but there should still be a single thing to import for decoupled consumers like
skopeo.When we add a new transport to
containers/image, not a single line should need to be updated inskopeo(beyond revendoring).That can of course be done by having each transport register itself, and then having a subpackage which just includes all of them without doing anything else with them.
runcom commentedon Oct 11, 2016
There's no need to have another package doing that (ofc you need to change skopeo to add a new transport and I'm fine with that). It's go idiomatic to have a package imported with _ (the underscore) to just call its init function (to register the transport in this case), another package to register everything isn't good to me instead since we need to leave to users the option and adding a single line in skopeo when a new transport is added isn't a big deal to me.
mtrmac commentedon Oct 11, 2016
ACK.
I’d rather not. It is fine to give callers flexibility, but there should be a default and easy way to consume everything without having to keep up and risking divergence. We don’t want to end up with 3 different CLIs which all accept
docker://busyboxbut only two acceptdir:and only one acceptsoci:. … I guess it makes sense to me to tie this totransports.ParseImageName; callers of an individualsomepackage.NewReferencecan do whatever they want, but anything which exposes the name syntax should support everything.mtrmac commentedon Oct 11, 2016
(Of course anyone can still explicitly opt out, or, well, import everything and then edit
KnownTransportsto drop something, or just do string filtering on input, or… But the easy way to use this package should consume everything I think.)runcom commentedon Oct 11, 2016
Isn't this the whole point of this being a library and that we have subpackages? Docker being the example here were it only needs the docker transport.
Maybe we need to refactor the library to be more flexible in this scenario?
mtrmac commentedon Oct 11, 2016
I was thinking something like this
containers/image/registeredtransportscontainsKnownTransports, which starts emptycontainers/image/dockerusable independently, registers itself intoregisteredtransportscontainers/image/openshiftusable independently, registers itself intoregisteredtransportscontainers/image/imageusable with anyImageSourcecontainers/image/signatureusesKnownTransportscontainers/image/copygetsImageReferenceinstances, usessignatureand itsKnownTransportscontainers/image/transportsimports all transports to register them, providesParseImageNameThen,
sometransport.{New,Parse}Reference.containers/image/image+ a single transport and read information about the image.copy+ any two transports (only) and copy stuff, again starting withsometransport.{New,Parse}Reference.ParseImageName, will always support all transfers.(I didn’t actually check that they packages are that independent right now. I think they are, or can be.)
Does this make sense? It seems quite flexible to me, except for the
ParseImageNamebit which is all or nothing.runcom commentedon Oct 11, 2016
marking this as enhancement - I plan to work on this after projectatomic/docker#200 since this is just nice to have when I'll open that same PR upstream in docker/docker
runcom commentedon Oct 11, 2016
@mtrmac will look further at what you suggested tomorrow