Expose ports for core services

Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
This commit is contained in:
Alex Ellis (OpenFaaS Ltd)
2020-09-16 21:13:23 +01:00
committed by Alex Ellis
parent 9e2f571cf7
commit 4189cfe52c
4 changed files with 35 additions and 0 deletions

View File

@ -41,6 +41,13 @@ type Service struct {
Caps []string
Args []string
DependsOn []string
Ports []ServicePort
}
type ServicePort struct {
TargetPort uint32
Port uint32
HostIP string
}
type Mount struct {
@ -288,6 +295,8 @@ func ParseCompose(config *compose.Config) ([]Service, error) {
})
}
fmt.Printf("Service: %s - %v\n", s.Name, s.Ports)
services[idx] = Service{
Name: s.Name,
Image: s.Image,
@ -297,12 +306,26 @@ func ParseCompose(config *compose.Config) ([]Service, error) {
Env: env,
Mounts: mounts,
DependsOn: s.DependsOn,
Ports: convertPorts(s.Ports),
}
}
return services, nil
}
func convertPorts(ports []compose.ServicePortConfig) []ServicePort {
servicePorts := []ServicePort{}
for _, p := range ports {
servicePorts = append(servicePorts, ServicePort{
Port: p.Published,
TargetPort: p.Target,
HostIP: p.HostIP,
})
}
return servicePorts
}
// LoadComposeFile is a helper method for loading a docker-compose file
func LoadComposeFile(wd string, file string) (*compose.Config, error) {
return LoadComposeFileWithArch(wd, file, env.GetClientArch)