takeltau 0.44.27 → 0.44.35

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c930f7f250bd6480ece0a2cccab9211e1756e7d4051a046754520bbea0b997b7
4
- data.tar.gz: a48606caaa7c511cdc2b4bc57f54dca50c22fb901a83b18128a7a5dfebfa7502
3
+ metadata.gz: e784334933edc9f9c65689cb759b700548c1094f5e267545f6c86c5125e7e0b2
4
+ data.tar.gz: bbef4da09c6bf229220cfe16b1eef529a82d36ceabaffc8678eda55f1c8a11dd
5
5
  SHA512:
6
- metadata.gz: 65623941de415bb307f329767b3fdbc360726ace1a094cd65a9675b4974c36fdad8e0f6fc89dbf5a9357cf33372b263c79ccbf5836d118df9e01ab81322fbc29
7
- data.tar.gz: 657ef5a7a80dd7c9796e29f77656cb5d42415922755afd852ba9498bcbf0542facbd6d1ccb7300924bef4bbe5d2a2dbf8b4e7f2251372fd2745c1f4e0d318ec4
6
+ metadata.gz: 7ebb0a7edcfc58a888af987d7743ae5f15518e2e8604f125a097f8b2c6015f7184fdd65edf56e2810ac63e8bb4d415e4ef6c4a1c9538eb2eaf4ee186e3431e16
7
+ data.tar.gz: 849e621d3ed843338cb433143f757387c3a78d0c22732b9be99d4f221df5b646a19b5bd745d83df09749e1221b1abd45de0d093be2475565437a9e248622ee39
@@ -92,7 +92,7 @@ ship_data_dir: 'takelship'
92
92
  ship_default_docker_host: '32375'
93
93
  ship_default_project: 'default'
94
94
  ship_docker_host: '32375'
95
- ship_env: '--env TAKELSHIP_UPDATE=true'
95
+ ship_env: ''
96
96
  ship_hostname: '%{ship_name}_%{unique}'
97
97
  ship_name: 'takelship'
98
98
  ship_podman_localhost: '127.0.0.1'
@@ -20,23 +20,19 @@ module ShipContainerLib
20
20
 
21
21
  # Run privileged docker command
22
22
  # rubocop:disable Metrics/AbcSize
23
- # rubocop:disable Metrics/MethodLength
24
- def _ship_container_lib_docker_privileged(ports, command, args = '')
23
+ def _ship_container_lib_docker_privileged(ports, command, args: '', ship_hostname_suffix: nil, publish_ports: true)
24
+ suffix = "-#{ship_hostname_suffix}" unless ship_hostname_suffix.nil?
25
+ ship_hostname = "#{_ship_container_lib_ship_hostname}#{suffix}"
25
26
  args_privileged = config.active['ship_run_args_privileged']
26
- args = "#{args} #{args_privileged}" if config.active['ship_run_args_privileged']
27
+ args = "#{args} #{args_privileged}" if args_privileged
28
+ ship_env = _ship_container_lib_ship_env ports
29
+ ports = _ship_container_lib_publish(ports, publish_ports)
27
30
  ship_data_dir = config.active['ship_data_dir']
28
- ship_env = [config.active['ship_env']]
29
- ports.each do |key, port|
30
- envvar = "TAKELSHIP_#{key}".upcase
31
- envstr = "--env #{envvar}=#{port['localhost']}"
32
- ship_env << envstr
33
- end
34
- ports = _ship_container_lib_publish(ports)
35
31
  cmd_docker_run_command = format(
36
32
  config.active['cmd_ship_project_start_docker_run_privileged'],
37
33
  ship_docker: config.active['cmd_ship_docker'],
38
- ship_hostname: _ship_container_lib_ship_hostname,
39
- ship_env: ship_env.join(' '),
34
+ ship_hostname: ship_hostname,
35
+ ship_env: ship_env,
40
36
  ports: ports,
41
37
  project_root_dir: config.active['project_root_dir'],
42
38
  ship_data_dir: ship_data_dir,
@@ -44,10 +40,9 @@ module ShipContainerLib
44
40
  image: _ship_container_lib_image,
45
41
  command: command
46
42
  )
47
- run cmd_docker_run_command
43
+ run_and_capture cmd_docker_run_command
48
44
  end
49
45
 
50
- # rubocop:enable Metrics/MethodLength
51
46
  # rubocop:enable Metrics/AbcSize
