mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 11:50:44 +00:00
Merge pull request #92547 from kensipe/apiservier-staticchecks-bools
fix Apiserver staticchecks for bools
This commit is contained in:
commit
31191f6055
@ -88,7 +88,7 @@ func (authzHandler unionAuthzRulesHandler) RulesFor(user user.Info, namespace st
|
||||
for _, currAuthzHandler := range authzHandler {
|
||||
resourceRules, nonResourceRules, incomplete, err := currAuthzHandler.RulesFor(user, namespace)
|
||||
|
||||
if incomplete == true {
|
||||
if incomplete {
|
||||
incompleteStatus = true
|
||||
}
|
||||
if err != nil {
|
||||
|
@ -141,7 +141,7 @@ func DeleteResource(r rest.GracefulDeleter, allowsOptions bool, scope *RequestSc
|
||||
// that will break existing clients.
|
||||
// Other cases where resource is not instantly deleted are: namespace deletion
|
||||
// and pod graceful deletion.
|
||||
if !wasDeleted && options.OrphanDependents != nil && *options.OrphanDependents == false {
|
||||
if !wasDeleted && options.OrphanDependents != nil && !*options.OrphanDependents {
|
||||
status = http.StatusAccepted
|
||||
}
|
||||
// if the rest.Deleter returns a nil object, fill out a status. Callers may return a valid
|
||||
|
@ -67,7 +67,7 @@ func (f *capManagersManager) capUpdateManagers(managed Managed) (newManaged Mana
|
||||
// Gather all entries from updates
|
||||
updaters := []string{}
|
||||
for manager, fields := range managed.Fields() {
|
||||
if fields.Applied() == false {
|
||||
if !fields.Applied() {
|
||||
updaters = append(updaters, manager)
|
||||
}
|
||||
}
|
||||
|
@ -683,10 +683,7 @@ func shouldOrphanDependents(ctx context.Context, e *Store, accessor metav1.Objec
|
||||
}
|
||||
|
||||
// Get default orphan policy from this REST object type if it exists
|
||||
if defaultGCPolicy == rest.OrphanDependents {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
return defaultGCPolicy == rest.OrphanDependents
|
||||
}
|
||||
|
||||
// shouldDeleteDependents returns true if the finalizer for foreground deletion should be set
|
||||
|
@ -1115,7 +1115,7 @@ func (t *Tester) testDeleteGracefulImmediate(obj runtime.Object, createFn Create
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error: %v", err)
|
||||
}
|
||||
if wasDeleted != true {
|
||||
if !wasDeleted {
|
||||
t.Errorf("unexpected, object %s should have been deleted immediately", objectMeta.GetName())
|
||||
}
|
||||
_, err = t.storage.(rest.Getter).Get(ctx, objectMeta.GetName(), &metav1.GetOptions{})
|
||||
|
@ -199,7 +199,7 @@ func validateTLSConfig(tlsConfig *apiserver.TLSConfig, fldPath *field.Path) fiel
|
||||
return allErrs
|
||||
}
|
||||
if tlsConfig.CABundle != "" {
|
||||
if exists, err := path.Exists(path.CheckFollowSymlink, tlsConfig.CABundle); exists == false || err != nil {
|
||||
if exists, err := path.Exists(path.CheckFollowSymlink, tlsConfig.CABundle); !exists || err != nil {
|
||||
allErrs = append(allErrs, field.Invalid(
|
||||
fldPath.Child("tlsConfig", "caBundle"),
|
||||
tlsConfig.CABundle,
|
||||
@ -211,7 +211,7 @@ func validateTLSConfig(tlsConfig *apiserver.TLSConfig, fldPath *field.Path) fiel
|
||||
fldPath.Child("tlsConfig", "clientCert"),
|
||||
"nil",
|
||||
"Using TLS requires clientCert"))
|
||||
} else if exists, err := path.Exists(path.CheckFollowSymlink, tlsConfig.ClientCert); exists == false || err != nil {
|
||||
} else if exists, err := path.Exists(path.CheckFollowSymlink, tlsConfig.ClientCert); !exists || err != nil {
|
||||
allErrs = append(allErrs, field.Invalid(
|
||||
fldPath.Child("tlsConfig", "clientCert"),
|
||||
tlsConfig.ClientCert,
|
||||
@ -222,7 +222,7 @@ func validateTLSConfig(tlsConfig *apiserver.TLSConfig, fldPath *field.Path) fiel
|
||||
fldPath.Child("tlsConfig", "clientKey"),
|
||||
"nil",
|
||||
"Using TLS requires requires clientKey"))
|
||||
} else if exists, err := path.Exists(path.CheckFollowSymlink, tlsConfig.ClientKey); exists == false || err != nil {
|
||||
} else if exists, err := path.Exists(path.CheckFollowSymlink, tlsConfig.ClientKey); !exists || err != nil {
|
||||
allErrs = append(allErrs, field.Invalid(
|
||||
fldPath.Child("tlsConfig", "clientKey"),
|
||||
tlsConfig.ClientKey,
|
||||
|
@ -80,9 +80,5 @@ type probabilisticGoawayDecider struct {
|
||||
|
||||
// Goaway implement GoawayDecider
|
||||
func (p *probabilisticGoawayDecider) Goaway(r *http.Request) bool {
|
||||
if p.next() < p.chance {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
return p.next() < p.chance
|
||||
}
|
||||
|
@ -113,17 +113,15 @@ func TestClientReceivedGOAWAY(t *testing.T) {
|
||||
|
||||
count := 0
|
||||
for {
|
||||
select {
|
||||
case <-timer.C:
|
||||
n, err := w.Write([]byte("w"))
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
flusher.Flush()
|
||||
count += n
|
||||
if count == watchExpectSendBytes {
|
||||
return
|
||||
}
|
||||
<-timer.C
|
||||
n, err := w.Write([]byte("w"))
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
flusher.Flush()
|
||||
count += n
|
||||
if count == watchExpectSendBytes {
|
||||
return
|
||||
}
|
||||
}
|
||||
})
|
||||
|
@ -18,6 +18,7 @@ package options
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/spf13/pflag"
|
||||
"k8s.io/utils/path"
|
||||
|
||||
@ -84,7 +85,7 @@ func (o *EgressSelectorOptions) Validate() []error {
|
||||
|
||||
errs := []error{}
|
||||
|
||||
if exists, err := path.Exists(path.CheckFollowSymlink, o.ConfigFile); exists == false || err != nil {
|
||||
if exists, err := path.Exists(path.CheckFollowSymlink, o.ConfigFile); !exists || err != nil {
|
||||
errs = append(errs, fmt.Errorf("egress-selector-config-file %s does not exist", o.ConfigFile))
|
||||
}
|
||||
|
||||
|
@ -85,11 +85,7 @@ func (o *ResourceConfig) EnableVersions(versions ...schema.GroupVersion) {
|
||||
|
||||
func (o *ResourceConfig) VersionEnabled(version schema.GroupVersion) bool {
|
||||
enabled, _ := o.GroupVersionConfigs[version]
|
||||
if enabled {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
return enabled
|
||||
}
|
||||
|
||||
func (o *ResourceConfig) DisableResources(resources ...schema.GroupVersionResource) {
|
||||
|
@ -348,9 +348,7 @@ func ClockWait(clk *testclock.FakeEventClock, counter counter.GoRoutineCounter,
|
||||
close(dunch)
|
||||
}, duration)
|
||||
counter.Add(-1)
|
||||
select {
|
||||
case <-dunch:
|
||||
}
|
||||
<-dunch
|
||||
}
|
||||
|
||||
func init() {
|
||||
|
@ -51,10 +51,8 @@ type RealEventClock struct {
|
||||
func (RealEventClock) EventAfterDuration(f EventFunc, d time.Duration) {
|
||||
ch := time.After(d)
|
||||
go func() {
|
||||
select {
|
||||
case t := <-ch:
|
||||
f(t)
|
||||
}
|
||||
t := <-ch
|
||||
f(t)
|
||||
}()
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user