-
-
Notifications
You must be signed in to change notification settings - Fork 55
(#83) Implemented Images.create() #94
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/** | ||
* Copyright (c) 2018, Mihai Emil Andronache | ||
* All rights reserved. | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions are met: | ||
* 1)Redistributions of source code must retain the above copyright notice, | ||
* this list of conditions and the following disclaimer. | ||
* 2)Redistributions in binary form must reproduce the above copyright notice, | ||
* this list of conditions and the following disclaimer in the documentation | ||
* and/or other materials provided with the distribution. | ||
* 3)Neither the name of docker-java-api nor the names of its | ||
* contributors may be used to endorse or promote products derived from | ||
* this software without specific prior written permission. | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE | ||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
* POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
package com.amihaiemil.docker; | ||
|
||
import java.net.URI; | ||
import java.net.URISyntaxException; | ||
import org.apache.http.client.utils.URIBuilder; | ||
|
||
/** | ||
* A {@link URIBuilder} that hides checked exceptions in the methods used | ||
* throughout this library. Used under the assumption that the structure | ||
* of URIs created using this class are valid. | ||
* @author George Aristy (george.aristy@gmail.com) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @llorllale don't forget There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @amihaiemil ok - the build should have failed, no? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @llorllale nope, I think those rules are in qulice, we use only checkstyle |
||
* @version $Id$ | ||
* @since 0.0.1 | ||
*/ | ||
final class UncheckedUriBuilder extends URIBuilder { | ||
/** | ||
* Ctor. | ||
* @param uri Base URI. | ||
* @throws IllegalArgumentException From {@link URI#create(String)}. | ||
* @throws NullPointerException From {@link URI#create(String)}. | ||
*/ | ||
UncheckedUriBuilder( | ||
final String uri | ||
) throws IllegalArgumentException, NullPointerException { | ||
super(URI.create(uri)); | ||
} | ||
|
||
@Override | ||
public UncheckedUriBuilder addParameter( | ||
final String name, final String value | ||
) { | ||
super.addParameter(name, value); | ||
return this; | ||
} | ||
|
||
@Override | ||
public URI build() { | ||
try { | ||
return super.build(); | ||
} catch (final URISyntaxException ex) { | ||
throw new IllegalStateException( | ||
"Unexpected error while building a URI!", ex | ||
); | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@llorllale Why return
this
here?Maybe we could return
Image
-- the created image. Since we have its name and, according to the API, we can use the id or name to do operations on an Image. WDYT? If you think it's ok, leave a puzzle for that.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@amihaiemil I'm not sure which sequence of commands for the docker API you're referring to.
I see that
search images
is exclusive to Docker Hub.The docs for
create image
do not show an example response with the image's ID.The example responses for
list images
do not include the name.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@llorllale ok, leave it like this for now, I'll think more about it