feat: customize name of secret (#125)

This commit is contained in:
Ugo Mignon 2023-10-24 10:18:41 +02:00 committed by GitHub
parent 6832edc9e9
commit 35abbe3c5c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -6,6 +6,7 @@ package controllers
import ( import (
"context" "context"
"fmt" "fmt"
"os"
"sync" "sync"
"github.com/go-logr/logr" "github.com/go-logr/logr"
@ -22,13 +23,18 @@ import (
) )
const ( const (
ClientIDKey = "client_id" DefaultClientID = "CLIENT_ID"
ClientSecretKey = "client_secret" DefaultSecretKey = "CLIENT_SECRET"
FinalizerName = "finalizer.ory.hydra.sh" FinalizerName = "finalizer.ory.hydra.sh"
DefaultNamespace = "default" DefaultNamespace = "default"
) )
var (
ClientIDKey = DefaultClientID
ClientSecretKey = DefaultSecretKey
)
type clientKey struct { type clientKey struct {
url string url string
port int port int
@ -66,6 +72,15 @@ type Options struct {
// Option is a functional option. // Option is a functional option.
type Option func(*Options) 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. // WithNamespace sets the kubernetes namespace for the controller.
// The default is "default". // The default is "default".
func WithNamespace(ns string) Option { func WithNamespace(ns string) Option {