Class: Putpaws::Iam::OperatorConfig
- Inherits:
-
Struct
- Object
- Struct
- Putpaws::Iam::OperatorConfig
- Defined in:
- lib/putpaws/iam/operator_config.rb
Overview
Named operator profiles declared in .putpaws/operators.json. A profile gives an organization-level name (Ex: developer, viewer) to a combination of putpaws command groups.
Constant Summary collapse
- EXAMPLE =
{ developer: {groups: %w[attach shell deploy logs codebuild]}, viewer: {groups: %w[logs]}, }
Instance Attribute Summary collapse
-
#extra_statements ⇒ Object
Returns the value of attribute extra_statements.
-
#groups ⇒ Object
Returns the value of attribute groups.
-
#name ⇒ Object
Returns the value of attribute name.
Class Method Summary collapse
- .all(path_prefix: '.putpaws') ⇒ Object
- .exist?(path_prefix: '.putpaws') ⇒ Boolean
- .find(name, path_prefix: '.putpaws') ⇒ Object
- .load(path_prefix: '.putpaws') ⇒ Object
- .path(path_prefix: '.putpaws') ⇒ Object
- .scaffold!(path_prefix: '.putpaws') ⇒ Object
Instance Attribute Details
#extra_statements ⇒ Object
Returns the value of attribute extra_statements
9 10 11 |
# File 'lib/putpaws/iam/operator_config.rb', line 9 def extra_statements @extra_statements end |
#groups ⇒ Object
Returns the value of attribute groups
9 10 11 |
# File 'lib/putpaws/iam/operator_config.rb', line 9 def groups @groups end |
#name ⇒ Object
Returns the value of attribute name
9 10 11 |
# File 'lib/putpaws/iam/operator_config.rb', line 9 def name @name end |
Class Method Details
.all(path_prefix: '.putpaws') ⇒ Object
35 36 37 38 39 |
# File 'lib/putpaws/iam/operator_config.rb', line 35 def self.all(path_prefix: '.putpaws') load(path_prefix: path_prefix).map{|k, v| new(name: k.to_s, groups: v[:groups] || [], extra_statements: v[:extra_statements] || []) } end |
.exist?(path_prefix: '.putpaws') ⇒ Boolean
19 20 21 |
# File 'lib/putpaws/iam/operator_config.rb', line 19 def self.exist?(path_prefix: '.putpaws') path(path_prefix: path_prefix).exist? end |
.find(name, path_prefix: '.putpaws') ⇒ Object
41 42 43 |
# File 'lib/putpaws/iam/operator_config.rb', line 41 def self.find(name, path_prefix: '.putpaws') all(path_prefix: path_prefix).detect{|x| x.name == name.to_s} end |
.load(path_prefix: '.putpaws') ⇒ Object
29 30 31 32 33 |
# File 'lib/putpaws/iam/operator_config.rb', line 29 def self.load(path_prefix: '.putpaws') p = path(path_prefix: path_prefix) return {} unless p.exist? JSON.parse(File.read(p), symbolize_names: true) end |
.path(path_prefix: '.putpaws') ⇒ Object
15 16 17 |
# File 'lib/putpaws/iam/operator_config.rb', line 15 def self.path(path_prefix: '.putpaws') Pathname.new(path_prefix).join('operators.json') end |
.scaffold!(path_prefix: '.putpaws') ⇒ Object
23 24 25 26 27 |
# File 'lib/putpaws/iam/operator_config.rb', line 23 def self.scaffold!(path_prefix: '.putpaws') p = path(path_prefix: path_prefix) File.write(p, JSON.pretty_generate(EXAMPLE) + "\n") p.to_s end |