qb 0.3.8 → 0.3.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.yardopts +4 -0
- data/exe/.qb_interop_receive +39 -0
- data/exe/qb +8 -5
- data/lib/qb.rb +64 -19
- data/lib/qb/cli/run.rb +1 -1
- data/lib/qb/github.rb +4 -0
- data/lib/qb/github/api.rb +43 -0
- data/lib/qb/github/issue.rb +83 -0
- data/lib/qb/github/repo_id.rb +127 -0
- data/lib/qb/github/resource.rb +59 -0
- data/lib/qb/github/types.rb +45 -0
- data/lib/qb/package.rb +131 -0
- data/lib/qb/package/gem.rb +2 -4
- data/lib/qb/package/version.rb +175 -2
- data/lib/qb/path.rb +2 -2
- data/lib/qb/repo.rb +137 -1
- data/lib/qb/repo/git.rb +55 -23
- data/lib/qb/repo/git/github.rb +137 -0
- data/lib/qb/role.rb +74 -30
- data/lib/qb/util.rb +1 -4
- data/lib/qb/util/docker_mixin.rb +30 -2
- data/lib/qb/util/interop.rb +68 -7
- data/lib/qb/util/logging.rb +215 -0
- data/lib/qb/util/stdio.rb +25 -9
- data/lib/qb/version.rb +16 -28
- data/library/stream +2 -2
- data/plugins/filter_plugins/ruby_interop_plugins.py +49 -31
- data/qb.gemspec +16 -4
- data/roles/qb.role/defaults/main.yml +6 -2
- data/roles/{qb.bump → qb/pkg/bump}/.qb-options.yml +0 -0
- data/roles/{qb.bump → qb/pkg/bump}/README.md +0 -0
- data/roles/{qb.bump → qb/pkg/bump}/defaults/main.yml +0 -0
- data/roles/{qb.bump → qb/pkg/bump}/library/bump +0 -0
- data/roles/{qb.bump → qb/pkg/bump}/meta/main.yml +0 -0
- data/roles/{qb.bump → qb/pkg/bump}/meta/qb.yml +0 -0
- data/roles/{qb.bump → qb/pkg/bump}/tasks/frontend/level/dev.yml +0 -0
- data/roles/{qb.bump → qb/pkg/bump}/tasks/frontend/level/rc.yml +0 -0
- data/roles/{qb.bump → qb/pkg/bump}/tasks/frontend/level/release.yml +0 -0
- data/roles/{qb.bump → qb/pkg/bump}/tasks/frontend/main.yml +0 -0
- data/roles/{qb.bump → qb/pkg/bump}/tasks/main.yml +1 -1
- data/roles/{qb.qb_role → qb/role/qb}/.qb-options.yml +0 -0
- data/roles/{qb.qb_role → qb/role/qb}/defaults/main.yml +0 -0
- data/roles/{qb.qb_role → qb/role/qb}/meta/main.yml +0 -0
- data/roles/{qb.qb_role → qb/role/qb}/meta/qb.yml +0 -0
- data/roles/{qb.qb_role → qb/role/qb}/tasks/main.yml +0 -0
- data/roles/{qb.qb_role → qb/role/qb}/templates/.gitkeep +0 -0
- data/roles/{qb.qb_role → qb/role/qb}/templates/qb.yml.j2 +0 -0
- data/roles/qb/test/rspec/spec/issue/defaults/main.yml +2 -0
- data/roles/qb/test/rspec/spec/issue/meta/main.yml +8 -0
- data/roles/qb/test/rspec/spec/issue/meta/qb.yml +67 -0
- data/roles/qb/test/rspec/spec/issue/tasks/main.yml +21 -0
- metadata +95 -26
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d3fd3a036ee3a1411833a1e6ac82066a7ee291c0
|
4
|
+
data.tar.gz: 9caacbd64094d48b491115d62a80940e1932438f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bf5bbd2d09e43ba8be882cfbf5fee05669c124c7366eda20b31e1ad86e13ec844dc7c9a237d342475994a187c12565ab7f8d8d21d5f88ab92b79bf128dbfae1b
|
7
|
+
data.tar.gz: 4f6351760bb78e66626ea2870d74c48468d6b5a102d12371a5caab719718dd799178762c4ac0ec755c55b73f9aed756572ca708c191b859293703a57914c7e22
|
data/.yardopts
CHANGED
@@ -0,0 +1,39 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# This script is the entry point for the Ansible "Ruby Interop" filter plugins
|
4
|
+
# that execute QB Ruby code via a sub-process to do shitty RPC.
|
5
|
+
#
|
6
|
+
# @todo
|
7
|
+
# Should prob eventually be merged into `//exe/qb` under a command, but
|
8
|
+
# not gonna right now. At least it's not a string in the Python file anymore.
|
9
|
+
#
|
10
|
+
|
11
|
+
# init bundler in dev env
|
12
|
+
if ENV['QB_DEV_ENV']
|
13
|
+
ENV.each {|k, v|
|
14
|
+
if k.start_with? 'QB_DEV_ENV_'
|
15
|
+
ENV[k.sub('QB_DEV_ENV_', '')] = v
|
16
|
+
end
|
17
|
+
}
|
18
|
+
require 'bundler/setup'
|
19
|
+
end
|
20
|
+
|
21
|
+
# Set the thread name so that logs make sense.
|
22
|
+
require 'thread'
|
23
|
+
Thread.current.name = "qb_interop_receive"
|
24
|
+
|
25
|
+
require 'qb'
|
26
|
+
|
27
|
+
# Connect to the master QB process for logging to CLI STDOUT (if it's there,
|
28
|
+
# which it should be in this case).
|
29
|
+
if ENV['QB_STDIO_ERR']
|
30
|
+
$stderr = UNIXSocket.new ENV['QB_STDIO_ERR']
|
31
|
+
|
32
|
+
QB::Util::Logging.setup
|
33
|
+
|
34
|
+
QB.debug "Connected to QB stderr stream at #{ ENV['QB_STDIO_ERR'] } #{ $stderr.path }."
|
35
|
+
end
|
36
|
+
|
37
|
+
# Kick off the interop. Payload will be read from STDIN and results written to
|
38
|
+
# STDOUT (both YAML at the moment).
|
39
|
+
QB::Util::Interop.receive
|
data/exe/qb
CHANGED
@@ -5,6 +5,7 @@ require 'pp'
|
|
5
5
|
require 'yaml'
|
6
6
|
require 'json'
|
7
7
|
require 'fileutils'
|
8
|
+
require 'thread'
|
8
9
|
|
9
10
|
require 'cmds'
|
10
11
|
|
@@ -19,20 +20,22 @@ DEBUG_ARGS = ['-D', '--DEBUG']
|
|
19
20
|
|
20
21
|
def set_debug! args
|
21
22
|
if DEBUG_ARGS.any? {|arg| args.include? arg}
|
22
|
-
|
23
|
-
QB.debug "ON"
|
23
|
+
QB::Util::Logging.setup level: :debug
|
24
24
|
DEBUG_ARGS.each {|arg| args.delete arg}
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
28
|
|
29
29
|
def main args
|
30
|
+
Thread.current.name = 'main'
|
31
|
+
logger = SemanticLogger['qb/exe/qb#main']
|
32
|
+
|
30
33
|
set_debug! args
|
31
|
-
|
34
|
+
logger.debug args: args
|
32
35
|
|
33
36
|
QB.check_ansible_version
|
34
37
|
|
35
|
-
|
38
|
+
logger.debug "Switch arg" => args[0]
|
36
39
|
|
37
40
|
status = case args[0]
|
38
41
|
when nil, '-h', '--help', 'help'
|
@@ -53,7 +56,7 @@ def main args
|
|
53
56
|
QB::CLI.run args
|
54
57
|
end
|
55
58
|
|
56
|
-
|
59
|
+
logger.debug "Exit status", status
|
57
60
|
|
58
61
|
# exit status
|
59
62
|
exit status
|
data/lib/qb.rb
CHANGED
@@ -1,40 +1,84 @@
|
|
1
|
+
# Requirements
|
2
|
+
# =======================================================================
|
3
|
+
|
4
|
+
# Stdlib
|
5
|
+
# -----------------------------------------------------------------------
|
6
|
+
|
7
|
+
# Deps
|
8
|
+
# -----------------------------------------------------------------------
|
1
9
|
require 'nrser/extras'
|
2
10
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
11
|
+
# Project / Package
|
12
|
+
# -----------------------------------------------------------------------
|
13
|
+
require 'qb/errors'
|
14
|
+
require 'qb/version'
|
15
|
+
require 'qb/util'
|
16
|
+
require 'qb/path'
|
17
|
+
|
18
|
+
|
19
|
+
# Refinements
|
20
|
+
# =======================================================================
|
21
|
+
|
22
|
+
require 'nrser/refinements'
|
23
|
+
using NRSER
|
24
|
+
|
25
|
+
require 'nrser/refinements/types'
|
26
|
+
using NRSER::Types
|
27
|
+
|
28
|
+
|
29
|
+
# Definitions
|
30
|
+
# =======================================================================
|
7
31
|
|
8
32
|
module QB
|
33
|
+
|
34
|
+
# Constants
|
35
|
+
# =====================================================================
|
36
|
+
|
9
37
|
ROOT = (Pathname.new(__FILE__).dirname + '..').expand_path
|
10
38
|
GEM_ROLES_DIR = ROOT + 'roles'
|
11
39
|
USER_ROLES_DIR = Pathname.new(ENV['HOME']).join '.ansible', 'roles'
|
12
40
|
|
13
41
|
|
42
|
+
# Mixins
|
43
|
+
# =====================================================================
|
44
|
+
|
45
|
+
include SemanticLogger::Loggable
|
46
|
+
|
47
|
+
|
14
48
|
def self.debug *args
|
15
|
-
return unless ENV['QB_DEBUG'] && args.length > 0
|
16
|
-
|
17
|
-
header = 'DEBUG'
|
18
|
-
|
19
49
|
if args[0].is_a? String
|
20
|
-
|
21
|
-
end
|
22
|
-
|
23
|
-
dumpObj = case args.length
|
24
|
-
when 0
|
25
|
-
header
|
26
|
-
when 1
|
27
|
-
{header => args[0]}
|
50
|
+
logger.debug *args
|
28
51
|
else
|
29
|
-
|
52
|
+
logger.debug payload: args
|
30
53
|
end
|
31
54
|
|
32
|
-
#
|
33
|
-
|
55
|
+
# return unless ENV['QB_DEBUG'] && args.length > 0
|
56
|
+
#
|
57
|
+
# header = 'DEBUG'
|
58
|
+
#
|
59
|
+
# if args[0].is_a? String
|
60
|
+
# header += " " + args.shift
|
61
|
+
# end
|
62
|
+
#
|
63
|
+
# dumpObj = case args.length
|
64
|
+
# when 0
|
65
|
+
# header
|
66
|
+
# when 1
|
67
|
+
# {header => args[0]}
|
68
|
+
# else
|
69
|
+
# {header => args}
|
70
|
+
# end
|
71
|
+
#
|
72
|
+
# # $stderr.puts("DEBUG " + format(msg, values))
|
73
|
+
# $stderr.puts dumpObj.pretty_inspect
|
34
74
|
end
|
35
75
|
|
36
76
|
end
|
37
77
|
|
78
|
+
|
79
|
+
# Post-Processing
|
80
|
+
# =======================================================================
|
81
|
+
|
38
82
|
# needs QB::*_ROLES_DIR
|
39
83
|
require 'qb/role'
|
40
84
|
require 'qb/options'
|
@@ -47,3 +91,4 @@ require 'qb/ansible_module'
|
|
47
91
|
|
48
92
|
require 'qb/package'
|
49
93
|
|
94
|
+
require 'qb/github'
|
data/lib/qb/cli/run.rb
CHANGED
data/lib/qb/github.rb
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
# Requirements
|
2
|
+
# =======================================================================
|
3
|
+
|
4
|
+
# Stdlib
|
5
|
+
# -----------------------------------------------------------------------
|
6
|
+
|
7
|
+
# Deps
|
8
|
+
# -----------------------------------------------------------------------
|
9
|
+
require 'octokit'
|
10
|
+
|
11
|
+
# Project / Package
|
12
|
+
# -----------------------------------------------------------------------
|
13
|
+
|
14
|
+
|
15
|
+
# Refinements
|
16
|
+
# =======================================================================
|
17
|
+
|
18
|
+
|
19
|
+
# Declarations
|
20
|
+
# =======================================================================
|
21
|
+
|
22
|
+
|
23
|
+
# Definitions
|
24
|
+
# =======================================================================
|
25
|
+
|
26
|
+
|
27
|
+
# @todo document QB::GitHub::API module.
|
28
|
+
module QB::GitHub::API
|
29
|
+
|
30
|
+
def self.client
|
31
|
+
@client ||= if token = ENV['GH_TOKEN']
|
32
|
+
Octokit::Client.new access_token: token
|
33
|
+
else
|
34
|
+
Octokit::Client.new
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
end # module QB::GitHub::API
|
39
|
+
|
40
|
+
|
41
|
+
|
42
|
+
# Post-Processing
|
43
|
+
# =======================================================================
|
@@ -0,0 +1,83 @@
|
|
1
|
+
# Requirements
|
2
|
+
# =======================================================================
|
3
|
+
|
4
|
+
# Stdlib
|
5
|
+
# -----------------------------------------------------------------------
|
6
|
+
|
7
|
+
# Deps
|
8
|
+
# -----------------------------------------------------------------------
|
9
|
+
|
10
|
+
# Project / Package
|
11
|
+
# -----------------------------------------------------------------------
|
12
|
+
require 'qb/github/resource'
|
13
|
+
|
14
|
+
|
15
|
+
# Refinements
|
16
|
+
# =======================================================================
|
17
|
+
|
18
|
+
require 'nrser/refinements'
|
19
|
+
using NRSER
|
20
|
+
|
21
|
+
require 'nrser/refinements/types'
|
22
|
+
using NRSER::Types
|
23
|
+
|
24
|
+
|
25
|
+
# Declarations
|
26
|
+
# =======================================================================
|
27
|
+
|
28
|
+
|
29
|
+
# Definitions
|
30
|
+
# =======================================================================
|
31
|
+
|
32
|
+
|
33
|
+
# @todo document QB::GitHub::Issue class.
|
34
|
+
class QB::GitHub::Issue < QB::GitHub::Resource
|
35
|
+
|
36
|
+
# Constants
|
37
|
+
# ======================================================================
|
38
|
+
|
39
|
+
|
40
|
+
# Class Methods
|
41
|
+
# ======================================================================
|
42
|
+
|
43
|
+
|
44
|
+
# @todo Document find method.
|
45
|
+
#
|
46
|
+
# @param [type] arg_name
|
47
|
+
# @todo Add name param description.
|
48
|
+
#
|
49
|
+
# @return [return_type]
|
50
|
+
# @todo Document return value.
|
51
|
+
#
|
52
|
+
def self.find_by repo_id:, number:
|
53
|
+
new QB::GitHub::API.client.issue( repo_id.path, number )
|
54
|
+
end # .find
|
55
|
+
|
56
|
+
|
57
|
+
|
58
|
+
# Properties
|
59
|
+
# ======================================================================
|
60
|
+
|
61
|
+
prop :title, type: t.str, source: ->() { self[:title] }
|
62
|
+
prop :title_filename, source: :title_filename
|
63
|
+
|
64
|
+
# Constructor
|
65
|
+
# ======================================================================
|
66
|
+
|
67
|
+
# Instance Methods
|
68
|
+
# ======================================================================
|
69
|
+
|
70
|
+
def [] key
|
71
|
+
@octokit_resource[key]
|
72
|
+
end
|
73
|
+
|
74
|
+
def title_filename
|
75
|
+
|
76
|
+
end
|
77
|
+
|
78
|
+
end # class QB::GitHub::Issue
|
79
|
+
|
80
|
+
|
81
|
+
|
82
|
+
# Post-Processing
|
83
|
+
# =======================================================================
|
@@ -0,0 +1,127 @@
|
|
1
|
+
# Requirements
|
2
|
+
# =======================================================================
|
3
|
+
|
4
|
+
# Stdlib
|
5
|
+
# -----------------------------------------------------------------------
|
6
|
+
|
7
|
+
# Deps
|
8
|
+
# -----------------------------------------------------------------------
|
9
|
+
|
10
|
+
# Project / Package
|
11
|
+
# -----------------------------------------------------------------------
|
12
|
+
require 'qb/util/resource'
|
13
|
+
require 'qb/github/types'
|
14
|
+
|
15
|
+
|
16
|
+
# Refinements
|
17
|
+
# =======================================================================
|
18
|
+
|
19
|
+
require 'nrser/refinements'
|
20
|
+
using NRSER
|
21
|
+
|
22
|
+
require 'nrser/refinements/types'
|
23
|
+
using NRSER::Types
|
24
|
+
|
25
|
+
|
26
|
+
# Definitions
|
27
|
+
# =======================================================================
|
28
|
+
|
29
|
+
|
30
|
+
# Unique identifier for a GitHub repo, which is a composite of an `owner`
|
31
|
+
# and a `name` string.
|
32
|
+
#
|
33
|
+
class QB::GitHub::RepoID < QB::Util::Resource
|
34
|
+
|
35
|
+
# Configuration
|
36
|
+
# =====================================================================
|
37
|
+
|
38
|
+
# Props
|
39
|
+
# ---------------------------------------------------------------------
|
40
|
+
|
41
|
+
### Primary Properties
|
42
|
+
|
43
|
+
prop :owner, type: QB::GitHub::Types.repo_owner
|
44
|
+
prop :name, type: QB::GitHub::Types.repo_name
|
45
|
+
|
46
|
+
|
47
|
+
### Derived Properties
|
48
|
+
|
49
|
+
prop :path, type: t.non_empty_str, source: :path
|
50
|
+
prop :full_name, type: t.maybe(t.str), source: :full_name
|
51
|
+
|
52
|
+
|
53
|
+
# Class Methods
|
54
|
+
# ======================================================================
|
55
|
+
|
56
|
+
|
57
|
+
# Instance Methods
|
58
|
+
# ======================================================================
|
59
|
+
|
60
|
+
# "Path" on GitHub for the repo - the `<owner>/<name>` part that comes
|
61
|
+
# after the host in URLs.
|
62
|
+
#
|
63
|
+
# Called `full_name` in GitHub API (we include a `#full_name` method alias
|
64
|
+
# as well).
|
65
|
+
#
|
66
|
+
# This is also what we return for {#to_s}.
|
67
|
+
#
|
68
|
+
# @example
|
69
|
+
# repo_id = QB::GitHub::RepoID.new owner: 'nrser', name: 'qb'
|
70
|
+
# repo_id.path
|
71
|
+
# # => "nrser/qb"
|
72
|
+
#
|
73
|
+
# @return [String]
|
74
|
+
#
|
75
|
+
def path
|
76
|
+
"#{ owner }/#{ name }"
|
77
|
+
end # #path
|
78
|
+
|
79
|
+
alias_method :full_name, :path
|
80
|
+
alias_method :to_s, :path
|
81
|
+
|
82
|
+
|
83
|
+
# SSH protocol URL string for use as a Git remote.
|
84
|
+
#
|
85
|
+
# @example
|
86
|
+
# repo_id = QB::GitHub::RepoID.new owner: 'nrser', name: 'qb'
|
87
|
+
# repo_id.git_ssh_url
|
88
|
+
# # => "git@github.com:nrser/qb.git"
|
89
|
+
#
|
90
|
+
# @return [String]
|
91
|
+
#
|
92
|
+
def git_ssh_url
|
93
|
+
"git@github.com:#{ path }.git"
|
94
|
+
end # #to_git_ssh_url
|
95
|
+
|
96
|
+
|
97
|
+
# HTTPS protocol URL string for use as a Git remote.
|
98
|
+
#
|
99
|
+
# @example
|
100
|
+
# repo_id = QB::GitHub::RepoID.new owner: 'nrser', name: 'qb'
|
101
|
+
# repo_id.git_https_url
|
102
|
+
# # => "https://github.com/nrser/qb.git"
|
103
|
+
#
|
104
|
+
# @return [String]
|
105
|
+
#
|
106
|
+
def git_https_url
|
107
|
+
"https://github.com/#{ path }.git"
|
108
|
+
end
|
109
|
+
|
110
|
+
|
111
|
+
# Return {#git_ssh_url} or {#git_https_url} depending on `protocol`
|
112
|
+
# parameter.
|
113
|
+
#
|
114
|
+
# @param [Symbol] protocol
|
115
|
+
# `:ssh` or `:https`.
|
116
|
+
#
|
117
|
+
# @return [String]
|
118
|
+
# URL.
|
119
|
+
#
|
120
|
+
def git_url protocol
|
121
|
+
t.match protocol,
|
122
|
+
:ssh, ->( _ ) { git_ssh_url },
|
123
|
+
:https, ->( _ ) { git_https_url }
|
124
|
+
end # #to_url
|
125
|
+
|
126
|
+
|
127
|
+
end # class QB::GitHub::RepoID
|