Skip to content

Commit d6c60b3

Browse files
committed
use sets to track certs to install
Signed-off-by: Ankita Thomas <[email protected]>
1 parent 8083e10 commit d6c60b3

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

Diff for: pkg/controller/install/certresources.go

+5-4
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
apierrors "k8s.io/apimachinery/pkg/api/errors"
1313
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1414
"k8s.io/apimachinery/pkg/util/intstr"
15+
"k8s.io/apimachinery/pkg/util/sets"
1516
corev1ac "k8s.io/client-go/applyconfigurations/core/v1"
1617
rbacv1ac "k8s.io/client-go/applyconfigurations/rbac/v1"
1718

@@ -274,15 +275,15 @@ func shouldRotateCerts(certSecret *corev1.Secret, hosts []string) bool {
274275
func (i *StrategyDeploymentInstaller) ShouldRotateCerts(s Strategy) (bool, error) {
275276
strategy, ok := s.(*v1alpha1.StrategyDetailsDeployment)
276277
if !ok {
277-
return false, fmt.Errorf("attempted to install %s strategy with deployment installer", strategy.GetStrategyName())
278+
return false, fmt.Errorf("failed to install %s strategy with deployment installer: unsupported deployment install strategy", strategy.GetStrategyName())
278279
}
279280

280-
hasCerts := map[string]struct{}{}
281+
hasCerts := sets.NewString()
281282
for _, c := range i.getCertResources() {
282-
hasCerts[c.getDeploymentName()] = struct{}{}
283+
hasCerts.Insert(c.getDeploymentName())
283284
}
284285
for _, sddSpec := range strategy.DeploymentSpecs {
285-
if _, ok := hasCerts[sddSpec.Name]; ok {
286+
if hasCerts.Has(sddSpec.Name) {
286287
certSecret, err := i.strategyClient.GetOpLister().CoreV1().SecretLister().Secrets(i.owner.GetNamespace()).Get(SecretName(ServiceName(sddSpec.Name)))
287288
if err == nil {
288289
if shouldRotateCerts(certSecret, HostnamesForService(ServiceName(sddSpec.Name), i.owner.GetNamespace())) {

0 commit comments

Comments
 (0)