Skip to content

Commit 89cfb9c

Browse files
author
github-actions
committed
Google Java Format
1 parent 6c92e82 commit 89cfb9c

File tree

3 files changed

+218
-199
lines changed

3 files changed

+218
-199
lines changed

projects/control-service/projects/pipelines_control_service/src/main/java/com/vmware/taurus/service/deploy/JobImageDeployer.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ public class JobImageDeployer {
4747
@Value("${datajobs.deployment.readOnlyRootFilesystem:}")
4848
private boolean readOnlyRootFilesystem;
4949

50-
5150
private static final String VOLUME_NAME = "vdk";
5251
private static final String VOLUME_MOUNT_PATH = "/vdk";
5352
private static final String EPHEMERAL_VOLUME_NAME = "tmpfs";

projects/control-service/projects/pipelines_control_service/src/main/java/com/vmware/taurus/service/deploy/SupportedPythonVersions.java

Lines changed: 98 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -14,116 +14,117 @@
1414
import org.springframework.stereotype.Component;
1515
import lombok.extern.slf4j.Slf4j;
1616

17-
18-
/**
19-
* Handles operations related to supported python versions for data job deployments.
20-
*/
17+
/** Handles operations related to supported python versions for data job deployments. */
2118
@Component
2219
@RequiredArgsConstructor
2320
@Slf4j
2421
public class SupportedPythonVersions {
2522

26-
@Value("#{${datajobs.deployment.supportedPythonVersions}}")
27-
private HashMap<String, HashMap<String, String>> supportedPythonVersions;
28-
29-
@Value("${datajobs.vdk.image}")
30-
private String vdkImage;
23+
@Value("#{${datajobs.deployment.supportedPythonVersions}}")
24+
private HashMap<String, HashMap<String, String>> supportedPythonVersions;
3125

32-
@Value("${datajobs.deployment.dataJobBaseImage:python:3.9-slim}")
33-
private String deploymentDataJobBaseImage;
26+
@Value("${datajobs.vdk.image}")
27+
private String vdkImage;
3428

35-
private static final String VDK_IMAGE = "vdkImage";
29+
@Value("${datajobs.deployment.dataJobBaseImage:python:3.9-slim}")
30+
private String deploymentDataJobBaseImage;
3631

37-
private static final String BASE_IMAGE = "baseImage";
38-
39-
/**
40-
* Check if the python_version passed by the user is supported by the Control Service.
41-
* @param python_version python version passed by the user.
42-
* @return true if the version is supported, and false otherwise.
43-
*/
44-
public boolean isPythonVersionSupported(String python_version) {
45-
if (!supportedPythonVersions.isEmpty()) {
46-
return supportedPythonVersions.containsKey(python_version);
47-
} else {
48-
return false;
49-
}
50-
}
32+
private static final String VDK_IMAGE = "vdkImage";
5133

52-
/**
53-
* Returns a string of the python versions supported by the Control Service, in the
54-
* format: [3.7, 3.8, ...]. If the supportedPythonVersions configuration is not set,
55-
* the method returns the default python version set in the deploymentDataJobBaseImage
56-
* configuration property.
57-
* @return A string of all python versions supported by the Control Service
58-
*/
59-
public String getSupportedPythonVersions() {
60-
if (!supportedPythonVersions.isEmpty()) {
61-
return supportedPythonVersions.keySet().toString();
62-
} else {
63-
try {
64-
return "[" + getDefaultPythonVersion() + "]";
65-
} catch (IllegalArgumentException e) {
66-
throw new IllegalArgumentException(e);
67-
}
68-
}
69-
}
34+
private static final String BASE_IMAGE = "baseImage";
7035

71-
/**
72-
* Returns the name of the data job base image as stored in the docker registry. If
73-
* supportedPythonVersions is set, and the python_version passed by the user is supported
74-
* according to the configuration, the base image corresponding to the python_version is
75-
* returned. Otherwise, the default base image name as set in deploymentDataJobBaseImage
76-
* is returned.
77-
* @param python_version a string indicating the python version passed by the user
78-
* @return a string of the data job base image.
79-
*/
80-
public String getJobBaseImage(String python_version) {
81-
if (!supportedPythonVersions.isEmpty() && isPythonVersionSupported(python_version)) {
82-
return supportedPythonVersions.get(python_version).get(BASE_IMAGE);
83-
} else {
84-
return deploymentDataJobBaseImage;
85-
}
36+
/**
37+
* Check if the python_version passed by the user is supported by the Control Service.
38+
*
39+
* @param python_version python version passed by the user.
40+
* @return true if the version is supported, and false otherwise.
41+
*/
42+
public boolean isPythonVersionSupported(String python_version) {
43+
if (!supportedPythonVersions.isEmpty()) {
44+
return supportedPythonVersions.containsKey(python_version);
45+
} else {
46+
return false;
8647
}
87-
88-
public String getDefaultJobBaseImage() {
89-
return deploymentDataJobBaseImage;
48+
}
49+
50+
/**
51+
* Returns a string of the python versions supported by the Control Service, in the format: [3.7,
52+
* 3.8, ...]. If the supportedPythonVersions configuration is not set, the method returns the
53+
* default python version set in the deploymentDataJobBaseImage configuration property.
54+
*
55+
* @return A string of all python versions supported by the Control Service
56+
*/
57+
public String getSupportedPythonVersions() {
58+
if (!supportedPythonVersions.isEmpty()) {
59+
return supportedPythonVersions.keySet().toString();
60+
} else {
61+
try {
62+
return "[" + getDefaultPythonVersion() + "]";
63+
} catch (IllegalArgumentException e) {
64+
throw new IllegalArgumentException(e);
65+
}
9066
}
91-
92-
/**
93-
* Returns the name of the vdk image as stored in the docker registry. If
94-
* supportedPythonVersions is set, and the python_version, passed by the user, is supported
95-
* according to the configuration, the vdk image corresponding to the python_version is
96-
* returned. Otherwise, the default vdk image name as set in vdkImage is returned.
97-
* @param python_version a string indicating the python version passed by the user
98-
* @return a string of the data job base image.
99-
*/
100-
public String getVdkImage(String python_version) {
101-
if (!supportedPythonVersions.isEmpty() && isPythonVersionSupported(python_version)) {
102-
return supportedPythonVersions.get(python_version).get(VDK_IMAGE);
103-
} else {
104-
return vdkImage;
105-
}
67+
}
68+
69+
/**
70+
* Returns the name of the data job base image as stored in the docker registry. If
71+
* supportedPythonVersions is set, and the python_version passed by the user is supported
72+
* according to the configuration, the base image corresponding to the python_version is returned.
73+
* Otherwise, the default base image name as set in deploymentDataJobBaseImage is returned.
74+
*
75+
* @param python_version a string indicating the python version passed by the user
76+
* @return a string of the data job base image.
77+
*/
78+
public String getJobBaseImage(String python_version) {
79+
if (!supportedPythonVersions.isEmpty() && isPythonVersionSupported(python_version)) {
80+
return supportedPythonVersions.get(python_version).get(BASE_IMAGE);
81+
} else {
82+
return deploymentDataJobBaseImage;
10683
}
107-
108-
public String getDefaultVdkImage() {
109-
return vdkImage;
84+
}
85+
86+
public String getDefaultJobBaseImage() {
87+
return deploymentDataJobBaseImage;
88+
}
89+
90+
/**
91+
* Returns the name of the vdk image as stored in the docker registry. If supportedPythonVersions
92+
* is set, and the python_version, passed by the user, is supported according to the
93+
* configuration, the vdk image corresponding to the python_version is returned. Otherwise, the
94+
* default vdk image name as set in vdkImage is returned.
95+
*
96+
* @param python_version a string indicating the python version passed by the user
97+
* @return a string of the data job base image.
98+
*/
99+
public String getVdkImage(String python_version) {
100+
if (!supportedPythonVersions.isEmpty() && isPythonVersionSupported(python_version)) {
101+
return supportedPythonVersions.get(python_version).get(VDK_IMAGE);
102+
} else {
103+
return vdkImage;
110104
}
111-
112-
/**
113-
* Returns the default python version supported by the Control Service. The version number is
114-
* extracted from the datajobs.deployment.dataJobBaseImage application property. The property
115-
* is set as for example, `python:3.9-slim`, and we use a regex to match `3.9` and return it
116-
* to the caller.
117-
* @return a string indicating the default python version supported by the Control Service.
118-
* @throws IllegalArgumentException
119-
*/
120-
public String getDefaultPythonVersion() throws IllegalArgumentException {
121-
Pattern pattern = Pattern.compile("(\\d+\\.\\d+)");
122-
Matcher matcher = pattern.matcher(deploymentDataJobBaseImage);
123-
if (matcher.find()) {
124-
return matcher.group(1);
125-
} else {
126-
throw new IllegalArgumentException("Could not extract python version number from datajobs.deployment.dataJobBaseImage.");
127-
}
105+
}
106+
107+
public String getDefaultVdkImage() {
108+
return vdkImage;
109+
}
110+
111+
/**
112+
* Returns the default python version supported by the Control Service. The version number is
113+
* extracted from the datajobs.deployment.dataJobBaseImage application property. The property is
114+
* set as for example, `python:3.9-slim`, and we use a regex to match `3.9` and return it to the
115+
* caller.
116+
*
117+
* @return a string indicating the default python version supported by the Control Service.
118+
* @throws IllegalArgumentException
119+
*/
120+
public String getDefaultPythonVersion() throws IllegalArgumentException {
121+
Pattern pattern = Pattern.compile("(\\d+\\.\\d+)");
122+
Matcher matcher = pattern.matcher(deploymentDataJobBaseImage);
123+
if (matcher.find()) {
124+
return matcher.group(1);
125+
} else {
126+
throw new IllegalArgumentException(
127+
"Could not extract python version number from datajobs.deployment.dataJobBaseImage.");
128128
}
129+
}
129130
}

0 commit comments

Comments
 (0)