Skip to content

Commit

Permalink
poc: fix lib import
Browse files Browse the repository at this point in the history
Signed-off-by: realanna <anna.reale@dynatrace.com>
  • Loading branch information
RealAnna committed May 17, 2023
1 parent 9a731a7 commit 4385f3e
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 64 deletions.
95 changes: 44 additions & 51 deletions klt-cert-manager/pkg/fake/manager_mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions klt-cert-manager/pkg/webhook/builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ func TestBuilder_Run(t *testing.T) {
mockManager.GetAPIReaderFunc = func() client.Reader {
return newFakeClient()
}
webhookServer := &webhook.Server{}
mockManager.GetWebhookServerFunc = func() *webhook.Server {
webhookServer := webhook.NewServer(webhook.Options{})
mockManager.GetWebhookServerFunc = func() webhook.Server {
return webhookServer
}

Expand Down
8 changes: 5 additions & 3 deletions klt-cert-manager/pkg/webhook/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"k8s.io/apimachinery/pkg/runtime"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/manager"
"sigs.k8s.io/controller-runtime/pkg/webhook"
)

const (
Expand Down Expand Up @@ -43,9 +44,10 @@ func (provider WebhookProvider) createOptions(scheme *runtime.Scheme, namespace
}

func (provider WebhookProvider) SetupWebhookServer(mgr manager.Manager) {

webhookServer := mgr.GetWebhookServer()
webhookServer.CertDir = provider.certificateDirectory
webhookServer.KeyName = provider.keyFileName
webhookServer.CertName = provider.certificateFileName
webhookServer.(*webhook.DefaultServer).Options.CertDir = provider.certificateDirectory
webhookServer.(*webhook.DefaultServer).Options.KeyName = provider.keyFileName
webhookServer.(*webhook.DefaultServer).Options.CertName = provider.certificateFileName

}
16 changes: 8 additions & 8 deletions klt-cert-manager/pkg/webhook/manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,23 +31,23 @@ func TestCreateOptions(t *testing.T) {
})
t.Run("configures webhooks server", func(t *testing.T) {
provider := NewWebhookManagerProvider("certs-dir", "key-file", "cert-file")
expectedWebhookServer := &webhook.Server{}
expectedWebhookServer := webhook.NewServer(webhook.Options{})

mgr := &fake.MockManager{
GetWebhookServerFunc: func() *webhook.Server {
GetWebhookServerFunc: func() webhook.Server {
return expectedWebhookServer
},
}

provider.SetupWebhookServer(mgr)

assert.Equal(t, "certs-dir", expectedWebhookServer.CertDir)
assert.Equal(t, "key-file", expectedWebhookServer.KeyName)
assert.Equal(t, "cert-file", expectedWebhookServer.CertName)
assert.Equal(t, "certs-dir", expectedWebhookServer.(*webhook.DefaultServer).Options.CertDir)
assert.Equal(t, "key-file", expectedWebhookServer.(*webhook.DefaultServer).Options.KeyName)
assert.Equal(t, "cert-file", expectedWebhookServer.(*webhook.DefaultServer).Options.CertName)

mgrWebhookServer := mgr.GetWebhookServer()
assert.Equal(t, "certs-dir", mgrWebhookServer.CertDir)
assert.Equal(t, "key-file", mgrWebhookServer.KeyName)
assert.Equal(t, "cert-file", mgrWebhookServer.CertName)
assert.Equal(t, "certs-dir", mgrWebhookServer.(*webhook.DefaultServer).Options.CertDir)
assert.Equal(t, "key-file", mgrWebhookServer.(*webhook.DefaultServer).Options.KeyName)
assert.Equal(t, "cert-file", mgrWebhookServer.(*webhook.DefaultServer).Options.CertName)
})
}

0 comments on commit 4385f3e

Please sign in to comment.