mirror of
https://github.com/openfaas/faasd.git
synced 2025-06-09 08:26:47 +00:00
Update order of code
Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
This commit is contained in:
parent
283e8ed2c1
commit
970015ac85
@ -27,6 +27,20 @@ const (
|
|||||||
faasdNamespace = "default"
|
faasdNamespace = "default"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type Service struct {
|
||||||
|
Image string
|
||||||
|
Env []string
|
||||||
|
Name string
|
||||||
|
Mounts []Mount
|
||||||
|
Caps []string
|
||||||
|
Args []string
|
||||||
|
}
|
||||||
|
|
||||||
|
type Mount struct {
|
||||||
|
Src string
|
||||||
|
Dest string
|
||||||
|
}
|
||||||
|
|
||||||
type Supervisor struct {
|
type Supervisor struct {
|
||||||
client *containerd.Client
|
client *containerd.Client
|
||||||
cni gocni.CNI
|
cni gocni.CNI
|
||||||
@ -49,28 +63,6 @@ func NewSupervisor(sock string) (*Supervisor, error) {
|
|||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Supervisor) Close() {
|
|
||||||
defer s.client.Close()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *Supervisor) Remove(svcs []Service) error {
|
|
||||||
ctx := namespaces.WithNamespace(context.Background(), faasdNamespace)
|
|
||||||
|
|
||||||
for _, svc := range svcs {
|
|
||||||
err := cninetwork.DeleteCNINetwork(ctx, s.cni, s.client, svc.Name)
|
|
||||||
if err != nil {
|
|
||||||
log.Printf("[Delete] error removing CNI network for %s, %s\n", svc.Name, err)
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
err = service.Remove(ctx, s.client, svc.Name)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *Supervisor) Start(svcs []Service) error {
|
func (s *Supervisor) Start(svcs []Service) error {
|
||||||
ctx := namespaces.WithNamespace(context.Background(), faasdNamespace)
|
ctx := namespaces.WithNamespace(context.Background(), faasdNamespace)
|
||||||
|
|
||||||
@ -90,7 +82,6 @@ func (s *Supervisor) Start(svcs []Service) error {
|
|||||||
if writeHostsErr != nil {
|
if writeHostsErr != nil {
|
||||||
return fmt.Errorf("cannot write hosts file: %s", writeHostsErr)
|
return fmt.Errorf("cannot write hosts file: %s", writeHostsErr)
|
||||||
}
|
}
|
||||||
// os.Chown("hosts", 101, 101)
|
|
||||||
|
|
||||||
images := map[string]containerd.Image{}
|
images := map[string]containerd.Image{}
|
||||||
|
|
||||||
@ -211,6 +202,28 @@ func (s *Supervisor) Start(svcs []Service) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *Supervisor) Close() {
|
||||||
|
defer s.client.Close()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *Supervisor) Remove(svcs []Service) error {
|
||||||
|
ctx := namespaces.WithNamespace(context.Background(), faasdNamespace)
|
||||||
|
|
||||||
|
for _, svc := range svcs {
|
||||||
|
err := cninetwork.DeleteCNINetwork(ctx, s.cni, s.client, svc.Name)
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("[Delete] error removing CNI network for %s, %s\n", svc.Name, err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
err = service.Remove(ctx, s.client, svc.Name)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func withOCIArgs(args []string) oci.SpecOpts {
|
func withOCIArgs(args []string) oci.SpecOpts {
|
||||||
if len(args) > 0 {
|
if len(args) > 0 {
|
||||||
return oci.WithProcessArgs(args...)
|
return oci.WithProcessArgs(args...)
|
||||||
@ -220,17 +233,3 @@ func withOCIArgs(args []string) oci.SpecOpts {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type Service struct {
|
|
||||||
Image string
|
|
||||||
Env []string
|
|
||||||
Name string
|
|
||||||
Mounts []Mount
|
|
||||||
Caps []string
|
|
||||||
Args []string
|
|
||||||
}
|
|
||||||
|
|
||||||
type Mount struct {
|
|
||||||
Src string
|
|
||||||
Dest string
|
|
||||||
}
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user