Skip to content

Commit

Permalink
Make Logging options configurable using configfile.
Browse files Browse the repository at this point in the history
Signed-off-by: Tim Ramlot <42113979+inteon@users.noreply.github.com>
  • Loading branch information
inteon committed Aug 11, 2023
1 parent 9d618a1 commit 5f69478
Show file tree
Hide file tree
Showing 16 changed files with 131 additions and 244 deletions.
7 changes: 6 additions & 1 deletion cmd/webhook/app/webhook.go
Expand Up @@ -95,7 +95,7 @@ func NewServerCommand(stopCh <-chan struct{}) *cobra.Command {
os.Exit(1)
}

if err := logf.ValidateAndApply(webhookFlags.Logging); err != nil {
if err := logf.ValidateAndApply(&webhookConfig.Logging); err != nil {
log.Error(err, "Failed to validate webhook flags")
os.Exit(1)
}
Expand All @@ -117,6 +117,11 @@ func NewServerCommand(stopCh <-chan struct{}) *cobra.Command {
log.Error(err, "Failed to set feature gates from config file")
os.Exit(1)
}

if err := logf.ValidateAndApply(&webhookConfig.Logging); err != nil {
log.Error(err, "Failed to validate webhook flags")
os.Exit(1)
}
}

srv, err := cmwebhook.NewCertManagerWebhookServer(log, *webhookConfig)
Expand Down
1 change: 1 addition & 0 deletions hack/k8s-codegen.sh
Expand Up @@ -104,6 +104,7 @@ conversion_inputs=(
internal/apis/acme/v1alpha3 \
internal/apis/acme/v1beta1 \
internal/apis/acme/v1 \
internal/apis/config/util \
internal/apis/config/webhook/v1alpha1 \
internal/apis/config/controller/v1alpha1 \
internal/apis/meta/v1 \
Expand Down
68 changes: 0 additions & 68 deletions internal/apis/config/controller/v1alpha1/conversion.go
Expand Up @@ -15,71 +15,3 @@ limitations under the License.
*/

package v1alpha1

import (
controller "github.com/cert-manager/cert-manager/internal/apis/config/controller"
v1alpha1 "github.com/cert-manager/cert-manager/pkg/apis/config/controller/v1alpha1"
conversion "k8s.io/apimachinery/pkg/conversion"
"k8s.io/component-base/logs"
logsapi "k8s.io/component-base/logs/api/v1"
)

func Convert_v1alpha1_ControllerConfiguration_To_controller_ControllerConfiguration(in *v1alpha1.ControllerConfiguration, out *controller.ControllerConfiguration, s conversion.Scope) error {
if err := autoConvert_v1alpha1_ControllerConfiguration_To_controller_ControllerConfiguration(in, out, s); err != nil {
return err
}
return nil
}

func Convert_controller_ControllerConfiguration_To_v1alpha1_ControllerConfiguration(in *controller.ControllerConfiguration, out *v1alpha1.ControllerConfiguration, s conversion.Scope) error {
if err := autoConvert_controller_ControllerConfiguration_To_v1alpha1_ControllerConfiguration(in, out, s); err != nil {
return err
}
return nil
}

func Convert_Pointer_float32_To_float32(in **float32, out *float32, s conversion.Scope) error {
if *in == nil {
*out = 0
return nil
}
*out = float32(**in)
return nil
}

func Convert_float32_To_Pointer_float32(in *float32, out **float32, s conversion.Scope) error {
temp := float32(*in)
*out = &temp
return nil
}

func Convert_Pointer_int32_To_int(in **int32, out *int, s conversion.Scope) error {
if *in == nil {
*out = 0
return nil
}
*out = int(**in)
return nil
}

func Convert_int_To_Pointer_int32(in *int, out **int32, s conversion.Scope) error {
temp := int32(*in)
*out = &temp
return nil
}

func Convert_Pointer_v1_LoggingConfiguration_To_v1_LoggingConfiguration(in **logsapi.LoggingConfiguration, out *logsapi.LoggingConfiguration, s conversion.Scope) error {
if *in == nil {
temp := logs.NewOptions()
temp.DeepCopyInto(out)
return nil
}
(*in).DeepCopyInto(out)
return nil
}

func Convert_v1_LoggingConfiguration_To_Pointer_v1_LoggingConfiguration(in *logsapi.LoggingConfiguration, out **logsapi.LoggingConfiguration, s conversion.Scope) error {
temp := in.DeepCopy()
*out = temp
return nil
}
82 changes: 0 additions & 82 deletions internal/apis/config/controller/v1alpha1/conversion_test.go

This file was deleted.

8 changes: 2 additions & 6 deletions internal/apis/config/controller/v1alpha1/defaults.go
Expand Up @@ -20,7 +20,7 @@ import (
"fmt"

"k8s.io/apimachinery/pkg/runtime"
"k8s.io/component-base/logs"
logsapi "k8s.io/component-base/logs/api/v1"

"time"

Expand Down Expand Up @@ -71,8 +71,6 @@ var (
defaultEnableProfiling = false
defaultProfilerAddr = "localhost:6060"

defaultLogging = logs.NewOptions()

defaultClusterIssuerAmbientCredentials = true
defaultIssuerAmbientCredentials = false

Expand Down Expand Up @@ -243,9 +241,7 @@ func SetDefaults_ControllerConfiguration(obj *v1alpha1.ControllerConfiguration)
obj.PprofAddress = defaultProfilerAddr
}

if obj.Logging == nil {
obj.Logging = defaultLogging
}
logsapi.SetRecommendedLoggingConfiguration(&obj.Logging)
}

func SetDefaults_LeaderElectionConfig(obj *v1alpha1.LeaderElectionConfig) {
Expand Down

0 comments on commit 5f69478

Please sign in to comment.