Skip to content

Commit c4f5b68

Browse files
author
Igor Komlew
authored
Revert "Configure Coordinator from ENV in init(), prepare for explicit init (#5577)" (#5628)
This reverts commit ce07339.
1 parent a7bdabf commit c4f5b68

3 files changed

Lines changed: 11 additions & 27 deletions

File tree

providers/coordinator.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,11 @@ var BuiltinCoreID = coreconf.Config.ID
4646

4747
var Coordinator ProvidersCoordinator
4848

49-
func newCoordinator(globalAutoUpdateCfg UpdateProvidersConfig) *coordinator {
49+
func newCoordinator() *coordinator {
5050
c := &coordinator{
51-
runningByID: map[string]*RunningProvider{},
52-
runtimes: map[string]*Runtime{},
53-
schema: newExtensibleSchema(),
54-
autoUpdateConfig: globalAutoUpdateCfg,
51+
runningByID: map[string]*RunningProvider{},
52+
runtimes: map[string]*Runtime{},
53+
schema: newExtensibleSchema(),
5554
}
5655
c.schema.coordinator = c
5756
return c
@@ -69,7 +68,6 @@ type coordinator struct {
6968
runtimeCnt int
7069
mutex sync.Mutex
7170
schema extensibleSchema
72-
autoUpdateConfig UpdateProvidersConfig
7371
}
7472

7573
type builtinProvider struct {
@@ -110,7 +108,9 @@ func (c *coordinator) newRuntime() *Runtime {
110108
providers: map[string]*ConnectedProvider{},
111109
recording: recording.Null{},
112110
shutdownTimeout: defaultShutdownTimeout,
113-
AutoUpdate: c.autoUpdateConfig,
111+
AutoUpdate: UpdateProvidersConfig{
112+
Enabled: true,
113+
},
114114
}
115115

116116
c.mutex.Lock()

providers/extensible_schema_test.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@ import (
1313

1414
func TestExtensibleSchema(t *testing.T) {
1515
s := newExtensibleSchema()
16-
s.coordinator = newCoordinator(UpdateProvidersConfig{
17-
Enabled: true,
18-
})
16+
s.coordinator = newCoordinator()
1917

2018
s.Add("first", &resources.Schema{
2119
Resources: map[string]*resources.ResourceInfo{

providers/providers.go

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import (
2222
"github.com/hashicorp/go-retryablehttp"
2323
"github.com/rs/zerolog/log"
2424
"github.com/spf13/afero"
25-
"github.com/spf13/viper"
2625
"github.com/ulikunitz/xz"
2726
"go.mondoo.com/cnquery/v11/cli/config"
2827
"go.mondoo.com/cnquery/v11/logger/zerologadapter"
@@ -62,20 +61,9 @@ func init() {
6261

6362
LastProviderInstall = time.Now().Unix()
6463

65-
viper.SetEnvPrefix("mondoo")
66-
viper.AutomaticEnv()
67-
68-
autoUpdateEnabled := true
69-
config.InitViperConfig()
70-
if viper.IsSet("auto_update") {
71-
autoUpdateEnabled = viper.GetBool("auto_update")
72-
}
73-
74-
coordinatorCfg := UpdateProvidersConfig{
75-
Enabled: autoUpdateEnabled,
76-
RefreshInterval: 60 * 60,
77-
}
78-
Coordinator = newCoordinator(coordinatorCfg)
64+
// Initialize the global coordinator instance
65+
coordinator := newCoordinator()
66+
Coordinator = coordinator
7967
}
8068

8169
type ProviderLookup struct {
@@ -948,9 +936,7 @@ func TryProviderUpdate(provider *Provider, update UpdateProvidersConfig) (*Provi
948936
log.Info().
949937
Str("installed", provider.Version).
950938
Str("latest", latest).
951-
Bool("update is enabled", update.Enabled).
952939
Msg("found a new version for '" + provider.Name + "' provider")
953-
954940
provider, err = installVersion(provider.Name, latest)
955941
if err != nil {
956942
return nil, err

0 commit comments

Comments
 (0)