Files
browser/platform/service/lifecycle_defaults.go

52 lines
1.9 KiB
Go

package service
import "browser.local/platform/domain"
func applyPluginCreateDefaults(plugin domain.GamePlugin, definition domain.ServerDeploymentDefinition) domain.ServerDeploymentDefinition {
definition = domain.CopyServerDeploymentDefinition(definition)
if definition.ProfileKey == "" && len(plugin.RuntimeProfiles.LifecycleProfiles) > 0 {
definition.ProfileKey = plugin.RuntimeProfiles.LifecycleProfiles[0].Key
}
if definition.Mode != domain.ServerDeploymentModeGuided {
return definition
}
if definition.CreateInputs == nil {
definition.CreateInputs = map[string]string{}
}
for _, field := range plugin.CreateFields {
if _, present := definition.CreateInputs[field.Key]; !present && field.DefaultValue != "" {
definition.CreateInputs[field.Key] = field.DefaultValue
}
}
return definition
}
func deploymentNeedsCompleteRuntimeBinding(_ domain.GamePlugin, definition domain.ServerDeploymentDefinition) bool {
return definition.Mode == ""
}
// lifecycleDefaultProfileKey selects a plugin-declared lifecycle profile when
// an older server record has no explicit deployment profile. Runtime bindings
// remain optional logical transport overrides; they must not be required for
// standard Run lifecycle, file, or log workflows.
func lifecycleDefaultProfileKey(_ domain.ServerInstance, plugin domain.GamePlugin, profileKey string) string {
if profileKey != "" {
if profile, ok := runtimeLifecycleProfileForKey(plugin.RuntimeProfiles, profileKey); ok {
return profile.Key
}
return profileKey
}
return firstRuntimeLifecycleProfileKey(plugin)
}
func defaultRunDistributionProfileKey(plugin domain.GamePlugin, profileKey string) string {
return lifecycleDefaultProfileKey(domain.ServerInstance{}, plugin, profileKey)
}
func firstRuntimeLifecycleProfileKey(plugin domain.GamePlugin) string {
if len(plugin.RuntimeProfiles.LifecycleProfiles) == 0 {
return ""
}
return plugin.RuntimeProfiles.LifecycleProfiles[0].Key
}