-
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
Add support for configuration of credential helper with environment variables #3575
Conversation
...re/src/main/java/com/google/cloud/tools/jib/registry/credentials/DockerCredentialHelper.java
Show resolved
Hide resolved
Thanks for your contribution! |
...re/src/main/java/com/google/cloud/tools/jib/registry/credentials/DockerCredentialHelper.java
Show resolved
Hide resolved
...re/src/main/java/com/google/cloud/tools/jib/registry/credentials/DockerCredentialHelper.java
Show resolved
Hide resolved
...rc/test/java/com/google/cloud/tools/jib/registry/credentials/DockerCredentialHelperTest.java
Show resolved
Hide resolved
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>3.8.0</version> | ||
<configuration> | ||
<release>11</release> |
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.
We don't run integration tests on GitHub Actions but on a different CI. And we use Java 8 there.
<source>1.8</source>
<target>1.8</target>
<to> | ||
<image>${_TARGET_IMAGE}</image> | ||
<credHelper> | ||
<helper>gcr</helper> |
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.
Looks like we don't have an integration test using <credHelper>gcr</credHelper>
, which should continue to work. Could you add that too? Thanks!
...plugins-common/src/main/java/com/google/cloud/tools/jib/plugins/common/RawConfiguration.java
Show resolved
Hide resolved
@@ -180,9 +226,14 @@ public FromConfiguration() { | |||
|
|||
@Nullable @Parameter private String image; | |||
@Parameter private List<String> tags = Collections.emptyList(); | |||
@Nullable @Parameter private String credHelper; | |||
@Parameter private CredHelperParameters credHelper; |
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.
I think we can just do
@Parameter private CredHelperParameters credHelper; | |
@Parameter private CredHelperParameters credHelper = new CredHelperParameters(); |
and remove the constructor you added.
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.
Makes sense - will refactor. Out of curiosity - are there any other benefits to the inline initialization you suggested apart from less code?
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.
In this case, nothing other than that, IMO. But we kinda prefer, e.g.,
class Pool {
private boolean resize = true;
private Integer size = 10;
}
to
class Pool {
private boolean resize;
private Integer size;
Pool() {
this.resize = true;
this.size = new Integer(10);
}
}
and have been applying this style consistently.
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.
Got it
@Parameter private ToAuthConfiguration auth = new ToAuthConfiguration(); | ||
|
||
/** Constructor for defaults. */ | ||
public ToConfiguration() { |
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.
Can be removed by the above.
/** Configuration for {@code [from|to].credHelper} parameter. */ | ||
public static class CredHelperParameters implements CredHelperConfiguration { | ||
@Nullable @Parameter private String helper; | ||
@Parameter private Map<String, String> environment; |
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.
ditto
@Parameter private Map<String, String> environment; | |
@Parameter private Map<String, String> environment = new HashMap<>(); |
and remove the constructor.
import org.gradle.api.tasks.Input; | ||
import org.gradle.api.tasks.Nested; | ||
import org.gradle.api.tasks.Optional; | ||
|
||
/** Object in {@link JibExtension} that configures the base image. */ | ||
public class BaseImageParameters { | ||
public class BaseImageParameters extends ImageParameters { |
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.
We are not really a fan of inheritance for this kind of usage. I'd usually add ImageParameters
as a field. But then, the parameter structure doesn't match the actual Jib configuration. (That is, AuthParameters
should be a field as we have image.auth
.) I think it's still fine to add the cred helper parameters as a field. What do you think?
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.
Hmm I think I get what you mean. I was trying to reduce the code duplication between BaseImageParameters
and TargetImageParameters
. I guess making ImageParameters
a field would mean Jib configuration might have to change? e.g to configure auth we might need to do something like from.image.auth
as opposed to from.auth
?
If that's the case, I'm happy to revert and keep as it was before while making CredHelperParameters
fields in both
BaseImageParameters
and TargetImageParameters
.
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.
I guess making
ImageParameters
a field would mean Jib configuration might have to change? e.g to configure auth we might need to do something likefrom.image.auth
as opposed tofrom.auth
?
I think technically it is not impossible to have ImageParameters
as a field while retaining the current Jib configuration structure. However, I don't really like doing that. I'd rather have the code structure in sync with Jib configuration.
So yeah, let's keep CredHelperParameters
as a field.
@zhumin8 just FYI, for external contributions, we need to add the |
@chanseokoh Thanks for the reminder. |
Thanks @chanseokoh. I've addressed comments in latest commit. |
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.
Thanks! I'll take another look later.
...re/src/main/java/com/google/cloud/tools/jib/registry/credentials/DockerCredentialHelper.java
Show resolved
Hide resolved
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.
Overall, looks go to me. Just a few minor comments.
Also, could you update jib-maven-plugin/CHANGELOG.md
and jib-gradle-plugin/CHANGELOG.md
? (BTW, don't update other docs about the new configuration parameters in this PR, since we update them after making a release.)
jib-maven-plugin/src/main/java/com/google/cloud/tools/jib/maven/JibPluginConfiguration.java
Show resolved
Hide resolved
And you can ignore the SonarCloud failure. |
…ctoring and updating changelog
Thanks @chanseokoh. Updated as discussed. |
SonarCloud Quality Gate failed. |
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.
Awesome! Thanks for your contribution.
Fixes #2814