Skip to content

Commit

Permalink
Get config in webhook (#496)
Browse files Browse the repository at this point in the history
* Remove member config files and use the ones from toolchain-common

* Get key from config

* Get config from memberoperatorconfig

* Update dependencies

* Cleanup

* Add unit tests for multiple keys

* Update toolchain-common dependency

* Uncomment test case

* Update toolchain-common dependency

* Fix lint error

* Add comment for clarification

---------

Co-authored-by: Alexey Kazakov <[email protected]>
  • Loading branch information
rajivnathan and alexeykazakov authored Nov 13, 2023
1 parent 2fc1c05 commit fb165ea
Show file tree
Hide file tree
Showing 21 changed files with 197 additions and 772 deletions.
6 changes: 3 additions & 3 deletions cmd/consoleplugin/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import (
"time"

toolchainv1alpha1 "github.com/codeready-toolchain/api/api/v1alpha1"
"github.com/codeready-toolchain/member-operator/controllers/memberoperatorconfig"
"github.com/codeready-toolchain/member-operator/pkg/consoleplugin"
"github.com/codeready-toolchain/member-operator/pkg/klog"
membercfg "github.com/codeready-toolchain/toolchain-common/pkg/configuration/memberoperatorconfig"

"go.uber.org/zap/zapcore"
corev1 "k8s.io/api/core/v1"
Expand Down Expand Up @@ -102,7 +102,7 @@ func main() {
os.Exit(1)
}

config, err := memberoperatorconfig.GetConfiguration(cl)
config, err := membercfg.GetConfiguration(cl)
if err != nil {
setupLog.Error(err, "Error retrieving Configuration")
os.Exit(1)
Expand All @@ -113,7 +113,7 @@ func main() {
gracefulShutdown(gracefulTimeout, pluginServer)
}

func startConsolePluginService(config memberoperatorconfig.WebConsolePluginConfig) *consoleplugin.Server {
func startConsolePluginService(config membercfg.WebConsolePluginConfig) *consoleplugin.Server {
consolePluginServer := consoleplugin.NewConsolePluginServer(config, setupLog)
consolePluginServer.Start()

Expand Down
9 changes: 9 additions & 0 deletions cmd/webhook/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"github.com/codeready-toolchain/member-operator/pkg/klog"
"github.com/codeready-toolchain/member-operator/pkg/webhook/mutatingwebhook"
"github.com/codeready-toolchain/member-operator/pkg/webhook/validatingwebhook"
membercfg "github.com/codeready-toolchain/toolchain-common/pkg/configuration/memberoperatorconfig"

"go.uber.org/zap/zapcore"
"k8s.io/apimachinery/pkg/runtime"
Expand Down Expand Up @@ -90,6 +91,14 @@ func main() {
setupLog.Error(err, "creating a new client failed")
os.Exit(1)
}

// Calling GetConfiguration here to load the configuration and populate the cache
_, err = membercfg.GetConfiguration(cl)
if err != nil {
setupLog.Error(err, "getting member operator config failed")
os.Exit(1)
}

rolebindingValidator := &validatingwebhook.RoleBindingRequestValidator{
Client: cl,
}
Expand Down
279 changes: 0 additions & 279 deletions controllers/memberoperatorconfig/configuration.go

This file was deleted.

Loading

0 comments on commit fb165ea

Please sign in to comment.