Skip to content
This repository was archived by the owner on Jul 18, 2025. It is now read-only.

Make required arguments required.#162

Merged
calavera merged 3 commits into
docker-archive-public:masterfrom
vdemeester:137-required-containers
Apr 12, 2016
Merged

Make required arguments required.#162
calavera merged 3 commits into
docker-archive-public:masterfrom
vdemeester:137-required-containers

Conversation

@vdemeester

Copy link
Copy Markdown
Contributor

Change method signatures to make required arguments actually required (using a paramater), all accross the API 🐮.

It's not complete (there is a few FIXME still), I'm opening the PR to gather opinion on this ; I also think it should not be merged until docker 1.11 is released 🐵.

@stevvooe is this something that you had in mind ?

/cc @calavera @MHBauer @dongluochen

This is related to and fixes #137.

🐸

Signed-off-by: Vincent Demeester vincent@sbr.pm

Comment thread types/client.go Outdated
ImageID string // ImageID is the name of the image to pull
Tag string // Tag is the name of the tag to be pulled
RegistryAuth string // RegistryAuth is the base64 encoded credentials for the registry
Tag string // Tag is the name of the tag to be pulled

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Tag should be part of argument. For example, "redis:latest" should be part of the argument. For now, we have to parse this on the client side, but in the future, this format should be daemon specific.

@stevvooe

Copy link
Copy Markdown
Contributor

@vdemeester This is exactly what I was talking about. This is a fantastic start!

@MHBauer

MHBauer commented Mar 21, 2016

Copy link
Copy Markdown
Contributor

I like it. Makes using the api more understandable at a glance.

@calavera

Copy link
Copy Markdown
Contributor

go for it!

I also think it should not be merged until docker 1.11 is released

agreed

@vdemeester vdemeester changed the title WIP: Make required arguments required. Make required arguments required. Mar 25, 2016
Comment thread client/image_reference.go Outdated
@@ -0,0 +1,27 @@
package client

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

should this be in types?

Should we have a more general package under types/reference? We've talked about this several times, maybe now it's the right moment to do it

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@calavera ah yes, good idea 😉

@vdemeester

Copy link
Copy Markdown
Contributor Author

@stevvooe updated with reference handling. I'm not sure I got all right but 😝

@calavera

Copy link
Copy Markdown
Contributor

LGTM

Comment thread types/reference/image_reference.go Outdated
tag = tagged.Tag()
}
// This is in order to support a reference like :
// tag@sha256:ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Calling this tag is confusing. Use name. When speaking about image references, the tag is the portion after the name (ie name:tag or name:tag@digest).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ah I see what you mean :)

Change method signatures to make required arguments actually
required (using a paramater), all accross the API.

Signed-off-by: Vincent Demeester <vincent@sbr.pm>
At some point the format of the reference should be daemon specific, and
thus should not be *imposed* via the repository:tag current
arguments. The engine-api library should encorage the use of reference.

Signed-off-by: Vincent Demeester <vincent@sbr.pm>
Comment thread client/interface.go
ContainerAttach(ctx context.Context, options types.ContainerAttachOptions) (types.HijackedResponse, error)
ContainerCommit(ctx context.Context, options types.ContainerCommitOptions) (types.ContainerCommitResponse, error)
ContainerAttach(ctx context.Context, container string, options types.ContainerAttachOptions) (types.HijackedResponse, error)
ContainerCommit(ctx context.Context, container string, options types.ContainerCommitOptions) (types.ContainerCommitResponse, error)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Hum, there is RepositoryName and Tag in the types.ContainerCommitOptions struct.. It could also be replaced by a ref, I'll look into it.

Comment thread types/reference/image_reference.go Outdated
// This is in order to support a reference like :
// name@sha256:ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
if digested, isDigested := ref.(distreference.Digested); isDigested {
tag = fmt.Sprintf("%s@%s", tag, digested.Digest().String())

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 think the Docker API currently supports providing both a tag and a digest. Do you know of any places where this is allowed?

BTW, if we keep this, I would drop the Sprintf and do tag += "@" + digested.Digest().String().

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I would prefer not to introduce another string format which is a subset of the reference format. If we want to support both tag and digest in the Docker API we should send it as a full reference and not try and to sneak it in with the tag.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The problem here is the variable naming. The name tag should be name. The code may be wrong, as well.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think you are right, there is a disconnect between what the comment says it is supporting name@sha256:ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff which would assume a valid reference such as docker.io/library/ubuntu@name@sha256:ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff and what the code is doing latest@name@sha256:ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff which is not a valid reference.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

oh that's right, I completely messed up this part, working on it 👼

… for reference related code O:).

Signed-off-by: Vincent Demeester <vincent@sbr.pm>
@vdemeester

Copy link
Copy Markdown
Contributor Author

@dmcgowan @aaronlehmann @stevvooe updated 👼

@stevvooe

stevvooe commented Apr 4, 2016

Copy link
Copy Markdown
Contributor

LGTM

I think we should put a note there that we intend to fix the fact that digest is transmitted in tag. That was not the intention. We should probably have an issue somewhere to simply take a ref over the API.

@vdemeester

Copy link
Copy Markdown
Contributor Author

@stevvooe You mean for https://github.com/docker/engine-api/pull/162/files#diff-dbeb877b7334f75bc4c9063000523d71R19 or on a more general scale ? (every part of the Image* api that has repository and tag ?)

Once this (and the docker/docker counter part) is merged, I'll create an issue about it and start to work this out in both repository 😉

@stevvooe

stevvooe commented Apr 5, 2016

Copy link
Copy Markdown
Contributor

@vdemeester I mean on a more general scale, but I am not sure about the level of complexity. The client-side parsing introduces a lot of errors but the reduced complexity may make the API easier to use in the future.

@vdemeester

Copy link
Copy Markdown
Contributor Author

/cc @calavera still LGTM ? 👼

@vdemeester

Copy link
Copy Markdown
Contributor Author

/cc @MHBauer @dongluochen @vieux @duglin for final reviews too 👼

@calavera

Copy link
Copy Markdown
Contributor

LGTM

Comment thread client/container_logs.go
// ContainerLogs returns the logs generated by a container in an io.ReadCloser.
// It's up to the caller to close the stream.
func (cli *Client) ContainerLogs(ctx context.Context, options types.ContainerLogsOptions) (io.ReadCloser, error) {
func (cli *Client) ContainerLogs(ctx context.Context, container string, options types.ContainerLogsOptions) (io.ReadCloser, error) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I suggest updating container to containerID? There are other places with this problem. No ambiguity is better.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

These can take a name (I think), so containerID is inaccurate.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@dongluochen I used container on purpose as it can be container ID or name (also did the change elsewhere).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

agreed, container is a better name.

@dongluochen

Copy link
Copy Markdown
Contributor

LGTM. I have a small change quest on parameter names.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make required arguments required - optional arguments should be optional

8 participants