我正在使用JClouds-Chef API动态创建新的Chef Environments。我的代码的主要要点:
Environment.builder()
.name("${appName}_${envStr}")
.description("A really cool app")
.cookbookVersion("my_app", "0.2.0")
.cookbookVersion("my_logs", "0.1.0")
.attributes(buildAttributes(envStr))
.build()
运行时,我收到以下错误:
[main] INFO com.myapp.ChefManager - org.jclouds.http.HttpResponseException: command: POST https://mychef01/environments HTTP/1.1 failed with response: HTTP/1.1 400 Bad Request; content: [Invalid value '0.2.0' for cookbook_versions]
at org.jclouds.chef.handlers.ChefErrorHandler.handleError(ChefErrorHandler.java:57)
at org.jclouds.http.handlers.DelegatingErrorHandler.handleError(DelegatingErrorHandler.java:67)
at org.jclouds.http.internal.BaseHttpCommandExecutorService.shouldContinue(BaseHttpCommandExecutorService.java:180)
我发现去年有人similar issue,看来这可能是厨师10和厨师11之间引入的错误?如果是这样,JClouds-Chef是否存在黑客攻击或解决方法?
答案 0 :(得分:0)
您可以将约束运算符添加到版本字符串吗?类似的东西:
Environment.builder()
.name("${appName}_${envStr}")
.description("A really cool app")
.cookbookVersion("my_app", "= 0.2.0")
.cookbookVersion("my_logs", "= 0.1.0")
.attributes(buildAttributes(envStr))
.build()