aws-codedeploy-agent 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (91) hide show
  1. data/aws-codedeploy-agent.gemspec +5 -5
  2. data/certs/host-agent-deployment-signer-ca-chain.pem +30 -0
  3. data/conf/codedeployagent.yml +0 -1
  4. data/lib/instance_agent.rb +1 -13
  5. data/lib/instance_agent/agent/base.rb +38 -12
  6. data/lib/instance_agent/agent/plugin.rb +21 -0
  7. data/lib/instance_agent/config.rb +2 -1
  8. data/lib/instance_agent/platform/linux_util.rb +4 -0
  9. data/lib/instance_agent/plugins/codedeploy/application_specification/ace_info.rb +133 -0
  10. data/lib/instance_agent/plugins/codedeploy/application_specification/acl_info.rb +163 -0
  11. data/lib/instance_agent/plugins/codedeploy/application_specification/application_specification.rb +143 -0
  12. data/lib/instance_agent/plugins/codedeploy/application_specification/context_info.rb +23 -0
  13. data/lib/instance_agent/plugins/codedeploy/application_specification/file_info.rb +23 -0
  14. data/lib/instance_agent/plugins/codedeploy/application_specification/linux_permission_info.rb +121 -0
  15. data/lib/instance_agent/plugins/codedeploy/application_specification/mode_info.rb +66 -0
  16. data/lib/instance_agent/plugins/codedeploy/application_specification/range_info.rb +134 -0
  17. data/lib/instance_agent/plugins/codedeploy/application_specification/script_info.rb +27 -0
  18. data/lib/instance_agent/plugins/codedeploy/codedeploy_control.rb +100 -0
  19. data/lib/instance_agent/plugins/codedeploy/command_executor.rb +359 -0
  20. data/lib/instance_agent/plugins/codedeploy/command_poller.rb +178 -0
  21. data/lib/instance_agent/plugins/codedeploy/deployment_specification.rb +161 -0
  22. data/lib/instance_agent/plugins/codedeploy/hook_executor.rb +226 -0
  23. data/lib/instance_agent/plugins/codedeploy/install_instruction.rb +389 -0
  24. data/lib/instance_agent/plugins/codedeploy/installer.rb +147 -0
  25. data/lib/instance_agent/plugins/codedeploy/onpremise_config.rb +42 -0
  26. data/lib/instance_agent/plugins/codedeploy/register_plugin.rb +17 -0
  27. data/lib/instance_agent/runner/child.rb +20 -5
  28. data/lib/instance_agent/runner/master.rb +2 -15
  29. data/lib/instance_metadata.rb +2 -2
  30. data/test/certificate_helper.rb +1 -1
  31. data/test/helpers/instance_agent_helper.rb +1 -0
  32. data/test/instance_agent/agent/base_test.rb +16 -3
  33. data/test/instance_agent/config_test.rb +2 -1
  34. data/test/instance_agent/plugins/codedeploy/application_specification_test.rb +1713 -0
  35. data/test/instance_agent/{codedeploy_plugin → plugins/codedeploy}/codedeploy_control_test.rb +1 -1
  36. data/test/instance_agent/{codedeploy_plugin → plugins/codedeploy}/command_executor_test.rb +32 -9
  37. data/test/instance_agent/{codedeploy_plugin → plugins/codedeploy}/command_poller_test.rb +13 -14
  38. data/test/instance_agent/{codedeploy_plugin → plugins/codedeploy}/deployment_specification_test.rb +98 -25
  39. data/test/instance_agent/{codedeploy_plugin → plugins/codedeploy}/hook_executor_test.rb +83 -15
  40. data/test/instance_agent/plugins/codedeploy/install_instruction_test.rb +568 -0
  41. data/test/instance_agent/{codedeploy_plugin → plugins/codedeploy}/installer_test.rb +12 -9
  42. data/test/instance_agent/plugins/codedeploy/onpremise_config_test.rb +72 -0
  43. data/test/instance_agent/runner/child_test.rb +1 -1
  44. data/vendor/gems/.codedeploy-commands-1.0.0.created.rid +1 -1
  45. data/vendor/gems/codedeploy-commands/lib/aws/plugins/deploy_control_endpoint.rb +4 -0
  46. data/vendor/gems/jmespath-1.0.1/lib/jmespath.rb +41 -0
  47. data/vendor/gems/jmespath-1.0.1/lib/jmespath/caching_parser.rb +30 -0
  48. data/vendor/gems/jmespath-1.0.1/lib/jmespath/errors.rb +17 -0
  49. data/vendor/gems/jmespath-1.0.1/lib/jmespath/expr_node.rb +15 -0
  50. data/vendor/gems/jmespath-1.0.1/lib/jmespath/lexer.rb +116 -0
  51. data/vendor/gems/jmespath-1.0.1/lib/jmespath/parser.rb +347 -0
  52. data/vendor/gems/jmespath-1.0.1/lib/jmespath/runtime.rb +71 -0
  53. data/vendor/gems/jmespath-1.0.1/lib/jmespath/token.rb +41 -0
  54. data/vendor/gems/jmespath-1.0.1/lib/jmespath/token_stream.rb +60 -0
  55. data/vendor/gems/jmespath-1.0.1/lib/jmespath/tree_interpreter.rb +523 -0
  56. data/vendor/gems/jmespath-1.0.1/lib/jmespath/version.rb +3 -0
  57. data/vendor/gems/process_manager/lib/process_manager/master.rb +16 -5
  58. data/vendor/specifications/{aws-sdk-core-2.0.5.gemspec → aws-sdk-core-2.0.42.gemspec} +9 -11
  59. data/vendor/specifications/builder-3.2.2.gemspec +1 -1
  60. data/vendor/specifications/codedeploy-commands-1.0.0.gemspec +7 -6
  61. data/vendor/specifications/gli-2.5.6.gemspec +1 -1
  62. data/vendor/specifications/jmespath-1.0.1.gemspec +29 -0
  63. data/vendor/specifications/little-plugger-1.1.3.gemspec +1 -1
  64. data/vendor/specifications/logging-1.8.1.gemspec +1 -1
  65. data/vendor/specifications/multi_json-1.7.7.gemspec +1 -1
  66. data/vendor/specifications/multi_json-1.8.4.gemspec +1 -1
  67. data/vendor/specifications/multi_xml-0.5.5.gemspec +1 -1
  68. data/vendor/specifications/process_manager-0.0.13.gemspec +1 -1
  69. data/vendor/specifications/simple_pid-0.2.1.gemspec +1 -1
  70. metadata +76 -63
  71. data/lib/instance_agent/codedeploy_plugin/application_specification/ace_info.rb +0 -133
  72. data/lib/instance_agent/codedeploy_plugin/application_specification/acl_info.rb +0 -163
  73. data/lib/instance_agent/codedeploy_plugin/application_specification/application_specification.rb +0 -142
  74. data/lib/instance_agent/codedeploy_plugin/application_specification/context_info.rb +0 -23
  75. data/lib/instance_agent/codedeploy_plugin/application_specification/file_info.rb +0 -23
  76. data/lib/instance_agent/codedeploy_plugin/application_specification/linux_permission_info.rb +0 -121
  77. data/lib/instance_agent/codedeploy_plugin/application_specification/mode_info.rb +0 -66
  78. data/lib/instance_agent/codedeploy_plugin/application_specification/range_info.rb +0 -134
  79. data/lib/instance_agent/codedeploy_plugin/application_specification/script_info.rb +0 -27
  80. data/lib/instance_agent/codedeploy_plugin/codedeploy_control.rb +0 -72
  81. data/lib/instance_agent/codedeploy_plugin/command_executor.rb +0 -357
  82. data/lib/instance_agent/codedeploy_plugin/command_poller.rb +0 -170
  83. data/lib/instance_agent/codedeploy_plugin/deployment_specification.rb +0 -150
  84. data/lib/instance_agent/codedeploy_plugin/hook_executor.rb +0 -206
  85. data/lib/instance_agent/codedeploy_plugin/install_instruction.rb +0 -374
  86. data/lib/instance_agent/codedeploy_plugin/installer.rb +0 -143
  87. data/lib/instance_agent/codedeploy_plugin/request_helper.rb +0 -28
  88. data/test/instance_agent/codedeploy_plugin/application_specification_test.rb +0 -1710
  89. data/test/instance_agent/codedeploy_plugin/install_instruction_test.rb +0 -566
  90. data/test/instance_agent/codedeploy_plugin/request_helper_test.rb +0 -37
  91. data/vendor/specifications/jamespath-0.5.1.gemspec +0 -35
