override fun getState()

in jetbrains-core/src/software/aws/toolkits/jetbrains/services/lambda/execution/local/LocalLambdaRunConfiguration.kt [173:236]


    override fun getState(executor: Executor, environment: ExecutionEnvironment): SamRunningState {
        try {
            val options: LocalLambdaRunSettings = if (serializableOptions.functionOptions.useTemplate) {
                if (serializableOptions.functionOptions.isImage) {
                    val (templateFile, logicalName) = validateSamTemplateDetails(templateFile(), logicalId())

                    val resource = SamTemplateUtils
                        .findImageFunctionsFromTemplate(project, templateFile)
                        .firstOrNull { it.logicalName == logicalId() } ?: throw IllegalStateException("Function ${logicalId()} not found in template!")
                    val function = resource as? SamFunction ?: throw IllegalStateException("Image functions must be a SAM function")

                    val debugger = imageDebugger() ?: throw IllegalStateException("No image debugger with ID ${rawImageDebugger()}")

                    val dockerFile = function.dockerFile() ?: "Dockerfile"
                    val dockerFilePath = Paths.get(templateFile.path).parent.resolve(function.codeLocation()).resolve(dockerFile)
                    ImageTemplateRunSettings(
                        templateFile,
                        debugger,
                        logicalName,
                        LocalFileSystem.getInstance().refreshAndFindFileByIoFile(dockerFilePath.toFile())
                            ?: throw IllegalStateException("Unable to get virtual file for path $dockerFilePath"),
                        pathMappings,
                        environmentVariables(),
                        ConnectionSettings(resolveCredentials(), resolveRegion()),
                        serializableOptions.samOptions.copy(),
                        serializableOptions.debugHost,
                        resolveInput()
                    )
                } else {
                    val (templateFile, logicalId) = validateSamTemplateDetails(templateFile(), logicalId())
                    val resolvedFunction = resolveLambdaInfo(project = project, functionOptions = serializableOptions.functionOptions)
                    TemplateRunSettings(
                        templateFile,
                        resolvedFunction.runtime,
                        resolvedFunction.architecture,
                        resolvedFunction.handler,
                        logicalId,
                        environmentVariables(),
                        ConnectionSettings(resolveCredentials(), resolveRegion()),
                        serializableOptions.samOptions.copy(),
                        serializableOptions.debugHost,
                        resolveInput()
                    )
                }
            } else {
                val resolvedFunction = resolveLambdaInfo(project = project, functionOptions = serializableOptions.functionOptions)
                HandlerRunSettings(
                    resolvedFunction.runtime,
                    resolvedFunction.architecture,
                    resolvedFunction.handler,
                    timeout(),
                    memorySize(),
                    environmentVariables(),
                    ConnectionSettings(resolveCredentials(), resolveRegion()),
                    serializableOptions.samOptions.copy(),
                    serializableOptions.debugHost,
                    resolveInput()
                )
            }
            return SamRunningState(environment, options)
        } catch (e: Exception) {
            throw ExecutionException(e.message, e)
        }
    }