Skip to content

reference: upstreams additions from forked docker/reference package#1277

Closed
stevvooe wants to merge 2 commits into
distribution:masterfrom
stevvooe:reference-package-additions
Closed

reference: upstreams additions from forked docker/reference package#1277
stevvooe wants to merge 2 commits into
distribution:masterfrom
stevvooe:reference-package-additions

Conversation

@stevvooe

Copy link
Copy Markdown
Collaborator
Rather than fork, we have now upstreamed some of the additions required in
https://github.com/docker/docker/pull/18586. Of upmost importance is the
addition of a useful WithName function.

While did attempt to restrict Reference implementations to being from the
reference package, making Reference a proper algebraic data type, we ran into
issues with the usage in the main docker project. We will re-examine this
approach in the future.

This change will be followed up with some other additions from the daemon.

Signed-off-by: Stephen J Day stephen.day@docker.com

Comment thread reference/reference.go Outdated

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo: should be NamedOnly

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Fixed.

@stevvooe stevvooe force-pushed the reference-package-additions branch from cad87a1 to adbf469 Compare December 17, 2015 21:52
@stevvooe

Copy link
Copy Markdown
Collaborator Author

Consider moving the "docker default" behavior into this package, as well.

Comment thread reference/reference.go Outdated

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see what you're going for here but I don't think we should make this interface change yet, because it will make it impossible to vendor an updated distribution repository in the Docker Engine until all the reference changes are upstreamed. We will need to vendor an updated distribution repository soon to get the updated manifest code. So I would prefer to wait until the Engine is ported over to a unified reference package before adding a internal() method to this interface.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am sorry, but I want to force that requirement. I am not to thrilled about the forking of the reference package and have put in measures to ensure that doesn't happen again. This also let's us write helper functions with stronger guarantees.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand that you want to force the requirement, but I think it needs to come after the package is unified. I don't want to merge something that will make it impossible to vendor an updated distribution package without further big changes, especially when I need to vendor an updated distribution package soon.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Per our conversation, this has been removed.

@stevvooe stevvooe force-pushed the reference-package-additions branch from adbf469 to b27eda9 Compare December 18, 2015 19:43
Comment thread reference/regexp.go

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you plan to address this before merging, or in a followup?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will come in a follow up.

@dmcgowan

Copy link
Copy Markdown
Collaborator

Consider moving the "docker default" behavior into this package, as well.

I would prefer to add ...WithDefault functions which specify the default behavior. In that case we can provide what docker needs without polluting the package with legacy default behavior.

@stevvooe stevvooe force-pushed the reference-package-additions branch 3 times, most recently from a78e63a to 637b365 Compare January 13, 2016 02:51
@aaronlehmann

Copy link
Copy Markdown

There is a compile error in reference.go.

I think the changes to WithName and WithTag should be reverted now that internal() is not part of the method set, since they assume the reference is one of the concrete types defined in this file.

@stevvooe stevvooe force-pushed the reference-package-additions branch from 637b365 to 16657ab Compare January 13, 2016 21:16
@stevvooe

Copy link
Copy Markdown
Collaborator Author

@aaronlehmann Should be fixed now.

Comment thread reference/reference.go

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this function be preserved, perhaps under the name ParseNameOnly? It is used in several places in the engine.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this not identical to ParseNamed?

It seems there are two paths here: one path uses ParseNamed + NamedOnly/IsNameOnly and the other uses this function (or what would be ParseNameOnly). Do we need to ensure that we only use the repository name or do need to ensure that the input is strictly the repository name?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not identical to ParseNamed because this function won't accept tags or digests. There are some cases where an item being parsed is strictly a name only, and tags or digests shouldn't be accepted. It would be useful to keep this convenience function to support this case. It's fine with me if it's implemented as ParseNamed + NamedOnly.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, so I'll add something with the strict behavior.

Rather than fork, we have now upstreamed some of the additions required in
moby/moby#18586. Of upmost importance is the
addition of a useful WithName function.

While did attempt to restrict Reference implementations to being from the
reference package, making Reference a proper algebraic data type, we ran into
issues with the usage in the main docker project. We will re-examine this
approach in the future.

This change will be followed up with some other additions from the daemon.

Signed-off-by: Stephen J Day <stephen.day@docker.com>
@stevvooe stevvooe force-pushed the reference-package-additions branch from 16657ab to 6664e6d Compare January 13, 2016 22:00
@aaronlehmann

Copy link
Copy Markdown

LGTM - but please hold off on merging to avoid interfering with cross-repository push vendoring

Signed-off-by: Stephen J Day <stephen.day@docker.com>
Comment thread reference/reference.go

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like this won't play nicely without backing types defined outside this package. This seems like an oversight, because the godoc comment says implies it works with other types.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was that not covered by the comment?

+// If the target of named is from another package, any data on the backing
+// type will be lost and replaced with an instance from this package. Simply
+// put, the resulting type will only include information available on the
+// interface.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I may be misreading the code, but it looks like if you call it with a type that's not handled by the switch statement, it returns ErrNameDisallowed.

So the comment says the extra data from a foreign type will be lost, but in reality you just get an error.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The cases for Canonical, Named and Tagged are handled. What else is missing?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see those. I only see concrete types being handled.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Er, looking at the wrong one. Are you implying it should look like WithTag below?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I think that would make sense.

@dmp42

dmp42 commented Jan 25, 2016

Copy link
Copy Markdown
Contributor

What's the status on this one?

@stevvooe

Copy link
Copy Markdown
Collaborator Author

@dmp42 We are still working towards a balance here. The engine PR will drive this one.

@dmcgowan

Copy link
Copy Markdown
Collaborator

Merged alternate with #1778

@dmcgowan dmcgowan closed this Jan 10, 2017
@dmcgowan dmcgowan removed this from the Registry/2.7 milestone Mar 21, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants