-
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
Share PluginConfigurationProcessor between Gradle and Maven #1163
Conversation
The
Essentially, we want to try to:
Let's discuss this a bit more. |
Sounds good at the high level.
What's the difference of the two validations? Will the first validation require our own validation logic? If so, shouldn't such code be shared too?
And what is the exact definition of
BTW, for now I don't see a need to have a separate class for |
Yea, I was mostly just suggesting a potential pipeline, but the first validation is for validating at the configuration level for cases not handled by the built-in plugin validators (like
Yes, I think these errors will be more for execution errors rather than configuration validation errors.
I think these are mostly just to indicate whether they are validated or not. It can be the same class that implements |
Okay, for now I think we can move forward with |
Oh, forgot to say this. We may run into some chick-and-egg type of complication in this regard. For example, to compute the layer configurations to set, we need to know the right |
Yes, that sounds good. We can definitely work towards more structured layouts in an iterative manner. |
Will try to make this PR work. Tagging the "PR: Not Ready" label until then. |
240beca
to
0c2c341
Compare
Ready for review. For reviewers, here are some core changes:
|
Travis is stalling (also in other PRs), so let's ignore that for now. |
I think I'm a bit late to the "high-level feedback" stage, but I wanted to give my 2 cents. Correct me if I'm wrong (I very well might be, I only skimmed a bit of this PR), but now the available configuration parameters are referenced in I can see the positives of having a structured pipeline for canonicalization and validation, but this is just my opinion from a maintenance/code simplicity perspective. We can move on with this if others think it's a good idea, but I think it's something worth thinking about. |
I see what you mean, but I think it isn't like we are making it worse. Let's look into the classes you mentioned.
|
Oh, and for |
@TadCordle does that make sense or do you still have something to add? |
jib-gradle-plugin/src/main/java/com/google/cloud/tools/jib/gradle/TaskCommon.java
Outdated
Show resolved
Hide resolved
...on/src/main/java/com/google/cloud/tools/jib/plugins/common/PluginConfigurationProcessor.java
Show resolved
Hide resolved
jib-gradle-plugin/src/main/java/com/google/cloud/tools/jib/gradle/BuildDockerTask.java
Show resolved
Hide resolved
EventDispatcher eventDispatcher = | ||
new DefaultEventDispatcher(projectProperties.getEventHandlers()); | ||
ImageReference targetImageReference = | ||
ConfigurationPropertyValidator.getGeneratedTargetDockerTag( |
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.
nit: Doesn't have to be this PR but noticed this method is rather long with embedded logic - we probably should break this up a bit.
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.
Yeah, not just BuildDockerTask
. BuildImageTask
and BuildTarTask
are equally long and we can certainly do better.
jib-gradle-plugin/src/main/java/com/google/cloud/tools/jib/gradle/BuildDockerTask.java
Show resolved
Hide resolved
...plugins-common/src/main/java/com/google/cloud/tools/jib/plugins/common/RawConfiguration.java
Outdated
Show resolved
Hide resolved
jib-gradle-plugin/src/main/java/com/google/cloud/tools/jib/gradle/TaskCommon.java
Show resolved
Hide resolved
boolean getUseOnlyProjectCache(); | ||
|
||
@Nullable | ||
AuthProperty getInferredAuth(String authTarget) throws InferredAuthRetrievalException; |
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, it feels a bit off that this is returning an AuthProperty
here given that this is the raw configuration meant as the common configuration to pipe the maven/gradle-specific configuration into, but here it feels like it is looping back to plugin configuration since AuthProperty
is implemented by the maven configuration JibPluginConfiguration.AuthConfiguration
.
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.
AuthProperty
is merely an interface in itself that supplies auth info: username, password, and the source. I guess you feel a bit off here because you are associating the interface tightly with a certain implementation (which happens to be JibPluginConfiguration.AuthConfiguration
in this case) or this AuthProperty
interface is exclusively created for plugin auth configuration usage. But from my perspective, AuthProperty
just provides what the interface describes: username, password, and the source. So I don't feel it's looping back; the raw configuration is providing auth info, and this is simply done through some reasonable interface that is reusable across the codebase. It's just that AuthConfiguration
is one implementation that is Maven specific. Does that make sense?
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.
Okay, we can keep it as this. It might just feel off to me since the getInferredAuth
is the only method here that performs a costly operation and is only implemented on the Maven side. Maybe it belongs in the processor class to process it and feed it into the configuration rather than be a method on the raw configuration, but this is fine for now.
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.
Yeah, it also makes sense to feed it to the config processor rather than having it in the raw configuration, and I have thought about that too, but after some thinking, I got to the conclusion that this auth info is just values from a static file (settings.xml
) not much different from getting values from pom.xml
, and conceptually fits with "raw configuration values". However, I also see we may need to decrypt the values, so in another sense, it requires some processing. I'll add a TODO for considering passing an additional base image auth provider into the config processor.
jib-maven-plugin/src/main/java/com/google/cloud/tools/jib/maven/JibPluginConfiguration.java
Outdated
Show resolved
Hide resolved
@chanseokoh Yeah that makes sense. Just seems like a lot of layers to me. |
/** Indicates that the string path is not in the absolute unix-path style. */ | ||
public class NotAbsoluteUnixPathException extends Exception { | ||
|
||
public NotAbsoluteUnixPathException(String appRoot, Throwable 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.
Probably should use another var name than appRoot
...on/src/main/java/com/google/cloud/tools/jib/plugins/common/PluginConfigurationProcessor.java
Show resolved
Hide resolved
boolean getUseOnlyProjectCache(); | ||
|
||
@Nullable | ||
AuthProperty getInferredAuth(String authTarget) throws InferredAuthRetrievalException; |
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.
Okay, we can keep it as this. It might just feel off to me since the getInferredAuth
is the only method here that performs a costly operation and is only implemented on the Maven side. Maybe it belongs in the processor class to process it and feed it into the configuration rather than be a method on the raw configuration, but this is fine for now.
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.
LGTM. Will have a second reviewer approve.
*/ | ||
public class AppRootInvalidException extends Exception { | ||
|
||
public AppRootInvalidException(String pathValue, Throwable 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.
nit: I think the pathValue
(maybe call it invalidAppRoot
?) should be its own field with a getter rather than the message of the exception?
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.
Will do. I think we still need to set the exception message to the pathValue
though.
This removes plugin-specific
PluginConfigurationProcessor
classes by merging them in the newPluginConfigurationProcessor
in jib-plugins-common.Also:
Fixes #1090
Closes #1088
Did not touch tests, so builds will fail. I'm setting up the PR to get the early, high-level feedback if this direction seems good.I tried to share the
PluginConfigurationProcessor
code, and it turns out to be a no easy task.The old code cannot be removed for now.By the way, my assumption:
PluginConfigurationProcessor
is the class for reading and interpreting raw config parameters to instantiate and hold aJibContainerBuilder
instance. The longestprocessCommonConfiguration()
I think is mainly for reusing code betweenjib:Build
,jib:DockerBuild
, andjib:BuildTar
for configuringJibContainerBuilder
. The class also has grown to add a couple more static utility methods to share code between tasks.In order to share code, I think we need an adapter for retrieving raw configuration values from Maven and Gradle, so for now, I created the interface
RawConfigurations
, which is mostly a POJO mapping Maven and Gradle raw configs.The PR may have some pitfalls; for now, this PR is for early feedback.