diff --git a/services/rego/cmd.go b/services/rego/cmd.go index 2ec12adf7..5cac7c233 100644 --- a/services/rego/cmd.go +++ b/services/rego/cmd.go @@ -3,7 +3,6 @@ package rego import ( config2 "github.com/opengovern/og-util/pkg/config" "github.com/opengovern/og-util/pkg/httpserver" - "github.com/opengovern/og-util/pkg/koanf" "github.com/opengovern/og-util/pkg/steampipe" integration_type "github.com/opengovern/opencomply/services/integration/integration-type" "github.com/opengovern/opencomply/services/rego/api" @@ -15,7 +14,8 @@ import ( ) func Command() *cobra.Command { - cnf := koanf.Provide("rego", config.RegoConfig{}) + var cnf config.RegoConfig + config2.ReadFromEnv(&cnf, nil) cmd := &cobra.Command{ RunE: func(cmd *cobra.Command, _ []string) error { @@ -30,43 +30,12 @@ func Command() *cobra.Command { for _, integrationType := range integration_type.IntegrationTypes { describerConfig := integrationType.GetConfiguration() - err := steampipe.PopulateSteampipeConfig(config2.ElasticSearch{ - Address: cnf.ElasticSearch.Address, - Username: cnf.ElasticSearch.Username, - Password: cnf.ElasticSearch.Password, - IsOpenSearch: cnf.ElasticSearch.IsOpenSearch, - IsOnAks: cnf.ElasticSearch.IsOnAks, - AwsRegion: cnf.ElasticSearch.AWSRegion, - AssumeRoleArn: cnf.ElasticSearch.AssumeRoleARN, - ExternalID: cnf.ElasticSearch.ExternalID, - IngestionEndpoint: cnf.ElasticSearch.IngestionEndpoint, - }, describerConfig.SteampipePluginName) + err := steampipe.PopulateSteampipeConfig(cnf.ElasticSearch, describerConfig.SteampipePluginName) if err != nil { return err } } - if err := steampipe.PopulateOpenGovernancePluginSteampipeConfig(config2.ElasticSearch{ - Address: cnf.ElasticSearch.Address, - Username: cnf.ElasticSearch.Username, - Password: cnf.ElasticSearch.Password, - IsOpenSearch: cnf.ElasticSearch.IsOpenSearch, - IsOnAks: cnf.ElasticSearch.IsOnAks, - AwsRegion: cnf.ElasticSearch.AWSRegion, - AssumeRoleArn: cnf.ElasticSearch.AssumeRoleARN, - ExternalID: cnf.ElasticSearch.ExternalID, - IngestionEndpoint: cnf.ElasticSearch.IngestionEndpoint, - }, config2.Postgres{ - Host: cnf.Steampipe.Host, - Port: cnf.Steampipe.Port, - DB: cnf.Steampipe.DB, - Username: cnf.Steampipe.Username, - Password: cnf.Steampipe.Password, - SSLMode: cnf.Steampipe.SSLMode, - MaxIdleConns: cnf.Steampipe.MaxIdleConns, - MaxOpenConns: cnf.Steampipe.MaxOpenConns, - ConnMaxIdleTime: cnf.Steampipe.ConnMaxIdleTime, - ConnMaxLifetime: cnf.Steampipe.ConnMaxLifetime, - }); err != nil { + if err := steampipe.PopulateOpenGovernancePluginSteampipeConfig(cnf.ElasticSearch, cnf.Steampipe); err != nil { return err } diff --git a/services/rego/config/service.go b/services/rego/config/service.go index 3fd1673c6..201f75cef 100644 --- a/services/rego/config/service.go +++ b/services/rego/config/service.go @@ -1,9 +1,11 @@ package config -import "github.com/opengovern/og-util/pkg/koanf" +import ( + "github.com/opengovern/og-util/pkg/config" +) type RegoConfig struct { - Http koanf.HttpServer `json:"http,omitempty" koanf:"http"` - ElasticSearch koanf.ElasticSearch `json:"elasticsearch,omitempty" koanf:"elasticsearch"` - Steampipe koanf.Postgres `json:"steampipe,omitempty" koanf:"steampipe"` + Http config.HttpServer `json:"http,omitempty" koanf:"http"` + ElasticSearch config.ElasticSearch `json:"elasticsearch,omitempty" koanf:"elasticsearch"` + Steampipe config.Postgres `json:"steampipe,omitempty" koanf:"steampipe"` }