Pass source of service to Deployment API; render templates properly (#969)
* Pass source of service to Deployment API; render templates properly * Enable Go modules by default. Honor runtime.Service.Exec * Make sure you remove go.mod and go.sum
This commit is contained in:
@@ -19,7 +19,7 @@ type service struct {
|
||||
|
||||
func newService(s *runtime.Service, c runtime.CreateOptions) *service {
|
||||
kservice := client.DefaultService(s.Name, s.Version)
|
||||
kdeploy := client.DefaultDeployment(s.Name, s.Version)
|
||||
kdeploy := client.DefaultDeployment(s.Name, s.Version, s.Source)
|
||||
|
||||
env := make([]client.EnvVar, 0, len(c.Env))
|
||||
for _, evar := range c.Env {
|
||||
@@ -27,15 +27,18 @@ func newService(s *runtime.Service, c runtime.CreateOptions) *service {
|
||||
env = append(env, client.EnvVar{Name: evarPair[0], Value: evarPair[1]})
|
||||
}
|
||||
|
||||
// TODO: should we append instead of overriding?
|
||||
// if environment has been supplied update deployment
|
||||
// if environment has been supplied update deployment default environment
|
||||
if len(env) > 0 {
|
||||
kdeploy.Spec.Template.PodSpec.Containers[0].Env = env
|
||||
kdeploy.Spec.Template.PodSpec.Containers[0].Env = append(kdeploy.Spec.Template.PodSpec.Containers[0].Env, env...)
|
||||
}
|
||||
|
||||
// if Command has been supplied override the default command
|
||||
if len(c.Command) > 0 {
|
||||
kdeploy.Spec.Template.PodSpec.Containers[0].Command = c.Command
|
||||
// if Exec/Command has been supplied override the default command
|
||||
if len(s.Exec) > 0 {
|
||||
kdeploy.Spec.Template.PodSpec.Containers[0].Command = s.Exec
|
||||
} else {
|
||||
if len(c.Command) > 0 {
|
||||
kdeploy.Spec.Template.PodSpec.Containers[0].Command = c.Command
|
||||
}
|
||||
}
|
||||
|
||||
return &service{
|
||||
|
Reference in New Issue
Block a user