Skip to content

Commit adc6166

Browse files
committed
Allow stubbing certificate request name generation
Signed-off-by: James Munnelly <[email protected]>
1 parent 6ca41bd commit adc6166

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

manager/manager.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,9 @@ func NewManager(opts Options) (*Manager, error) {
187187
maxRequestsPerVolume: opts.MaxRequestsPerVolume,
188188
nodeNameHash: nodeNameHash,
189189
backoffConfig: *opts.RenewalBackoffConfig,
190+
requestNameGenerator: func() string {
191+
return string(uuid.NewUUID())
192+
},
190193
}
191194

192195
vols, err := opts.MetadataReader.ListVolumes()
@@ -285,6 +288,10 @@ type Manager struct {
285288

286289
// backoffConfig configures the exponential backoff applied to certificate renewal failures.
287290
backoffConfig wait.Backoff
291+
292+
// requestNameGenerator generates a new random name for a certificaterequest object
293+
// Defaults to uuid.NewUUID() from k8s.io/apimachinery/pkg/util/uuid.
294+
requestNameGenerator func() string
288295
}
289296

290297
// issue will step through the entire issuance flow for a volume.
@@ -467,7 +474,7 @@ func (m *Manager) labelSelectorForVolume(volumeID string) (labels.Selector, erro
467474
func (m *Manager) submitRequest(ctx context.Context, meta metadata.Metadata, csrBundle *CertificateRequestBundle, csrPEM []byte) (*cmapi.CertificateRequest, error) {
468475
req := &cmapi.CertificateRequest{
469476
ObjectMeta: metav1.ObjectMeta{
470-
Name: string(uuid.NewUUID()),
477+
Name: m.requestNameGenerator(),
471478
Namespace: csrBundle.Namespace,
472479
Annotations: csrBundle.Annotations,
473480
Labels: map[string]string{

0 commit comments

Comments
 (0)