Class: OnContainer::Secrets::GoogleCloud::Fetcher
- Inherits:
-
ServiceBase
- Object
- ServiceBase
- OnContainer::Secrets::GoogleCloud::Fetcher
- Defined in:
- lib/on_container/secrets/google_cloud/fetcher.rb
Constant Summary collapse
- PROJECT_PATTERN =
%r{\Aprojects\/(\w+)\/.*}.freeze
- SECRET_NAME_PATTERN =
%r{secrets\/([\w-]+)\/?}.freeze
- SECRET_VERSION_PATTERN =
%r{versions\/(\d+|latest)\z}.freeze
Instance Attribute Summary collapse
-
#project ⇒ Object
readonly
Returns the value of attribute project.
-
#secret_name ⇒ Object
readonly
Returns the value of attribute secret_name.
-
#secret_version ⇒ Object
readonly
Returns the value of attribute secret_version.
Attributes inherited from ServiceBase
Instance Method Summary collapse
-
#initialize(given_key, client: nil) ⇒ Fetcher
constructor
A new instance of Fetcher.
- #perform! ⇒ Object
Methods included from Common::SafePerformable
Constructor Details
#initialize(given_key, client: nil) ⇒ Fetcher
Returns a new instance of Fetcher.
16 17 18 19 20 21 |
# File 'lib/on_container/secrets/google_cloud/fetcher.rb', line 16 def initialize(given_key, client: nil) @client = client @project = extract_project given_key @secret_version = extract_secret_version given_key @secret_name = extract_secret_name given_key end |
Instance Attribute Details
#project ⇒ Object (readonly)
Returns the value of attribute project.
14 15 16 |
# File 'lib/on_container/secrets/google_cloud/fetcher.rb', line 14 def project @project end |
#secret_name ⇒ Object (readonly)
Returns the value of attribute secret_name.
14 15 16 |
# File 'lib/on_container/secrets/google_cloud/fetcher.rb', line 14 def secret_name @secret_name end |
#secret_version ⇒ Object (readonly)
Returns the value of attribute secret_version.
14 15 16 |
# File 'lib/on_container/secrets/google_cloud/fetcher.rb', line 14 def secret_version @secret_version end |
Instance Method Details
#perform! ⇒ Object
23 24 25 26 27 28 29 30 31 32 |
# File 'lib/on_container/secrets/google_cloud/fetcher.rb', line 23 def perform! # Build the resource name of the secret version. name = client.secret_version_path project: @project, secret: @secret_name, secret_version: @secret_version version = client.access_secret_version name: name YAML.load version.payload.data end |