Skip to content

Commit

Permalink
move fields to debug
Browse files Browse the repository at this point in the history
  • Loading branch information
jpinsonneau committed Oct 20, 2023
1 parent ee1bf51 commit 2cbe30a
Show file tree
Hide file tree
Showing 25 changed files with 1,183 additions and 990 deletions.
85 changes: 66 additions & 19 deletions api/v1alpha1/flowcollector_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (

"github.com/netobserv/network-observability-operator/api/v1beta2"
utilconversion "github.com/netobserv/network-observability-operator/pkg/conversion"
"github.com/netobserv/network-observability-operator/pkg/helper"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
apiconversion "k8s.io/apimachinery/pkg/conversion"
"sigs.k8s.io/controller-runtime/pkg/conversion"
Expand All @@ -41,16 +42,6 @@ func (r *FlowCollector) ConvertTo(dstRaw conversion.Hub) error {
// Manually restore data.
restored := &v1beta2.FlowCollector{}
if ok, err := utilconversion.UnmarshalData(r, restored); err != nil || !ok {
// fallback on current loki config as Manual mode if metadata are not available
dst.Spec.Loki.Mode = v1beta2.LokiModeManual
dst.Spec.Loki.Manual.IngesterURL = r.Spec.Loki.URL
dst.Spec.Loki.Manual.QuerierURL = r.Spec.Loki.QuerierURL
dst.Spec.Loki.Manual.StatusURL = r.Spec.Loki.StatusURL
dst.Spec.Loki.Manual.TenantID = r.Spec.Loki.TenantID
dst.Spec.Loki.Manual.AuthToken = r.Spec.Loki.AuthToken
if err := Convert_v1alpha1_ClientTLS_To_v1beta2_ClientTLS(&r.Spec.Loki.TLS, &dst.Spec.Loki.Manual.TLS, nil); err != nil {
return fmt.Errorf("copying v1alplha1.Loki.TLS into v1beta2.Loki.Manual.TLS: %w", err)
}
return err
}

Expand All @@ -62,14 +53,14 @@ func (r *FlowCollector) ConvertTo(dstRaw conversion.Hub) error {

// Processor
dst.Spec.Processor.LogTypes = restored.Spec.Processor.LogTypes
if restored.Spec.Processor.ConversationHeartbeatInterval != nil {
dst.Spec.Processor.ConversationHeartbeatInterval = restored.Spec.Processor.ConversationHeartbeatInterval
if restored.Spec.Processor.Debug.ConversationHeartbeatInterval != nil {
dst.Spec.Processor.Debug.ConversationHeartbeatInterval = restored.Spec.Processor.Debug.ConversationHeartbeatInterval
}
if restored.Spec.Processor.ConversationEndTimeout != nil {
dst.Spec.Processor.ConversationEndTimeout = restored.Spec.Processor.ConversationEndTimeout
if restored.Spec.Processor.Debug.ConversationEndTimeout != nil {
dst.Spec.Processor.Debug.ConversationEndTimeout = restored.Spec.Processor.Debug.ConversationEndTimeout
}
if restored.Spec.Processor.ConversationTerminatingTimeout != nil {
dst.Spec.Processor.ConversationTerminatingTimeout = restored.Spec.Processor.ConversationTerminatingTimeout
if restored.Spec.Processor.Debug.ConversationTerminatingTimeout != nil {
dst.Spec.Processor.Debug.ConversationTerminatingTimeout = restored.Spec.Processor.Debug.ConversationTerminatingTimeout
}
if restored.Spec.Processor.Metrics.DisableAlerts != nil {
dst.Spec.Processor.Metrics.DisableAlerts = restored.Spec.Processor.Metrics.DisableAlerts
Expand Down Expand Up @@ -157,6 +148,16 @@ func Convert_v1beta2_FLPMetrics_To_v1alpha1_FLPMetrics(in *v1beta2.FLPMetrics, o
// we have new defined fields in v1beta2 not in v1alpha1
// nolint:golint,stylecheck,revive
func Convert_v1beta2_FlowCollectorLoki_To_v1alpha1_FlowCollectorLoki(in *v1beta2.FlowCollectorLoki, out *FlowCollectorLoki, s apiconversion.Scope) error {
out.URL = helper.LokiIngesterURL(in)
out.QuerierURL = helper.LokiQuerierURL(in)
out.StatusURL = helper.LokiStatusURL(in)
out.TenantID = helper.LokiTenantID(in)
switch in.Mode {
case v1beta2.LokiModeManual:
out.AuthToken = in.Manual.AuthToken
case v1beta2.LokiModeLokiStack:
out.AuthToken = v1beta2.LokiAuthForwardUserToken
}
return autoConvert_v1beta2_FlowCollectorLoki_To_v1alpha1_FlowCollectorLoki(in, out, s)
}

Expand All @@ -168,21 +169,21 @@ func Convert_v1alpha1_FlowCollectorLoki_To_v1beta2_FlowCollectorLoki(in *FlowCol
}

// This function need to be manually created because conversion-gen not able to create it intentionally because
// we have new defined fields in v1beta1 not in v1alpha1
// we have new defined fields in v1beta2 not in v1alpha1
// nolint:golint,stylecheck,revive
func Convert_v1beta2_FlowCollectorConsolePlugin_To_v1alpha1_FlowCollectorConsolePlugin(in *v1beta2.FlowCollectorConsolePlugin, out *FlowCollectorConsolePlugin, s apiconversion.Scope) error {
return autoConvert_v1beta2_FlowCollectorConsolePlugin_To_v1alpha1_FlowCollectorConsolePlugin(in, out, s)
}

// This function need to be manually created because conversion-gen not able to create it intentionally because
// we have new defined fields in v1beta1 not in v1alpha1
// we have new defined fields in v1beta2 not in v1alpha1
// nolint:golint,stylecheck,revive
func Convert_v1beta2_FlowCollectorExporter_To_v1alpha1_FlowCollectorExporter(in *v1beta2.FlowCollectorExporter, out *FlowCollectorExporter, s apiconversion.Scope) error {
return autoConvert_v1beta2_FlowCollectorExporter_To_v1alpha1_FlowCollectorExporter(in, out, s)
}

// This function need to be manually created because conversion-gen not able to create it intentionally because
// we have new defined fields in v1beta1 not in v1alpha1
// we have new defined fields in v1beta2 not in v1alpha1
// nolint:golint,stylecheck,revive
func Convert_v1beta2_FlowCollectorEBPF_To_v1alpha1_FlowCollectorEBPF(in *v1beta2.FlowCollectorEBPF, out *FlowCollectorEBPF, s apiconversion.Scope) error {
return autoConvert_v1beta2_FlowCollectorEBPF_To_v1alpha1_FlowCollectorEBPF(in, out, s)
Expand All @@ -194,3 +195,49 @@ func Convert_v1beta2_FlowCollectorEBPF_To_v1alpha1_FlowCollectorEBPF(in *v1beta2
func Convert_v1beta2_ServerTLS_To_v1alpha1_ServerTLS(in *v1beta2.ServerTLS, out *ServerTLS, s apiconversion.Scope) error {
return autoConvert_v1beta2_ServerTLS_To_v1alpha1_ServerTLS(in, out, s)
}

// This function need to be manually created because conversion-gen not able to create it intentionally because
// we have new defined fields in v1beta2 not in v1alpha1
// nolint:golint,stylecheck,revive
func Convert_v1alpha1_FlowCollectorConsolePlugin_To_v1beta2_FlowCollectorConsolePlugin(in *FlowCollectorConsolePlugin, out *v1beta2.FlowCollectorConsolePlugin, s apiconversion.Scope) error {
return autoConvert_v1alpha1_FlowCollectorConsolePlugin_To_v1beta2_FlowCollectorConsolePlugin(in, out, s)
}

// This function need to be manually created because conversion-gen not able to create it intentionally because
// we have new defined fields in v1beta2 not in v1alpha1
// nolint:golint,stylecheck,revive
func Convert_v1alpha1_FlowCollectorFLP_To_v1beta2_FlowCollectorFLP(in *FlowCollectorFLP, out *v1beta2.FlowCollectorFLP, s apiconversion.Scope) error {
return autoConvert_v1alpha1_FlowCollectorFLP_To_v1beta2_FlowCollectorFLP(in, out, s)
}

// This function need to be manually created because conversion-gen not able to create it intentionally because
// we have new defined fields in v1beta2 not in v1alpha1
// nolint:golint,stylecheck,revive
func Convert_v1alpha1_DebugConfig_To_v1beta2_DebugAgentConfig(in *DebugConfig, out *v1beta2.DebugAgentConfig, s apiconversion.Scope) error {
out.Env = in.Env
return nil
}

// This function need to be manually created because conversion-gen not able to create it intentionally because
// we have new defined fields in v1beta2 not in v1alpha1
// nolint:golint,stylecheck,revive
func Convert_v1beta2_DebugAgentConfig_To_v1alpha1_DebugConfig(in *v1beta2.DebugAgentConfig, out *DebugConfig, s apiconversion.Scope) error {
out.Env = in.Env
return nil
}

// This function need to be manually created because conversion-gen not able to create it intentionally because
// we have new defined fields in v1beta2 not in v1alpha1
// nolint:golint,stylecheck,revive
func Convert_v1alpha1_DebugConfig_To_v1beta2_DebugProcessorConfig(in *DebugConfig, out *v1beta2.DebugProcessorConfig, s apiconversion.Scope) error {
out.Env = in.Env
return nil
}

// This function need to be manually created because conversion-gen not able to create it intentionally because
// we have new defined fields in v1beta2 not in v1alpha1
// nolint:golint,stylecheck,revive
func Convert_v1beta2_DebugProcessorConfig_To_v1alpha1_DebugConfig(in *v1beta2.DebugProcessorConfig, out *DebugConfig, s apiconversion.Scope) error {
out.Env = in.Env
return nil
}
Loading

0 comments on commit 2cbe30a

Please sign in to comment.