Commit 50caba21 authored by Lukas Burgey's avatar Lukas Burgey
Browse files

Don't overwrite credential states from the script

Also adds logging if the script did not add UserCredentialStates. In
that case the client generates them based on the state of the whole
script execution.
parent a197eb0a
...@@ -366,23 +366,28 @@ func (c *config) handleTask(t task) (err error) { ...@@ -366,23 +366,28 @@ func (c *config) handleTask(t task) (err error) {
t.Log("Output: %s", output) t.Log("Output: %s", output)
} }
// TODO change the API towards the scripts so the can tell us which credentials they actually deploy // if the script does not provide any credential specific states we expect all
// here we just expect the script to make them all reach the StateTarget // credentials to have the same state as the whole execution (output.State)
var userCredentialStates = make(s.UserCredentialStates) if output.UserCredentialStates == nil {
for credType, credList := range t.Credentials { if *scriptDebugging {
for _, credential := range credList { t.Log("The script did not provided credential specific states")
if stateMap, ok := userCredentialStates[credType]; !ok { }
userCredentialStates[credType] = map[string]s.State{
credential.Name: t.StateTarget, var userCredentialStates = make(s.UserCredentialStates)
for credType, credList := range t.Credentials {
for _, credential := range credList {
if stateMap, ok := userCredentialStates[credType]; !ok {
userCredentialStates[credType] = map[string]s.State{
credential.Name: output.State,
}
} else {
stateMap[credential.Name] = output.State
} }
} else {
stateMap[credential.Name] = t.StateTarget
} }
} }
output.UserCredentialStates = userCredentialStates
} }
output.UserCredentialStates = userCredentialStates
c.DoneTasks <- taskReply{ c.DoneTasks <- taskReply{
ID: t.ID, ID: t.ID,
Service: t.Service, Service: t.Service,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment