stax 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/stax/docker.rb +4 -28
- data/lib/stax/staxfile.rb +22 -2
- data/lib/stax/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ff348fae4586ba8565b0716cafbd57a2804fa9ead68069195ec351815833201b
|
4
|
+
data.tar.gz: dcae498f9406661f84112b0034c15a844a1945ef746e19188c05fce565c8e9ed
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e6469ff904a334f9fd228f14c754c59f6b273d9bd0916ca367cabdad103f72d29993f45f6101a12215249197d32fc7dd6cfa1bd78cdbe45c17508b0baa24f223
|
7
|
+
data.tar.gz: 75cae424254fc98fb6696051b2d08e3f1c6a045f54c64e257fb78a6cf65ad6f86f220ab5482568803e396568ae7a5d64b677577b69674ff99f9c455095ec0b38
|
data/lib/stax/docker.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
require 'stax/aws/sts'
|
2
1
|
require 'stax/aws/ecr'
|
3
2
|
|
4
3
|
module Stax
|
@@ -7,7 +6,7 @@ module Stax
|
|
7
6
|
no_commands do
|
8
7
|
## default to ECR registry for this account
|
9
8
|
def docker_registry
|
10
|
-
@_docker_registry ||= "#{
|
9
|
+
@_docker_registry ||= "#{aws_account_id}.dkr.ecr.#{aws_region}.amazonaws.com"
|
11
10
|
end
|
12
11
|
|
13
12
|
## name the docker repo after the git repo
|
@@ -21,7 +20,7 @@ module Stax
|
|
21
20
|
end
|
22
21
|
|
23
22
|
## build a docker image locally
|
24
|
-
def
|
23
|
+
def docker_build
|
25
24
|
debug("Docker build #{docker_image}")
|
26
25
|
system "docker build -t #{docker_image} #{Git.toplevel}"
|
27
26
|
end
|
@@ -31,28 +30,6 @@ module Stax
|
|
31
30
|
debug("Docker push #{docker_image}")
|
32
31
|
system "docker push #{docker_image}"
|
33
32
|
end
|
34
|
-
|
35
|
-
## override this for your argus setup
|
36
|
-
def docker_argus_queue
|
37
|
-
@_docker_argus_queue ||= Aws::Sqs.queue_url('argus.fifo')
|
38
|
-
end
|
39
|
-
|
40
|
-
def docker_argus_build
|
41
|
-
debug("Sending to argus #{Git.branch}:#{Git.sha}")
|
42
|
-
org, repo = Git.repo.split('/')
|
43
|
-
Aws::Sqs.send(
|
44
|
-
queue_url: docker_argus_queue,
|
45
|
-
message_group_id: repo,
|
46
|
-
message_body: {
|
47
|
-
org: org,
|
48
|
-
repo: repo,
|
49
|
-
branch: Git.branch,
|
50
|
-
sha: Git.sha,
|
51
|
-
}.to_json
|
52
|
-
).tap do |r|
|
53
|
-
puts r&.message_id
|
54
|
-
end
|
55
|
-
end
|
56
33
|
end
|
57
34
|
|
58
35
|
desc 'registry', 'show registry name'
|
@@ -73,8 +50,7 @@ module Stax
|
|
73
50
|
## override this method with the desired builder
|
74
51
|
desc 'build', 'build docker image'
|
75
52
|
def build
|
76
|
-
|
77
|
-
# docker_argus_build
|
53
|
+
docker_build
|
78
54
|
end
|
79
55
|
|
80
56
|
desc 'login', 'login to registry'
|
@@ -103,4 +79,4 @@ module Stax
|
|
103
79
|
end
|
104
80
|
|
105
81
|
end
|
106
|
-
end
|
82
|
+
end
|
data/lib/stax/staxfile.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
module Stax
|
2
2
|
@@_root_path = nil
|
3
3
|
@@_stack_list = []
|
4
|
+
@@_command_list = []
|
4
5
|
|
5
6
|
## the stax root is defined as location of Staxfile
|
6
7
|
def self.root_path
|
@@ -12,6 +13,11 @@ module Stax
|
|
12
13
|
@@_stack_list
|
13
14
|
end
|
14
15
|
|
16
|
+
## list of commands defined in Staxfile
|
17
|
+
def self.command_list
|
18
|
+
@@_command_list
|
19
|
+
end
|
20
|
+
|
15
21
|
## search up the dir tree for nearest Staxfile
|
16
22
|
def self.find_staxfile
|
17
23
|
Pathname.pwd.ascend do |path|
|
@@ -24,6 +30,7 @@ module Stax
|
|
24
30
|
if root_path
|
25
31
|
load(root_path.join('Staxfile'))
|
26
32
|
require_stacks
|
33
|
+
require_commands
|
27
34
|
end
|
28
35
|
end
|
29
36
|
|
@@ -35,6 +42,14 @@ module Stax
|
|
35
42
|
end
|
36
43
|
end
|
37
44
|
|
45
|
+
## auto-require any command lib files
|
46
|
+
def self.require_commands
|
47
|
+
command_list.each do |command|
|
48
|
+
f = root_path.join('lib', "#{command}.rb")
|
49
|
+
require(f) if File.exist?(f)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
38
53
|
## add a stack by name, creates class as needed
|
39
54
|
def self.add_stack(name, opt = {})
|
40
55
|
@@_stack_list << name
|
@@ -64,9 +79,14 @@ module Stax
|
|
64
79
|
end
|
65
80
|
|
66
81
|
## add a non-stack command at top level
|
67
|
-
def self.add_command(name, klass)
|
82
|
+
def self.add_command(name, klass = nil)
|
83
|
+
@@_command_list << name
|
84
|
+
|
85
|
+
## class defaults to eg Stax::Name::Cmd
|
86
|
+
klass ||= self.const_get(name.to_s.split(/[_-]/).map(&:capitalize).join + '::Cmd')
|
87
|
+
|
68
88
|
Cli.desc(name, "#{name} commands")
|
69
89
|
Cli.subcommand(name, klass)
|
70
90
|
end
|
71
91
|
|
72
|
-
end
|
92
|
+
end
|
data/lib/stax/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stax
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Richard Lister
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-09-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -624,7 +624,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
624
624
|
- !ruby/object:Gem::Version
|
625
625
|
version: '0'
|
626
626
|
requirements: []
|
627
|
-
rubygems_version: 3.
|
627
|
+
rubygems_version: 3.0.3
|
628
628
|
signing_key:
|
629
629
|
specification_version: 4
|
630
630
|
summary: Control Cloudformation stack and other stuff.
|