Skip to content

Commit f754da6

Browse files
Merge pull request #1856 from ecordell/46-service-duplicate-ownerrefs
Bug 1896051: Services should not have duplicate ownerrefs
2 parents 055190e + 49f5e33 commit f754da6

14 files changed

+2343
-3
lines changed

pkg/controller/certs/certs.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,18 @@ import (
1515
"time"
1616
)
1717

18+
type CertGenerator interface {
19+
Generate(notAfter time.Time, organization string, ca *KeyPair, hosts []string) (*KeyPair, error)
20+
}
21+
22+
type CertGeneratorFunc func(notAfter time.Time, organization string, ca *KeyPair, hosts []string) (*KeyPair, error)
23+
24+
func (f CertGeneratorFunc) Generate(notAfter time.Time, organization string, ca *KeyPair, hosts []string) (*KeyPair, error) {
25+
return f(notAfter, organization, ca, hosts)
26+
}
27+
28+
var _ CertGenerator = CertGeneratorFunc(CreateSignedServingPair)
29+
1830
// KeyPair stores an x509 certificate and its ECDSA private key
1931
type KeyPair struct {
2032
Cert *x509.Certificate

pkg/controller/install/certresources.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ var _ certResource = &apiServiceDescriptionsWithCAPEM{}
2222

2323
var _ certResource = &webhookDescriptionWithCAPEM{}
2424

25+
// TODO: to keep refactoring minimal for backports, this is factored out here so that it can be replaced
26+
// during tests. but it should be properly injected instead.
27+
var certGenerator certs.CertGenerator = certs.CertGeneratorFunc(certs.CreateSignedServingPair)
28+
2529
const (
2630
// DefaultCertMinFresh is the default min-fresh value - 1 day
2731
DefaultCertMinFresh = time.Hour * 24
@@ -256,7 +260,7 @@ func (i *StrategyDeploymentInstaller) installCertRequirementsForDeployment(deplo
256260
fmt.Sprintf("%s.%s", service.GetName(), i.owner.GetNamespace()),
257261
fmt.Sprintf("%s.%s.svc", service.GetName(), i.owner.GetNamespace()),
258262
}
259-
servingPair, err := certs.CreateSignedServingPair(rotateAt, Organization, ca, hosts)
263+
servingPair, err := certGenerator.Generate(rotateAt, Organization, ca, hosts)
260264
if err != nil {
261265
logger.Warnf("could not generate signed certs for hosts %v", hosts)
262266
return nil, nil, err

0 commit comments

Comments
 (0)