takelage 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +6 -7
- data/lib/takelage/bit/check/cli.rb +23 -0
- data/lib/takelage/bit/check/module.rb +24 -0
- data/lib/takelage/bit/cli.rb +2 -3
- data/lib/takelage/bit/clipboard/cli.rb +1 -0
- data/lib/takelage/bit/clipboard/module.rb +44 -6
- data/lib/takelage/bit/scope/cli.rb +1 -0
- data/lib/takelage/bit/scope/module.rb +5 -0
- data/lib/takelage/default.yml +14 -5
- data/lib/takelage/docker/container/module.rb +7 -3
- data/lib/takelage/git/check/cli.rb +2 -1
- data/lib/takelage/git/check/module.rb +7 -7
- data/lib/takelage/version +1 -1
- data/lib/takelage.rb +2 -0
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cb5d74447dcfd62750e7edddf49a98b3a4a2565316b5e0fed13342ee6248d24d
|
4
|
+
data.tar.gz: 9c6ac4feb670f45dc5e728d7a92114020e7e69f8ac7b37ff158507d0d430cac0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1c2b09725d668cc8c54194dd856dc5ba8411074f6d5aadd935c1f04c8c9fa839cecd0941c270cb2454a54fc2dc0bad6b8d0798579ba3a440c67bf61e25567a95
|
7
|
+
data.tar.gz: 1ec42421048df41cc9ce2836ae3df0f19e7023e1ff779efc62e17828f41e888300d926baba3f84bc013c70f450a7c2f4f84227b927e2bfa1c9db312cad95790f
|
data/README.md
CHANGED
@@ -18,7 +18,7 @@ The takelage devops framework consists of these projects:
|
|
18
18
|
| --- | ----------- |
|
19
19
|
| *[takelage-dev](https://github.com/geospin-takelage/takelage-dev)* | takelage development environment |
|
20
20
|
| *[takelage-cli](https://github.com/geospin-takelage/takelage-cli)* | takelage command line interface |
|
21
|
-
| *[takelage-bit](https://github.com/geospin-takelage/takelage-bit)* | takelage
|
21
|
+
| *[takelage-bit](https://github.com/geospin-takelage/takelage-bit)* | takelage bit server |
|
22
22
|
|
23
23
|
## Installation
|
24
24
|
|
@@ -57,6 +57,7 @@ tau purge | # Alias for tau [docker container purge](features/takelage/docker/do
|
|
57
57
|
tau push | # Alias for tau [bit clipboard push](features/takelage/bit/bit.clipboard.push.feature)
|
58
58
|
tau update | # Alias for tau [docker image update](features/takelage/docker/docker.image.update.feature)
|
59
59
|
tau version | # Alias for tau [self version](features/takelage/self/self.version.feature)
|
60
|
+
tau [bit check workspace](features/takelage/bit/bit.check.workspace.feature) | # Check if a bit workspace exists
|
60
61
|
tau [bit clipboard copy](features/takelage/bit/bit.clipboard.copy.feature) [DIR] [SCOPE] | # Copy new [DIR] to [SCOPE]
|
61
62
|
tau [bit clipboard paste](features/takelage/bit/bit.clipboard.paste.feature) [COMPONENT] [DIR] | # Paste bit [COMPONENT] into [DIR]
|
62
63
|
tau [bit clipboard pull](features/takelage/bit/bit.clipboard.pull.feature) | # Pull all updates for bit components from bit remote scopes
|
@@ -113,15 +114,13 @@ or *tau config*.
|
|
113
114
|
|
114
115
|
### Configuration Examples
|
115
116
|
|
116
|
-
- You should the following configuration items in your *~/.takelage.yml
|
117
|
+
- You should the following configuration items in your *~/.takelage.yml*
|
118
|
+
if you want to use a private bit remote server:
|
117
119
|
|
118
120
|
```yaml
|
119
121
|
---
|
120
|
-
bit_remote: 'ssh://bit@bit.example.com:
|
121
|
-
bit_ssh: 'ssh -p
|
122
|
-
docker_image: 'takelage'
|
123
|
-
docker_repo: 'hub.example.com'
|
124
|
-
docker_tagsurl: 'https://hub.example.com/v2/repositories/library/takelage/tags'
|
122
|
+
bit_remote: 'ssh://bit@bit.example.com:222:/bit'
|
123
|
+
bit_ssh: 'ssh -p 222 bit@bit.example.com'
|
125
124
|
```
|
126
125
|
|
127
126
|
- If you want to pin a specific docker tag for one of your projects
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Takelage
|
2
|
+
|
3
|
+
# takelage bit check
|
4
|
+
class BitCheck < SubCommandBase
|
5
|
+
|
6
|
+
include LoggingModule
|
7
|
+
include SystemModule
|
8
|
+
include ConfigModule
|
9
|
+
include BitCheckModule
|
10
|
+
|
11
|
+
#
|
12
|
+
# bit check workspace
|
13
|
+
#
|
14
|
+
desc 'workspace', 'Check if a bit workspace exists'
|
15
|
+
long_desc <<-LONGDESC.gsub("\n", "\x5")
|
16
|
+
Check if a bit workspace exists
|
17
|
+
LONGDESC
|
18
|
+
# Check if a bit workspace exists.
|
19
|
+
def workspace
|
20
|
+
exit bit_check_workspace
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# takelage bit check module
|
2
|
+
module BitCheckModule
|
3
|
+
|
4
|
+
# Backend method for bit check workspace.
|
5
|
+
# @return [Boolean] is this a bit workspace?
|
6
|
+
def bit_check_workspace
|
7
|
+
log.debug 'Check if this is a bit workspace'
|
8
|
+
|
9
|
+
cmd_bit_repo = config.active['bit_repo']
|
10
|
+
stdout_str_repo, stderr_str_repo, status_repo = run_and_check cmd_bit_repo
|
11
|
+
|
12
|
+
cmd_pwd = config.active['pwd']
|
13
|
+
stdout_str_dir, stderr_str_dir, status_dir = run_and_check cmd_pwd
|
14
|
+
|
15
|
+
dir = stdout_str_dir.strip
|
16
|
+
|
17
|
+
unless status_repo.exitstatus.zero?
|
18
|
+
log.debug "No bit workspace found in \"#{dir}\""
|
19
|
+
return false
|
20
|
+
end
|
21
|
+
|
22
|
+
true
|
23
|
+
end
|
24
|
+
end
|
data/lib/takelage/bit/cli.rb
CHANGED
@@ -5,9 +5,8 @@ module Takelage
|
|
5
5
|
# takelage bit
|
6
6
|
class Bit < SubCommandBase
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
include ConfigModule
|
8
|
+
desc 'check [COMMAND]', 'Check bit state'
|
9
|
+
subcommand 'check', BitCheck
|
11
10
|
|
12
11
|
desc 'clipboard [COMMAND]', 'Manage bit clipboard'
|
13
12
|
subcommand 'clipboard', BitClipboard
|
@@ -5,6 +5,11 @@ module BitClipboardModule
|
|
5
5
|
def bit_clipboard_copy(dir, scope)
|
6
6
|
log.debug "Running bit copy \"#{dir}\" to \"#{scope}\""
|
7
7
|
|
8
|
+
unless bit_check_workspace
|
9
|
+
log.error 'No bit workspace'
|
10
|
+
return
|
11
|
+
end
|
12
|
+
|
8
13
|
if git_check_workspace
|
9
14
|
unless git_check_master
|
10
15
|
log.error 'Not on git master branch'
|
@@ -19,12 +24,30 @@ module BitClipboardModule
|
|
19
24
|
|
20
25
|
log.debug "Adding the directory \"#{dir}\" as a tagged bit component"
|
21
26
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
27
|
+
bit_dev = config.active['bit_dev']
|
28
|
+
|
29
|
+
# check if scope is a candidate for a bit.dev remote scope
|
30
|
+
if scope.start_with? bit_dev + '.'
|
31
|
+
|
32
|
+
# check if bit.dev remote scope exists
|
33
|
+
cmd_bit_list_scope = config.active['bit_list_scope'] % {scope: scope}
|
34
|
+
stdout_str, stderr_str, status = run_and_check cmd_bit_list_scope
|
35
|
+
|
36
|
+
unless status.exitstatus.zero?
|
37
|
+
log.error "No bit.dev remote scope \"#{scope}\" found"
|
38
|
+
return
|
39
|
+
end
|
40
|
+
|
41
|
+
else
|
42
|
+
|
43
|
+
# check if bit remote scope is added to local workspace
|
44
|
+
cmd_bit_list_remotes = config.active['bit_list_remotes']
|
45
|
+
stdout_str, stderr_str, status = run_and_check cmd_bit_list_remotes
|
46
|
+
|
47
|
+
unless /.*\s+#{scope}\s+.*/m.match? stdout_str
|
48
|
+
log.error "No bit remote scope \"#{scope}\" found in local bit workspace"
|
49
|
+
return
|
50
|
+
end
|
28
51
|
end
|
29
52
|
|
30
53
|
# check if a README.bit file exists in a subdirectory
|
@@ -73,6 +96,11 @@ module BitClipboardModule
|
|
73
96
|
def bit_clipboard_paste(cid, dir)
|
74
97
|
log.debug "Running bit paste \"#{cid}\" to \"#{dir}\""
|
75
98
|
|
99
|
+
unless bit_check_workspace
|
100
|
+
log.error 'No bit workspace'
|
101
|
+
return
|
102
|
+
end
|
103
|
+
|
76
104
|
if git_check_workspace
|
77
105
|
unless git_check_master
|
78
106
|
log.error 'Not on git master branch'
|
@@ -97,6 +125,11 @@ module BitClipboardModule
|
|
97
125
|
def bit_clipboard_pull
|
98
126
|
log.debug "Running bit pull"
|
99
127
|
|
128
|
+
unless bit_check_workspace
|
129
|
+
log.error 'No bit workspace'
|
130
|
+
return
|
131
|
+
end
|
132
|
+
|
100
133
|
if git_check_workspace
|
101
134
|
unless git_check_master
|
102
135
|
log.error 'Not on git master branch'
|
@@ -122,6 +155,11 @@ module BitClipboardModule
|
|
122
155
|
def bit_clipboard_push
|
123
156
|
log.debug "Running bit push"
|
124
157
|
|
158
|
+
unless bit_check_workspace
|
159
|
+
log.error 'No bit workspace'
|
160
|
+
return
|
161
|
+
end
|
162
|
+
|
125
163
|
if git_check_workspace
|
126
164
|
unless git_check_master
|
127
165
|
log.error 'Not on git master branch'
|
@@ -5,6 +5,11 @@ module BitScopeModule
|
|
5
5
|
def bit_scope_add(scope)
|
6
6
|
log.debug "Adding bit remote scope \"#{scope}\" to local workspace"
|
7
7
|
|
8
|
+
unless bit_check_workspace
|
9
|
+
log.error 'No bit workspace'
|
10
|
+
return
|
11
|
+
end
|
12
|
+
|
8
13
|
if git_check_workspace
|
9
14
|
unless git_check_master
|
10
15
|
log.error 'Not on git master branch'
|
data/lib/takelage/default.yml
CHANGED
@@ -1,17 +1,24 @@
|
|
1
1
|
---
|
2
2
|
bit_add_dir: 'bit add --skip-update --id %{id} --main %{dir}/README.bit %{dir}'
|
3
3
|
bit_checkout_all: 'bit checkout --ignore-package-json --skip-update -i --all latest'
|
4
|
+
bit_dev: 'takelage'
|
4
5
|
bit_export_to_scope: 'bit export --skip-update %{scope}'
|
5
6
|
bit_export_all: 'bit export --skip-update'
|
6
7
|
bit_import_cid: 'bit import --ignore-package-json --skip-update -p %{dir} %{cid}'
|
7
8
|
bit_import_all: 'bit import --skip-update --ignore-package-json -m manual'
|
8
9
|
bit_list_remotes: 'bit remote --skip-update'
|
10
|
+
bit_list_scope: 'bit list --skip-update --raw %{scope}'
|
11
|
+
bit_remote: ''
|
12
|
+
bit_repo: 'bit status'
|
9
13
|
bit_scope_root: '/bit'
|
10
14
|
bit_scope_list: 'find %{root} -name scope.json'
|
11
15
|
bit_scope_new: 'mkdir -p %{root}/%{scope} && cd %{root}/%{scope} && bit init -b'
|
12
16
|
bit_scope_remove: 'rm -fr %{root}/%{scope}'
|
17
|
+
bit_ssh: ''
|
13
18
|
bit_tag_id: 'bit tag --skip-update --skip-tests %{id}'
|
14
19
|
bit_tag_all: 'bit tag --all'
|
20
|
+
docker_image: 'takelage'
|
21
|
+
docker_repo: 'takelage'
|
15
22
|
docker_socket_agent_port: 20000
|
16
23
|
docker_socket_agent_ssh_port: 20001
|
17
24
|
docker_socket_agent_extra_port: 20002
|
@@ -21,10 +28,12 @@ docker_socket_gpgconf: 'gpgconf --list-dirs'
|
|
21
28
|
docker_socket_kill: 'sudo kill -SIGTERM %{pid}'
|
22
29
|
docker_socket_start: 'sudo socat TCP-LISTEN:%{port},bind=%{host},reuseaddr,fork UNIX-CLIENT:%{path}'
|
23
30
|
docker_tag: 'latest'
|
31
|
+
docker_tagsurl: 'https://hub.docker.com/v2/repositories/takelage/takelage/tags'
|
32
|
+
git_branch: 'git symbolic-ref HEAD'
|
33
|
+
git_repo: 'git -C . rev-parse'
|
34
|
+
git_status: 'git status --porcelain'
|
35
|
+
git_unstaged: 'git diff --exit-code'
|
36
|
+
git_uncommitted: 'git diff --cached --exit-code'
|
24
37
|
info_project_main: 'project.yml'
|
25
38
|
info_project_private: 'private/project.yml'
|
26
|
-
|
27
|
-
#bit_ssh: 'ssh -p 2222 bit@bit.example.com'
|
28
|
-
#docker_image: 'takelage'
|
29
|
-
#docker_repo: 'hub.docker.com'
|
30
|
-
#docker_tagsurl: 'https://hub.docker.com/v2/repositories/library/takelage/tags'
|
39
|
+
pwd: 'pwd'
|
@@ -163,7 +163,7 @@ module DockerContainerModule
|
|
163
163
|
|
164
164
|
# Get container name by id.
|
165
165
|
def _get_container_name_by_id container
|
166
|
-
log.debug "Getting name of container #{container}"
|
166
|
+
log.debug "Getting name of container \"#{container}\""
|
167
167
|
|
168
168
|
cmd_get_container_name_by_id = 'docker ps ' +
|
169
169
|
"--filter id=#{container} "+
|
@@ -171,13 +171,17 @@ module DockerContainerModule
|
|
171
171
|
|
172
172
|
stdout_str, stderr_str, status = run_and_check cmd_get_container_name_by_id
|
173
173
|
|
174
|
-
stdout_str.chomp
|
174
|
+
name = stdout_str.chomp
|
175
|
+
|
176
|
+
log.debug "Container #{container} has name \"#{name}\""
|
177
|
+
|
178
|
+
name
|
175
179
|
end
|
176
180
|
|
177
181
|
# Get all docker containers.
|
178
182
|
# @return [Array] list of docker containers
|
179
183
|
def _get_containers
|
180
|
-
log.debug "Getting all #{@docker_image}
|
184
|
+
log.debug "Getting all containers of image \"#{@docker_image}\""
|
181
185
|
|
182
186
|
cmd_docker_get = 'docker ps ' +
|
183
187
|
'--all ' +
|
@@ -8,9 +8,9 @@ module GitCheckModule
|
|
8
8
|
|
9
9
|
return false unless git_check_workspace
|
10
10
|
|
11
|
-
cmd_git_unstaged = '
|
12
|
-
cmd_git_uncommitted = '
|
13
|
-
cmd_git_status = '
|
11
|
+
cmd_git_unstaged = config.active['git_unstaged']
|
12
|
+
cmd_git_uncommitted = config.active['git_uncommitted']
|
13
|
+
cmd_git_status = config.active['git_status']
|
14
14
|
|
15
15
|
stdout_str, stderr_str, status_unstaged = run_and_check cmd_git_unstaged
|
16
16
|
stdout_str, stderr_str, status_uncommitted = run_and_check cmd_git_uncommitted
|
@@ -31,7 +31,7 @@ module GitCheckModule
|
|
31
31
|
|
32
32
|
return false unless git_check_workspace
|
33
33
|
|
34
|
-
cmd_get_branch = '
|
34
|
+
cmd_get_branch = config.active['git_branch']
|
35
35
|
stdout_str, stderr_str, status = run_and_check cmd_get_branch
|
36
36
|
|
37
37
|
branch = stdout_str.strip.split('/')[-1]
|
@@ -46,10 +46,10 @@ module GitCheckModule
|
|
46
46
|
def git_check_workspace
|
47
47
|
log.debug 'Check if this is a git workspace'
|
48
48
|
|
49
|
-
|
50
|
-
stdout_str_repo, stderr_str_repo, status_repo = run_and_check
|
49
|
+
cmd_git_repo = config.active['git_repo']
|
50
|
+
stdout_str_repo, stderr_str_repo, status_repo = run_and_check cmd_git_repo
|
51
51
|
|
52
|
-
cmd_pwd = 'pwd'
|
52
|
+
cmd_pwd = config.active['pwd']
|
53
53
|
stdout_str_dir, stderr_str_dir, status_dir = run_and_check cmd_pwd
|
54
54
|
|
55
55
|
dir = stdout_str_dir.strip
|
data/lib/takelage/version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.4.0
|
data/lib/takelage.rb
CHANGED
@@ -19,6 +19,8 @@ require_relative 'takelage/lib/project'
|
|
19
19
|
require_relative 'takelage/git/check/module'
|
20
20
|
require_relative 'takelage/git/check/cli'
|
21
21
|
require_relative 'takelage/git/cli'
|
22
|
+
require_relative 'takelage/bit/check/module'
|
23
|
+
require_relative 'takelage/bit/check/cli'
|
22
24
|
require_relative 'takelage/bit/scope/module'
|
23
25
|
require_relative 'takelage/bit/scope/cli'
|
24
26
|
require_relative 'takelage/bit/clipboard/module'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: takelage
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Geospin
|
@@ -177,6 +177,8 @@ files:
|
|
177
177
|
- bin/tau
|
178
178
|
- lib/Thorfile
|
179
179
|
- lib/takelage.rb
|
180
|
+
- lib/takelage/bit/check/cli.rb
|
181
|
+
- lib/takelage/bit/check/module.rb
|
180
182
|
- lib/takelage/bit/cli.rb
|
181
183
|
- lib/takelage/bit/clipboard/cli.rb
|
182
184
|
- lib/takelage/bit/clipboard/module.rb
|