From 35abbe3c5c1294cfce6e34f41cf37054c64747b4 Mon Sep 17 00:00:00 2001 From: Ugo Mignon <56931733+TartanLeGrand@users.noreply.github.com> Date: Tue, 24 Oct 2023 10:18:41 +0200 Subject: [PATCH] feat: customize name of secret (#125) --- controllers/oauth2client_controller.go | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/controllers/oauth2client_controller.go b/controllers/oauth2client_controller.go index 98c61c0..8ef02dd 100644 --- a/controllers/oauth2client_controller.go +++ b/controllers/oauth2client_controller.go @@ -6,6 +6,7 @@ package controllers import ( "context" "fmt" + "os" "sync" "github.com/go-logr/logr" @@ -22,13 +23,18 @@ import ( ) const ( - ClientIDKey = "client_id" - ClientSecretKey = "client_secret" - FinalizerName = "finalizer.ory.hydra.sh" + DefaultClientID = "CLIENT_ID" + DefaultSecretKey = "CLIENT_SECRET" + FinalizerName = "finalizer.ory.hydra.sh" DefaultNamespace = "default" ) +var ( + ClientIDKey = DefaultClientID + ClientSecretKey = DefaultSecretKey +) + type clientKey struct { url string port int @@ -66,6 +72,15 @@ type Options struct { // Option is a functional option. type Option func(*Options) +func init() { + if os.Getenv("CLIENT_ID_KEY") != "" { + ClientIDKey = os.Getenv("CLIENT_ID_KEY") + } + if os.Getenv("CLIENT_SECRET_KEY") != "" { + ClientSecretKey = os.Getenv("CLIENT_SECRET_KEY") + } +} + // WithNamespace sets the kubernetes namespace for the controller. // The default is "default". func WithNamespace(ns string) Option {