-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Adds to.tags configuration for Gradle. #978
Changes from 3 commits
0b02f08
42409bd
258d436
f3f2099
645d2a1
f041e9d
ae827b0
119f40b
84fcc02
0be8ec7
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,68 @@ | ||
/* | ||
* Copyright 2018 Google LLC. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not | ||
* use this file except in compliance with the License. You may obtain a copy of | ||
* the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations under | ||
* the License. | ||
*/ | ||
|
||
package com.google.cloud.tools.jib.gradle; | ||
|
||
import javax.annotation.Nullable; | ||
import javax.inject.Inject; | ||
import org.gradle.api.Action; | ||
import org.gradle.api.model.ObjectFactory; | ||
|
||
/** {@link ImageParameters} that configure the base image. */ | ||
public class BaseImageParameters implements ImageParameters { | ||
|
||
private AuthParameters auth; | ||
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. Seems like this can be |
||
|
||
@Nullable private String image; | ||
@Nullable private String credHelper; | ||
|
||
@Inject | ||
public BaseImageParameters(ObjectFactory objectFactory, String imageDescriptor) { | ||
auth = objectFactory.newInstance(AuthParameters.class, imageDescriptor + ".auth"); | ||
} | ||
|
||
@Nullable | ||
@Override | ||
public String getImage() { | ||
return image; | ||
} | ||
|
||
@Override | ||
public void setImage(String image) { | ||
this.image = image; | ||
} | ||
|
||
@Nullable | ||
@Override | ||
public String getCredHelper() { | ||
return credHelper; | ||
} | ||
|
||
@Override | ||
public void setCredHelper(String credHelper) { | ||
this.credHelper = credHelper; | ||
} | ||
|
||
@Override | ||
public AuthParameters getAuth() { | ||
return auth; | ||
} | ||
|
||
@Override | ||
public void auth(Action<? super AuthParameters> action) { | ||
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. Does 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. Yes that would work - is there a preference for using the specific type over allowing super types? 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. This is not a public facing API, and I was wondering if there is anyone calling 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. This is for like the 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. I think it might have something to do with gradle decorating things. |
||
action.execute(auth); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,9 +17,7 @@ | |
package com.google.cloud.tools.jib.gradle; | ||
|
||
import javax.annotation.Nullable; | ||
import javax.inject.Inject; | ||
import org.gradle.api.Action; | ||
import org.gradle.api.model.ObjectFactory; | ||
import org.gradle.api.tasks.Input; | ||
import org.gradle.api.tasks.Nested; | ||
import org.gradle.api.tasks.Optional; | ||
|
@@ -31,47 +29,25 @@ | |
* <p>{@code image} (required) is the image reference and {@code credHelper} (optional) is the name | ||
* (after {@code docker-credential} of the credential helper for accessing the {@code image}. | ||
*/ | ||
public class ImageParameters { | ||
|
||
private AuthParameters auth; | ||
|
||
@Nullable private String image; | ||
@Nullable private String credHelper; | ||
|
||
@Inject | ||
public ImageParameters(ObjectFactory objectFactory, String imageDescriptor) { | ||
auth = objectFactory.newInstance(AuthParameters.class, imageDescriptor + ".auth"); | ||
} | ||
interface ImageParameters { | ||
|
||
@Input | ||
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. Is this 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. Yea I believe so, since it does not work without |
||
@Nullable | ||
@Optional | ||
public String getImage() { | ||
return image; | ||
} | ||
String getImage(); | ||
|
||
public void setImage(String image) { | ||
this.image = image; | ||
} | ||
void setImage(String image); | ||
|
||
@Input | ||
@Nullable | ||
@Optional | ||
public String getCredHelper() { | ||
return credHelper; | ||
} | ||
String getCredHelper(); | ||
|
||
public void setCredHelper(String credHelper) { | ||
this.credHelper = credHelper; | ||
} | ||
void setCredHelper(String credHelper); | ||
|
||
@Nested | ||
@Optional | ||
AuthParameters getAuth() { | ||
return auth; | ||
} | ||
AuthParameters getAuth(); | ||
|
||
public void auth(Action<? super AuthParameters> action) { | ||
action.execute(auth); | ||
} | ||
void auth(Action<? super AuthParameters> action); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
/* | ||
* Copyright 2018 Google LLC. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not | ||
* use this file except in compliance with the License. You may obtain a copy of | ||
* the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations under | ||
* the License. | ||
*/ | ||
|
||
package com.google.cloud.tools.jib.gradle; | ||
|
||
import java.util.Collections; | ||
import java.util.Set; | ||
import javax.annotation.Nullable; | ||
import javax.inject.Inject; | ||
import org.gradle.api.Action; | ||
import org.gradle.api.model.ObjectFactory; | ||
import org.gradle.api.tasks.Input; | ||
import org.gradle.api.tasks.Optional; | ||
|
||
/** {@link ImageParameters} that configure the target image. */ | ||
public class TargetImageParameters implements ImageParameters { | ||
|
||
private AuthParameters auth; | ||
|
||
@Nullable private String image; | ||
private Set<String> tags = Collections.emptySet(); | ||
@Nullable private String credHelper; | ||
|
||
@Inject | ||
public TargetImageParameters(ObjectFactory objectFactory, String imageDescriptor) { | ||
auth = objectFactory.newInstance(AuthParameters.class, imageDescriptor + ".auth"); | ||
} | ||
|
||
@Nullable | ||
@Override | ||
public String getImage() { | ||
return image; | ||
} | ||
|
||
@Override | ||
public void setImage(String image) { | ||
this.image = image; | ||
} | ||
|
||
@Input | ||
@Optional | ||
public Set<String> getTags() { | ||
return tags; | ||
} | ||
|
||
public void setTags(Set<String> tags) { | ||
this.tags = tags; | ||
} | ||
|
||
@Nullable | ||
@Override | ||
public String getCredHelper() { | ||
return credHelper; | ||
} | ||
|
||
@Override | ||
public void setCredHelper(String credHelper) { | ||
this.credHelper = credHelper; | ||
} | ||
|
||
@Override | ||
public AuthParameters getAuth() { | ||
return auth; | ||
} | ||
|
||
@Override | ||
public void auth(Action<? super AuthParameters> action) { | ||
action.execute(auth); | ||
} | ||
} |
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.
If this is to be implemented in a later PR, I'd remove it from here. It's just a test method, and I don't think we need a placeholder.
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.
Oh yea, I will implement this in this PR. I wanted to solicit some comments about the way
BaseImageParameters
andTargetImageParameters
are laid out first.