public class KubernetesUtils extends Object
Constructor and Description |
---|
KubernetesUtils() |
Modifier and Type | Method and Description |
---|---|
static void |
copyFileOrDirectory(String source,
String destination)
Copy file or directory.
|
static void |
deleteDirectory(String path)
Deletes a given directory.
|
static String |
extractBalxName(String balxFilePath)
Extract the ballerina file name from a given file path
|
static Set<String> |
getArray(org.wso2.ballerinalang.compiler.tree.expressions.BLangArrayLiteral bArrayLiteral)
Generate set of string using a
BLangArrayLiteral . |
static Map<String,EnvVarValueModel> |
getEnvVarMap(org.wso2.ballerinalang.compiler.tree.expressions.BLangExpression envVarValues)
Convert environment variable values into a map for deployment model.
|
static Set<org.ballerinax.docker.generator.models.CopyFileModel> |
getExternalFileMap(org.wso2.ballerinalang.compiler.tree.expressions.BLangRecordLiteral.BLangRecordKeyValue keyValue)
Get the set of external files to copy to docker image.
|
static Set<String> |
getImagePullSecrets(org.wso2.ballerinalang.compiler.tree.expressions.BLangRecordLiteral.BLangRecordKeyValue keyValue)
Get Image pull secrets.
|
static Map<String,String> |
getMap(List<org.wso2.ballerinalang.compiler.tree.expressions.BLangRecordLiteral.BLangRecordKeyValue> keyValues)
Generate map by splitting keyValues.
|
static String |
getValidName(String name)
Returns valid kubernetes name.
|
static boolean |
isBlank(String str) |
static List<io.fabric8.kubernetes.api.model.EnvVar> |
populateEnvVar(Map<String,EnvVarValueModel> envMap)
Get a list of environment variables.
|
static void |
printDebug(String msg)
Prints a debug message.
|
static void |
printError(String msg)
Prints an Error message.
|
static void |
printInstruction(String msg)
Prints an Instruction message.
|
static byte[] |
readFileContent(Path targetFilePath)
Read contents of a File.
|
static String |
resolveValue(String variable)
Resolve variable value from environment variable if $env{} is used.
|
static void |
writeToFile(String context,
String outputFileName)
Write content to a File.
|
public static void writeToFile(String context, String outputFileName) throws IOException
context
- context of the fileoutputFileName
- target file pathIOException
- If an error occurs when writing to a filepublic static byte[] readFileContent(Path targetFilePath) throws KubernetesPluginException
targetFilePath
- target file pathKubernetesPluginException
- If an error occurs when reading filepublic static void copyFileOrDirectory(String source, String destination) throws KubernetesPluginException
source
- source file/directory pathdestination
- destination file/directory pathKubernetesPluginException
public static String extractBalxName(String balxFilePath)
balxFilePath
- balx file path.public static void printError(String msg)
msg
- message to be printedpublic static void printDebug(String msg)
msg
- message to be printedpublic static void printInstruction(String msg)
msg
- message to be printedpublic static void deleteDirectory(String path) throws KubernetesPluginException
path
- path to directoryKubernetesPluginException
- if an error occurs while deletingpublic static boolean isBlank(String str)
public static String resolveValue(String variable) throws KubernetesPluginException
variable
- variable valueKubernetesPluginException
public static Map<String,String> getMap(List<org.wso2.ballerinalang.compiler.tree.expressions.BLangRecordLiteral.BLangRecordKeyValue> keyValues) throws KubernetesPluginException
keyValues
- key value paris.KubernetesPluginException
public static Set<String> getArray(org.wso2.ballerinalang.compiler.tree.expressions.BLangArrayLiteral bArrayLiteral) throws KubernetesPluginException
BLangArrayLiteral
.bArrayLiteral
- Array literal.KubernetesPluginException
public static String getValidName(String name)
name
- actual valuepublic static Map<String,EnvVarValueModel> getEnvVarMap(org.wso2.ballerinalang.compiler.tree.expressions.BLangExpression envVarValues) throws KubernetesPluginException
envVarValues
- Value of env field of Deployment annotation.KubernetesPluginException
public static Set<String> getImagePullSecrets(org.wso2.ballerinalang.compiler.tree.expressions.BLangRecordLiteral.BLangRecordKeyValue keyValue)
keyValue
- Value of imagePullSecret field of Job annotation.public static Set<org.ballerinax.docker.generator.models.CopyFileModel> getExternalFileMap(org.wso2.ballerinalang.compiler.tree.expressions.BLangRecordLiteral.BLangRecordKeyValue keyValue) throws KubernetesPluginException
keyValue
- Value of copyFiles field of Job annotation.KubernetesPluginException
- if an error occur while getting the pathspublic static List<io.fabric8.kubernetes.api.model.EnvVar> populateEnvVar(Map<String,EnvVarValueModel> envMap)
envMap
- Map of Environment variablesCopyright © 2019 WSO2. All rights reserved.