Skip to content

Commit

Permalink
Merge pull request #51 from clementguillot/50-use-optional-in-configu…
Browse files Browse the repository at this point in the history
…ration-objects

50 use optional in configuration objects
  • Loading branch information
clementguillot authored Mar 1, 2024
2 parents 53aa941 + 3c78bb5 commit 6092d12
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 29 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Since Nx Cloud is a proprietary software from Narwhal Technologies Inc., it is h
## Project structure

| Application/library | Summary |
|------------------------| ------------------------------------------------------------- |
|------------------------|---------------------------------------------------------------|
| [`apps/api`](apps/api) | Backend of Nx Cloud CE, handles requests from Nx Cloud client |

## External Code and Licenses
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
package org.nxcloudce.api.storage.model

data class Bucket(val name: String, val forcePathStyle: Boolean = false)
data class Bucket(val name: String)
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.nxcloudce.api.storage.s3

import io.smallrye.config.ConfigMapping
import java.util.*

@ConfigMapping(prefix = "nx-server.storage.s3")
interface S3Configuration {
Expand All @@ -14,5 +15,5 @@ interface S3Configuration {

fun bucket(): String

fun forcePathStyle(): Boolean?
fun forcePathStyle(): Optional<Boolean>
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class S3Producers {
S3Client {
endpointUrl = Url.parse(s3Configuration.endpoint())
region = s3Configuration.region()
forcePathStyle = s3Configuration.forcePathStyle()
forcePathStyle = s3Configuration.forcePathStyle().map { it }.orElse(null)
credentialsProvider =
StaticCredentialsProvider {
accessKeyId = s3Configuration.accessKeyId()
Expand All @@ -26,7 +26,7 @@ class S3Producers {

@Produces
@ApplicationScoped
fun bucket(s3Configuration: S3Configuration): Bucket = Bucket(s3Configuration.bucket(), s3Configuration.forcePathStyle() ?: false)
fun bucket(s3Configuration: S3Configuration): Bucket = Bucket(s3Configuration.bucket())

@Produces
@ApplicationScoped
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ class S3Repository(
bucket = this@S3Repository.bucket.name
key = objectPath
}
return s3Client.presignGetObject(
getRequest,
presignExpiration,
).url.toString()
return s3Client
.presignGetObject(getRequest, presignExpiration)
.url
.toString()
}

override suspend fun generatePutUrl(objectPath: String): String {
Expand All @@ -35,9 +35,9 @@ class S3Repository(
bucket = this@S3Repository.bucket.name
key = objectPath
}
return s3Client.presignPutObject(
putRequest,
presignExpiration,
).url.toString()
return s3Client
.presignPutObject(putRequest, presignExpiration)
.url
.toString()
}
}
19 changes: 10 additions & 9 deletions apps/api/src/main/resources/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,20 @@ quarkus:
api-key-parameter-name: authorization

nx-server:
application-url: http://localhost:8080
client-bundle-version: 2402.02.12
client-bundle-path: static/client-bundle
storage:
s3:
endpoint: http://localhost:9000
region: us-east-1
access-key-id: nx-cloud-ce
secret-access-key: nx-cloud-ce
bucket: nx-cloud-ce
force-path-style: true

"%dev":
quarkus:
mongodb:
connection-string: mongodb://localhost:27017
nx-server:
application-url: http://localhost:8080
storage:
s3:
endpoint: http://localhost:9000
region: us-east-1
access-key-id: nx-cloud-ce
secret-access-key: nx-cloud-ce
bucket: nx-cloud-ce
force-path-style: true
2 changes: 1 addition & 1 deletion apps/api/src/test/resources/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ quarkus:
s3:
devservices:
enabled: true
buckets: [nx-cloud-ce]
buckets: [ nx-cloud-ce ]

nx-server:
application-url: http://localtest
Expand Down
12 changes: 6 additions & 6 deletions compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ version: "3.8"
services:
mongo:
image: mongo:7.0.5
command: ["--replSet", "rs0", "--bind_ip_all", "--port", "27017"]
command: [ "--replSet", "rs0", "--bind_ip_all", "--port", "27017" ]
ports:
- 27017:27017
extra_hosts:
Expand All @@ -21,7 +21,7 @@ services:
mongo-express:
image: mongo-express
ports:
- '9500:9500'
- "9500:9500"
environment:
ME_CONFIG_MONGODB_URL: mongodb://mongo:27017/
PORT: 9500
Expand All @@ -31,13 +31,13 @@ services:
environment:
MINIO_ROOT_USER: nx-cloud-ce
MINIO_ROOT_PASSWORD: nx-cloud-ce
MINIO_SERVER_URL: 'http://localhost:9000'
MINIO_STORAGE_USE_HTTPS: 'false'
MINIO_SERVER_URL: "http://localhost:9000"
MINIO_STORAGE_USE_HTTPS: "false"
volumes:
- minio-data:/data
ports:
- '9000:9000'
- '9001:9001'
- "9000:9000"
- "9001:9001"

volumes:
mongo-config-data:
Expand Down

0 comments on commit 6092d12

Please sign in to comment.