Skip to content

Commit

Permalink
fix(service_intergration): empty user config to API convertion
Browse files Browse the repository at this point in the history
  • Loading branch information
ivan-savciuc authored and Serpentiel committed Nov 10, 2023
1 parent 33f9cff commit 72c9845
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
4 changes: 2 additions & 2 deletions controllers/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ func getSecretPrefix(o objWithSecret) string {
// userConfigurationToAPI converts user config into a map
func userConfigurationToAPI(c any, groups ...string) (map[string]any, error) {
if c == nil || (reflect.ValueOf(c).Kind() == reflect.Ptr && reflect.ValueOf(c).IsNil()) {
return nil, nil
return map[string]any{}, nil
}

o := &sheriff.Options{
Expand All @@ -192,7 +192,7 @@ func userConfigurationToAPI(c any, groups ...string) (map[string]any, error) {
if !ok {
// It is an empty pointer
// sheriff just returned the very same object
return nil, nil
return map[string]any{}, nil
}

return m, nil
Expand Down
9 changes: 8 additions & 1 deletion controllers/serviceintegration_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package controllers
import (
"context"
"fmt"
"slices"
"strconv"
"strings"

Expand Down Expand Up @@ -77,6 +78,12 @@ func (h ServiceIntegrationHandler) createOrUpdate(ctx context.Context, avn *aive

reason = "Created"
} else {
// Not all service integrations have user_config available; skip the update if user_config is unavailable.
withUserConfig := []string{"clickhouse_kafka", "clickhouse_postgresql", "datadog", "kafka_connect", "kafka_logs", "kafka_mirrormaker", "logs", "metrics", "external_aws_cloudwatch_metrics"}
if !slices.Contains(withUserConfig, si.Spec.IntegrationType) {
return nil
}

userConfigMap, err := UpdateUserConfiguration(userConfig)
if err != nil {
return err
Expand All @@ -92,7 +99,7 @@ func (h ServiceIntegrationHandler) createOrUpdate(ctx context.Context, avn *aive
)
reason = "Updated"
if err != nil {
if strings.Contains(err.Error(), "user config not changed") {
if strings.Contains(strings.ToLower(err.Error()), "user config not changed") {
return nil
}
return err
Expand Down

0 comments on commit 72c9845

Please sign in to comment.