使用 Berkshelf 解决递归 git 食谱依赖项 [英] Resolve recursive git cookbook dependencies with Berkshelf

查看:9
本文介绍了使用 Berkshelf 解决递归 git 食谱依赖项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

tl;dr 版本:Berkshelf 是否能够解决基于 Git 的食谱中的递归依赖关系,如果可以,如何解决?

我尝试使用 Berkshelf 管理我的 Chef 食谱依赖项.这些食谱都存储在内部 Git 存储库中.依赖如下:

I try to manage my Chef cookbook dependencies with Berkshelf. The cookbooks are all stored in internal Git repositories. The dependencies are as follows:

env_dockerhub_dev 
  >>depends on>> app_dockerhub 
    >>depends on>> app_docker

我项目中的主要 Berksfile 如下所示:

The main Berksfile in my project looks like this:

source "https://supermarket.chef.io"

cookbook "env_dockerhub_dev", git: "git@URL_TO_GIT_SERVER/chef_env_dockerhub_dev.git"

env_dockerhub_dev 食谱有一个像这样的 metadata.rb:

The env_dockerhub_dev cookbook has a metadata.rb like this:

name             'env_dockerhub_dev'
...
depends          'app_dockerhub'
depends          'base_ubuntu'

还有一个像这样的Berksfile:

source "https://supermarket.chef.io"

cookbook "app_dockerhub", git: "git@URL_TO_GIT_SERVER/chef_app_dockerhub.git"
cookbook "base_ubuntu", git: "git@URL_TO_GIT_SERVER/chef_base_ubuntu.git"

当我现在运行 berks install 时,我收到以下错误消息:

When I now run berks install I get the following error message:

Resolving cookbook dependencies...

Fetching 'env_dockerhub_dev' from git@URL_TO_GIT_SERVER/chef_env_dockerhub_dev.git (at master)
Fetching cookbook index from https://supermarket.chef.io...
Unable to satisfy constraints on package app_dockerhub, which does not exist, due to solution constraint (env_dockerhub_dev = 0.1.0). Solution constraints that may result in a constraint on app_dockerhub:     [(env_dockerhub_dev = 0.1.0) -> (app_dockerhub >= 0.0.0)]
Missing artifacts: app_dockerhub,base_ubuntu
Demand that cannot be met: (env_dockerhub_dev = 0.1.0)
Unable to find a solution for demands: env_dockerhub_dev (0.1.0)

当我将所有内部说明书的所有 Git URL 添加到主"Berksfile(我项目根目录中的 Berksfile)中时,我可以解决这个问题:

I can fix the problem, when I add all the Git URLs for all my internal cookbooks into the "main" Berksfile (the Berksfile in the root of my project) like this:

source "https://supermarket.chef.io"

# the main cookbook
cookbook "env_dockerhub_dev", git: "git@URL_TO_GIT_SERVER/chef_env_dockerhub_dev.git"

# the cookbooks that are "recursively" 
cookbook "app_dockerhub", git: "git@gURL_TO_GIT_SERVER/chef_app_dockerhub.git"
cookbook "app_docker", git: "git@URL_TO_GIT_SERVER/chef_app_docker.git"

无论如何 - 我认为这不应该是解决这个问题的方法.

Anyhow - I think this should not be the solution for this problem.

非常感谢您的帮助!

推荐答案

好的 - 阅读本文 https://github.com/berkshelf/berkshelf/pull/304 我想我发现这真的不可能.仍然不明白为什么 - 但这是另一个问题:-)

Ok - reading this https://github.com/berkshelf/berkshelf/pull/304 I think I found out that this is really not possible. Still don't get why - but that's another issue :-)

正如我的问题中提到的,一种解决方案是在顶层 Berksfile 中添加所有食谱依赖项及其 git URL:

As mentioned in my question, a solution is to add all cookbook dependencies and their git URL in the toplevel Berksfile:

source "https://supermarket.chef.io"

# the main cookbook
cookbook "env_dockerhub_dev", git: "git@URL_TO_GIT_SERVER/chef_env_dockerhub_dev.git"

# other cookbook dependencies (resolved recursively)
cookbook "app_dockerhub", git: "git@gURL_TO_GIT_SERVER/chef_app_dockerhub.git"
cookbook "app_docker", git: "git@URL_TO_GIT_SERVER/chef_app_docker.git"

这篇关于使用 Berkshelf 解决递归 git 食谱依赖项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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