Repository navigation
Record JRE version details in Java image metadata - #291
Conversation
- a JAVA_VERSION environment variable in keeping with the
OpenJDK Official Docker Images
- labels for the JDK version, vendor, and source (debian package
name and version)
|
There are formatting errors. You need to use the same Once #290 is merged, I expect the updated |
|
Ok will do — thanks for the pointer. |
|
Is the problem with the label keys that we're not choosing standard ones? |
| openjdk-11-jre*: 11.0.1+13-2~bpo9+1 | ||
| """ | ||
| if version.startswith("8u"): return version.split("-",2)[0] | ||
| if version.startswith("11."): return version.split("+",2)[0] |
There was a problem hiding this comment.
nit: I believe version.split("+")[0] (no optional second parameter) will work and look simpler. I don't think we need this kind of optimization.
There was a problem hiding this comment.
Agree. Perhaps the consumer can handle this on their own.
| """ | ||
| if version.startswith("8u"): return version.split("-",2)[0] | ||
| if version.startswith("11."): return version.split("+",2)[0] | ||
| return "unknown: " + version |
There was a problem hiding this comment.
Hmm... would it be difficult to not set JAVA_VERSION if unknown?
There was a problem hiding this comment.
I'd actually like to trigger a build error. Thinking to the day that we pull in Java 15 and end up with a broken version string.
There was a problem hiding this comment.
Ok, that should use the fail() function.
There was a problem hiding this comment.
fail() does the trick:
ERROR: /Users/bsd/Manumitting/Projects/GooglePluginEclipse/repo-distroless/java/BUILD:13:1: Traceback (most recent call last):
File "/Users/bsd/Manumitting/Projects/GooglePluginEclipse/repo-distroless/java/BUILD", line 13
container_image(name = rule_name, base = "//cc" if...", <5 more arguments>)
File "/Users/bsd/Manumitting/Projects/GooglePluginEclipse/repo-distroless/java/BUILD", line 27, in container_image
jre_ver(versions[jre_deb])
File "/Users/bsd/Manumitting/Projects/GooglePluginEclipse/repo-distroless/java/jre_ver.bzl", line 10, in jre_ver
fail(("unrecognized openjdk package v...))
unrecognized openjdk package version: 15.0.2
ERROR: error loading package 'java': Package 'java' contains errors
INFO: Elapsed time: 0.093s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (1 packages loaded)
Yeah. Both Docker and OCI recommend namespacing labels/annotations using reverse-DNS prefixes. |
chanseokoh
left a comment
There was a problem hiding this comment.
LGTM. We can add labels in a later PR.
#276 requests that the
javaimages provide information as to the JRE version. This PR follows on from #290 and adds the following metadata to thedistroless/javaimages:JAVA_VERSIONenvironment variable to the JRE version, currently8u181for the Java 8 image and11.0.1for the Java 11 imageit sets three labels:jdk.vendoris hard-coded toopenjdksince we explicitly select theopenjdk-*-jre-headlesspackagesjdk.versionis the same release number reported inJAVA_VERSIONjdk.sourcerecords soe provenance information listing the Debian package name and version: currentlyopenjdk-8-jre-headless 8u181-b13-2~deb9u1andopenjdk-11-jre-headless 11.0.1+13-2~bpo9+1Update: I'm not convinced of these label keys, and since environment variables are as easy to access as labels, the
JAVA_VERSIONwill do for now.It adds some metadata tests too
though the.jdk.sourcetests are commented out as they require container-structure-test v1.7.0 (bazelbuild/rules_docker#685)I'm not particularly enamoured by the label names.My priority is theJAVA_VERSIONenvironment variable.