mirror of
https://github.com/openfaas/faas.git
synced 2025-06-20 23:26:34 +00:00
Add secret management to the update handler
**What** - Pass secrets to the updateSpec method Signed-off-by: Lucas Roesler <roesler.lucas@gmail.com>
This commit is contained in:
committed by
Alex Ellis
parent
7c28f7d97e
commit
1a055deb49
@ -45,7 +45,14 @@ func MakeUpdateFunctionHandler(metricsOptions metrics.MetricOptions, c *client.C
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
updateSpec(&request, &service.Spec, maxRestarts, restartDelay)
|
secrets, err := makeSecretsArray(c, request.Secrets)
|
||||||
|
if err != nil {
|
||||||
|
log.Println(err)
|
||||||
|
w.WriteHeader(http.StatusBadRequest)
|
||||||
|
w.Write([]byte("Deployment error: " + err.Error()))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
updateSpec(&request, &service.Spec, maxRestarts, restartDelay, secrets)
|
||||||
|
|
||||||
updateOpts := types.ServiceUpdateOptions{}
|
updateOpts := types.ServiceUpdateOptions{}
|
||||||
updateOpts.RegistryAuthFrom = types.RegistryAuthFromSpec
|
updateOpts.RegistryAuthFrom = types.RegistryAuthFromSpec
|
||||||
@ -72,7 +79,7 @@ func MakeUpdateFunctionHandler(metricsOptions metrics.MetricOptions, c *client.C
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func updateSpec(request *requests.CreateFunctionRequest, spec *swarm.ServiceSpec, maxRestarts uint64, restartDelay time.Duration) {
|
func updateSpec(request *requests.CreateFunctionRequest, spec *swarm.ServiceSpec, maxRestarts uint64, restartDelay time.Duration, secrets []*swarm.SecretReference) {
|
||||||
|
|
||||||
constraints := []string{}
|
constraints := []string{}
|
||||||
if request.Constraints != nil && len(request.Constraints) > 0 {
|
if request.Constraints != nil && len(request.Constraints) > 0 {
|
||||||
@ -103,6 +110,7 @@ func updateSpec(request *requests.CreateFunctionRequest, spec *swarm.ServiceSpec
|
|||||||
Target: request.Network,
|
Target: request.Network,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
spec.TaskTemplate.ContainerSpec.Secrets = secrets
|
||||||
|
|
||||||
spec.TaskTemplate.Resources = buildResources(request)
|
spec.TaskTemplate.Resources = buildResources(request)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user