You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by el...@apache.org on 2017/04/04 21:10:16 UTC
[2/3] calcite-avatica git commit: [CALCITE-1364] Validate the avatica
version in the Dockerfile
[CALCITE-1364] Validate the avatica version in the Dockerfile
Project: http://git-wip-us.apache.org/repos/asf/calcite-avatica/repo
Commit: http://git-wip-us.apache.org/repos/asf/calcite-avatica/commit/6c86219b
Tree: http://git-wip-us.apache.org/repos/asf/calcite-avatica/tree/6c86219b
Diff: http://git-wip-us.apache.org/repos/asf/calcite-avatica/diff/6c86219b
Branch: refs/heads/docker
Commit: 6c86219bd7cf205d3261e7ae79f6b640bc6c57af
Parents: ba02fea
Author: Josh Elser <el...@apache.org>
Authored: Tue Apr 4 16:51:33 2017 -0400
Committer: Josh Elser <el...@apache.org>
Committed: Tue Apr 4 17:04:29 2017 -0400
----------------------------------------------------------------------
docker/pom.xml | 24 +++++++++
docker/src/main/dockerhub/Dockerfile | 5 +-
.../verify-dockerhub-dockerfile-version.groovy | 53 ++++++++++++++++++++
pom.xml | 7 ++-
4 files changed, 87 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/calcite-avatica/blob/6c86219b/docker/pom.xml
----------------------------------------------------------------------
diff --git a/docker/pom.xml b/docker/pom.xml
index 8b28900..39027a7 100644
--- a/docker/pom.xml
+++ b/docker/pom.xml
@@ -90,5 +90,29 @@ limitations under the License.
</plugins>
</build>
</profile>
+ <profile>
+ <!-- Need to verify that the URL we're pulling from in the Dockerfile is correct for this release -->
+ <id>apache-release</id>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.gmaven</groupId>
+ <artifactId>groovy-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>check-dockerhub-dockerfile-version</id>
+ <phase>validate</phase>
+ <goals>
+ <goal>execute</goal>
+ </goals>
+ <configuration>
+ <source>${project.basedir}/src/test/scripts/verify-dockerhub-dockerfile-version.groovy</source>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
</profiles>
</project>
http://git-wip-us.apache.org/repos/asf/calcite-avatica/blob/6c86219b/docker/src/main/dockerhub/Dockerfile
----------------------------------------------------------------------
diff --git a/docker/src/main/dockerhub/Dockerfile b/docker/src/main/dockerhub/Dockerfile
index 12bb196..6e4a9cb 100644
--- a/docker/src/main/dockerhub/Dockerfile
+++ b/docker/src/main/dockerhub/Dockerfile
@@ -20,8 +20,11 @@ MAINTAINER Apache Avatica <de...@calcite.apache.org>
RUN useradd -m avatica
RUN mkdir -p /home/avatica/classpath
+# This line must be preserved. The Maven build will verify this version matches its version
+ARG AVATICA_VERSION="1.10.0"
+
# Dependencies
-ADD https://repository.apache.org/content/groups/public/org/apache/calcite/avatica/avatica-standalone-server/1.10.0/avatica-standalone-server-1.10.0-shaded.jar /home/avatica/classpath
+ADD https://repository.apache.org/content/groups/public/org/apache/calcite/avatica/avatica-standalone-server/${AVATICA_VERSION}/avatica-standalone-server-${AVATICA_VERSION}-shaded.jar /home/avatica/classpath
# Make sure avatica owns its files
RUN chown -R avatica: /home/avatica
http://git-wip-us.apache.org/repos/asf/calcite-avatica/blob/6c86219b/docker/src/test/scripts/verify-dockerhub-dockerfile-version.groovy
----------------------------------------------------------------------
diff --git a/docker/src/test/scripts/verify-dockerhub-dockerfile-version.groovy b/docker/src/test/scripts/verify-dockerhub-dockerfile-version.groovy
new file mode 100644
index 0000000..2908be2
--- /dev/null
+++ b/docker/src/test/scripts/verify-dockerhub-dockerfile-version.groovy
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.io.File;
+import java.nio.file.Files;
+
+System.out.println("Verifying the included version in the Dockerhub Dockerfile");
+
+String expectedPrefix = "ARG AVATICA_VERSION=";
+String expectedVersion = project.getVersion();
+
+if (null == expectedVersion) {
+ throw new IllegalArgumentException("Did not find Maven project version");
+}
+
+String dockerfilePath = "src/main/dockerhub/Dockerfile";
+File dockerfile = new File(basedir, dockerfilePath);
+if (!dockerfile.isFile()) {
+ throw new FileNotFoundException("Could not file dockerhub Dockerfile at " + dockerfilePath);
+}
+
+List<String> lines = Files.readAllLines(dockerfile.toPath());
+for (String line : lines) {
+ line = line.trim();
+ if (line.startsWith(expectedPrefix)) {
+ String value = line.substring(expectedPrefix.length());
+ // Trim leading and trailing quotation marks
+ value = value.substring(1, value.length() - 1);
+ if (expectedVersion.equals(value)) {
+ System.out.println("Found expected version in DockerHub dockerfile of " + value);
+ return true;
+ } else {
+ throw new IllegalArgumentException("Expected Avatica version of " + expectedVersion + " but got " + value);
+ }
+ }
+}
+
+throw new IllegalArgumentException("Could not extract Avatica version from " + dockerfile);
http://git-wip-us.apache.org/repos/asf/calcite-avatica/blob/6c86219b/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 075c262..445467e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -524,7 +524,7 @@ limitations under the License.
<groupId>com.spotify</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>0.4.13</version>
- <plugin>
+ </plugin>
<plugin>
<groupId>de.thetaphi</groupId>
<artifactId>forbiddenapis</artifactId>
@@ -597,6 +597,11 @@ limitations under the License.
<version>${build-helper-maven-plugin.version}</version>
</plugin>
<plugin>
+ <groupId>org.codehaus.gmaven</groupId>
+ <artifactId>groovy-maven-plugin</artifactId>
+ <version>2.0</version>
+ </plugin>
+ <plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>javacc-maven-plugin</artifactId>
<version>${javacc-maven-plugin.version}</version>