def Run(self, args): if args.config: # If the user has specified an config file, use that. config_filename = args.config else: # Otherwise, check for an app.yaml in the source directory. config_filename = os.path.join(args.source_dir, 'app.yaml') if not os.path.exists(config_filename): config_filename = None # If there was an config file either specified by the user or in the source # directory, load it. if config_filename: try: myi = yaml_parsing.ModuleYamlInfo.FromFile(config_filename) config = myi.parsed except IOError as ex: log.error('Unable to open %s: %s', config_filename, ex) return else: config = None fingerprinter.GenerateConfigs( args.source_dir, fingerprinting.Params(appinfo=config, custom=args.custom)) # If the user has a config file, make sure that they're using a custom # runtime. if config and args.custom and config.GetEffectiveRuntime() != 'custom': log.status.Print(RUNTIME_MISMATCH_MSG % config_filename)
def _Run(args): """Run the `gcloud app gen-config` command.""" if args.config: # If the user has specified an config file, use that. config_filename = args.config else: # Otherwise, check for an app.yaml in the source directory. config_filename = os.path.join(args.source_dir, 'app.yaml') if not os.path.exists(config_filename): config_filename = None # If there was an config file either specified by the user or in the source # directory, load it. if config_filename: try: myi = yaml_parsing.ServiceYamlInfo.FromFile(config_filename) config = myi.parsed except IOError as ex: log.error('Unable to open %s: %s', config_filename, ex) return else: config = None fingerprinter.GenerateConfigs( args.source_dir, ext_runtime.Params(appinfo=config, custom=args.custom, runtime=args.runtime), config_filename) # If the user has a config file, make sure that they're using a custom # runtime. # TODO(b/36050339): If --config is given, should it still be modified? if config and args.custom and config.GetEffectiveRuntime() != 'custom': alter = console_io.PromptContinue( default=False, message=output_helpers.RUNTIME_MISMATCH_MSG.format( config_filename), prompt_string='Would you like to update it now?') if alter: _AlterRuntime(config_filename, 'custom') log.status.Print('[{0}] has been updated.'.format(config_filename)) else: log.status.Print( 'Please update [{0}] manually by changing the runtime ' 'field to custom.'.format(config_filename))