Action Asim's Feedback
This commit is contained in:
parent
d8110b70a3
commit
aa58a9749b
@ -327,7 +327,8 @@ func (k *kubernetes) List() ([]*runtime.Service, error) {
|
||||
func (k *kubernetes) Update(s *runtime.Service) error {
|
||||
// create new kubernetes micro service
|
||||
service := newService(s, runtime.CreateOptions{
|
||||
Type: k.options.Type,
|
||||
Type: k.options.Type,
|
||||
Source: k.options.Source,
|
||||
})
|
||||
|
||||
// update build time annotation
|
||||
@ -343,8 +344,8 @@ func (k *kubernetes) Delete(s *runtime.Service) error {
|
||||
|
||||
// create new kubernetes micro service
|
||||
service := newService(s, runtime.CreateOptions{
|
||||
Type: k.options.Type,
|
||||
BaseImage: k.options.Source,
|
||||
Type: k.options.Type,
|
||||
Source: k.options.Source,
|
||||
})
|
||||
|
||||
return service.Stop(k.client)
|
||||
|
@ -34,6 +34,13 @@ func newService(s *runtime.Service, c runtime.CreateOptions) *service {
|
||||
kservice := client.NewService(name, version, c.Type)
|
||||
kdeploy := client.NewDeployment(name, version, c.Type)
|
||||
|
||||
if len(s.Source) > 0 {
|
||||
for _, c := range kdeploy.Spec.Template.PodSpec.Containers {
|
||||
c.Image = s.Source
|
||||
c.Command = []string{name}
|
||||
}
|
||||
}
|
||||
|
||||
// attach our values to the deployment; name, version, source
|
||||
kdeploy.Metadata.Annotations["name"] = s.Name
|
||||
kdeploy.Metadata.Annotations["version"] = s.Version
|
||||
|
@ -51,8 +51,8 @@ type CreateOptions struct {
|
||||
Output io.Writer
|
||||
// Type of service to create
|
||||
Type string
|
||||
// Base image for docker
|
||||
BaseImage string
|
||||
// Source of the code
|
||||
Source string
|
||||
}
|
||||
|
||||
// ReadOptions queries runtime services
|
||||
@ -94,13 +94,6 @@ func WithOutput(out io.Writer) CreateOption {
|
||||
}
|
||||
}
|
||||
|
||||
// WithBaseImage sets the docker img
|
||||
func WithBaseImage(img string) CreateOption {
|
||||
return func(o *CreateOptions) {
|
||||
o.BaseImage = img
|
||||
}
|
||||
}
|
||||
|
||||
// ReadService returns services with the given name
|
||||
func ReadService(service string) ReadOption {
|
||||
return func(o *ReadOptions) {
|
||||
|
@ -226,11 +226,9 @@ func NewService(name, version, typ string) *Service {
|
||||
}
|
||||
|
||||
// NewService returns default micro kubernetes deployment definition
|
||||
func NewDeployment(name, version, typ string, opts ...DeploymentOption) *Deployment {
|
||||
func NewDeployment(name, version, typ string) *Deployment {
|
||||
log.Tracef("kubernetes default deployment: name: %s, version: %s", name, version)
|
||||
|
||||
options := NewDeploymentOptions(opts)
|
||||
|
||||
Labels := map[string]string{
|
||||
"name": name,
|
||||
"version": version,
|
||||
@ -267,7 +265,7 @@ func NewDeployment(name, version, typ string, opts ...DeploymentOption) *Deploym
|
||||
PodSpec: &PodSpec{
|
||||
Containers: []Container{{
|
||||
Name: name,
|
||||
Image: options.BaseImage,
|
||||
Image: DefaultImage,
|
||||
Env: []EnvVar{env},
|
||||
Command: []string{"go", "run", "main.go"},
|
||||
Ports: []ContainerPort{{
|
||||
|
@ -1,9 +1,5 @@
|
||||
package client
|
||||
|
||||
type DeploymentOptions struct {
|
||||
BaseImage string
|
||||
}
|
||||
|
||||
type LogOptions struct {
|
||||
Params map[string]string
|
||||
}
|
||||
@ -14,7 +10,6 @@ type WatchOptions struct {
|
||||
|
||||
type LogOption func(*LogOptions)
|
||||
type WatchOption func(*WatchOptions)
|
||||
type DeploymentOption func(*DeploymentOptions)
|
||||
|
||||
// LogParams provides additional params for logs
|
||||
func LogParams(p map[string]string) LogOption {
|
||||
@ -29,24 +24,3 @@ func WatchParams(p map[string]string) WatchOption {
|
||||
w.Params = p
|
||||
}
|
||||
}
|
||||
|
||||
// WithBaseImage sets the base image for the deployment
|
||||
func WithBaseImage(img string) DeploymentOption {
|
||||
return func(d *DeploymentOptions) {
|
||||
d.BaseImage = img
|
||||
}
|
||||
}
|
||||
|
||||
// NewDeploymentOptions returns an initialized DeploymentOptions
|
||||
func NewDeploymentOptions(opts []DeploymentOption) DeploymentOptions {
|
||||
var options DeploymentOptions
|
||||
for _, o := range opts {
|
||||
o(&options)
|
||||
}
|
||||
|
||||
if options.BaseImage == "" {
|
||||
options.BaseImage = DefaultImage
|
||||
}
|
||||
|
||||
return options
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user