Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tabell for å lagre status på import/eksport jobbene #380

Merged
merged 21 commits into from
Aug 14, 2023
Merged
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
10 changes: 5 additions & 5 deletions .github/workflows/build-deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ jobs:
image: ${{ steps.docker-push.outputs.image }}

deploy-to-dev:
name: Deploy to dev-gcp
name: Deploy to dev-fss
needs: docker-build-push
if: github.ref == 'refs/heads/arkitektur'
if: github.ref == 'refs/heads/tabell'
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
Expand All @@ -51,7 +51,7 @@ jobs:
RESOURCE: nais/dev.yaml

deploy-to-prod:
name: Deploy to dev-gcp
name: Deploy to prod-fss
needs: docker-build-push
if: github.ref == 'refs/heads/master'
runs-on: ubuntu-latest
Expand All @@ -71,7 +71,7 @@ jobs:
if: github.ref == 'refs/heads/use_gar_distroless'
steps:
- uses: actions/checkout@v3
- name: Deploy topics to dev-gcp
- name: Deploy topics to dev-fss
uses: nais/deploy/actions/deploy@v1
env:
APIKEY: ${{ secrets.NAIS_DEPLOY_APIKEY }}
Expand All @@ -92,7 +92,7 @@ jobs:
if: github.ref == 'refs/heads/master'
steps:
- uses: actions/checkout@v3
- name: Deploy topics to prod-gcp
- name: Deploy topics to prod-fss
uses: nais/deploy/actions/deploy@v1
env:
APIKEY: ${{ secrets.NAIS_DEPLOY_APIKEY }}
Expand Down
26 changes: 22 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
<com.oracle.ojdbc.ojdbc8.version>19.3.0.0</com.oracle.ojdbc.ojdbc8.version>
<com.h2database.h2.version>2.2.220</com.h2database.h2.version>
<org.apache.logging.log4j.version>3.0.0-alpha1</org.apache.logging.log4j.version>
<jetbrainsExposedVersion>0.42.0</jetbrainsExposedVersion>
</properties>
<dependencies>
<dependency>
Expand Down Expand Up @@ -125,6 +126,22 @@
<version>${no.nav.vault-jdbc.version}</version>
</dependency>

<dependency>
<groupId>org.jetbrains.exposed</groupId>
<artifactId>exposed-core</artifactId>
<version>${jetbrainsExposedVersion}</version>
</dependency>
<dependency>
<groupId>org.jetbrains.exposed</groupId>
<artifactId>exposed-jdbc</artifactId>
<version>${jetbrainsExposedVersion}</version>
</dependency>
<dependency>
<groupId>org.jetbrains.exposed</groupId>
<artifactId>exposed-java-time</artifactId>
<version>${jetbrainsExposedVersion}</version>
</dependency>

<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
Expand Down Expand Up @@ -196,7 +213,6 @@
<version>${net.minidev.json-smart.version}</version>
</dependency>


<dependency>
<groupId>no.nav.arbeidsgiver</groupId>
<artifactId>altinn-rettigheter-proxy-klient</artifactId>
Expand Down Expand Up @@ -259,12 +275,14 @@
<artifactId>kotlinx-coroutines-core-jvm</artifactId>
<version>1.6.4</version>
</dependency>

<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-test</artifactId>
<version>${kotlin.version}</version>
<groupId>io.kotest</groupId>
<artifactId>kotest-assertions-core-jvm</artifactId>
<version>5.6.2</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>net.javacrumbs.json-unit</groupId>
<artifactId>json-unit-assertj</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package no.nav.arbeidsgiver.sykefravarsstatistikk.api.applikasjon.domenemodeller

/**
* Viser status på alle stegene som gjøres ved automatisk
* import og eksport av sykefraværsstatistikk.
*/
interface ImportEksportStatus {
val årstallOgKvartal: ÅrstallOgKvartal
val importertStatistikk: Boolean
val importertVirksomhetsdata: Boolean
val forberedtNesteEksport: Boolean
val eksportertPåKafka: Boolean
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
package no.nav.arbeidsgiver.sykefravarsstatistikk.api.config

import com.zaxxer.hikari.HikariConfig
import com.zaxxer.hikari.HikariDataSource
import no.nav.vault.jdbc.hikaricp.HikariCPVaultUtil
import no.nav.vault.jdbc.hikaricp.VaultError
import org.flywaydb.core.Flyway
import org.jetbrains.exposed.sql.Database
import org.jetbrains.exposed.sql.transactions.TransactionManager
import org.slf4j.LoggerFactory
import org.springframework.beans.factory.annotation.Qualifier
import org.springframework.beans.factory.annotation.Value
import org.springframework.boot.autoconfigure.flyway.FlywayMigrationStrategy
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import org.springframework.context.annotation.Primary
import org.springframework.context.annotation.Profile
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate
import javax.sql.DataSource

@Configuration
@Profile("dev", "prod")
open class ApplikasjonDBConfig {
// URL hentes i Vault
@Value("\${spring.datasource.url}")
private val databaseUrl: String? = null

@Value("\${database.navn}")
private val databaseNavn: String? = null

@Value("\${vault.mount-path}")
private val mountPath: String? = null
@Primary
@Bean(name = ["sykefravarsstatistikkDataSource"])
open fun userDataSource(): DataSource? {
return dataSource("admin")
}

@Primary
@Bean(name = ["sykefravarsstatistikkJdbcTemplate"])
open fun sykefravarsstatistikkJdbcTemplate(
@Qualifier("sykefravarsstatistikkDataSource") dataSource: DataSource
): NamedParameterJdbcTemplate {
return NamedParameterJdbcTemplate(dataSource)
}

@Bean
open fun database(
@Qualifier("sykefravarsstatistikkDataSource") dataSource: DataSource,
): Database {
val db = Database.connect(dataSource)
TransactionManager.defaultDatabase = db
return db
}

private fun dataSource(user: String): HikariDataSource? {
val config = HikariConfig()
config.poolName = "Sykefraværsstatistikk-connection-pool"
config.jdbcUrl = databaseUrl
config.maximumPoolSize = 8
config.minimumIdle = 1
val hikariDataSourceWithVaultIntegration: HikariDataSource? = try {
HikariCPVaultUtil.createHikariDataSourceWithVaultIntegration(
config, mountPath, dbRole(user)
)
} catch (vaultError: VaultError) {
logger.warn("[GCP-migrering] Kunne ikke opprette DS. Returnerer null. ", vaultError)
return null
}
return hikariDataSourceWithVaultIntegration
}

@Bean
open fun flywayMigrationStrategy(): FlywayMigrationStrategy {
return FlywayMigrationStrategy { flyway: Flyway? ->
Flyway.configure()
.dataSource(dataSource("admin"))
.initSql(String.format("SET ROLE \"%s\"", dbRole("admin")))
.load()
.migrate()
}
}

private fun dbRole(role: String): String {
return java.lang.String.join("-", databaseNavn, role)
}

companion object {
private val logger = LoggerFactory.getLogger(ApplikasjonDBConfig::class.java)
}
}

This file was deleted.

Loading