mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-27 13:37:30 +00:00
Fix golint findings
This commit is contained in:
parent
cc835a86c9
commit
87592b3811
@ -574,18 +574,18 @@ type CloudConfig struct {
|
|||||||
// [ServiceOverride "1"]
|
// [ServiceOverride "1"]
|
||||||
// Service = s3
|
// Service = s3
|
||||||
// Region = region1
|
// Region = region1
|
||||||
// Url = https://s3.foo.bar
|
// URL = https://s3.foo.bar
|
||||||
// SigningRegion = signing_region
|
// SigningRegion = signing_region
|
||||||
//
|
//
|
||||||
// [ServiceOverride "2"]
|
// [ServiceOverride "2"]
|
||||||
// Service = ec2
|
// Service = ec2
|
||||||
// Region = region2
|
// Region = region2
|
||||||
// Url = https://ec2.foo.bar
|
// URL = https://ec2.foo.bar
|
||||||
// SigningRegion = signing_region
|
// SigningRegion = signing_region
|
||||||
ServiceOverride map[string]*struct {
|
ServiceOverride map[string]*struct {
|
||||||
Service string
|
Service string
|
||||||
Region string
|
Region string
|
||||||
Url string
|
URL string
|
||||||
SigningRegion string
|
SigningRegion string
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -604,9 +604,9 @@ func (cfg *CloudConfig) validateOverrides() error {
|
|||||||
if region == "" {
|
if region == "" {
|
||||||
return fmt.Errorf("service region is missing [Region is \"\"] in override %s", onum)
|
return fmt.Errorf("service region is missing [Region is \"\"] in override %s", onum)
|
||||||
}
|
}
|
||||||
url := strings.TrimSpace(ovrd.Url)
|
url := strings.TrimSpace(ovrd.URL)
|
||||||
if url == "" {
|
if url == "" {
|
||||||
return fmt.Errorf("url is missing [Url is \"\"] in override %s", onum)
|
return fmt.Errorf("url is missing [URL is \"\"] in override %s", onum)
|
||||||
}
|
}
|
||||||
signingRegion := strings.TrimSpace(ovrd.SigningRegion)
|
signingRegion := strings.TrimSpace(ovrd.SigningRegion)
|
||||||
if signingRegion == "" {
|
if signingRegion == "" {
|
||||||
@ -614,9 +614,8 @@ func (cfg *CloudConfig) validateOverrides() error {
|
|||||||
}
|
}
|
||||||
if _, ok := set[name+"_"+region]; ok {
|
if _, ok := set[name+"_"+region]; ok {
|
||||||
return fmt.Errorf("duplicate entry found for service override [%s] (%s in %s)", onum, name, region)
|
return fmt.Errorf("duplicate entry found for service override [%s] (%s in %s)", onum, name, region)
|
||||||
} else {
|
|
||||||
set[name+"_"+region] = true
|
|
||||||
}
|
}
|
||||||
|
set[name+"_"+region] = true
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -636,7 +635,7 @@ func (cfg *CloudConfig) getResolver() func(service, region string,
|
|||||||
for _, override := range cfg.ServiceOverride {
|
for _, override := range cfg.ServiceOverride {
|
||||||
if override.Service == service && override.Region == region {
|
if override.Service == service && override.Region == region {
|
||||||
return endpoints.ResolvedEndpoint{
|
return endpoints.ResolvedEndpoint{
|
||||||
URL: override.Url,
|
URL: override.URL,
|
||||||
SigningRegion: override.SigningRegion,
|
SigningRegion: override.SigningRegion,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
@ -218,7 +218,7 @@ func TestOverridesActiveConfig(t *testing.T) {
|
|||||||
|
|
||||||
[ServiceOverride "1"]
|
[ServiceOverride "1"]
|
||||||
Region=sregion
|
Region=sregion
|
||||||
Url=https://s3.foo.bar
|
URL=https://s3.foo.bar
|
||||||
SigningRegion=sregion
|
SigningRegion=sregion
|
||||||
`),
|
`),
|
||||||
nil,
|
nil,
|
||||||
@ -232,7 +232,7 @@ func TestOverridesActiveConfig(t *testing.T) {
|
|||||||
|
|
||||||
[ServiceOverride "1"]
|
[ServiceOverride "1"]
|
||||||
Service=s3
|
Service=s3
|
||||||
Url=https://s3.foo.bar
|
URL=https://s3.foo.bar
|
||||||
SigningRegion=sregion
|
SigningRegion=sregion
|
||||||
`),
|
`),
|
||||||
nil,
|
nil,
|
||||||
@ -261,7 +261,7 @@ func TestOverridesActiveConfig(t *testing.T) {
|
|||||||
[ServiceOverride "1"]
|
[ServiceOverride "1"]
|
||||||
Service=s3
|
Service=s3
|
||||||
Region=sregion
|
Region=sregion
|
||||||
Url=https://s3.foo.bar
|
URL=https://s3.foo.bar
|
||||||
`),
|
`),
|
||||||
nil,
|
nil,
|
||||||
true, false,
|
true, false,
|
||||||
@ -275,7 +275,7 @@ func TestOverridesActiveConfig(t *testing.T) {
|
|||||||
[ServiceOverride "1"]
|
[ServiceOverride "1"]
|
||||||
Service = s3
|
Service = s3
|
||||||
Region = sregion
|
Region = sregion
|
||||||
Url = https://s3.foo.bar
|
URL = https://s3.foo.bar
|
||||||
SigningRegion = sregion
|
SigningRegion = sregion
|
||||||
`),
|
`),
|
||||||
nil,
|
nil,
|
||||||
@ -291,13 +291,13 @@ func TestOverridesActiveConfig(t *testing.T) {
|
|||||||
[ServiceOverride "1"]
|
[ServiceOverride "1"]
|
||||||
Service=s3
|
Service=s3
|
||||||
Region=sregion1
|
Region=sregion1
|
||||||
Url=https://s3.foo.bar
|
URL=https://s3.foo.bar
|
||||||
SigningRegion=sregion
|
SigningRegion=sregion
|
||||||
|
|
||||||
[ServiceOverride "2"]
|
[ServiceOverride "2"]
|
||||||
Service=ec2
|
Service=ec2
|
||||||
Region=sregion2
|
Region=sregion2
|
||||||
Url=https://ec2.foo.bar
|
URL=https://ec2.foo.bar
|
||||||
SigningRegion=sregion`),
|
SigningRegion=sregion`),
|
||||||
nil,
|
nil,
|
||||||
false, true,
|
false, true,
|
||||||
@ -312,13 +312,13 @@ func TestOverridesActiveConfig(t *testing.T) {
|
|||||||
[ServiceOverride "1"]
|
[ServiceOverride "1"]
|
||||||
Service=s3
|
Service=s3
|
||||||
Region=sregion1
|
Region=sregion1
|
||||||
Url=https://s3.foo.bar
|
URL=https://s3.foo.bar
|
||||||
SigningRegion=sregion
|
SigningRegion=sregion
|
||||||
|
|
||||||
[ServiceOverride "2"]
|
[ServiceOverride "2"]
|
||||||
Service=s3
|
Service=s3
|
||||||
Region=sregion1
|
Region=sregion1
|
||||||
Url=https://s3.foo.bar
|
URL=https://s3.foo.bar
|
||||||
SigningRegion=sregion`),
|
SigningRegion=sregion`),
|
||||||
nil,
|
nil,
|
||||||
true, false,
|
true, false,
|
||||||
@ -332,13 +332,13 @@ func TestOverridesActiveConfig(t *testing.T) {
|
|||||||
[ServiceOverride "1"]
|
[ServiceOverride "1"]
|
||||||
Service=s3
|
Service=s3
|
||||||
Region=region1
|
Region=region1
|
||||||
Url=https://s3.foo.bar
|
URL=https://s3.foo.bar
|
||||||
SigningRegion=sregion
|
SigningRegion=sregion
|
||||||
|
|
||||||
[ServiceOverride "2"]
|
[ServiceOverride "2"]
|
||||||
Service=ec2
|
Service=ec2
|
||||||
Region=region2
|
Region=region2
|
||||||
Url=https://ec2.foo.bar
|
URL=https://ec2.foo.bar
|
||||||
SigningRegion=sregion
|
SigningRegion=sregion
|
||||||
`),
|
`),
|
||||||
nil,
|
nil,
|
||||||
@ -353,13 +353,13 @@ func TestOverridesActiveConfig(t *testing.T) {
|
|||||||
[ServiceOverride "1"]
|
[ServiceOverride "1"]
|
||||||
Service=s3
|
Service=s3
|
||||||
Region=region1
|
Region=region1
|
||||||
Url=https://s3.foo.bar
|
URL=https://s3.foo.bar
|
||||||
SigningRegion=sregion
|
SigningRegion=sregion
|
||||||
|
|
||||||
[ServiceOverride "2"]
|
[ServiceOverride "2"]
|
||||||
Service=s3
|
Service=s3
|
||||||
Region=region2
|
Region=region2
|
||||||
Url=https://s3.foo.bar
|
URL=https://s3.foo.bar
|
||||||
SigningRegion=sregion
|
SigningRegion=sregion
|
||||||
`),
|
`),
|
||||||
nil,
|
nil,
|
||||||
@ -391,7 +391,7 @@ func TestOverridesActiveConfig(t *testing.T) {
|
|||||||
var found *struct {
|
var found *struct {
|
||||||
Service string
|
Service string
|
||||||
Region string
|
Region string
|
||||||
Url string
|
URL string
|
||||||
SigningRegion string
|
SigningRegion string
|
||||||
}
|
}
|
||||||
for _, v := range cfg.ServiceOverride {
|
for _, v := range cfg.ServiceOverride {
|
||||||
@ -409,9 +409,9 @@ func TestOverridesActiveConfig(t *testing.T) {
|
|||||||
found.SigningRegion, test.name)
|
found.SigningRegion, test.name)
|
||||||
}
|
}
|
||||||
targetName := fmt.Sprintf("https://%s.foo.bar", sd.name)
|
targetName := fmt.Sprintf("https://%s.foo.bar", sd.name)
|
||||||
if found.Url != targetName {
|
if found.URL != targetName {
|
||||||
t.Errorf("Expected Endpoint '%s', received '%s' for case %s",
|
t.Errorf("Expected Endpoint '%s', received '%s' for case %s",
|
||||||
targetName, found.Url, test.name)
|
targetName, found.URL, test.name)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn := cfg.getResolver()
|
fn := cfg.getResolver()
|
||||||
|
Loading…
Reference in New Issue
Block a user