Skip to content

Commit 4666124

Browse files
Rani Horevluispollo
Rani Horev
authored andcommitted
fix(dgs): minor fixes in notifications query
Squashed commit of the following: commit c786e3f7471deb104b136c90ef7278eb9ee1652f Author: Rani <[email protected]> Date: Tue Jun 22 07:19:15 2021 +0300 fix(dgs): convert level to enum commit 2f8c17aed02b74609e59af6bede77dee75e4a277 Author: Rani <[email protected]> Date: Tue Jun 22 07:15:53 2021 +0300 fix(dgs): make notification objects non-nullable (but keep the array nullable) (cherry picked from commit de9fc62364d5b79494c65d4c32d5d7a75e15d876)
1 parent 2345714 commit 4666124

File tree

3 files changed

+11
-8
lines changed

3 files changed

+11
-8
lines changed

keel-web/src/main/kotlin/com/netflix/spinnaker/keel/rest/dgs/ApplicationFetcher.kt

+3-5
Original file line numberDiff line numberDiff line change
@@ -297,12 +297,10 @@ class ApplicationFetcher(
297297
* Fetches the list of dismissible notifications for the application in context.
298298
*/
299299
@DgsData(parentType = DgsConstants.MDAPPLICATION.TYPE_NAME, field = DgsConstants.MDAPPLICATION.Notifications)
300-
fun applicationNotifications(dfe: DataFetchingEnvironment): CompletableFuture<List<MdNotification>>? {
300+
fun applicationNotifications(dfe: DataFetchingEnvironment): List<MdNotification>? {
301301
val config = applicationFetcherSupport.getDeliveryConfigFromContext(dfe)
302-
return CompletableFuture.supplyAsync {
303-
notificationRepository.notificationHistory(config.application, true, setOf(WARNING, ERROR))
304-
.map { it.toDgs() }
305-
}
302+
return notificationRepository.notificationHistory(config.application, true, setOf(WARNING, ERROR))
303+
.map { it.toDgs() }
306304
}
307305

308306
// add function for putting the resources on the artifactVersion

keel-web/src/main/kotlin/com/netflix/spinnaker/keel/rest/dgs/conversions.kt

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import com.netflix.spinnaker.keel.api.artifacts.GitMetadata
1111
import com.netflix.spinnaker.keel.bakery.diff.PackageDiff
1212
import com.netflix.spinnaker.keel.graphql.types.MdArtifact
1313
import com.netflix.spinnaker.keel.graphql.types.MdCommitInfo
14+
import com.netflix.spinnaker.keel.graphql.types.MdEventLevel
1415
import com.netflix.spinnaker.keel.graphql.types.MdGitMetadata
1516
import com.netflix.spinnaker.keel.graphql.types.MdLocation
1617
import com.netflix.spinnaker.keel.graphql.types.MdMoniker
@@ -106,7 +107,7 @@ fun Pause.toDgsPaused(): MdPausedInfo =
106107
fun DismissibleNotification.toDgs() =
107108
MdNotification(
108109
id = uid?.toString() ?: error("Can't convert application event with missing UID: $this"),
109-
level = level.name,
110+
level = MdEventLevel.valueOf(level.name),
110111
message = message,
111112
isActive = isActive,
112113
triggeredAt = triggeredAt,

keel-web/src/main/resources/schema/schema.graphql

+6-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ type MdApplication {
1212
isPaused: Boolean
1313
pausedInfo: MdPausedInfo
1414
environments: [MdEnvironment!]!
15-
notifications: [MdNotification]
15+
notifications: [MdNotification!]
1616
}
1717

1818
type MdEnvironment {
@@ -301,7 +301,7 @@ input MdUnpinArtifactVersionPayload {
301301

302302
type MdNotification {
303303
id: String!
304-
level: String!
304+
level: MdEventLevel!
305305
message: String!
306306
triggeredAt: InstantTime
307307
triggeredBy: String
@@ -312,6 +312,10 @@ type MdNotification {
312312
dismissedBy: String
313313
}
314314

315+
enum MdEventLevel {
316+
SUCCESS, INFO, WARNING, ERROR
317+
}
318+
315319
input MdDismissNotificationPayload {
316320
id: String!
317321
}

0 commit comments

Comments
 (0)