Skip to content

Commit

Permalink
fix: config
Browse files Browse the repository at this point in the history
  • Loading branch information
Mahanmmi committed Dec 19, 2024
1 parent 0dfce12 commit e7c09c5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 39 deletions.
39 changes: 4 additions & 35 deletions services/rego/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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 {
Expand All @@ -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
}

Expand Down
10 changes: 6 additions & 4 deletions services/rego/config/service.go
Original file line number Diff line number Diff line change
@@ -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"`
}

0 comments on commit e7c09c5

Please sign in to comment.