Skip to content

Commit

Permalink
[addon-operator] fix/rename source field (#521)
Browse files Browse the repository at this point in the history
Signed-off-by: Pavel Okhlopkov <[email protected]>
Co-authored-by: Pavel Okhlopkov <[email protected]>
  • Loading branch information
ldmonster and Pavel Okhlopkov authored Nov 7, 2024
1 parent 9435e33 commit 4a41f5d
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 22 deletions.
5 changes: 5 additions & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ linters-settings:
- prefix(github.com/flant/)
goimports:
local-prefixes: github.com/flant/
# TODO: replace deprecated methods
# ignore deprecated
# https://staticcheck.dev/docs/checks/#SA1019
staticcheck:
checks: ["all","-SA1019"]
sloglint:
# Enforce not mixing key-value pairs and attributes.
no-mixed-args: true
Expand Down
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ go 1.22.8

require (
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc
github.com/deckhouse/deckhouse/pkg/log v0.0.0-20241102120041-7e44e3e22ab9
github.com/deckhouse/deckhouse/pkg/log v0.0.0-20241106140903-258b93b3334e
github.com/dominikbraun/graph v0.23.0
github.com/ettle/strcase v0.2.0
github.com/flant/kube-client v1.2.1
github.com/flant/shell-operator v1.5.0
github.com/flant/kube-client v1.2.2
github.com/flant/shell-operator v1.5.1
github.com/go-chi/chi/v5 v5.1.0
github.com/go-openapi/loads v0.19.5
github.com/go-openapi/spec v0.19.8
Expand Down
12 changes: 6 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM=
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/deckhouse/deckhouse/pkg/log v0.0.0-20241102120041-7e44e3e22ab9 h1:gCV1iKcaE69x3Knzj8isyVyEtRuG2YI4nmLIzBHBWeQ=
github.com/deckhouse/deckhouse/pkg/log v0.0.0-20241102120041-7e44e3e22ab9/go.mod h1:Mk5HRzkc5pIcDIZ2JJ6DPuuqnwhXVkb3you8M8Mg+4w=
github.com/deckhouse/deckhouse/pkg/log v0.0.0-20241106140903-258b93b3334e h1:QUQy+5Bv7/UzhfrytiG3c5gfLGhPppepVbRpbMisVIw=
github.com/deckhouse/deckhouse/pkg/log v0.0.0-20241106140903-258b93b3334e/go.mod h1:Mk5HRzkc5pIcDIZ2JJ6DPuuqnwhXVkb3you8M8Mg+4w=
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78=
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc=
github.com/distribution/distribution/v3 v3.0.0-beta.1 h1:X+ELTxPuZ1Xe5MsD3kp2wfGUhc8I+MPfRis8dZ818Ic=
Expand Down Expand Up @@ -132,12 +132,12 @@ github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2
github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
github.com/flant/go-openapi-validate v0.19.12-flant.1 h1:GuB9XEfiLHq3M7fafRLq1AWkndSY/+/5MX7ad1xJ/8A=
github.com/flant/go-openapi-validate v0.19.12-flant.1/go.mod h1:Rzou8hA/CBw8donlS6WNEUQupNvUZ0waH08tGe6kAQ4=
github.com/flant/kube-client v1.2.1 h1:8lHF8+wGZrhsXM6TeS3CNAPupXyx7UJLkBvNMpCe/ZI=
github.com/flant/kube-client v1.2.1/go.mod h1:62vCzrIUzWMU4DB0Pn6/02Pu7uwKh5/mHGWy2NmxZAk=
github.com/flant/kube-client v1.2.2 h1:27LBs+PKJEFnkQXjPU9eIps7a7iyI13AKcSYj897DCU=
github.com/flant/kube-client v1.2.2/go.mod h1:eMa3aJ6V1PRWSQ/RCROkObDpY4S74uM84SJS4G/LINg=
github.com/flant/libjq-go v1.6.3-0.20201126171326-c46a40ff22ee h1:evii83J+/6QGNvyf6tjQ/p27DPY9iftxIBb37ALJRTg=
github.com/flant/libjq-go v1.6.3-0.20201126171326-c46a40ff22ee/go.mod h1:f+REaGl/+pZR97rbTcwHEka/MAipoQQ2Mc0iQUj4ak0=
github.com/flant/shell-operator v1.5.0 h1:97lDunlvoaoza82ZGMIeP0poCj5JaIVOYdIqudKEtWY=
github.com/flant/shell-operator v1.5.0/go.mod h1:Q+XeEfVANG29ZUIgppI/uMtKCdvNktrY7V5+7gd+6dQ=
github.com/flant/shell-operator v1.5.1 h1:FnNKEOUipM7eC87zP8QeFDkvRNcU6htUEhdwMKa3U68=
github.com/flant/shell-operator v1.5.1/go.mod h1:Kbq8JNtKfoT8aqbHxygvgd6WoMImne8/upAYx9QyHUA=
github.com/fogleman/gg v1.3.0 h1:/7zJX8F6AaYQc57WQCyN9cAIz+4bCJGO9B+dyW29am8=
github.com/fogleman/gg v1.3.0/go.mod h1:R/bRT+9gY/C5z7JzPU0zXsXHKM4/ayA+zqcVNZzPa1k=
github.com/foxcpp/go-mockdns v1.0.0 h1:7jBqxd3WDWwi/6WhDvacvH1XsN3rOLXyHM1uhvIx6FI=
Expand Down
6 changes: 3 additions & 3 deletions pkg/addon-operator/kube_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ import (
var DefaultHelmMonitorKubeClientMetricLabels = map[string]string{"component": "helm_monitor"}

// defaultHelmMonitorKubeClient initializes a Kubernetes client for helm monitor.
func defaultHelmMonitorKubeClient(metricStorage *metric_storage.MetricStorage, metricLabels map[string]string) *klient.Client {
client := klient.New()
func defaultHelmMonitorKubeClient(metricStorage *metric_storage.MetricStorage, metricLabels map[string]string, logger *log.Logger) *klient.Client {
client := klient.New(klient.WithLogger(logger))
client.WithContextName(sh_app.KubeContext)
client.WithConfigPath(sh_app.KubeConfig)
client.WithRateLimiterSettings(app.HelmMonitorKubeClientQps, app.HelmMonitorKubeClientBurst)
Expand All @@ -30,7 +30,7 @@ func defaultHelmMonitorKubeClient(metricStorage *metric_storage.MetricStorage, m
}

func InitDefaultHelmResourcesManager(ctx context.Context, metricStorage *metric_storage.MetricStorage, logger *log.Logger) (helm_resources_manager.HelmResourcesManager, error) {
kubeClient := defaultHelmMonitorKubeClient(metricStorage, DefaultHelmMonitorKubeClientMetricLabels)
kubeClient := defaultHelmMonitorKubeClient(metricStorage, DefaultHelmMonitorKubeClientMetricLabels, logger.Named("helm-monitor-kube-client"))
if err := kubeClient.Init(); err != nil {
return nil, fmt.Errorf("initialize Kubernetes client for Helm resources manager: %s\n", err)
}
Expand Down
12 changes: 6 additions & 6 deletions pkg/addon-operator/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -1048,9 +1048,9 @@ func (op *AddonOperator) StartModuleManagerEventHandler() {
// dynamically_enabled_extender
case dynamic_extender.DynamicExtenderEvent:
logLabels := map[string]string{
"event.id": uuid.Must(uuid.NewV4()).String(),
"type": "ModuleScheduler event",
"source": "DymicallyEnabledExtenderChanged",
"event.id": uuid.Must(uuid.NewV4()).String(),
"type": "ModuleScheduler event",
"event_source": "DymicallyEnabledExtenderChanged",
}
eventLogEntry := utils.EnrichLoggerWithLabels(logEntry, logLabels)
// if global hooks haven't been run yet, script enabled extender fails due to missing global values
Expand Down Expand Up @@ -1086,9 +1086,9 @@ func (op *AddonOperator) StartModuleManagerEventHandler() {
// kube_config_extender
case config.KubeConfigEvent:
logLabels := map[string]string{
"event.id": uuid.Must(uuid.NewV4()).String(),
"type": "ModuleScheduler event",
"source": "KubeConfigExtenderChanged",
"event.id": uuid.Must(uuid.NewV4()).String(),
"type": "ModuleScheduler event",
"event_source": "KubeConfigExtenderChanged",
}
eventLogEntry := utils.EnrichLoggerWithLabels(logEntry, logLabels)
switch event.Type {
Expand Down
2 changes: 1 addition & 1 deletion pkg/kube_config_manager/backend/configmap/configmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ func (b Backend) saveModuleConfigValues(ctx context.Context, moduleName string,
b.logger.Infof("Save module '%s' values to ConfigMap/%s", moduleName, b.name)
}

err := b.mergeValues(ctx, moduleKubeConfig.GetValuesWithModuleName()) //nolint: staticcheck
err := b.mergeValues(ctx, moduleKubeConfig.GetValuesWithModuleName()) //nolint: staticcheck,nolintlint

return moduleKubeConfig.Checksum, err
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/kube_config_manager/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func ParseModuleKubeConfigFromValues(moduleName string, values utils.Values) *Mo
return nil
}

//nolint: staticcheck
//nolint: staticcheck,nolintlint
moduleValues := values.SectionByKey(valuesKey)

checksum := moduleValues.Checksum()
Expand Down
4 changes: 2 additions & 2 deletions pkg/kube_config_manager/kube_config_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ grafanaEnabled: "false"
moduleConfig, hasConfig := config.Modules[name]
assert.True(t, hasConfig)
assert.Equal(t, expect.isEnabled, moduleConfig.IsEnabled)
assert.Equal(t, expect.values, moduleConfig.GetValuesWithModuleName()) //nolint: staticcheck
assert.Equal(t, expect.values, moduleConfig.GetValuesWithModuleName()) //nolint: staticcheck,nolintlint
})
}
})
Expand Down Expand Up @@ -439,7 +439,7 @@ func Test_KubeConfigManager_error_on_Init(t *testing.T) {
// g.Expect(config.IsInvalid).To(Equal(false), "Current config should be valid")
g.Expect(config.Modules).To(HaveLen(1), "Current config should have module sections")
g.Expect(config.Modules).To(HaveKey("valid-module-name"), "Current config should have module section for 'valid-module-name'")
modValues := config.Modules["valid-module-name"].GetValuesWithModuleName() //nolint: staticcheck
modValues := config.Modules["valid-module-name"].GetValuesWithModuleName() //nolint: staticcheck,nolintlint
g.Expect(modValues.HasKey("validModuleName")).To(BeTrue())
m := modValues["validModuleName"]
vals := m.(map[string]interface{})
Expand Down

0 comments on commit 4a41f5d

Please sign in to comment.