@@ -1,133 +0,0 @@
1
- module InstanceAgent
2
- module CodeDeployPlugin
3
- module ApplicationSpecification
4
-
5
- #Helper Class for storing an ace
6
- class AceInfo
7
-
8
- attr_reader :default, :type, :name, :read, :write, :execute
9
-
10
- def initialize(ace, internal=false)
11
- @default = false
12
- @type = nil
13
- @name = ""
14
- parts = ace.split(":", -1).reverse
15
- if (parts.length < 2) || (parts.length > 4)
16
- raise AppSpecValidationException, "invalid acl entry #{ace}"
17
- end
18
-
19
- if (parts.length == 4)
20
- if !(parts[3].eql?("d") || (parts[3].eql?("default")))
21
- raise AppSpecValidationException, "invalid acl entry #{ace}"
22
- end
23
- @default = true
24
- end
25
-
26
- if parts.length >= 3
27
- if parts[2].eql?("d") || (parts[2].eql?("default"))
28
- if @default
29
- raise AppSpecValidationException, "invalid acl entry #{ace}"
30
- end
31
- @default = true
32
- elsif parts[2].eql?("m") || parts[2].eql?("mask")
33
- @type = "mask"
34
- elsif parts[2].eql?("o") || parts[2].eql?("other")
35
- @type = "other"
36
- elsif parts[2].eql?("g") || parts[2].eql?("group")
37
- @type = "group"
38
- elsif parts[2].eql?("u") || parts[2].eql?("user")
39
- @type = "user"
40
- else
41
- raise AppSpecValidationException, "invalid acl entry #{ace}"
42
- end
43
- end
44
-
45
- if parts[1].eql?("m") || parts[1].eql?("mask")
46
- if @type.nil?
47
- @type = "mask"
48
- else
49
- @name = "mask"
50
- end
51
- elsif parts[1].eql?("o") || parts[1].eql?("other")
52
- if @type.nil?
53
- @type = "other"
54
- else
55
- @name = "other"
56
- end
57
- else
58
- if @type.nil?
59
- @type = "user"
60
- end
61
- @name = parts[1]
62
- end
63
-
64
- if (@type.eql?("mask") || @type.eql?("other")) && !@name.empty?
65
- raise AppSpecValidationException, "invalid acl entry #{ace}"
66
- end
67
- if (!internal && !@default && !@type.eql?("mask") && @name.empty?)
68
- raise AppSpecValidationException, "use mode to set the base acl entry #{ace}"
69
- end
70
-
71
- perm_chars = parts[0].chars.entries
72
- if (perm_chars.length == 1) && (perm_chars[0].ord >= "0".ord) && (perm_chars[0].ord <= "7".ord)
73
- perm_bits = to_bits(perm_chars[0].to_i, 3)
74
- @read = (perm_bits[0] == 1)
75
- @write = (perm_bits[1] == 1)
76
- @execute = (perm_bits[2] == 1)
77
- else
78
- @read = false
79
- @write = false
80
- @execute = false
81
- perm_chars.each do |perm|
82
- case perm
83
- when 'r'
84
- @read = true
85
- when 'w'
86
- @write = true
87
- when 'x'
88
- @execute = true
89
- when '-'
90
- else
91
- raise AppSpecValidationException, "unrecognized permission character #{perm} in #{ace}"
92
- end
93
- end
94
- end
95
- end
96
-
97
- #format [default:][user|group|mask|other]:[name]:(r|-)(w|-)(x|-)
98
- def get_ace
99
- result = "";
100
- if @default
101
- result = "default:"
102
- end
103
- result = result + type + ":" + name + ":"
104
- if (@read)
105
- result = result + "r"
106
- else
107
- result = result + "-"
108
- end
109
- if (@write)
110
- result = result + "w"
111
- else
112
- result = result + "-"
113
- end
114
- if (@execute)
115
- result = result + "x"
116
- else
117
- result = result + "-"
118
- end
119
- result
120
- end
121
-
122
- def to_bits(num, min_size)
123
- bits = Array.new(min_size, 0)
124
- num_bits = num.to_s(2).split("")
125
- diff = [0, min_size - num_bits.length].max
126
- num_bits.map.with_index {|n,i| bits[i+diff] = n.to_i}
127
- bits
128
- end
129
- end
130
-
131
- end
132
- end
133
- end
@@ -1,163 +0,0 @@
1
- module InstanceAgent
2
- module CodeDeployPlugin
3
- module ApplicationSpecification
4
-
5
- #Helper Class for storing an acl
6
- class AclInfo
7
-
8
- attr_reader :aces, :additional
9
-
10
- def initialize(acl)
11
- @aces = []
12
- @additional = []
13
- acl.each do |ace|
14
- @aces << AceInfo.new(ace)
15
- end
16
- end
17
-
18
- #format [default:][user|group|mask|other]:[name]:(r|-)(w|-)(x|-) (or nil if none present)
19
- def get_default_ace
20
- @aces.each do |ace|
21
- if ace.default
22
- return ace.get_ace
23
- end
24
- end
25
- @additional.each do |ace|
26
- if ace.default
27
- return ace.get_ace
28
- end
29
- end
30
- nil
31
- end
32
-
33
- #format array of aces with format: [default:][user|group|mask|other]:[name]:(r|-)(w|-)(x|-)
34
- def get_acl
35
- aces = []
36
- @aces.each do |ace|
37
- aces << ace.get_ace
38
- end
39
- @additional.each do |ace|
40
- aces << ace.get_ace
41
- end
42
- aces
43
- end
44
-
45
- def add_ace(ace)
46
- additional << AceInfo.new(ace, true)
47
- end
48
-
49
- def clear_additional()
50
- additional = []
51
- end
52
-
53
- def has_base_named?
54
- @aces.each do |ace|
55
- if !ace.default && !ace.name.eql?("")
56
- return true
57
- end
58
- end
59
- @additional.each do |ace|
60
- if !ace.default && !ace.name.eql?("")
61
- return true
62
- end
63
- end
64
- false
65
- end
66
-
67
- def has_base_mask?
68
- @aces.each do |ace|
69
- if !ace.default && ace.type.eql?("mask")
70
- return true
71
- end
72
- end
73
- @additional.each do |ace|
74
- if !ace.default && ace.type.eql?("mask")
75
- return true
76
- end
77
- end
78
- false
79
- end
80
-
81
- def has_default?
82
- !get_default_ace.nil?
83
- end
84
-
85
- def has_default_user?
86
- @aces.each do |ace|
87
- if ace.default && ace.type.eql?("user") && ace.name.eql?("")
88
- return true
89
- end
90
- end
91
- @additional.each do |ace|
92
- if ace.default && ace.type.eql?("user") && ace.name.eql?("")
93
- return true
94
- end
95
- end
96
- false
97
- end
98
-
99
- def has_default_group?
100
- !get_default_group_ace.nil?
101
- end
102
-
103
- #format [default:][user|group|mask|other]:[name]:(r|-)(w|-)(x|-) (or nil if not present)
104
- def get_default_group_ace
105
- @aces.each do |ace|
106
- if ace.default && ace.type.eql?("group") && ace.name.eql?("")
107
- return ace.get_ace
108
- end
109
- end
110
- @additional.each do |ace|
111
- if ace.default && ace.type.eql?("group") && ace.name.eql?("")
112
- return ace.get_ace
113
- end
114
- end
115
- nil
116
- end
117
-
118
- def has_default_other?
119
- @aces.each do |ace|
120
- if ace.default && ace.type.eql?("other")
121
- return true
122
- end
123
- end
124
- @additional.each do |ace|
125
- if ace.default && ace.type.eql?("other")
126
- return true
127
- end
128
- end
129
- false
130
- end
131
-
132
- def has_default_named?
133
- @aces.each do |ace|
134
- if ace.default && !ace.name.eql?("")
135
- return true
136
- end
137
- end
138
- @additional.each do |ace|
139
- if ace.default && !ace.name.eql?("")
140
- return true
141
- end
142
- end
143
- false
144
- end
145
-
146
- def has_default_mask?
147
- @aces.each do |ace|
148
- if ace.default && ace.type.eql?("mask")
149
- return true
150
- end
151
- end
152
- @additional.each do |ace|
153
- if ace.default && ace.type.eql?("mask")
154
- return true
155
- end
156
- end
157
- false
158
- end
159
- end
160
-
161
- end
162
- end
163
- end
@@ -1,142 +0,0 @@
1
- module InstanceAgent
2
- module CodeDeployPlugin
3
- module ApplicationSpecification
4
-
5
- class AppSpecValidationException < Exception; end
6
- class ApplicationSpecification
7
-
8
- attr_reader :version, :os, :hooks, :files, :permissions
9
-
10
- def initialize(yaml_hash, opts = {})
11
- @version = parse_version(yaml_hash['version'])
12
- @os = parse_os(yaml_hash['os'])
13
- @hooks = parse_hooks(yaml_hash['hooks'] || {})
14
- @files = parse_files(yaml_hash['files'] || [])
15
- @permissions = parse_permissions(yaml_hash['permissions'] || [])
16
- end
17
-
18
- def self.parse(app_spec_string)
19
- new(YAML.load(app_spec_string))
20
- end
21
-
22
- private
23
- def supported_versions()
24
- [0.0]
25
- end
26
-
27
- def parse_version(version)
28
- if !supported_versions.include?(version)
29
- raise AppSpecValidationException, "unsupported version: #{version}"
30
- end
31
- version
32
- end
33
-
34
- def supported_oses()
35
- InstanceAgent::Platform.util.supported_oses()
36
- end
37
-
38
- def parse_os(os)
39
- if !supported_oses.include?(os)
40
- raise AppSpecValidationException, "unsupported os: #{os}"
41
- end
42
- os
43
- end
44
-
45
- def parse_files(file_map_hash)
46
- files = []
47
- #loop through hash and create fileInfo representations
48
- file_map_hash.each do |mapping|
49
- files << FileInfo.new(mapping['source'], mapping['destination'])
50
- end
51
- files
52
- end
53
-
54
- def parse_hooks(hooks_hash)
55
- temp_hooks_hash = Hash.new
56
- hooks_hash.each_pair do |hook, scripts|
57
- current_hook_scripts = []
58
- scripts.each do |script|
59
- if (script.has_key?('location'))
60
- current_hook_scripts << InstanceAgent::CodeDeployPlugin::ApplicationSpecification::ScriptInfo.new(script['location'].strip,
61
- {
62
- :runas => script.has_key?('runas') ? script['runas'].strip : nil,
63
- :timeout => script['timeout']
64
- })
65
- else
66
- raise AppSpecValidationException, 'script provided without a location value'
67
- end
68
- end
69
- temp_hooks_hash[hook] = current_hook_scripts
70
- end
71
- temp_hooks_hash
72
- end
73
-
74
- def parse_permissions(permissions_list)
75
- permissions = []
76
- #loop through list and create permissionsInfo representations
77
- permissions_list.each do |permission|
78
- if !permission.has_key?('object')
79
- raise AppSpecValidationException, 'permission provided without a object value'
80
- end
81
- if @os.eql?('linux')
82
- permissions << InstanceAgent::CodeDeployPlugin::ApplicationSpecification::LinuxPermissionInfo.new(permission['object'].strip,
83
- {
84
- :pattern => ('**'.eql?(permission['pattern']) || permission['pattern'].nil?) ? '**' : parse_simple_glob(permission['pattern']),
85
- :except => parse_simple_glob_list(permission['except']),
86
- :type => parse_type_list(permission['type']),
87
- :owner => permission['owner'],
88
- :group => permission['group'],
89
- :mode => parse_mode(permission['mode']),
90
- :acls => parse_acl(permission['acls']),
91
- :context => parse_context(permission['context'])
92
- })
93
- else
94
- raise AppSpecValidationException, 'permissions only supported with linux os currently'
95
- end
96
- end
97
- permissions
98
- end
99
-
100
- #placeholder for parsing globs: we should verify that the glob is only including what we expect. For now just returning it as it is.
101
- def parse_simple_glob(glob)
102
- glob
103
- end
104
-
105
- def parse_simple_glob_list(glob_list)
106
- temp_glob_list = []
107
- (glob_list || []).each do |glob|
108
- temp_glob_list << parse_simple_glob(glob)
109
- end
110
- temp_glob_list
111
- end
112
-
113
- def supported_types
114
- ['file', 'directory']
115
- end
116
-
117
- def parse_type_list(type_list)
118
- type_list ||= supported_types
119
- type_list.each do |type|
120
- if !supported_types.include?(type)
121
- raise AppSpecValidationException, "assigning permissions to objects of type #{type} not supported"
122
- end
123
- end
124
- type_list
125
- end
126
-
127
- def parse_mode(mode)
128
- mode.nil? ? nil : InstanceAgent::CodeDeployPlugin::ApplicationSpecification::ModeInfo.new(mode)
129
- end
130
-
131
- def parse_acl(acl)
132
- acl.nil? ? nil : InstanceAgent::CodeDeployPlugin::ApplicationSpecification::AclInfo.new(acl)
133
- end
134
-
135
- def parse_context(context)
136
- context.nil? ? nil : InstanceAgent::CodeDeployPlugin::ApplicationSpecification::ContextInfo.new(context)
137
- end
138
- end
139
-
140
- end
141
- end
142
- end
@@ -1,23 +0,0 @@
1
- module InstanceAgent
2
- module CodeDeployPlugin
3
- module ApplicationSpecification
4
-
5
- #Helper Class for storing a context
6
- class ContextInfo
7
-
8
- attr_reader :user, :role, :type, :range
9
-
10
- def initialize(context)
11
- if context['type'].nil?
12
- raise AppSpecValidationException, "invalid context type required #{context.inspect}"
13
- end
14
- @user = context['name']
15
- @role = nil
16
- @type = context['type']
17
- @range = context['range'].nil? ? nil : RangeInfo.new(context['range'])
18
- end
19
- end
20
-
21
- end
22
- end
23
- end