Fix generated Run component identity
This commit is contained in:
+45
-8
@@ -69,18 +69,19 @@ func Load() Config {
|
||||
}
|
||||
|
||||
workspaceRoot := envOrDefault("RUN_WORKSPACE_ROOT", filepath.Join(".", ".run-workspace"))
|
||||
identity := loadPackagedIdentity()
|
||||
return Config{
|
||||
Mode: mode,
|
||||
PlatformURL: platformURL,
|
||||
RunEndpointID: envOrDefault("RUN_ENDPOINT_ID", stringOrDefault(BuildRunEndpointID, DefaultEndpointID)),
|
||||
RunEndpointID: identity.runEndpointID,
|
||||
DisplayName: envOrDefault("RUN_DISPLAY_NAME", stringOrDefault(BuildDisplayName, DefaultDisplayName)),
|
||||
Version: envOrDefault("RUN_VERSION", BuildVersion),
|
||||
RegistrationToken: envOrDefault("RUN_REGISTRATION_TOKEN", stringOrDefault(BuildRegistrationToken, "local-registration")),
|
||||
ServerInstanceID: envOrDefault("RUN_SERVER_INSTANCE_ID", BuildServerInstanceID),
|
||||
PluginID: envOrDefault("RUN_PLUGIN_ID", BuildPluginID),
|
||||
ComponentKind: envOrDefault("RUN_COMPONENT_KIND", BuildComponentKind),
|
||||
ComponentKey: envOrDefault("RUN_COMPONENT_KEY", BuildComponentKey),
|
||||
KeyGeneration: intEnvOrDefault("RUN_KEY_GENERATION", intStringOrDefault(BuildKeyGeneration, 0)),
|
||||
Version: identity.version,
|
||||
RegistrationToken: identity.registrationToken,
|
||||
ServerInstanceID: identity.serverInstanceID,
|
||||
PluginID: identity.pluginID,
|
||||
ComponentKind: identity.componentKind,
|
||||
ComponentKey: identity.componentKey,
|
||||
KeyGeneration: identity.keyGeneration,
|
||||
WorkspaceSeed: envOrDefault("RUN_WORKSPACE_SEED", BuildWorkspaceSeed),
|
||||
WorkspaceRoot: workspaceRoot,
|
||||
BuildSourceRoot: envOrDefault("RUN_BUILD_SOURCE_ROOT", "."),
|
||||
@@ -98,6 +99,42 @@ func Load() Config {
|
||||
}
|
||||
}
|
||||
|
||||
type packagedIdentity struct {
|
||||
runEndpointID string
|
||||
version string
|
||||
registrationToken string
|
||||
serverInstanceID string
|
||||
pluginID string
|
||||
componentKind string
|
||||
componentKey string
|
||||
keyGeneration int
|
||||
}
|
||||
|
||||
func loadPackagedIdentity() packagedIdentity {
|
||||
if BuildRegistrationToken != "" {
|
||||
return packagedIdentity{
|
||||
runEndpointID: stringOrDefault(BuildRunEndpointID, DefaultEndpointID),
|
||||
version: stringOrDefault(BuildVersion, DefaultVersion),
|
||||
registrationToken: BuildRegistrationToken,
|
||||
serverInstanceID: BuildServerInstanceID,
|
||||
pluginID: BuildPluginID,
|
||||
componentKind: BuildComponentKind,
|
||||
componentKey: BuildComponentKey,
|
||||
keyGeneration: intStringOrDefault(BuildKeyGeneration, 0),
|
||||
}
|
||||
}
|
||||
return packagedIdentity{
|
||||
runEndpointID: envOrDefault("RUN_ENDPOINT_ID", stringOrDefault(BuildRunEndpointID, DefaultEndpointID)),
|
||||
version: envOrDefault("RUN_VERSION", BuildVersion),
|
||||
registrationToken: envOrDefault("RUN_REGISTRATION_TOKEN", "local-registration"),
|
||||
serverInstanceID: envOrDefault("RUN_SERVER_INSTANCE_ID", BuildServerInstanceID),
|
||||
pluginID: envOrDefault("RUN_PLUGIN_ID", BuildPluginID),
|
||||
componentKind: envOrDefault("RUN_COMPONENT_KIND", BuildComponentKind),
|
||||
componentKey: envOrDefault("RUN_COMPONENT_KEY", BuildComponentKey),
|
||||
keyGeneration: intEnvOrDefault("RUN_KEY_GENERATION", intStringOrDefault(BuildKeyGeneration, 0)),
|
||||
}
|
||||
}
|
||||
|
||||
func stringOrDefault(value string, fallback string) string {
|
||||
if value == "" {
|
||||
return fallback
|
||||
|
||||
Reference in New Issue
Block a user