forked from LaconicNetwork/kompose
Merge pull request #976 from hangyan/hostname-domain-support
Support hostname and domainname
This commit is contained in:
@@ -69,6 +69,8 @@ type ServiceConfig struct {
|
||||
Port []Ports `compose:"ports"`
|
||||
Command []string `compose:"command"`
|
||||
WorkingDir string `compose:""`
|
||||
DomainName string `compose:"domainname"`
|
||||
HostName string `compose:"hostname"`
|
||||
Args []string `compose:"args"`
|
||||
VolList []string `compose:"volumes"`
|
||||
Network []string `compose:"network"`
|
||||
|
||||
@@ -53,11 +53,9 @@ func checkUnsupportedKey(composeProject *project.Project) []string {
|
||||
"DependsOn": false,
|
||||
"DNS": false,
|
||||
"DNSSearch": false,
|
||||
"DomainName": false,
|
||||
"EnvFile": false,
|
||||
"ExternalLinks": false,
|
||||
"ExtraHosts": false,
|
||||
"Hostname": false,
|
||||
"Ipc": false,
|
||||
"Logging": false,
|
||||
"MacAddress": false,
|
||||
|
||||
@@ -318,7 +318,7 @@ func TestUnsupportedKeys(t *testing.T) {
|
||||
}{
|
||||
"With Networks (service and root level)": {
|
||||
projectWithNetworks,
|
||||
[]string{"root level networks", "root level volumes", "hostname", "networks"},
|
||||
[]string{"root level networks", "root level volumes", "networks"},
|
||||
},
|
||||
"Empty Networks on Service level": {
|
||||
projectWithEmptyNetwork,
|
||||
|
||||
@@ -199,6 +199,8 @@ func libComposeToKomposeMapping(composeObject *project.Project) (kobject.Kompose
|
||||
log.Infof("Container name in service %q has been changed from %q to %q", name, composeServiceConfig.ContainerName, newName)
|
||||
}
|
||||
serviceConfig.Command = composeServiceConfig.Entrypoint
|
||||
serviceConfig.HostName = composeServiceConfig.Hostname
|
||||
serviceConfig.DomainName = composeServiceConfig.DomainName
|
||||
serviceConfig.Args = composeServiceConfig.Command
|
||||
serviceConfig.Dockerfile = composeServiceConfig.Build.Dockerfile
|
||||
serviceConfig.BuildArgs = composeServiceConfig.Build.Args
|
||||
|
||||
@@ -241,6 +241,8 @@ func dockerComposeToKomposeMapping(composeObject *types.Config) (kobject.Kompose
|
||||
serviceConfig.Command = composeServiceConfig.Entrypoint
|
||||
serviceConfig.Args = composeServiceConfig.Command
|
||||
serviceConfig.Labels = composeServiceConfig.Labels
|
||||
serviceConfig.HostName = composeServiceConfig.Hostname
|
||||
serviceConfig.DomainName = composeServiceConfig.DomainName
|
||||
|
||||
//
|
||||
// Deploy keys
|
||||
|
||||
@@ -514,6 +514,15 @@ func (k *Kubernetes) UpdateKubernetesObjects(name string, service kobject.Servic
|
||||
default:
|
||||
return errors.New("Unknown restart policy " + service.Restart + " for service " + name)
|
||||
}
|
||||
|
||||
// Configure hostname/domain_name settings
|
||||
if service.HostName != "" {
|
||||
template.Spec.Hostname = service.HostName
|
||||
}
|
||||
if service.DomainName != "" {
|
||||
template.Spec.Subdomain = service.DomainName
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user