Skip to content

Commit b8d9784

Browse files
committed
fix webhook certs
1 parent 447a1a0 commit b8d9784

File tree

1 file changed

+10
-8
lines changed
  • cmd/project-workspace-operator/app

1 file changed

+10
-8
lines changed

cmd/project-workspace-operator/app/init.go

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ func (o *InitOptions) Run(ctx context.Context) error {
206206
}
207207
log.Info("TLS route is ready")
208208

209-
opts := []webhooks.InstallOption{
209+
installOpts := []webhooks.InstallOption{
210210
webhooks.WithWebhookService{Name: whServiceName, Namespace: providerSystemNamespace},
211211
webhooks.WithWebhookSecret{Name: whSecretName, Namespace: providerSystemNamespace},
212212
webhooks.WithRemoteClient{Client: onboardingCluster.Client()},
@@ -221,9 +221,14 @@ func (o *InitOptions) Run(ctx context.Context) error {
221221
},
222222
},
223223
}
224+
certOpts := []webhooks.CertOption{
225+
webhooks.WithWebhookService{Name: whServiceName, Namespace: providerSystemNamespace},
226+
webhooks.WithWebhookSecret{Name: whSecretName, Namespace: providerSystemNamespace},
227+
}
224228
if o.PlatformCluster.RESTConfig().Host != onboardingCluster.RESTConfig().Host {
225229
// create a URL-based webhook otherwise
226-
opts = append(opts, webhooks.WithCustomBaseURL(fmt.Sprintf("https://%s:%d", gatewayResult.HostName, gatewayResult.TLSPort)))
230+
installOpts = append(installOpts, webhooks.WithCustomBaseURL(fmt.Sprintf("https://%s:%d", gatewayResult.HostName, gatewayResult.TLSPort)))
231+
certOpts = append(certOpts, webhooks.WithAdditionalDNSNames{gatewayResult.HostName})
227232
}
228233

229234
// webhook options we might or might not support at a later time
@@ -236,10 +241,7 @@ func (o *InitOptions) Run(ctx context.Context) error {
236241
log.Info("Webhooks are enabled, ensuring required resources ...")
237242

238243
// Generate webhook certificate
239-
if err := webhooks.GenerateCertificate(ctx, o.PlatformCluster.Client(),
240-
webhooks.WithWebhookService{Name: whServiceName, Namespace: providerSystemNamespace},
241-
webhooks.WithWebhookSecret{Name: whSecretName, Namespace: providerSystemNamespace},
242-
); err != nil {
244+
if err := webhooks.GenerateCertificate(ctx, o.PlatformCluster.Client(), certOpts...); err != nil {
243245
return fmt.Errorf("unable to generate webhook certificate: %w", err)
244246
}
245247

@@ -252,7 +254,7 @@ func (o *InitOptions) Run(ctx context.Context) error {
252254
&pwv1alpha1.Project{},
253255
&pwv1alpha1.Workspace{},
254256
},
255-
opts...,
257+
installOpts...,
256258
)
257259
if err != nil {
258260
return fmt.Errorf("unable to install webhooks: %w", err)
@@ -269,7 +271,7 @@ func (o *InitOptions) Run(ctx context.Context) error {
269271
&pwv1alpha1.Project{},
270272
&pwv1alpha1.Workspace{},
271273
},
272-
opts...,
274+
installOpts...,
273275
)
274276
if err != nil {
275277
return fmt.Errorf("unable to uninstall webhooks: %w", err)

0 commit comments

Comments
 (0)