mirror of
https://github.com/cuigh/swirl
synced 2024-12-28 14:51:57 +00:00
Support customizing hostname & hosts
This commit is contained in:
parent
5fa31d9afe
commit
d16f9605d5
@ -311,7 +311,11 @@ func ServiceUpdate(info *model.ServiceInfo) error { // nolint: gocyclo
|
||||
}
|
||||
}
|
||||
|
||||
// DNS
|
||||
// Host & DNS
|
||||
spec.TaskTemplate.ContainerSpec.Hostname = info.Hostname
|
||||
if info.Hosts != "" {
|
||||
spec.TaskTemplate.ContainerSpec.Hosts = strings.Split(info.Hosts, "\n")
|
||||
}
|
||||
spec.TaskTemplate.ContainerSpec.DNSConfig = info.GetDNSConfig()
|
||||
|
||||
options := types.ServiceUpdateOptions{
|
||||
@ -521,7 +525,11 @@ func ServiceCreate(info *model.ServiceInfo) error { // nolint: gocyclo
|
||||
}
|
||||
}
|
||||
|
||||
// DNS
|
||||
// Host & DNS
|
||||
service.TaskTemplate.ContainerSpec.Hostname = info.Hostname
|
||||
if info.Hosts != "" {
|
||||
service.TaskTemplate.ContainerSpec.Hosts = strings.Split(info.Hosts, "\n")
|
||||
}
|
||||
service.TaskTemplate.ContainerSpec.DNSConfig = info.GetDNSConfig()
|
||||
|
||||
opts := types.ServiceCreateOptions{EncodedRegistryAuth: info.RegistryAuth}
|
||||
|
@ -236,6 +236,8 @@ type ServiceInfo struct {
|
||||
Search string `json:"search,omitempty"`
|
||||
Options string `json:"options,omitempty"`
|
||||
} `json:"dns"`
|
||||
Hostname string `json:"hostname"`
|
||||
Hosts string `json:"hosts"`
|
||||
}
|
||||
|
||||
func NewServiceInfo(service swarm.Service) *ServiceInfo {
|
||||
@ -347,6 +349,10 @@ func NewServiceInfo(service swarm.Service) *ServiceInfo {
|
||||
si.DNS.Search = strings.Join(dns.Search, ",")
|
||||
si.DNS.Options = strings.Join(dns.Options, ",")
|
||||
}
|
||||
si.Hostname = spec.TaskTemplate.ContainerSpec.Hostname
|
||||
if len(spec.TaskTemplate.ContainerSpec.Hosts) > 0 {
|
||||
si.Hosts = strings.Join(spec.TaskTemplate.ContainerSpec.Hosts, "\n")
|
||||
}
|
||||
return si
|
||||
}
|
||||
|
||||
|
@ -100,7 +100,7 @@
|
||||
</li>
|
||||
<li>
|
||||
<a>
|
||||
<span>DNS</span>
|
||||
<span>Host & DNS</span>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
@ -533,17 +533,25 @@
|
||||
</div>
|
||||
<div style="display: none">
|
||||
<div class="field">
|
||||
<label class="label">Name servers</label>
|
||||
<label class="label">Hostname</label>
|
||||
<input name="hostname" class="input" value="{{ .Service.Hostname }}" placeholder="">
|
||||
</div>
|
||||
<div class="field">
|
||||
<label class="label">Hosts</label>
|
||||
<textarea name="hosts" class="textarea" placeholder="IP_address canonical_hostname [aliases...]">{{ .Service.Hosts }}</textarea>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label class="label">DNS name servers</label>
|
||||
<div class="control">
|
||||
<input name="dns.nameservers" class="input" value="{{ .Service.DNS.Nameservers }}" placeholder="e.g. 10.10.10.200,10.10.10.201">
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label class="label">Search</label>
|
||||
<label class="label">DNS search</label>
|
||||
<input name="dns.search" class="input" value="{{ .Service.DNS.Search }}" placeholder="e.g. xxx.com,yyy.net">
|
||||
</div>
|
||||
<div class="field">
|
||||
<label class="label">Options</label>
|
||||
<label class="label">DNS options</label>
|
||||
<input name="dns.options" class="input" value="{{ .Service.DNS.Options }}" placeholder="">
|
||||
</div>
|
||||
</div>
|
||||
|
@ -186,7 +186,7 @@
|
||||
</li>
|
||||
<li>
|
||||
<a>
|
||||
<span>DNS</span>
|
||||
<span>Host & DNS</span>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
@ -421,8 +421,18 @@
|
||||
{{end}}
|
||||
</div>
|
||||
<div style="display: none">
|
||||
{{ if .Service.Spec.TaskTemplate.ContainerSpec.DNSConfig }}
|
||||
<dl class="is-horizontal is-marginless">
|
||||
{{ if .Service.Spec.TaskTemplate.ContainerSpec.Hostname }}
|
||||
<dt class="has-text-left">Hostname</dt>
|
||||
<dd>{{ .Service.Spec.TaskTemplate.ContainerSpec.Hostname }}</dd>
|
||||
{{ end }}
|
||||
{{ if .Service.Spec.TaskTemplate.ContainerSpec.Hosts }}
|
||||
<dt class="has-text-left">Hosts</dt>
|
||||
{{ range .Service.Spec.TaskTemplate.ContainerSpec.Hosts }}
|
||||
<dd>{{ . }}</dd>
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ if .Service.Spec.TaskTemplate.ContainerSpec.DNSConfig }}
|
||||
{{ if .Service.Spec.TaskTemplate.ContainerSpec.DNSConfig.Nameservers }}
|
||||
<dt class="has-text-left">Name servers</dt>
|
||||
<dd>{{ join(.Service.Spec.TaskTemplate.ContainerSpec.DNSConfig.Nameservers, ",") }}</dd>
|
||||
@ -435,8 +445,8 @@
|
||||
<dt class="has-text-left">Options</dt>
|
||||
<dd>{{ join(.Service.Spec.TaskTemplate.ContainerSpec.DNSConfig.Options, ",") }}</dd>
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
</dl>
|
||||
{{ end }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user