diff --git a/services/apps/git_integration/src/crowdgit/services/software_value/config.go b/services/apps/git_integration/src/crowdgit/services/software_value/config.go index c1df580967..4a72dac5de 100644 --- a/services/apps/git_integration/src/crowdgit/services/software_value/config.go +++ b/services/apps/git_integration/src/crowdgit/services/software_value/config.go @@ -22,7 +22,6 @@ type Config struct { TargetPath string `koanf:"target.path"` SCCPath string `koanf:"scc.path"` InsightsDatabase DBConfig `koanf:"database.insights"` - CMDatabase DBConfig `koanf:"database.cm"` } func getConfig(targetPath string) (Config, error) { @@ -64,26 +63,5 @@ func getConfig(targetPath string) (Config, error) { config.InsightsDatabase.ReadOnly = readOnlyStr == "true" } - config.CMDatabase.User = os.Getenv("CROWD_DB_USERNAME") - config.CMDatabase.Password = os.Getenv("CROWD_DB_PASSWORD") - config.CMDatabase.DBName = os.Getenv("CROWD_DB_DATABASE") - config.CMDatabase.Host = os.Getenv("CROWD_DB_READ_HOST") - if portStr := os.Getenv("CROWD_DB_PORT"); portStr != "" { - if port, err := strconv.Atoi(portStr); err == nil { - config.CMDatabase.Port = port - } - } - config.CMDatabase.SSLMode = os.Getenv("CROWD_DB_SSLMODE") - if poolMaxStr := os.Getenv("CROWD_DB_POOL_MAX"); poolMaxStr != "" { - if poolMax, err := strconv.Atoi(poolMaxStr); err == nil { - config.CMDatabase.PoolMax = poolMax - } - } else { - config.CMDatabase.PoolMax = 10 // Default pool max - } - if readOnlyStr := os.Getenv("CROWD_DB_READONLY"); readOnlyStr != "" { - config.CMDatabase.ReadOnly = readOnlyStr == "true" - } - return config, nil } diff --git a/services/apps/git_integration/src/crowdgit/services/software_value/db.go b/services/apps/git_integration/src/crowdgit/services/software_value/db.go index ed7a5d33b9..8f908a490c 100644 --- a/services/apps/git_integration/src/crowdgit/services/software_value/db.go +++ b/services/apps/git_integration/src/crowdgit/services/software_value/db.go @@ -17,12 +17,6 @@ type InsightsDB struct { config DBConfig } -// CMDB holds the connection pool and configuration for the CM database. -type CMDB struct { - pool *pgxpool.Pool - config DBConfig -} - // newDBConnection establishes a new database connection pool. // This is a helper function used by NewInsightsDB and NewCMDB. func newDBConnection(ctx context.Context, config DBConfig) (*pgxpool.Pool, error) { @@ -81,18 +75,6 @@ func NewInsightsDB(ctx context.Context, config DBConfig) (*InsightsDB, error) { }, nil } -// NewCMDB creates a new CMDB instance. -func NewCMDB(ctx context.Context, config DBConfig) (*CMDB, error) { - pool, err := newDBConnection(ctx, config) - if err != nil { - return nil, err - } - return &CMDB{ - pool: pool, - config: config, - }, nil -} - // Close closes the database connection pool. func (db *InsightsDB) Close() { if db.pool != nil { @@ -100,13 +82,6 @@ func (db *InsightsDB) Close() { } } -// Close closes the database connection pool. -func (db *CMDB) Close() { - if db.pool != nil { - db.pool.Close() - } -} - // saveProjectCost upserts the project cost into the database table. func (db *InsightsDB) saveProjectCost(ctx context.Context, repository Repository, estimatedCost float64) error { // From PostgreSQL 15 and newer, there's another way to do this: https://www.postgresql.org/docs/15/sql-merge.html diff --git a/services/apps/git_integration/src/crowdgit/services/software_value/main.go b/services/apps/git_integration/src/crowdgit/services/software_value/main.go index 068682a8d5..e4dc02a412 100644 --- a/services/apps/git_integration/src/crowdgit/services/software_value/main.go +++ b/services/apps/git_integration/src/crowdgit/services/software_value/main.go @@ -15,7 +15,7 @@ import ( func main() { response := processRepository() outputJSON(response) - + // Always exit with code 0 - status details are in JSON response } @@ -63,18 +63,6 @@ func processRepository() StandardResponse { } defer insightsDb.Close() - cmdb, err := NewCMDB(ctx, config.CMDatabase) - if err != nil { - errorCode := ErrorCodeDatabaseConnection - errorMessage := fmt.Sprintf("Error connecting to CM database: %v", err) - return StandardResponse{ - Status: StatusFailure, - ErrorCode: &errorCode, - ErrorMessage: &errorMessage, - } - } - defer cmdb.Close() - // Get git URL for the repository gitUrl, err := getGitRepositoryURL(repoDir) if err != nil { @@ -297,4 +285,3 @@ func getErrorCodeFromSCCError(err error) string { } return ErrorCodeUnknown } -