diff options
author | 2021-02-24 14:19:20 +0000 | |
---|---|---|
committer | 2021-04-16 06:56:29 +0000 | |
commit | 4f438a4c4c753e3cd49e4dbaa68ee7f72628b548 (patch) | |
tree | 092cf0499bcf10a6410aa2305bc8deef6f867713 /components/datalake-handler/feeder/src/main/java/org | |
parent | 835ad818323544acb8b030a4f274de14496d7b02 (diff) |
Use non-root user to access datalake-feeder database and
update the base image to align with ONAP
Issue-ID: DCAEGEN2-2329
Issue-ID: DCAEGEN2-2420
Signed-off-by: Niranjana <niranjana.y60@wipro.com>
Change-Id: I26da297dcc4563a25d3cd6f558cc92627b17647b
Diffstat (limited to 'components/datalake-handler/feeder/src/main/java/org')
-rw-r--r-- | components/datalake-handler/feeder/src/main/java/org/onap/datalake/feeder/Application.java | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/components/datalake-handler/feeder/src/main/java/org/onap/datalake/feeder/Application.java b/components/datalake-handler/feeder/src/main/java/org/onap/datalake/feeder/Application.java index 83f56b1d..22d19192 100644 --- a/components/datalake-handler/feeder/src/main/java/org/onap/datalake/feeder/Application.java +++ b/components/datalake-handler/feeder/src/main/java/org/onap/datalake/feeder/Application.java @@ -3,6 +3,7 @@ * ONAP : DataLake * ================================================================================ * Copyright 2019 China Mobile +* Copyright (C) 2021 Wipro Limited. *================================================================================= * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,10 +21,13 @@ package org.onap.datalake.feeder; +import javax.sql.DataSource; + import org.onap.datalake.feeder.service.PullService; import org.springframework.boot.CommandLineRunner; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.jdbc.DataSourceBuilder; import org.springframework.context.annotation.Bean; import springfox.documentation.swagger2.annotations.EnableSwagger2; @@ -41,9 +45,19 @@ public class Application { public static void main(String[] args) { SpringApplication.run(Application.class, args); } - + @Bean public CommandLineRunner commandLineRunner(PullService pullService) { return args -> pullService.start(); } + + @Bean + public DataSource dataSource() { + + String url = "jdbc:postgresql://" + System.getenv("PG_HOST").trim() + ":" + System.getenv("PG_PORT").trim() + + "/datalake"; + return DataSourceBuilder.create().url(url).username(System.getenv("PG_USER").trim()) + .password(System.getenv("PG_PASSWORD").trim()).build(); + } } + |