我是否需要跨多个 YAML 文件复制“skip_files"? [英] Do I need to copy `skip_files` across multiple YAML files?

查看:12
本文介绍了我是否需要跨多个 YAML 文件复制“skip_files"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我仍然对 appengine 模块部署过程一无所知.我的应用包含三个模块,我独立更新和部署.

I'm still rather ignorant of the appengine module deployment process. My app has three modules that I update and deploy independently.

我刚刚注意到,虽然我在 app.yaml 中为我的默认模块声明了 skip_files,但我的自定义模块仍在部署所有内容.所以我将 app.yaml 中的指令复制粘贴到自定义 YAML 文件中.虽然我认为不需要经常更改这些,但我仍然希望尽可能多地干燥.

I just noticed that while I had skip_files declared in app.yaml for my default module, that my custom modules were still deploying everything. So I copied-pasted the directives from app.yaml to the custom YAML files. While I don't see the need to change these often, I'd still like to DRY as much as I can.

有没有办法定义一次 skip_files 并继承或引用这些指令?

Is there a way to define skip_files once and inherit or reference those directives?

推荐答案

GAE 将每个模块视为一个单独的独立应用程序,每个模块都在自己的实例中运行.模块之间不会在 GAE 基础设施级别共享应用可上传的工件.因此,如果我理解正确的话,甚至可以混合使用不同语言编写的模块.

GAE treats each module as a separate, standalone app, each running in its own instance. No app uploadable artifacts are shared at the GAE infra level between the modules. For that reasons it's even possible to mix modules written in different languages, if I understand correctly.

DRY 精神应用程序的文件或目录可以在源代码级别的模块之间共享",方法是将文件/目录的单个源副本符号链接到所有模块中.当应用程序部署到 GAE 中时,部署实用程序会用实际的符号链接目标内容替换符号链接.

In the DRY spirit app's files or directories can be "shared" between modules at the source code level by symlinking a single source copy of the file/dir into all the modules. When the app is deployed into GAE the deployment utility replaces to the symlinks with the actual symlink target content.

但是,符号链接方法不适用于文件级别以下的共享,例如文件中的部分.DRY 仍然可以应用于 GAE 基础架构明确支持的配置文件的某些 select 部分.

The symlinking method however is not applicable to sharing below the file level, like just sections in a file. DRY can still be applied to some select sections of config files explicitly supported by the GAE infra.

根据 文档:

The skip_files section happens to be one of such supported sections, according to the documentation:

includes 指令允许你包含配置文件适用于整个应用程序中的任何库或模块.例如,您可能会包含一个用户管理库,如下所示:

The includes directive allows you to include the configuration file for any library or module throughout your application. For example, you might include a user administration library as follows:

includes:
- lib/user_admin.yaml

...和...

使用包含仅检索以下类型的指令目标文件(如果存在):

Using includes retrieves only the following types of directives from the destination file (if present):

  • 内建
  • 包括
  • 处理程序
  • skip_files

基于此,我认为您可以在应用的顶级目录中有一个 app_shared.yaml 文件,其中包含您的 skip_files 模式(小心覆盖默认值,顺便说一句),然后您可以将其包含在模块的 .yaml 文件中:

Based on this I think you could have an app_shared.yaml file in your app's top level dir, containing your skip_files patterns (careful with overriding the defaults, BTW) which you could then be included in your modules' .yaml files:

includes:
- app_shared.yaml

您可能需要将 app_shared.yaml 符号链接到每个模块的目录(上述 DRY 方法),如果这是模块的 .yaml 文件存在的位置,如建议模块文档.

You may need to symlink app_shared.yaml into each of the module's dir (the above DRY method) if that's where the modules' .yaml files exist as suggested in the Modules Doc.

注意:我自己并没有实际使用包含方法,答案完全基于文档.

Note: I didn't actually use the inclusion method myself, the answer is based purely on the documentation.

这篇关于我是否需要跨多个 YAML 文件复制“skip_files"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