apmate 0.2.2 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/apmate.rb +1 -0
- data/lib/apmate/cli.rb +23 -4
- data/lib/apmate/commands/execution.rb +23 -0
- data/lib/apmate/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4369a43a2b860b838c43dd835523e50c8b588d10
|
4
|
+
data.tar.gz: 3d001d0f8c5a6f6228ad6fd5f1dc333d7b90409c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 361347ca3c6238f8e381c2397c59e83a948edf9706dc4322e42d336a52c2cca4cb4d2617a2abf9a8e956b66ff83dd3b0f03be6f98c159eafa8befed5f6e2bd31
|
7
|
+
data.tar.gz: a59d8fbea7989ff9f0fa10571578f804d96cb302995a5cd8ffed98ff47ca4afa85256d0ded8fc13d8dda60ae3c718efb3414d660b39cbd0b54b80be2996cfb32
|
data/lib/apmate.rb
CHANGED
data/lib/apmate/cli.rb
CHANGED
@@ -17,14 +17,15 @@ class Apmate::CLI
|
|
17
17
|
get_artifact_environment: '/api/artifacts/environment',
|
18
18
|
get_artifact: '/api/artifacts',
|
19
19
|
get_artifact_name: '/api/artifacts/name',
|
20
|
-
promote_environment: '/api/environments/promote'
|
20
|
+
promote_environment: '/api/environments/promote',
|
21
|
+
create_execution: '/api/executions'
|
21
22
|
}
|
22
23
|
|
23
24
|
def self.apply_file(file, opts)
|
24
25
|
Apmate::Logger.logger.info "applying file #{file}"
|
25
26
|
YAML.load_stream(File.read file).each do |yaml_hash|
|
26
27
|
Apmate::Logger.logger.debug "yaml_hash: #{yaml_hash}"
|
27
|
-
|
28
|
+
apmate_apply yaml_hash, opts
|
28
29
|
end
|
29
30
|
end
|
30
31
|
|
@@ -56,6 +57,19 @@ class Apmate::CLI
|
|
56
57
|
apmate_get(ENDPOINTS[:get_artifact], opts, params)
|
57
58
|
end
|
58
59
|
|
60
|
+
def self.apmate_create_execution(app_name, env_name, comp_name, action, opts)
|
61
|
+
uri = URI("#{Apmate::CLI::APMATE_BASE_URL}:#{Apmate::CLI::APMATE_PORT}#{ENDPOINTS[:create_execution]}")
|
62
|
+
params = {
|
63
|
+
execution: {
|
64
|
+
application_name: app_name,
|
65
|
+
environment_name: env_name,
|
66
|
+
component_name: comp_name,
|
67
|
+
action: action
|
68
|
+
}
|
69
|
+
}
|
70
|
+
apmate_post uri, params, opts
|
71
|
+
end
|
72
|
+
|
59
73
|
def self.apmate_get(endpoint, opts, params=nil)
|
60
74
|
Apmate::Logger.logger.debug "Beginning get request."
|
61
75
|
uri = URI("#{Apmate::CLI::APMATE_URL}#{endpoint}")
|
@@ -66,7 +80,7 @@ class Apmate::CLI
|
|
66
80
|
log_output(output, opts)
|
67
81
|
end
|
68
82
|
|
69
|
-
def self.
|
83
|
+
def self.apmate_apply(yaml_hash, opts)
|
70
84
|
Apmate::Logger.logger.debug "Beginning post request."
|
71
85
|
|
72
86
|
endpoint_object = yaml_hash['kind'].downcase.pluralize
|
@@ -78,6 +92,10 @@ class Apmate::CLI
|
|
78
92
|
payload = {'name': yaml_hash['metadata']['name']}.merge yaml_hash['spec']
|
79
93
|
Apmate::Logger.logger.debug "payload: #{payload}"
|
80
94
|
|
95
|
+
apmate_post uri, payload, opts
|
96
|
+
end
|
97
|
+
|
98
|
+
def self.apmate_post(uri, payload, opts)
|
81
99
|
request = Net::HTTP::Post.new(uri)
|
82
100
|
request.content_type = 'application/json'
|
83
101
|
request.body = payload.to_json
|
@@ -134,7 +152,8 @@ class Apmate::CLI
|
|
134
152
|
Command::HELP,
|
135
153
|
Command::APPLY,
|
136
154
|
get_command,
|
137
|
-
Command::PROMOTE
|
155
|
+
Command::PROMOTE,
|
156
|
+
Command::CREATE_EXECUTION
|
138
157
|
].each do |cmd|
|
139
158
|
command.add_command cmd
|
140
159
|
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Apmate::CLI::Command
|
2
|
+
CREATE_EXECUTION = Cri::Command.define do
|
3
|
+
name 'create_execution'
|
4
|
+
usage 'create_execution <application_name> <environment_name> <component_name> <action>'
|
5
|
+
summary 'Creates a StackStorm execution.'
|
6
|
+
description 'Creates a StackStorm execution.'
|
7
|
+
|
8
|
+
flag :h, :help, 'show help for this command' do |value, cmd|
|
9
|
+
puts cmd.help
|
10
|
+
exit 0
|
11
|
+
end
|
12
|
+
|
13
|
+
run do |opts, args, cmd|
|
14
|
+
Apmate::Logger.log_level(opts)
|
15
|
+
Apmate::Logger.verbosity(opts)
|
16
|
+
Apmate::Logger.logger.debug "opts: #{opts}"
|
17
|
+
Apmate::Logger.logger.debug "args: #{args}"
|
18
|
+
Apmate::Logger.logger.debug "cmd: #{cmd.to_s}"
|
19
|
+
cmd.run(['-h']) unless args.count == 4
|
20
|
+
Apmate::CLI.apmate_create_execution(args[0], args[1], args[2], args[3], opts)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/lib/apmate/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: apmate
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Patrick Baldridge
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-04-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cri
|
@@ -79,6 +79,7 @@ files:
|
|
79
79
|
- lib/apmate/cli.rb
|
80
80
|
- lib/apmate/commands/apply.rb
|
81
81
|
- lib/apmate/commands/base.rb
|
82
|
+
- lib/apmate/commands/execution.rb
|
82
83
|
- lib/apmate/commands/get.rb
|
83
84
|
- lib/apmate/commands/get/artifact.rb
|
84
85
|
- lib/apmate/commands/get/artifact_environment.rb
|