Skip to content
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

Use Gradle Property and Provider to enable lazy evaluation for jib.extraDirectories parameters #3737

Merged
merged 24 commits into from Aug 25, 2022

Conversation

emmileaf
Copy link
Contributor

@emmileaf emmileaf commented Aug 22, 2022

In this PR:

Enable lazy evaluation in Gradle for various jib.extraDirectories parameters (ref: discussions in #2732).

jib.extraDirectories.permissions: Map<String, String> => MapProperty<String, String>
jib.extraDirectories.paths.path.from: Path => Property<Path>
jib.extraDirectories.paths.path.into: String => Property<String>

Lazy evaluation (via a Provider) for configuring the jib.extraDirectories.paths parameter directly is also enabled. Previously a Provider was able to be passed, but gets treated as a non-provider object and resolves file paths too early.

Both use cases below are supported in this PR:

extraDirectories {
   paths = project.provider { [value1, value2] }
   permissions = project.provider { value }
}
extraDirectories {
   paths {
     path { 
       from = project.provider { value }
       into = project.provider { value }
       includes = project.provider { value }
       excludes = project.provider { value }
    }
  }
  permissions = project.provider { value }
}

@emmileaf
Copy link
Contributor Author

Hmm I’m not sure why codecov is marking the overloaded setPaths(Provider<>) and setFrom(Provider<>) as uncovered, despite the tests added in JibPluginTest.java. Will look into this!

@emmileaf emmileaf marked this pull request as ready for review August 22, 2022 18:58
Copy link
Contributor

@elefeint elefeint left a comment

Choose a reason for hiding this comment

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

This looks great to me.

Could you update documentation in jib-gradle-plugin/README.md?

return ConfigurationPropertyValidator.parseMapProperty(property);
Map<String, String> parsedPermissions =
ConfigurationPropertyValidator.parseMapProperty(property);
if (!parsedPermissions.equals(permissions.get())) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this check even matter? There is no harm in setting permissions to an equivalent object.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

True! I saw that both PR #3242 and #3034 both included this check in the getter, and my understanding was that we wanted to avoid setting a property multiple times here?

@@ -0,0 +1 @@
updated
Copy link
Contributor

Choose a reason for hiding this comment

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

This content is not used for anything? If so, let's have it say "unused" instead of "updated", so people don't search for meaning when looking into this test.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, this file was added to commit its parent directory, so that it is an existing directory for the test project used by JibPluginTest. The file name and contents are trivial, I will change this to something less confusing.

@emmileaf
Copy link
Contributor Author

@elefeint Thank you for the review! I’ve updated the readme and made a note in the changelog.

Copy link
Contributor

@mpeddada1 mpeddada1 left a comment

Choose a reason for hiding this comment

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

Thank you for the really detailed PR description! This is a pretty complex lazy evaluation use case to implement!

Copy link
Contributor

@mpeddada1 mpeddada1 left a comment

Choose a reason for hiding this comment

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

This is looking great! Added a couple of final minor comments.

@sonarcloud
Copy link

sonarcloud bot commented Aug 25, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

86.7% 86.7% Coverage
0.0% 0.0% Duplication

Copy link
Contributor

@mpeddada1 mpeddada1 left a comment

Choose a reason for hiding this comment

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

Excellent! Looks good on my end.

Copy link
Contributor

@elefeint elefeint left a comment

Choose a reason for hiding this comment

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

Very nice!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants