mirror of https://github.com/docker/cli.git
cli/compose/convert: result 1 (error) is always nil (unparam)
cli/compose/convert/service.go:592:76: convertDNSConfig - result 1 (error) is always nil (unparam) cli/compose/convert/service.go:538:110: convertEndpointSpec - result 1 (error) is always nil (unparam) Signed-off-by: Silvin Lubecki <silvin.lubecki@docker.com> Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
47741f81d1
commit
d640f44df3
|
@ -66,11 +66,7 @@ func Service(
|
|||
configs []*swarm.ConfigReference,
|
||||
) (swarm.ServiceSpec, error) {
|
||||
name := namespace.Scope(service.Name)
|
||||
|
||||
endpoint, err := convertEndpointSpec(service.Deploy.EndpointMode, service.Ports)
|
||||
if err != nil {
|
||||
return swarm.ServiceSpec{}, err
|
||||
}
|
||||
endpoint := convertEndpointSpec(service.Deploy.EndpointMode, service.Ports)
|
||||
|
||||
mode, err := convertDeployMode(service.Deploy.Mode, service.Deploy.Replicas)
|
||||
if err != nil {
|
||||
|
@ -103,10 +99,7 @@ func Service(
|
|||
return swarm.ServiceSpec{}, err
|
||||
}
|
||||
|
||||
dnsConfig, err := convertDNSConfig(service.DNS, service.DNSSearch)
|
||||
if err != nil {
|
||||
return swarm.ServiceSpec{}, err
|
||||
}
|
||||
dnsConfig := convertDNSConfig(service.DNS, service.DNSSearch)
|
||||
|
||||
var privileges swarm.Privileges
|
||||
privileges.CredentialSpec, err = convertCredentialSpec(
|
||||
|
@ -575,7 +568,7 @@ func convertResources(source composetypes.Resources) (*swarm.ResourceRequirement
|
|||
return resources, nil
|
||||
}
|
||||
|
||||
func convertEndpointSpec(endpointMode string, source []composetypes.ServicePortConfig) (*swarm.EndpointSpec, error) {
|
||||
func convertEndpointSpec(endpointMode string, source []composetypes.ServicePortConfig) *swarm.EndpointSpec {
|
||||
portConfigs := []swarm.PortConfig{}
|
||||
for _, port := range source {
|
||||
portConfig := swarm.PortConfig{
|
||||
|
@ -594,7 +587,7 @@ func convertEndpointSpec(endpointMode string, source []composetypes.ServicePortC
|
|||
return &swarm.EndpointSpec{
|
||||
Mode: swarm.ResolutionMode(strings.ToLower(endpointMode)),
|
||||
Ports: portConfigs,
|
||||
}, nil
|
||||
}
|
||||
}
|
||||
|
||||
func convertEnvironment(source map[string]*string) []string {
|
||||
|
@ -629,14 +622,14 @@ func convertDeployMode(mode string, replicas *uint64) (swarm.ServiceMode, error)
|
|||
return serviceMode, nil
|
||||
}
|
||||
|
||||
func convertDNSConfig(DNS []string, DNSSearch []string) (*swarm.DNSConfig, error) {
|
||||
func convertDNSConfig(DNS []string, DNSSearch []string) *swarm.DNSConfig {
|
||||
if DNS != nil || DNSSearch != nil {
|
||||
return &swarm.DNSConfig{
|
||||
Nameservers: DNS,
|
||||
Search: DNSSearch,
|
||||
}, nil
|
||||
}
|
||||
}
|
||||
return nil, nil
|
||||
return nil
|
||||
}
|
||||
|
||||
func convertCredentialSpec(namespace Namespace, spec composetypes.CredentialSpecConfig, refs []*swarm.ConfigReference) (*swarm.CredentialSpec, error) {
|
||||
|
|
|
@ -177,7 +177,7 @@ func TestConvertEndpointSpec(t *testing.T) {
|
|||
Published: 80,
|
||||
},
|
||||
}
|
||||
endpoint, err := convertEndpointSpec("vip", source)
|
||||
endpoint := convertEndpointSpec("vip", source)
|
||||
|
||||
expected := swarm.EndpointSpec{
|
||||
Mode: swarm.ResolutionMode(strings.ToLower("vip")),
|
||||
|
@ -195,7 +195,6 @@ func TestConvertEndpointSpec(t *testing.T) {
|
|||
},
|
||||
}
|
||||
|
||||
assert.NilError(t, err)
|
||||
assert.Check(t, is.DeepEqual(expected, *endpoint))
|
||||
}
|
||||
|
||||
|
@ -275,9 +274,7 @@ func TestConvertServiceNetworksCustomDefault(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestConvertDNSConfigEmpty(t *testing.T) {
|
||||
dnsConfig, err := convertDNSConfig(nil, nil)
|
||||
|
||||
assert.NilError(t, err)
|
||||
dnsConfig := convertDNSConfig(nil, nil)
|
||||
assert.Check(t, is.DeepEqual((*swarm.DNSConfig)(nil), dnsConfig))
|
||||
}
|
||||
|
||||
|
@ -287,8 +284,7 @@ var (
|
|||
)
|
||||
|
||||
func TestConvertDNSConfigAll(t *testing.T) {
|
||||
dnsConfig, err := convertDNSConfig(nameservers, search)
|
||||
assert.NilError(t, err)
|
||||
dnsConfig := convertDNSConfig(nameservers, search)
|
||||
assert.Check(t, is.DeepEqual(&swarm.DNSConfig{
|
||||
Nameservers: nameservers,
|
||||
Search: search,
|
||||
|
@ -296,8 +292,7 @@ func TestConvertDNSConfigAll(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestConvertDNSConfigNameservers(t *testing.T) {
|
||||
dnsConfig, err := convertDNSConfig(nameservers, nil)
|
||||
assert.NilError(t, err)
|
||||
dnsConfig := convertDNSConfig(nameservers, nil)
|
||||
assert.Check(t, is.DeepEqual(&swarm.DNSConfig{
|
||||
Nameservers: nameservers,
|
||||
Search: nil,
|
||||
|
@ -305,8 +300,7 @@ func TestConvertDNSConfigNameservers(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestConvertDNSConfigSearch(t *testing.T) {
|
||||
dnsConfig, err := convertDNSConfig(nil, search)
|
||||
assert.NilError(t, err)
|
||||
dnsConfig := convertDNSConfig(nil, search)
|
||||
assert.Check(t, is.DeepEqual(&swarm.DNSConfig{
|
||||
Nameservers: nil,
|
||||
Search: search,
|
||||
|
|
Loading…
Reference in New Issue