Skip to content

Commit

Permalink
tls: use index when storing a pointer in "all tls artifacts must be r…
Browse files Browse the repository at this point in the history
…egistered" test
  • Loading branch information
vrutkovs committed May 16, 2024
1 parent 48f59a6 commit f81799f
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions test/extended/operators/certs.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,15 +164,16 @@ var _ = g.Describe(fmt.Sprintf("[sig-arch][Late][Jira:%q]", "kube-apiserver"), g

newTLSRegistry := &certs.PKIRegistryInfo{}

for _, currCertKeyPair := range actualPKIContent.InClusterResourceData.CertKeyPairs {
currLocation := currCertKeyPair.SecretLocation
for i, inClusterCertKeyPair := range actualPKIContent.InClusterResourceData.CertKeyPairs {
currLocation := inClusterCertKeyPair.SecretLocation
if _, err := certgraphutils.LocateCertKeyPairBySecretLocation(currLocation, violationsPKIContent.CertKeyPairs); err == nil {
continue
}

_, err := certgraphutils.LocateCertKeyPairBySecretLocation(currLocation, expectedPKIContent.CertKeyPairs)
if err != nil {
newTLSRegistry.CertKeyPairs = append(newTLSRegistry.CertKeyPairs, certgraphapi.PKIRegistryCertKeyPair{InClusterLocation: &currCertKeyPair})

newTLSRegistry.CertKeyPairs = append(newTLSRegistry.CertKeyPairs, certgraphapi.PKIRegistryCertKeyPair{InClusterLocation: &actualPKIContent.InClusterResourceData.CertKeyPairs[i]})
}

}
Expand All @@ -189,10 +190,12 @@ var _ = g.Describe(fmt.Sprintf("[sig-arch][Late][Jira:%q]", "kube-apiserver"), g

certInfo, err := certgraphutils.LocateCertKeyPairByOnDiskLocation(currLocation.Cert, expectedPKIContent.CertKeyPairs)
if err != nil {
certInfo = &certgraphapi.PKIRegistryOnDiskCertKeyPair{
OnDiskLocation: certgraphapi.OnDiskLocation{
Path: currLocation.Cert.Path,
},
if certInfo == nil {
certInfo = &certgraphapi.PKIRegistryOnDiskCertKeyPair{
OnDiskLocation: certgraphapi.OnDiskLocation{
Path: currLocation.Cert.Path,
},
}
}
newTLSRegistry.CertKeyPairs = append(newTLSRegistry.CertKeyPairs, certgraphapi.PKIRegistryCertKeyPair{OnDiskLocation: certInfo})
}
Expand All @@ -219,15 +222,15 @@ var _ = g.Describe(fmt.Sprintf("[sig-arch][Late][Jira:%q]", "kube-apiserver"), g
}
}

for _, currCABundle := range actualPKIContent.InClusterResourceData.CertificateAuthorityBundles {
currLocation := currCABundle.ConfigMapLocation
for i, inClusterCABundle := range actualPKIContent.InClusterResourceData.CertificateAuthorityBundles {
currLocation := inClusterCABundle.ConfigMapLocation
if _, err := certgraphutils.LocateCABundleByConfigMapLocation(currLocation, violationsPKIContent.CertificateAuthorityBundles); err == nil {
continue
}

_, err := certgraphutils.LocateCABundleByConfigMapLocation(currLocation, expectedPKIContent.CertificateAuthorityBundles)
if err != nil {
newTLSRegistry.CertificateAuthorityBundles = append(newTLSRegistry.CertificateAuthorityBundles, certgraphapi.PKIRegistryCABundle{InClusterLocation: &currCABundle})
newTLSRegistry.CertificateAuthorityBundles = append(newTLSRegistry.CertificateAuthorityBundles, certgraphapi.PKIRegistryCABundle{InClusterLocation: &actualPKIContent.InClusterResourceData.CertificateAuthorityBundles[i]})
}
}

Expand Down

0 comments on commit f81799f

Please sign in to comment.