Skip to content

Commit

Permalink
Merge pull request #1301 from an2x:master
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 602907423
  • Loading branch information
cloud-teleport committed Jan 31, 2024
2 parents 6cf23f4 + 9e9991b commit 8502b16
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,25 @@ public File saveImageSpec(
new File(targetDirectory, templateDash.toLowerCase() + "-spec-generated-metadata.json");
LOG.info("Saving image spec " + file.getAbsolutePath());

// The serialized image spec should match com.google.api.services.dataflow.model.ContainerSpec
// model, ImageSpec contains some extra fields, so we'll pick up only the expected ones.

ImageSpec is = new ImageSpec();
is.setImage(imageSpec.getImage());
is.setSdkInfo(imageSpec.getSdkInfo());
is.setDefaultEnvironment(imageSpec.getDefaultEnvironment());

ImageSpecMetadata m = new ImageSpecMetadata();
m.setName(imageSpec.getMetadata().getName());
m.setDescription(imageSpec.getMetadata().getDescription());
m.setParameters(imageSpec.getMetadata().getParameters());
m.setStreaming(imageSpec.getMetadata().isStreaming());
m.setSupportsAtLeastOnce(imageSpec.getMetadata().isSupportsAtLeastOnce());
m.setSupportsExactlyOnce(imageSpec.getMetadata().isSupportsExactlyOnce());
is.setMetadata(m);

try (FileWriter writer = new FileWriter(file)) {
writer.write(gson.toJson(imageSpec));
writer.write(gson.toJson(is));
} catch (IOException e) {
throw new RuntimeException("Error writing image spec", e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +27,23 @@ public class ImageSpecMetadata {
private String name;
private String description;
private String mainClass;
private List<ImageSpecParameter> parameters = new ArrayList<>();
private Map<String, String> runtimeParameters = new HashMap<>();
private List<ImageSpecParameter> parameters;
private Map<String, String> runtimeParameters;
private ImageSpecCategory category;
private String internalName;
private String module;
private String documentationLink;
private List<String> requirements;
private List<ImageSpecAdditionalDocumentation> additionalDocumentation;
private boolean googleReleased;
private boolean preview;
private boolean udfSupport;
private boolean flexTemplate;
private Boolean googleReleased;
private Boolean preview;
private Boolean udfSupport;
private Boolean flexTemplate;
private String sourceFilePath;
private boolean hidden;
private boolean streaming;
private boolean supportsAtLeastOnce;
private boolean supportsExactlyOnce;
private Boolean hidden;
private Boolean streaming;
private Boolean supportsAtLeastOnce;
private Boolean supportsExactlyOnce;

public String getDescription() {
return description;
Expand All @@ -70,6 +70,9 @@ public void setMainClass(String mainClass) {
}

public List<ImageSpecParameter> getParameters() {
if (parameters == null) {
parameters = new ArrayList<>();
}
return parameters;
}

Expand All @@ -78,6 +81,9 @@ public void setParameters(List<ImageSpecParameter> parameters) {
}

public Map<String, String> getRuntimeParameters() {
if (runtimeParameters == null) {
runtimeParameters = new HashMap<>();
}
return runtimeParameters;
}

Expand Down Expand Up @@ -135,31 +141,31 @@ public void setModule(String module) {
}

public boolean isGoogleReleased() {
return googleReleased;
return googleReleased != null && googleReleased;
}

public void setGoogleReleased(boolean googleReleased) {
this.googleReleased = googleReleased;
}

public boolean isPreview() {
return preview;
return preview != null && preview;
}

public void setPreview(boolean preview) {
this.preview = preview;
}

public boolean isUdfSupport() {
return udfSupport;
return udfSupport != null && udfSupport;
}

public void setUdfSupport(boolean udfSupport) {
this.udfSupport = udfSupport;
}

public boolean isFlexTemplate() {
return flexTemplate;
return flexTemplate != null && flexTemplate;
}

public void setFlexTemplate(boolean flexTemplate) {
Expand All @@ -175,31 +181,31 @@ public void setSourceFilePath(String sourceFilePath) {
}

public boolean isHidden() {
return hidden;
return hidden != null && hidden;
}

public void setHidden(boolean hidden) {
this.hidden = hidden;
}

public boolean isStreaming() {
return streaming;
return streaming != null && streaming;
}

public void setStreaming(boolean streaming) {
this.streaming = streaming;
}

public boolean isSupportsAtLeastOnce() {
return supportsAtLeastOnce;
return supportsAtLeastOnce != null && supportsAtLeastOnce;
}

public void setSupportsAtLeastOnce(boolean supportsAtLeastOnce) {
this.supportsAtLeastOnce = supportsAtLeastOnce;
}

public boolean isSupportsExactlyOnce() {
return supportsExactlyOnce;
return supportsExactlyOnce != null && supportsExactlyOnce;
}

public void setSupportsExactlyOnce(boolean supportsExactlyOnce) {
Expand Down

0 comments on commit 8502b16

Please sign in to comment.