Skip to content

Commit 2a5998e

Browse files
committed
[WIP] Templates share image
1 parent 6b018bc commit 2a5998e

File tree

21 files changed

+245
-159
lines changed

21 files changed

+245
-159
lines changed

plugins/core-plugin/src/main/java/com/google/cloud/teleport/plugin/DockerfileGenerator.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@
4141
* includes Python, Yaml and Xlang templates
4242
*/
4343
public class DockerfileGenerator {
44-
44+
// TODO(DO NOT MERGE) - testing!
4545
public static final String BASE_CONTAINER_IMAGE =
46-
"gcr.io/dataflow-templates-base/java17-template-launcher-base-distroless:latest";
46+
"gcr.io/dataflow-build/yathu/java17-template-launcher-base-distroless:850175030";
4747
// Keep in sync with python version used in
4848
// https://github.com/GoogleCloudPlatform/DataflowTemplates/blob/main/python/generate_dependencies.sh
4949
public static final String BASE_PYTHON_CONTAINER_IMAGE =

plugins/core-plugin/src/main/java/com/google/cloud/teleport/plugin/TemplateSpecsGenerator.java

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
import java.io.File;
2727
import java.io.FileWriter;
2828
import java.io.IOException;
29-
import java.nio.file.Path;
3029
import java.util.List;
3130
import java.util.logging.Logger;
3231
import org.apache.commons.lang3.StringUtils;
@@ -121,14 +120,6 @@ public File saveMetadata(
121120
}
122121

123122
String imageName = templateDash.toLowerCase();
124-
if (StringUtils.isNotEmpty(templateAnnotation.flexContainerName())) {
125-
imageName = Path.of(templateAnnotation.flexContainerName()).getFileName().toString();
126-
}
127-
128-
if (!targetDirectory.exists()) {
129-
targetDirectory.mkdirs();
130-
}
131-
132123
File file = new File(targetDirectory, imageName + "-generated-metadata.json");
133124
LOG.info("Saving image spec metadata " + file.getAbsolutePath());
134125

plugins/core-plugin/src/test/java/com/google/cloud/teleport/plugin/TemplateSpecsGeneratorTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,8 @@ public void saveMetadataNestedFlex() {
105105
assertNotNull(saveMetadata);
106106
assertTrue(saveMetadata.exists());
107107
assertEquals(
108-
saveMetadata.getPath(),
109-
outputFolder.toPath().resolve("AtoBNestedFlex-generated-metadata.json").toString());
108+
outputFolder.toPath().resolve("atobnestedflex-generated-metadata.json").toString(),
109+
saveMetadata.getPath());
110110
}
111111

112112
@Test

plugins/templates-maven-plugin/src/main/java/com/google/cloud/teleport/plugin/maven/TemplatesReleaseMojo.java

Lines changed: 29 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,35 @@ public void execute() throws MojoExecutionException {
170170
return;
171171
}
172172

173+
String useRegion = StringUtils.isNotEmpty(region) ? region : "us-central1";
174+
TemplatesStageMojo configuredMojo =
175+
new TemplatesStageMojo(
176+
project,
177+
session,
178+
outputDirectory,
179+
outputClassesDirectory,
180+
resourcesDirectory,
181+
targetDirectory,
182+
projectId,
183+
templateName,
184+
bucketName,
185+
librariesBucketName,
186+
stagePrefix,
187+
useRegion,
188+
artifactRegion,
189+
gcpTempLocation,
190+
baseContainerImage,
191+
basePythonContainerImage,
192+
pythonTemplateLauncherEntryPoint,
193+
javaTemplateLauncherEntryPoint,
194+
pythonVersion,
195+
beamVersion,
196+
artifactRegistry,
197+
stagingArtifactRegistry,
198+
unifiedWorker,
199+
generateSBOM);
200+
configuredMojo.stageCommandSpecs(templateDefinitions);
201+
173202
for (TemplateDefinitions definition : templateDefinitions) {
174203

175204
ImageSpec imageSpec = definition.buildSpecModel(true);
@@ -181,36 +210,6 @@ public void execute() throws MojoExecutionException {
181210

182211
LOG.info("Staging template {}...", currentTemplateName);
183212

184-
String useRegion = StringUtils.isNotEmpty(region) ? region : "us-central1";
185-
186-
// TODO: is there a better way to get the plugin on the _same project_?
187-
TemplatesStageMojo configuredMojo =
188-
new TemplatesStageMojo(
189-
project,
190-
session,
191-
outputDirectory,
192-
outputClassesDirectory,
193-
resourcesDirectory,
194-
targetDirectory,
195-
projectId,
196-
templateName,
197-
bucketName,
198-
librariesBucketName,
199-
stagePrefix,
200-
useRegion,
201-
artifactRegion,
202-
gcpTempLocation,
203-
baseContainerImage,
204-
basePythonContainerImage,
205-
pythonTemplateLauncherEntryPoint,
206-
javaTemplateLauncherEntryPoint,
207-
pythonVersion,
208-
beamVersion,
209-
artifactRegistry,
210-
stagingArtifactRegistry,
211-
unifiedWorker,
212-
generateSBOM);
213-
214213
String templatePath = configuredMojo.stageTemplate(definition, imageSpec, pluginManager);
215214

216215
if (!definition.getTemplateAnnotation().stageImageOnly()) {

0 commit comments

Comments
 (0)