lex-onboard 0.1.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
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 8c69cbfdf34bc86cb734b9f6c3eec82e29778aed6e11f918df067e9f710dc164
|
|
4
|
+
data.tar.gz: 7661cfe9117f583265a1a89ec8416f1ed655a7cefa5851fdea6c3e60b51f4581
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 58b249f882b8eb5c6aa451282abe82cd8bb6be74d761a3900f837a0af42f8395b21f796f9e48113238ccec97b22fe0606b19fcddef66dcf323175495f56c3c51
|
|
7
|
+
data.tar.gz: 18a8c13b1a5e196b4a9d0da841c775ee76faa45cb00e7194e3b7a42ab11421a66dd16b0635721b301b25fa48b1b15b52829bada679db3d86915d83d531471942
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Legion
|
|
4
|
+
module Extensions
|
|
5
|
+
module Onboard
|
|
6
|
+
module Actor
|
|
7
|
+
class Provision < Legion::Extensions::Actors::Subscription
|
|
8
|
+
def runner_class
|
|
9
|
+
'Legion::Extensions::Onboard::Runners::Provision'
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def runner_function
|
|
13
|
+
'provision'
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def use_runner?
|
|
17
|
+
false
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def check_subtask?
|
|
21
|
+
false
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def generate_task?
|
|
25
|
+
false
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Legion
|
|
4
|
+
module Extensions
|
|
5
|
+
module Onboard
|
|
6
|
+
module Runners
|
|
7
|
+
module Provision
|
|
8
|
+
def provision(askid:, tfe_organization: 'terraform.uhg.com', requester_slack_webhook: nil, **)
|
|
9
|
+
steps = []
|
|
10
|
+
|
|
11
|
+
steps << run_step('vault_namespace') { create_vault_namespace(name: askid) }
|
|
12
|
+
steps << run_step('consul_partition') { create_consul_partition(name: askid) }
|
|
13
|
+
steps << run_step('tfe_project') { create_tfe_project(name: askid, organization: tfe_organization) }
|
|
14
|
+
steps << run_step('notify') { notify_requester(askid: askid, webhook: requester_slack_webhook) }
|
|
15
|
+
|
|
16
|
+
failed = steps.any? { |s| s[:status] == 'error' }
|
|
17
|
+
|
|
18
|
+
{
|
|
19
|
+
status: failed ? 'failed' : 'completed',
|
|
20
|
+
askid: askid,
|
|
21
|
+
steps: steps
|
|
22
|
+
}
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
private
|
|
26
|
+
|
|
27
|
+
def run_step(name)
|
|
28
|
+
yield
|
|
29
|
+
{ name: name, status: 'ok' }
|
|
30
|
+
rescue StandardError => e
|
|
31
|
+
{ name: name, status: 'error', error: e.message }
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def create_vault_namespace(name:)
|
|
35
|
+
return { result: false } unless defined?(Legion::Extensions::Vault::Client)
|
|
36
|
+
|
|
37
|
+
Legion::Extensions::Vault::Client.new.create_namespace(name: name)
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def create_consul_partition(name:)
|
|
41
|
+
return { result: false } unless defined?(Legion::Extensions::Consul::Client)
|
|
42
|
+
|
|
43
|
+
Legion::Extensions::Consul::Client.new.create_partition(name: name)
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def create_tfe_project(name:, organization:)
|
|
47
|
+
return { result: false } unless defined?(Legion::Extensions::Tfe::Client)
|
|
48
|
+
|
|
49
|
+
Legion::Extensions::Tfe::Client.new.create_project(organization: organization, name: name)
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def notify_requester(askid:, webhook: nil)
|
|
53
|
+
return true unless webhook && defined?(Legion::Extensions::Slack::Client)
|
|
54
|
+
|
|
55
|
+
Legion::Extensions::Slack::Client.new.send_webhook(
|
|
56
|
+
webhook: webhook, text: "Onboarding complete for #{askid}"
|
|
57
|
+
)
|
|
58
|
+
rescue StandardError
|
|
59
|
+
true
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: lex-onboard
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Esity
|
|
8
|
+
bindir: bin
|
|
9
|
+
cert_chain: []
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
|
+
dependencies: []
|
|
12
|
+
description: 'Automated onboarding: Vault namespace, Consul partition, TFE project
|
|
13
|
+
provisioning'
|
|
14
|
+
email:
|
|
15
|
+
- matthewdiverson@gmail.com
|
|
16
|
+
executables: []
|
|
17
|
+
extensions: []
|
|
18
|
+
extra_rdoc_files: []
|
|
19
|
+
files:
|
|
20
|
+
- lib/legion/extensions/onboard.rb
|
|
21
|
+
- lib/legion/extensions/onboard/actors/provision.rb
|
|
22
|
+
- lib/legion/extensions/onboard/runners/provision.rb
|
|
23
|
+
- lib/legion/extensions/onboard/version.rb
|
|
24
|
+
homepage: https://github.com/LegionIO
|
|
25
|
+
licenses:
|
|
26
|
+
- MIT
|
|
27
|
+
metadata:
|
|
28
|
+
rubygems_mfa_required: 'true'
|
|
29
|
+
rdoc_options: []
|
|
30
|
+
require_paths:
|
|
31
|
+
- lib
|
|
32
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
33
|
+
requirements:
|
|
34
|
+
- - ">="
|
|
35
|
+
- !ruby/object:Gem::Version
|
|
36
|
+
version: '3.4'
|
|
37
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
38
|
+
requirements:
|
|
39
|
+
- - ">="
|
|
40
|
+
- !ruby/object:Gem::Version
|
|
41
|
+
version: '0'
|
|
42
|
+
requirements: []
|
|
43
|
+
rubygems_version: 3.6.9
|
|
44
|
+
specification_version: 4
|
|
45
|
+
summary: LEX::Onboard
|
|
46
|
+
test_files: []
|