Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ type Config struct {
// Sources-api-go config
SourceApiBaseUrl string `mapstructure:"SOURCES_API_BASE_URL"`
SourceApiPrefix string `mapstructure:"SOURCES_API_PREFIX"`

// On-prem deployment config
ONPREM bool `mapstructure:"ONPREM"`
}

var cfg *Config = nil
Expand Down Expand Up @@ -166,6 +169,7 @@ func initConfig() {
}

viper.SetDefault("SOURCES_API_PREFIX", "/api/sources/v3.1")
viper.SetDefault("ONPREM", false)
viper.SetDefault("SERVICE_NAME", "rosocp")
viper.SetDefault("API_PORT", "8000")
viper.SetDefault("KRUIZE_WAIT_TIME", "30")
Expand Down
17 changes: 13 additions & 4 deletions internal/services/housekeeper/sourcesCleaner.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,25 @@ import (
"github.com/redhatinsights/ros-ocp-backend/internal/utils/sources"
)

// OnPremCostAppID is the default application ID used in on-prem deployments
const OnPremCostAppID = 0

var cost_app_id int

func StartSourcesListenerService() {
log := logging.GetLogger()
cfg := config.GetConfig()
var err error
cost_app_id, err = sources.GetCostApplicationID()
if err != nil {
log.Error("Unable to get cost application id", err)
os.Exit(1)

if cfg.ONPREM {
cost_app_id = OnPremCostAppID
log.Infof("ONPREM flag is set, cost_app_id set to %d", OnPremCostAppID)
} else {
cost_app_id, err = sources.GetCostApplicationID()
if err != nil {
log.Error("Unable to get cost application id", err)
os.Exit(1)
}
}

kafka.StartConsumer(cfg.SourcesEventTopic, sourcesListener)
Expand Down
Loading