Class: InstanceAgent::Plugins::CodeDeployPlugin::ApplicationSpecification::LinuxPermissionInfo
- Inherits:
-
Object
- Object
- InstanceAgent::Plugins::CodeDeployPlugin::ApplicationSpecification::LinuxPermissionInfo
- Defined in:
- lib/instance_agent/plugins/codedeploy/application_specification/linux_permission_info.rb
Overview
Helper Class for storing data parsed from permissions list
Instance Attribute Summary collapse
-
#acls ⇒ Object
readonly
Returns the value of attribute acls.
-
#context ⇒ Object
readonly
Returns the value of attribute context.
-
#except ⇒ Object
readonly
Returns the value of attribute except.
-
#group ⇒ Object
readonly
Returns the value of attribute group.
-
#mode ⇒ Object
readonly
Returns the value of attribute mode.
-
#object ⇒ Object
readonly
Returns the value of attribute object.
-
#owner ⇒ Object
readonly
Returns the value of attribute owner.
-
#pattern ⇒ Object
readonly
Returns the value of attribute pattern.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
-
#initialize(object, opts = {}) ⇒ LinuxPermissionInfo
constructor
A new instance of LinuxPermissionInfo.
- #matches_except?(name) ⇒ Boolean
- #matches_pattern?(name) ⇒ Boolean
- #validate_file_acl(object) ⇒ Object
- #validate_file_permission ⇒ Object
Constructor Details
#initialize(object, opts = {}) ⇒ LinuxPermissionInfo
Returns a new instance of LinuxPermissionInfo.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/instance_agent/plugins/codedeploy/application_specification/linux_permission_info.rb', line 9 def initialize(object, opts = {}) object = object.to_s if (object.empty?) raise AppSpecValidationException, 'Permission needs a object value' end @object = object @pattern = opts[:pattern] || "**" @except = opts[:except] || [] @type = opts[:type] || ["file", "directory"] @owner = opts[:owner] @group = opts[:group] @mode = opts[:mode] @acls = opts[:acls] @context = opts[:context] end |
Instance Attribute Details
#acls ⇒ Object (readonly)
Returns the value of attribute acls.
8 9 10 |
# File 'lib/instance_agent/plugins/codedeploy/application_specification/linux_permission_info.rb', line 8 def acls @acls end |
#context ⇒ Object (readonly)
Returns the value of attribute context.
8 9 10 |
# File 'lib/instance_agent/plugins/codedeploy/application_specification/linux_permission_info.rb', line 8 def context @context end |
#except ⇒ Object (readonly)
Returns the value of attribute except.
8 9 10 |
# File 'lib/instance_agent/plugins/codedeploy/application_specification/linux_permission_info.rb', line 8 def except @except end |
#group ⇒ Object (readonly)
Returns the value of attribute group.
8 9 10 |
# File 'lib/instance_agent/plugins/codedeploy/application_specification/linux_permission_info.rb', line 8 def group @group end |
#mode ⇒ Object (readonly)
Returns the value of attribute mode.
8 9 10 |
# File 'lib/instance_agent/plugins/codedeploy/application_specification/linux_permission_info.rb', line 8 def mode @mode end |
#object ⇒ Object (readonly)
Returns the value of attribute object.
8 9 10 |
# File 'lib/instance_agent/plugins/codedeploy/application_specification/linux_permission_info.rb', line 8 def object @object end |
#owner ⇒ Object (readonly)
Returns the value of attribute owner.
8 9 10 |
# File 'lib/instance_agent/plugins/codedeploy/application_specification/linux_permission_info.rb', line 8 def owner @owner end |
#pattern ⇒ Object (readonly)
Returns the value of attribute pattern.
8 9 10 |
# File 'lib/instance_agent/plugins/codedeploy/application_specification/linux_permission_info.rb', line 8 def pattern @pattern end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
8 9 10 |
# File 'lib/instance_agent/plugins/codedeploy/application_specification/linux_permission_info.rb', line 8 def type @type end |
Instance Method Details
#matches_except?(name) ⇒ Boolean
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/instance_agent/plugins/codedeploy/application_specification/linux_permission_info.rb', line 61 def matches_except?(name) name = name.chomp(File::SEPARATOR) base_object = sanitize_dir_path(@object) if !base_object.end_with?(File::SEPARATOR) base_object = base_object + File::SEPARATOR end if name.start_with?(base_object) rel_name = name[base_object.length..name.length] @except.each do |item| if matches_simple_glob(rel_name, item) return true end end end false end |
#matches_pattern?(name) ⇒ Boolean
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/instance_agent/plugins/codedeploy/application_specification/linux_permission_info.rb', line 45 def matches_pattern?(name) name = name.chomp(File::SEPARATOR) base_object = sanitize_dir_path(@object) if !base_object.end_with?(File::SEPARATOR) base_object = base_object + File::SEPARATOR end if name.start_with?(base_object) if ("**".eql?(@pattern)) return true end rel_name = name[base_object.length..name.length] return matches_simple_glob(rel_name, @pattern) end false end |
#validate_file_acl(object) ⇒ Object
36 37 38 39 40 41 42 43 |
# File 'lib/instance_agent/plugins/codedeploy/application_specification/linux_permission_info.rb', line 36 def validate_file_acl(object) if !@acls.nil? default_acl = @acls.get_default_ace if !default_acl.nil? raise "Attempt to set default acl #{default_acl} on file #{object}" end end end |
#validate_file_permission ⇒ Object
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/instance_agent/plugins/codedeploy/application_specification/linux_permission_info.rb', line 25 def () if @type.include?("file") if !"**".eql?(@pattern) raise AppSpecValidationException, "Attempt to use pattern #{@pattern} when assigning permissions to file #{@object}" end if !@except.empty? raise AppSpecValidationException, "Attempt to use except #{@except} when assigning permissions to file #{@object}" end end end |