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:
Silvin Lubecki 2019-04-02 13:40:25 +02:00 committed by Sebastiaan van Stijn
parent 47741f81d1
commit d640f44df3
No known key found for this signature in database
GPG Key ID: 76698F39D527CE8C
2 changed files with 12 additions and 25 deletions

View File

@ -66,11 +66,7 @@ func Service(
configs []*swarm.ConfigReference, configs []*swarm.ConfigReference,
) (swarm.ServiceSpec, error) { ) (swarm.ServiceSpec, error) {
name := namespace.Scope(service.Name) name := namespace.Scope(service.Name)
endpoint := convertEndpointSpec(service.Deploy.EndpointMode, service.Ports)
endpoint, err := convertEndpointSpec(service.Deploy.EndpointMode, service.Ports)
if err != nil {
return swarm.ServiceSpec{}, err
}
mode, err := convertDeployMode(service.Deploy.Mode, service.Deploy.Replicas) mode, err := convertDeployMode(service.Deploy.Mode, service.Deploy.Replicas)
if err != nil { if err != nil {
@ -103,10 +99,7 @@ func Service(
return swarm.ServiceSpec{}, err return swarm.ServiceSpec{}, err
} }
dnsConfig, err := convertDNSConfig(service.DNS, service.DNSSearch) dnsConfig := convertDNSConfig(service.DNS, service.DNSSearch)
if err != nil {
return swarm.ServiceSpec{}, err
}
var privileges swarm.Privileges var privileges swarm.Privileges
privileges.CredentialSpec, err = convertCredentialSpec( privileges.CredentialSpec, err = convertCredentialSpec(
@ -575,7 +568,7 @@ func convertResources(source composetypes.Resources) (*swarm.ResourceRequirement
return resources, nil 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{} portConfigs := []swarm.PortConfig{}
for _, port := range source { for _, port := range source {
portConfig := swarm.PortConfig{ portConfig := swarm.PortConfig{
@ -594,7 +587,7 @@ func convertEndpointSpec(endpointMode string, source []composetypes.ServicePortC
return &swarm.EndpointSpec{ return &swarm.EndpointSpec{
Mode: swarm.ResolutionMode(strings.ToLower(endpointMode)), Mode: swarm.ResolutionMode(strings.ToLower(endpointMode)),
Ports: portConfigs, Ports: portConfigs,
}, nil }
} }
func convertEnvironment(source map[string]*string) []string { func convertEnvironment(source map[string]*string) []string {
@ -629,14 +622,14 @@ func convertDeployMode(mode string, replicas *uint64) (swarm.ServiceMode, error)
return serviceMode, nil 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 { if DNS != nil || DNSSearch != nil {
return &swarm.DNSConfig{ return &swarm.DNSConfig{
Nameservers: DNS, Nameservers: DNS,
Search: DNSSearch, Search: DNSSearch,
}, nil }
} }
return nil, nil return nil
} }
func convertCredentialSpec(namespace Namespace, spec composetypes.CredentialSpecConfig, refs []*swarm.ConfigReference) (*swarm.CredentialSpec, error) { func convertCredentialSpec(namespace Namespace, spec composetypes.CredentialSpecConfig, refs []*swarm.ConfigReference) (*swarm.CredentialSpec, error) {

View File

@ -177,7 +177,7 @@ func TestConvertEndpointSpec(t *testing.T) {
Published: 80, Published: 80,
}, },
} }
endpoint, err := convertEndpointSpec("vip", source) endpoint := convertEndpointSpec("vip", source)
expected := swarm.EndpointSpec{ expected := swarm.EndpointSpec{
Mode: swarm.ResolutionMode(strings.ToLower("vip")), 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)) assert.Check(t, is.DeepEqual(expected, *endpoint))
} }
@ -275,9 +274,7 @@ func TestConvertServiceNetworksCustomDefault(t *testing.T) {
} }
func TestConvertDNSConfigEmpty(t *testing.T) { func TestConvertDNSConfigEmpty(t *testing.T) {
dnsConfig, err := convertDNSConfig(nil, nil) dnsConfig := convertDNSConfig(nil, nil)
assert.NilError(t, err)
assert.Check(t, is.DeepEqual((*swarm.DNSConfig)(nil), dnsConfig)) assert.Check(t, is.DeepEqual((*swarm.DNSConfig)(nil), dnsConfig))
} }
@ -287,8 +284,7 @@ var (
) )
func TestConvertDNSConfigAll(t *testing.T) { func TestConvertDNSConfigAll(t *testing.T) {
dnsConfig, err := convertDNSConfig(nameservers, search) dnsConfig := convertDNSConfig(nameservers, search)
assert.NilError(t, err)
assert.Check(t, is.DeepEqual(&swarm.DNSConfig{ assert.Check(t, is.DeepEqual(&swarm.DNSConfig{
Nameservers: nameservers, Nameservers: nameservers,
Search: search, Search: search,
@ -296,8 +292,7 @@ func TestConvertDNSConfigAll(t *testing.T) {
} }
func TestConvertDNSConfigNameservers(t *testing.T) { func TestConvertDNSConfigNameservers(t *testing.T) {
dnsConfig, err := convertDNSConfig(nameservers, nil) dnsConfig := convertDNSConfig(nameservers, nil)
assert.NilError(t, err)
assert.Check(t, is.DeepEqual(&swarm.DNSConfig{ assert.Check(t, is.DeepEqual(&swarm.DNSConfig{
Nameservers: nameservers, Nameservers: nameservers,
Search: nil, Search: nil,
@ -305,8 +300,7 @@ func TestConvertDNSConfigNameservers(t *testing.T) {
} }
func TestConvertDNSConfigSearch(t *testing.T) { func TestConvertDNSConfigSearch(t *testing.T) {
dnsConfig, err := convertDNSConfig(nil, search) dnsConfig := convertDNSConfig(nil, search)
assert.NilError(t, err)
assert.Check(t, is.DeepEqual(&swarm.DNSConfig{ assert.Check(t, is.DeepEqual(&swarm.DNSConfig{
Nameservers: nil, Nameservers: nil,
Search: search, Search: search,