-
Notifications
You must be signed in to change notification settings - Fork 560
Conversation
@@ -618,12 +618,12 @@ func TestSetVMSSDefaults(t *testing.T) { | |||
|
|||
properties.AgentPoolProfiles[0].Count = 110 | |||
setPropertiesDefaults(&mockCS, false, false) | |||
if *properties.AgentPoolProfiles[0].SinglePlacementGroup != false { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lol
pkg/acsengine/defaults_test.go
Outdated
@@ -618,12 +618,12 @@ func TestSetVMSSDefaults(t *testing.T) { | |||
|
|||
properties.AgentPoolProfiles[0].Count = 110 | |||
setPropertiesDefaults(&mockCS, false, false) | |||
if *properties.AgentPoolProfiles[0].SinglePlacementGroup != false { | |||
if *properties.AgentPoolProfiles[0].SinglePlacementGroup { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need the *
syntax here at all?
@@ -23,7 +23,7 @@ type APIModelValue struct { | |||
|
|||
// MapValues converts an arraw of rwa ApiModel values (like ["masterProfile.count=4","linuxProfile.adminUsername=admin"]) to a map | |||
func MapValues(m map[string]APIModelValue, setFlagValues []string) { | |||
if setFlagValues == nil || len(setFlagValues) == 0 { | |||
if len(setFlagValues) == 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no... really, are you sure you're unset?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pkg/acsengine/transform/apimodel_merger.go:26:5:warning: should omit nil check; len() for nil slices is defined as zero (S1009) (gosimple)
.
@@ -40,7 +40,7 @@ func (l *LinuxProfile) Validate() error { | |||
|
|||
// Validate implements APIObject | |||
func (a *AADProfile) Validate(rbacEnabled *bool) error { | |||
if rbacEnabled == nil || *rbacEnabled == false { | |||
if rbacEnabled == nil || !*rbacEnabled { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see helpers.IsTrueBoolPointer()
, I think that's a more expressive way to put the above. E.g.:
if !helper.IsTrueBoolPointer(rbacEnabled) {...
@@ -244,7 +244,6 @@ func TestConvertToV20180331AddonProfile(t *testing.T) { | |||
|
|||
func TestConvertKubernetesConfigToEnableRBACV20180331AgentPoolOnly(t *testing.T) { | |||
var kc *KubernetesConfig | |||
kc = nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lol I'm surprised the compiler accepts this
@@ -384,7 +384,7 @@ func convertV20180331AgentPoolOnlyWindowsProfile(obj *v20180331.WindowsProfile) | |||
} | |||
|
|||
func convertV20180331AgentPoolOnlyKubernetesConfig(enableRBAC *bool) *KubernetesConfig { | |||
if enableRBAC != nil && *enableRBAC == true { | |||
if enableRBAC != nil && *enableRBAC { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see my above suggestion
@@ -226,19 +226,18 @@ func TestConvertV20170831AgentPoolOnlyOrchestratorProfile_KubernetesConfig(t *te | |||
t.Error("OrchestratorProfile.KubernetesConfig expected not to be nil") | |||
} | |||
|
|||
if op.KubernetesConfig.EnableRbac == nil || *op.KubernetesConfig.EnableRbac == true { | |||
if op.KubernetesConfig.EnableRbac == nil || *op.KubernetesConfig.EnableRbac { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
t.Error("OrchestratorProfile.KubernetesConfig.EnableRbac expected to be *false") | ||
} | ||
|
||
if op.KubernetesConfig.EnableSecureKubelet == nil || *op.KubernetesConfig.EnableSecureKubelet == true { | ||
if op.KubernetesConfig.EnableSecureKubelet == nil || *op.KubernetesConfig.EnableSecureKubelet { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
t.Error("OrchestratorProfile.KubernetesConfig.EnableSecureKubelet expected to be *false") | ||
} | ||
|
||
} | ||
|
||
func TestConvertV20180331AgentPoolOnlyKubernetesConfig(t *testing.T) { | ||
var kc *KubernetesConfig | ||
kc = convertV20180331AgentPoolOnlyKubernetesConfig(helpers.PointerToBool(true)) | ||
var kc = convertV20180331AgentPoolOnlyKubernetesConfig(helpers.PointerToBool(true)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💥
@@ -272,15 +271,15 @@ func TestConvertV20180331AgentPoolOnlyKubernetesConfig(t *testing.T) { | |||
t.Error("EnableRbac expected not to be nil") | |||
} | |||
|
|||
if *kc.EnableRbac != false { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wow
t.Error("EnableRbac expected to be false") | ||
} | ||
|
||
if kc.EnableSecureKubelet == nil { | ||
t.Error("EnableSecureKubelet expected not to be nil") | ||
} | ||
|
||
if *kc.EnableSecureKubelet != false { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
@@ -297,15 +296,15 @@ func TestConvertV20180331AgentPoolOnlyKubernetesConfig(t *testing.T) { | |||
t.Error("EnableRbac expected not to be nil") | |||
} | |||
|
|||
if *kc.EnableRbac != false { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
...
t.Error("EnableRbac expected to be false") | ||
} | ||
|
||
if kc.EnableSecureKubelet == nil { | ||
t.Error("EnableSecureKubelet expected not to be nil") | ||
} | ||
|
||
if *kc.EnableSecureKubelet != false { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make it stop
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It stops here.
@@ -112,7 +112,7 @@ func (az *AzureClient) CreateRoleAssignmentSimple(ctx context.Context, resourceG | |||
}, | |||
} | |||
|
|||
re := regexp.MustCompile("(?i)status=(\\d+)") | |||
re := regexp.MustCompile(`(?i)status=(\d+)`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm, that extra \
, wouldn't that mean that that regex wouldn't be looking for a digit? How did the prior regex even work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The original regex is a normal, interpreted string literal, so it needed to escape the backslash. Using the backtics syntax makes it a raw string literal, so no escaping is needed. Raw string literals are preferable for regexes for readability and copy-and-pasting.
} | ||
|
||
return false | ||
return strings.Contains(e.ExpandedDefinition.Properties.OrchestratorProfile.KubernetesConfig.NetworkPolicy, name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💥 💥
@@ -212,7 +212,7 @@ func (d *Deployment) WaitForReplicas(n int, sleep, duration time.Duration) ([]po | |||
select { | |||
case err := <-errCh: | |||
return pods, err | |||
case _ = <-readyCh: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wut
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess you can elide the no-op assignment inside a select
statement.
@@ -554,7 +554,7 @@ func (p *Pod) ValidateOmsAgentLogs(execCmdString string, sleep, duration time.Du | |||
|
|||
// CheckWindowsOutboundConnection will keep retrying the check if an error is received until the timeout occurs or it passes. This helps us when DNS may not be available for some time after a pod starts. | |||
func (p *Pod) CheckWindowsOutboundConnection(sleep, duration time.Duration) (bool, error) { | |||
exp, err := regexp.Compile("(StatusCode\\s*:\\s*200)") | |||
exp, err := regexp.Compile(`(StatusCode\s*:\s*200)`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I'm getting it now that the surrounding quotes were escaping the slashes and then passing those into the regex compiler literally
This silences the gosimple linter and preserves the readable semantic intent of the test.
Codecov Report
@@ Coverage Diff @@
## master #3802 +/- ##
=========================================
+ Coverage 55.65% 55.7% +0.05%
=========================================
Files 109 109
Lines 16233 16232 -1
=========================================
+ Hits 9034 9042 +8
+ Misses 6410 6398 -12
- Partials 789 792 +3 |
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: jackfrancis, mboersma The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
What this PR does / why we need it:
Simplifies some code as suggested by the
gosimple
plugin togometalinter
and enables that plugin for themake test-style
target.(We can't run this plugin in general for linting, however, because it suggests some incorrect changes topkg/api/types_test.go
.)Special notes for your reviewer:
Obviously not a critical change, but I've had this branch sitting around for a month so I freshened it up and made a PR.
If applicable:
Release note: