mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-21 19:01:49 +00:00
cleanup: use append other than for loop
Signed-off-by: HaoJie Liu <liuhaojie@beyondcent.com>
This commit is contained in:
parent
303f47c0c0
commit
29b5cd04bd
@ -393,9 +393,7 @@ func getMatchedLimitedScopes(evaluator quota.Evaluator, inputObject runtime.Obje
|
||||
klog.ErrorS(err, "Error while matching limited Scopes")
|
||||
return []corev1.ScopedResourceSelectorRequirement{}, err
|
||||
}
|
||||
for _, scope := range matched {
|
||||
scopes = append(scopes, scope)
|
||||
}
|
||||
scopes = append(scopes, matched...)
|
||||
}
|
||||
return scopes, nil
|
||||
}
|
||||
@ -455,9 +453,7 @@ func CheckRequest(quotas []corev1.ResourceQuota, a admission.Attributes, evaluat
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error matching scopes of quota %s, err: %v", resourceQuota.Name, err)
|
||||
}
|
||||
for _, scope := range localRestrictedScopes {
|
||||
restrictedScopes = append(restrictedScopes, scope)
|
||||
}
|
||||
restrictedScopes = append(restrictedScopes, localRestrictedScopes...)
|
||||
|
||||
match, err := evaluator.Matches(&resourceQuota, inputObject)
|
||||
if err != nil {
|
||||
@ -595,9 +591,7 @@ func getScopeSelectorsFromQuota(quota corev1.ResourceQuota) []corev1.ScopedResou
|
||||
Operator: corev1.ScopeSelectorOpExists})
|
||||
}
|
||||
if quota.Spec.ScopeSelector != nil {
|
||||
for _, scopeSelector := range quota.Spec.ScopeSelector.MatchExpressions {
|
||||
selectors = append(selectors, scopeSelector)
|
||||
}
|
||||
selectors = append(selectors, quota.Spec.ScopeSelector.MatchExpressions...)
|
||||
}
|
||||
return selectors
|
||||
}
|
||||
|
@ -450,11 +450,9 @@ type CompletedConfig struct {
|
||||
// of our configured apiserver. We should prefer this to adding healthChecks directly to
|
||||
// the config unless we explicitly want to add a healthcheck only to a specific health endpoint.
|
||||
func (c *Config) AddHealthChecks(healthChecks ...healthz.HealthChecker) {
|
||||
for _, check := range healthChecks {
|
||||
c.HealthzChecks = append(c.HealthzChecks, check)
|
||||
c.LivezChecks = append(c.LivezChecks, check)
|
||||
c.ReadyzChecks = append(c.ReadyzChecks, check)
|
||||
}
|
||||
c.HealthzChecks = append(c.HealthzChecks, healthChecks...)
|
||||
c.LivezChecks = append(c.LivezChecks, healthChecks...)
|
||||
c.ReadyzChecks = append(c.ReadyzChecks, healthChecks...)
|
||||
}
|
||||
|
||||
// AddPostStartHook allows you to add a PostStartHook that will later be added to the server itself in a New call.
|
||||
|
@ -83,9 +83,7 @@ func getCertificateNames(cert *x509.Certificate) []string {
|
||||
if !cnIsIP && cnIsValidDomain {
|
||||
names = append(names, cn)
|
||||
}
|
||||
for _, san := range cert.DNSNames {
|
||||
names = append(names, san)
|
||||
}
|
||||
names = append(names, cert.DNSNames...)
|
||||
// intentionally all IPs in the cert are ignored as SNI forbids passing IPs
|
||||
// to select a cert. Before go 1.6 the tls happily passed IPs as SNI values.
|
||||
|
||||
|
@ -50,9 +50,7 @@ func GetHumanCertDetail(certificate *x509.Certificate) string {
|
||||
for _, ip := range certificate.IPAddresses {
|
||||
validServingNames = append(validServingNames, ip.String())
|
||||
}
|
||||
for _, dnsName := range certificate.DNSNames {
|
||||
validServingNames = append(validServingNames, dnsName)
|
||||
}
|
||||
validServingNames = append(validServingNames, certificate.DNSNames...)
|
||||
servingString := ""
|
||||
if len(validServingNames) > 0 {
|
||||
servingString = fmt.Sprintf(" validServingFor=[%s]", strings.Join(validServingNames, ","))
|
||||
|
Loading…
Reference in New Issue
Block a user