-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#1236 Environment display options for a build
- Loading branch information
1 parent
69ad6b8
commit 40f0fff
Showing
28 changed files
with
918 additions
and
462 deletions.
There are no files selected for viewing
12 changes: 12 additions & 0 deletions
12
...main/java/net/nemerosa/ontrack/extension/environments/promotions/EnvironmentBuildCount.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package net.nemerosa.ontrack.extension.environments.promotions | ||
|
||
import net.nemerosa.ontrack.model.annotations.APIDescription | ||
import net.nemerosa.ontrack.model.structure.Build | ||
|
||
@APIDescription("Number of environments where a build is deployed") | ||
data class EnvironmentBuildCount( | ||
@APIDescription("Associated build") | ||
val build: Build, | ||
@APIDescription("Number of environments where a build is deployed") | ||
val count: Int, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
...rc/main/java/net/nemerosa/ontrack/extension/environments/settings/EnvironmentsSettings.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package net.nemerosa.ontrack.extension.environments.settings | ||
|
||
import net.nemerosa.ontrack.model.annotations.APIDescription | ||
|
||
data class EnvironmentsSettings( | ||
@APIDescription("How the environments a build is deployed into are displayed") | ||
val buildDisplayOption: EnvironmentsSettingsBuildDisplayOption = EnvironmentsSettingsBuildDisplayOption.HIGHEST, | ||
) |
20 changes: 20 additions & 0 deletions
20
...emerosa/ontrack/extension/environments/settings/EnvironmentsSettingsBuildDisplayOption.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package net.nemerosa.ontrack.extension.environments.settings | ||
|
||
enum class EnvironmentsSettingsBuildDisplayOption { | ||
|
||
/** | ||
* All environments must be displayed | ||
*/ | ||
ALL, | ||
|
||
/** | ||
* Only the highest environment is displayed | ||
*/ | ||
HIGHEST, | ||
|
||
/** | ||
* Only a count of the environments is displayed | ||
*/ | ||
COUNT, | ||
|
||
} |
17 changes: 17 additions & 0 deletions
17
...ain/java/net/nemerosa/ontrack/extension/environments/settings/EnvironmentsSettingsCasc.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package net.nemerosa.ontrack.extension.environments.settings | ||
|
||
import net.nemerosa.ontrack.extension.casc.context.settings.AbstractSubSettingsContext | ||
import net.nemerosa.ontrack.model.settings.CachedSettingsService | ||
import net.nemerosa.ontrack.model.settings.SettingsManagerService | ||
import org.springframework.stereotype.Component | ||
|
||
@Component | ||
class EnvironmentsSettingsCasc( | ||
settingsManagerService: SettingsManagerService, | ||
cachedSettingsService: CachedSettingsService | ||
) : AbstractSubSettingsContext<EnvironmentsSettings>( | ||
"environments", | ||
EnvironmentsSettings::class, | ||
settingsManagerService, | ||
cachedSettingsService | ||
) |
32 changes: 32 additions & 0 deletions
32
.../java/net/nemerosa/ontrack/extension/environments/settings/EnvironmentsSettingsManager.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package net.nemerosa.ontrack.extension.environments.settings | ||
|
||
import net.nemerosa.ontrack.model.form.Form | ||
import net.nemerosa.ontrack.model.security.SecurityService | ||
import net.nemerosa.ontrack.model.settings.AbstractSettingsManager | ||
import net.nemerosa.ontrack.model.settings.CachedSettingsService | ||
import net.nemerosa.ontrack.model.support.SettingsRepository | ||
import net.nemerosa.ontrack.model.support.setEnum | ||
import org.springframework.stereotype.Component | ||
|
||
@Component | ||
class EnvironmentsSettingsManager( | ||
cachedSettingsService: CachedSettingsService, | ||
securityService: SecurityService, | ||
private val settingsRepository: SettingsRepository, | ||
) : AbstractSettingsManager<EnvironmentsSettings>( | ||
EnvironmentsSettings::class.java, | ||
cachedSettingsService, | ||
securityService | ||
) { | ||
|
||
override fun doSaveSettings(settings: EnvironmentsSettings) { | ||
settingsRepository.setEnum<EnvironmentsSettings, EnvironmentsSettingsBuildDisplayOption>(settings::buildDisplayOption) | ||
} | ||
|
||
override fun getId(): String = "environments" | ||
|
||
override fun getTitle(): String = "Environments" | ||
|
||
@Deprecated("Deprecated in Java") | ||
override fun getSettingsForm(settings: EnvironmentsSettings?): Form = Form.create() | ||
} |
23 changes: 23 additions & 0 deletions
23
...java/net/nemerosa/ontrack/extension/environments/settings/EnvironmentsSettingsProvider.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package net.nemerosa.ontrack.extension.environments.settings | ||
|
||
import net.nemerosa.ontrack.model.settings.SettingsProvider | ||
import net.nemerosa.ontrack.model.support.SettingsRepository | ||
import net.nemerosa.ontrack.model.support.getEnum | ||
import org.springframework.stereotype.Component | ||
|
||
@Component | ||
class EnvironmentsSettingsProvider( | ||
private val settingsRepository: SettingsRepository, | ||
) : SettingsProvider<EnvironmentsSettings> { | ||
|
||
override fun getSettings() = EnvironmentsSettings( | ||
buildDisplayOption = settingsRepository.getEnum( | ||
property = EnvironmentsSettings::buildDisplayOption, | ||
defaultValue = EnvironmentsSettingsBuildDisplayOption.HIGHEST, | ||
), | ||
) | ||
|
||
override fun getSettingsClass(): Class<EnvironmentsSettings> = | ||
EnvironmentsSettings::class.java | ||
|
||
} |
34 changes: 34 additions & 0 deletions
34
.../main/java/net/nemerosa/ontrack/extension/environments/ui/GQLTypeEnvironmentBuildCount.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package net.nemerosa.ontrack.extension.environments.ui | ||
|
||
import graphql.Scalars.GraphQLID | ||
import graphql.schema.GraphQLObjectType | ||
import net.nemerosa.ontrack.extension.environments.promotions.EnvironmentBuildCount | ||
import net.nemerosa.ontrack.graphql.schema.GQLType | ||
import net.nemerosa.ontrack.graphql.schema.GQLTypeCache | ||
import net.nemerosa.ontrack.graphql.support.getTypeDescription | ||
import net.nemerosa.ontrack.graphql.support.intField | ||
import net.nemerosa.ontrack.graphql.support.toNotNull | ||
import org.springframework.stereotype.Component | ||
|
||
@Component | ||
class GQLTypeEnvironmentBuildCount : GQLType { | ||
|
||
override fun getTypeName(): String = EnvironmentBuildCount::class.java.simpleName | ||
|
||
override fun createType(cache: GQLTypeCache): GraphQLObjectType = | ||
GraphQLObjectType.newObject() | ||
.name(typeName) | ||
.description(getTypeDescription(EnvironmentBuildCount::class)) | ||
.field { | ||
it.name("id") | ||
.description("ID of the count (build ID)") | ||
.type(GraphQLID.toNotNull()) | ||
.dataFetcher { env -> | ||
val count = env.getSource<EnvironmentBuildCount>() | ||
count.build.id() | ||
} | ||
} | ||
.intField(EnvironmentBuildCount::count) | ||
.build() | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.