firespring_dev_commands 2.1.1.pre.alpha.4 → 2.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/firespring_dev_commands/aws/account.rb +1 -0
- data/lib/firespring_dev_commands/aws/cloudformation.rb +7 -0
- data/lib/firespring_dev_commands/aws/credentials.rb +1 -0
- data/lib/firespring_dev_commands/common.rb +2 -2
- data/lib/firespring_dev_commands/slack/global.rb +6 -1
- data/lib/firespring_dev_commands/slack.rb +5 -0
- data/lib/firespring_dev_commands/templates/ci.rb +6 -0
- data/lib/firespring_dev_commands/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: abb45242307cc08509ddc63a507488ce03e1d545ef01abc2f909d2b09382c8a1
|
4
|
+
data.tar.gz: 2f65a0f2845675e4930ff062865d47535c086b88267be51bba1e142f4b678057
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7d699f6345d0cae3650009a92330ee4b46882c849ac85fe6cb99e53861e9a57bd9e53e119e28be8ffbce6066d9e021985a7e93734aec848705b227cdd291522a
|
7
|
+
data.tar.gz: 972fd3a65395c8cff43136fb5cadaf96f1ab554c78feb917c9f7fccb765f3210d680e7e653f46693d9568f42bf04ef7a670e4036cf0eedec33e214b969e62ea0
|
@@ -23,6 +23,7 @@ module Dev
|
|
23
23
|
# The name of the file containing the Aws settings
|
24
24
|
CONFIG_FILE = "#{Dev::Aws::CONFIG_DIR}/config".freeze
|
25
25
|
|
26
|
+
# Returns the config ini file associated with this object
|
26
27
|
def self.config_ini
|
27
28
|
IniFile.new(filename: CONFIG_FILE, default: 'default')
|
28
29
|
end
|
@@ -69,6 +69,13 @@ module Dev
|
|
69
69
|
@state = FAILED
|
70
70
|
end
|
71
71
|
|
72
|
+
# Get the cloudformation stack
|
73
|
+
def exist?
|
74
|
+
!client.describe_stacks(stack_name: name).stacks.empty?
|
75
|
+
rescue ::Aws::CloudFormation::Errors::ValidationError
|
76
|
+
false
|
77
|
+
end
|
78
|
+
|
72
79
|
# Update the cloudformation stack
|
73
80
|
def update(should_wait: true)
|
74
81
|
# Call upload function to get the s3 url
|
@@ -11,6 +11,7 @@ module Dev
|
|
11
11
|
# The local file where temporary credentials are stored
|
12
12
|
CONFIG_FILE = "#{Dev::Aws::CONFIG_DIR}/credentials".freeze
|
13
13
|
|
14
|
+
# Returns the config ini file associated with this object
|
14
15
|
def self.config_ini
|
15
16
|
IniFile.new(filename: CONFIG_FILE, default: 'default')
|
16
17
|
end
|
@@ -89,8 +89,8 @@ module Dev
|
|
89
89
|
true
|
90
90
|
end
|
91
91
|
|
92
|
-
# Remove all leading non
|
93
|
-
# Remove all trailing non
|
92
|
+
# Remove all leading non left-curly-brace characters
|
93
|
+
# Remove all trailing non right-curly-brace characters
|
94
94
|
def strip_non_json(str)
|
95
95
|
str.sub(/\A[^{]*{/m, '{').sub(/}[^}]*\z/m, '}')
|
96
96
|
end
|
@@ -3,21 +3,26 @@ require 'dotenv'
|
|
3
3
|
|
4
4
|
module Dev
|
5
5
|
class Slack
|
6
|
+
# A class to manage slack global configuration settings
|
6
7
|
class Global
|
7
8
|
# The filename where we store the local auth information
|
8
9
|
CONFIG_FILE = "#{Dir.home}/.env.slack".freeze
|
9
10
|
|
11
|
+
# The name of the environmental setting which holds the slack token
|
10
12
|
SLACK_API_TOKEN = 'SLACK_API_TOKEN'.freeze
|
11
13
|
|
14
|
+
# Method to load the slack config file and then configure slack
|
12
15
|
def configure
|
13
16
|
# Always load the env slack auth
|
14
17
|
Dotenv.load(CONFIG_FILE) if File.exist?(CONFIG_FILE)
|
15
18
|
|
16
19
|
::Slack.configure do |c|
|
17
|
-
c.token = ENV.fetch(
|
20
|
+
c.token = ENV.fetch(SLACK_API_TOKEN, nil)
|
18
21
|
c.logger = LOG if ENV['ENABLE_SLACK_DEBUG'].to_s.strip == 'true'
|
19
22
|
end
|
20
23
|
end
|
24
|
+
|
25
|
+
# Run the configure when creating this class to load any existing settings
|
21
26
|
new.configure
|
22
27
|
|
23
28
|
# Write the new slack auth value to the env file
|
@@ -1,18 +1,23 @@
|
|
1
1
|
require 'slack'
|
2
2
|
|
3
3
|
module Dev
|
4
|
+
# The main slack class for posting/uploading messages
|
4
5
|
class Slack
|
6
|
+
# The attribute which contains the underlying slack web client object
|
5
7
|
attr_accessor :client
|
6
8
|
|
9
|
+
# Create a new slack web client and make sure it has valid credentials
|
7
10
|
def initialize
|
8
11
|
@client = ::Slack::Web::Client.new
|
9
12
|
@client.auth_test
|
10
13
|
end
|
11
14
|
|
15
|
+
# Post the text to the given channel
|
12
16
|
def post(channel:, text:)
|
13
17
|
client.chat_postMessage(channel:, text:)
|
14
18
|
end
|
15
19
|
|
20
|
+
# Upload the text to the give channel as a text file
|
16
21
|
def upload_text(channel:, text:, title: 'Text File', filename: 'file.txt')
|
17
22
|
raise 'text should be a string' unless text.is_a?(String)
|
18
23
|
|
@@ -31,6 +31,8 @@ module Dev
|
|
31
31
|
|
32
32
|
# Start create on all stacks without waiting so they are created in parallel
|
33
33
|
cloudformations.each do |cloudformation|
|
34
|
+
next if cloudformation.exist?
|
35
|
+
|
34
36
|
cloudformation.create(should_wait: false)
|
35
37
|
end
|
36
38
|
LOG.info 'Waiting for all stacks to finish create'
|
@@ -62,6 +64,8 @@ module Dev
|
|
62
64
|
|
63
65
|
# Start update on all stacks without waiting so they are updated in parallel
|
64
66
|
cloudformations.each do |cloudformation|
|
67
|
+
next unless cloudformation.exist?
|
68
|
+
|
65
69
|
cloudformation.update(should_wait: false)
|
66
70
|
end
|
67
71
|
LOG.info 'Waiting for all stacks to finish update'
|
@@ -93,6 +97,8 @@ module Dev
|
|
93
97
|
|
94
98
|
# Start delete on all stacks without waiting so they are deleted in parallel
|
95
99
|
cloudformations.each do |cloudformation|
|
100
|
+
next unless cloudformation.exist?
|
101
|
+
|
96
102
|
cloudformation.delete(should_wait: false)
|
97
103
|
end
|
98
104
|
LOG.info 'Waiting for all stacks to finish delete'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: firespring_dev_commands
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.1
|
4
|
+
version: 2.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Firespring
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-08-
|
11
|
+
date: 2023-08-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -330,9 +330,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
330
330
|
version: '3.1'
|
331
331
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
332
332
|
requirements:
|
333
|
-
- - "
|
333
|
+
- - ">="
|
334
334
|
- !ruby/object:Gem::Version
|
335
|
-
version:
|
335
|
+
version: '0'
|
336
336
|
requirements: []
|
337
337
|
rubygems_version: 3.4.10
|
338
338
|
signing_key:
|