Ejemplo n.º 1
0
        public async Task <IActionResult> RuntimeSettings(string fullTypeName, ConfigureAppModel model)
        {
            var app      = (IApp)Activator.CreateInstance(ResolveAppType(fullTypeName));
            var analyzer = new AppAnalyzer(app);

            model.ApplyTo(analyzer);
            model = new ConfigureAppModel();
            await model.InitializeAsync(analyzer);

            return(View(model));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Deploy(string fullTypeName, ConfigureAppModel model)
        {
            var app      = (IApp)Activator.CreateInstance(ResolveAppType(fullTypeName));
            var analyzer = new AppAnalyzer(app);

            model.ApplyTo(analyzer);

            var appBuilder = new AppBuilder();
            await analyzer.Build(appBuilder);

            var restoredModel = new ConfigureAppModel();
            await restoredModel.InitializeAsync(analyzer);

            restoredModel.RuntimeSettings.Clear();
            restoredModel.RuntimeSettings.AddRange(model.RuntimeSettings);
            // generate parameters
            var parametersYaml      = GenerateParametersYaml(restoredModel);
            var runtimeSettingsYaml = GenerateRuntimeSettingsYaml(restoredModel);


            var svcFile     = Path.GetTempFileName();
            var paramsFile  = Path.GetTempFileName();
            var runtimeFile = Path.GetTempFileName();

            try {
                using (var svcStream = System.IO.File.Create(svcFile)){
                    appBuilder.BuiltApp.WriteTo(svcStream);
                    await svcStream.FlushAsync();
                }
                await System.IO.File.WriteAllTextAsync(paramsFile, parametersYaml, Encoding.UTF8);

                await System.IO.File.WriteAllTextAsync(runtimeFile, runtimeSettingsYaml, Encoding.UTF8);

                await _backend.RunAsync(model.DeploymentName, svcFile, paramsFile, runtimeFile);
            } finally {
                System.IO.File.Delete(svcFile);
                System.IO.File.Delete(paramsFile);
                System.IO.File.Delete(runtimeFile);
            }

            return(RedirectToAction("List", "AppLibs"));
        }