在Secret Manager docs之后,我创建了一个秘密,现在尝试以编程方式检索该秘密。我的实现如下所示:
require 'google/cloud/secret_manager'
class SecretManager
def self.read(secret_id)
return unless secret_id
Google::Cloud::SecretManager.secret_manager_service.access_secret_version(
name: "projects/my-test-project/secrets/#{secret_id}/versions/latest"
).payload.data
end
end
执行后,我得到以下信息:
irb(main):001:0> SecretManager.read('my-test-key')
objc[9757]: +[__NSCFConstantString initialize] may have been in progress in another thread when fork() was called.
objc[9757]: +[__NSCFConstantString initialize] may have been in progress in another thread when fork() was called. We cannot safely call it or ignore it in the fork() child process. Crashing instead. Set a breakpoint on objc_initializeAfterForkError to debug.
此外,我发现了这个问题(已有2年的历史了):https://bugs.ruby-lang.org/issues/14009,但建议的解决方案对我而言并不可行。
我正在运行OSX 10.14.6,Ruby 2.6.5,Rails 6.0.2.1