52
47
 
53
48
  # Run a docker command in a takelship container
@@ -84,8 +79,24 @@ module ShipContainerLib
84
79
  )
85
80
  end
86
81
 
82
+ # Create ship environment string
83
+ def _ship_container_lib_ship_env(ports)
84
+ ship_env = [config.active['ship_env']]
85
+ ports.each do |key, port|
86
+ envvar = "TAKELSHIP_#{key}".upcase
87
+ envstr = "--env #{envvar}=#{port['localhost']}"
88
+ ship_env << envstr
89
+ end
90
+ update = '--env TAKELSHIP_UPDATE=true'
91
+ update = "--env TAKELSHIP_UPDATE=#{ENV['TAKELSHIP_UPDATE']}" if ENV.key?('TAKELSHIP_UPDATE')
92
+ ship_env << update
93
+ ship_env.join(' ')
94
+ end
95
+
87
96
  # Create publish ports string
88
- def _ship_container_lib_publish(ports)
97
+ def _ship_container_lib_publish(ports, publish_ports)
98
+ return '' unless publish_ports
99
+
89
100
  publish = []
90
101
  ports.each do |port|
91
102
  shipport = port[1]['takelship'].to_s
@@ -27,7 +27,7 @@ module Takeltau
27
27
  It will neither run the [PROJECT] in a takelship nor create service data.
28
28
  LONGDESC
29
29
  def create(project = 'default')
30
- say ship_project_create project
30
+ exit ship_project_create project
31
31
  end
32
32
 
33
33
  #
@@ -87,7 +87,7 @@ module Takeltau
87
87
  It will neither run the [PROJECT] in a takelship nor touch the service data.
88
88
  LONGDESC
89
89
  def update(project = 'default')
90
- say ship_project_create project, 'Updated'
90
+ exit ship_project_create project, 'Updated'
91
91
  end
92
92
  end
93
93
  end
@@ -10,12 +10,16 @@ module ShipProjectCreate
10
10
 
11
11
  log.debug "Dumping takelship project \"#{project}\""
12
12
  ports = _ship_ports_lib_get_ports(takelship, project)
13
- project_root_dir = config.active['project_root_dir']
14
- ship_data_dir = config.active['ship_data_dir']
15
- args = []
16
- args << "--volume #{project_root_dir}/#{ship_data_dir}:/home/podman/takelship"
17
- args << '--env TAKELSHIP_DUMP=true'
18
- _ship_container_lib_docker_privileged ports, project, args.join(' ')
19
- "#{verb} takelship project \"#{project}\"."
13
+
14
+ ship_status = _ship_container_lib_docker_privileged(
15
+ ports,
16
+ project,
17
+ ship_hostname_suffix: 'dump',
18
+ publish_ports: false
19
+ )
20
+ return false unless _ship_container_lib_started? ship_status
21
+
22
+ say "#{verb} takelship project \"#{project}\"."
23
+ true
20
24
  end
21
25
  end
@@ -17,7 +17,9 @@ module ShipProjectStart
17
17
  _ship_ports_lib_write_ports(ports, project)
18
18
 
19
19
  log.debug "Starting takelship project \"#{project}\""
20
- _ship_container_lib_docker_privileged ports, project
20
+ ship_status = _ship_container_lib_docker_privileged ports, project
21
+ return false unless _ship_container_lib_started? ship_status
22
+
21
23
  _ship_project_start_print_banner project
22
24
  _ship_project_start_print_ports ports
23
25
  true
@@ -51,6 +53,15 @@ module ShipProjectStart
51
53
  false
52
54
  end
53
55
 
56
+ # check if the ship started successfully
57
+ def _ship_container_lib_started?(ship_status)
58
+ return true if ship_status[2].zero?
59
+
60
+ say 'Unable to start the takelship. The error message was:'
61
+ say ship_status[1].to_s.strip.delete_prefix('"').delete_suffix('"')
62
+ false
63
+ end
64
+
54
65
  # print banner with status information
55
66
  def _ship_project_start_print_banner(project)
56
67
  ship_hostname = _ship_container_lib_ship_hostname
data/lib/takeltau/version CHANGED
@@ -1 +1 @@
1
- 0.44.27
1
+ 0.44.35
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: takeltau
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.44.27
4
+ version: 0.44.35
5
5
  platform: ruby
6
6
  authors:
7
7
  - Takelwerk