-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added configMaps section in Kubernetes #6646
Conversation
Anumita
commented
Mar 9, 2018
Tasks/Kubernetes/task.loc.json
Outdated
@@ -13,7 +13,7 @@ | |||
"version": { | |||
"Major": 0, | |||
"Minor": 1, | |||
"Patch": 15 | |||
"Patch": 53 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
53?
Tasks/Kubernetes/task.json
Outdated
"label": "Force update configmap", | ||
"defaultValue": "true", | ||
"helpMarkDown": "Delete the configmap if it exists and create a new one with updated values.", | ||
"groupName": "configMaps" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From the spec, I can see that Secrets and Config map is combined. Did you talk to Atul.
Tasks/Kubernetes/src/kubernetes.ts
Outdated
executeCreateConfigMapCommand(clusterConnection, configMapName); | ||
} | ||
else { | ||
executeKubectlCommand(clusterConnection); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in case of secret, then config map will command be executed?
Tasks/Kubernetes/src/kubernetes.ts
Outdated
}, function failure(err) { | ||
tl.setResult(tl.TaskResult.Failed, err.message); | ||
}).done(); | ||
} | ||
else if(configMapName) { | ||
executeCreateConfigMapCommand(clusterConnection, configMapName); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will command be executed after creating config map?
Tasks/Kubernetes/src/kubernetes.ts
Outdated
kubectlConfigMap.run(clusterConnection, configMapName).fin(function cleanup(){ | ||
clusterConnection.close(); | ||
}).then(function success() { | ||
executeKubectlCommand(clusterConnection); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the function name is executeCreateConfigMapCommand, it should not run any other kubectl command. You need to refactor the code.
Tasks/Kubernetes/Tests/L0.ts
Outdated
@@ -311,6 +315,84 @@ describe('Kubernetes Suite', function() { | |||
console.log(tr.stderr); | |||
done(); | |||
}); | |||
|
|||
it('Runs successfully for kubectl create configMap from file or directory with forceUpdate', (done:MochaDone) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add test cases to validate following scenerios.
- create secret -> create configmap -> kubectl commad execution. All three commands are getting executed.
- create configmap -> kubectl commad. These two commands are independently getting executed.
- create secret -> kubectl commad. These two commands are independently getting executed.
Please check the error scenarios also. |
Tasks/Kubernetes/src/kubernetes.ts
Outdated
clusterConnection.close(); | ||
}).then(function success() { | ||
executeKubectlCommand(clusterConnection); | ||
}, function failure(err) { | ||
tl.setResult(tl.TaskResult.Failed, err.message); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can use try catch here. clusterConnection is not cleaned while exception occurs.
"loc.input.label.configMapFile": "ConfigMap File", | ||
"loc.input.help.configMapFile": "Specify a file or directory that contains the configMaps", | ||
"loc.input.label.configMapArguments": "Arguments", | ||
"loc.input.help.configMapArguments": "Specify keys and literal values to insert in configMap.For example, --from-literal=key1=value1 --from-literal=key2=\"top secret\". Please use double quotes to specify any literals that have spaces.", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use not 'Please Use'. Get these messages reviewed by Atul.
connection.close(); | ||
}); | ||
} | ||
catch (error) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why was this try catch needed? catch at the end of promise should be enough, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That catches exceptions only in the run function and not in the open function
Tasks/Kubernetes/src/kubernetes.ts
Outdated
} | ||
|
||
// execute kubectl command | ||
function executeKubectlCommand(clusterConnection: ClusterConnection) : any { | ||
|
||
var command = tl.getInput("command", true); | ||
var result = ""; | ||
var ouputVariableName = tl.getInput("kubectlOutput", false); | ||
kubectl.run(clusterConnection, command, (data) => result += data) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you have to return back the promise from kubectl.run
|
||
export function run(connection: ClusterConnection, configMapName: string): any { | ||
if(tl.getBoolInput("forceUpdateConfigMap") == true) { | ||
return deleteConfigMap(connection, configMapName).fin(() =>{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is deletion of config map ok?
@@ -5,6 +5,7 @@ import path = require('path'); | |||
|
|||
import ClusterConnection from "./clusterconnection"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As you mentioned, make sure that it works in a re-runnable scenario.
{ | ||
return executeKubetclGetConfigmapCommand(connection, configMapName).then(function success() { | ||
tl.debug(tl.loc('ConfigMapExists', configMapName)); | ||
}, function failure() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will it be failure?
} | ||
|
||
return configMapFromFromFileArgument; | ||
} else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why it is else here?