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

Fix platform configuration in Gradle plugin #2783

Merged
merged 6 commits into from
Sep 24, 2020
Merged

Conversation

chanseokoh
Copy link
Member

Fixes #2781.

We started with the default amd64/linux, and we were always adding new platforms.

@chanseokoh chanseokoh requested a review from a team September 23, 2020 22:27
}

@Nested
@Optional
public ListProperty<PlatformParameters> getPlatforms() {
return platforms;
if (!platforms.get().isEmpty()) {
Copy link
Member

Choose a reason for hiding this comment

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

It does feel a little weird that a getter is mutating things.

Copy link
Member

@loosebazooka loosebazooka Sep 24, 2020

Choose a reason for hiding this comment

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

could we just delegate default setting to a lower level of the system?

Copy link
Member Author

Choose a reason for hiding this comment

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

Technically it doesn't mutate an internal state, but it's true the class is no longer a POJO or bean. I also didn't like it and wondered other solutions yesterday. Setting the default at other levels could be another way, but it also had some cons.

Today, I think I found a better way than these: start the class with the default value as before, but only reset it when the user specifies platforms {}. This behavior is also more or less similar to how it works in Maven; if nothing is defined, Maven assumes amd64/linux, but as soon as the user specifies <platforms>, it becomes an empty list.. What do you think?

Copy link
Member

Choose a reason for hiding this comment

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

Hrmm, I just realized I don't understand how this affects verifying image compatibility? Do we have code somewhere that verifies and image matches the specified platform?

Copy link
Member Author

Choose a reason for hiding this comment

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

#2781 and this PR have nothing to do with verifying image platforms. The issue was that defining

jib.from.platforms {
  platform {
    architecture = 'non-amd64'
    os = '...'
  }
}

incorrectly resulted in two platforms configured: the configured one plus the default amd64/linux. This was because platform { ...} just called ListProperty.add().

@@ -38,14 +38,14 @@
@Inject
public BaseImageParameters(ObjectFactory objectFactory) {
auth = objectFactory.newInstance(AuthParameters.class, "from.auth");
platforms = objectFactory.listProperty(PlatformParameters.class).empty();
platforms = objectFactory.listProperty(PlatformParameters.class);
Copy link
Member Author

Choose a reason for hiding this comment

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

empty() turns out to be unnecessary.

@chanseokoh chanseokoh merged commit 212cc8a into master Sep 24, 2020
@chanseokoh chanseokoh deleted the i2781-gradle-platforms branch September 24, 2020 18:44
loosebazooka pushed a commit that referenced this pull request Sep 30, 2020
* Fix platform configuration in Gradle plugin
* CHANGELOG
* Reset default platform when given "platforms" action
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

jib-gradle-plugin fails when the platform/architecture is not amd64.
3 participants