labclient 0.4.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/labclient/client/helpers.rb +9 -1
- data/lib/labclient/client/meta.rb +1 -0
- data/lib/labclient/client/setup.rb +4 -3
- data/lib/labclient/client.rb +11 -8
- data/lib/labclient/feature_flags/list.rb +1 -1
- data/lib/labclient/files/file.rb +11 -0
- data/lib/labclient/files/show.rb +6 -6
- data/lib/labclient/groups/ldap/sync.rb +0 -1
- data/lib/labclient/http.rb +16 -6
- data/lib/labclient/issues/delete.rb +2 -2
- data/lib/labclient/jobs/artifacts.rb +24 -8
- data/lib/labclient/jobs/job.rb +10 -3
- data/lib/labclient/klass.rb +4 -9
- data/lib/labclient/lab_struct.rb +39 -7
- data/lib/labclient/merge_requests/delete.rb +10 -2
- data/lib/labclient/notifications/update.rb +1 -1
- data/lib/labclient/projects/methods.rb +11 -3
- data/lib/labclient/registry/repository.rb +5 -0
- data/lib/labclient/repository/repository_tree.rb +7 -0
- data/lib/labclient/repository/tree.rb +1 -1
- data/lib/labclient/terraform/create.rb +23 -0
- data/lib/labclient/terraform/delete.rb +16 -0
- data/lib/labclient/terraform/lock.rb +17 -0
- data/lib/labclient/terraform/show.rb +22 -0
- data/lib/labclient/terraform/terraform_state.rb +11 -0
- data/lib/labclient/terraform/unlock.rb +16 -0
- data/lib/labclient/version.rb +7 -1
- data/lib/labclient.rb +17 -7
- metadata +17 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 866bed156a753e7148f538c380d453899259cae098cca155fba3ed81517d71c7
|
4
|
+
data.tar.gz: 2f52c954789f226ead00127e029428f2bc32f85757112211082d0a204ecd1c53
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 13c0c5f1201b8a4a4d77ad09b7496a6ea1c14af360e7d19cce1877467a6b6a70acb018025a36c2746532ffed98e258e6960b03436ebb24bc717d6c895f35af25
|
7
|
+
data.tar.gz: b1b10db7e1ab7a4ed4a428330d5fac26fead66f09c220b4147e236aa380066d40a439cb6beb60ab0afd321f4620ffe654250af6121114481d935756cc671a901
|
@@ -94,7 +94,15 @@ module LabClient
|
|
94
94
|
|
95
95
|
# Helper for Accessing the Retry Headers
|
96
96
|
def retry_after
|
97
|
-
|
97
|
+
retry_header || delay_factor || 1
|
98
|
+
end
|
99
|
+
|
100
|
+
def retry_header
|
101
|
+
resp.headers['retry-after']&.to_i
|
102
|
+
end
|
103
|
+
|
104
|
+
def retry_debug_headers
|
105
|
+
resp.headers.select { |k, _v| k.include? 'ratelimit' }
|
98
106
|
end
|
99
107
|
|
100
108
|
# Handle Retry Logic
|
@@ -17,14 +17,15 @@ module LabClient
|
|
17
17
|
# If nothing entered Prompt for Input
|
18
18
|
def prompt_for_url
|
19
19
|
print 'Enter GitLab URL (e.g. https://gitlab.com): '
|
20
|
-
@settings[:url] = $stdin.gets
|
20
|
+
@settings[:url] = ENV['LABCLIENT_TESTING'] ? 'testu' : $stdin.gets&.chomp
|
21
21
|
raise 'LabClient Error - Missing URL!' if @settings[:url].blank?
|
22
22
|
end
|
23
23
|
|
24
24
|
# Check for Token
|
25
25
|
def prompt_for_token
|
26
26
|
print 'Enter Personal Access Token: '
|
27
|
-
|
27
|
+
|
28
|
+
@settings[:token] = ENV['LABCLIENT_TESTING'] ? 'testt' : $stdin.gets&.chomp
|
28
29
|
end
|
29
30
|
|
30
31
|
# Fill Defaults
|
@@ -35,7 +36,7 @@ module LabClient
|
|
35
36
|
@settings[:debug] = false if @settings[:quiet].nil?
|
36
37
|
@settings[:debug] = false if @settings[:debug].nil?
|
37
38
|
@settings[:token_type] = 'Private-Token' if @settings[:token_type].nil?
|
38
|
-
@settings[:retry] = { max: 5, delay_factor:
|
39
|
+
@settings[:retry] = { max: 5, delay_factor: 10, count: 0 } if @settings[:retry].nil?
|
39
40
|
end
|
40
41
|
|
41
42
|
# Support for Named Profiles
|
data/lib/labclient/client.rb
CHANGED
@@ -37,7 +37,6 @@ module LabClient
|
|
37
37
|
debug_handler if debug?
|
38
38
|
|
39
39
|
post_request_handlers
|
40
|
-
|
41
40
|
process resp
|
42
41
|
rescue LabClient::Error => e
|
43
42
|
logger.fatal('Request Failed', e.error_details) unless quiet?
|
@@ -46,7 +45,7 @@ module LabClient
|
|
46
45
|
self.retries += 1
|
47
46
|
|
48
47
|
# Assume Retry After by Default
|
49
|
-
logger.debug('Retry After', value: retry_after) if debug?
|
48
|
+
logger.debug('Retry After', value: retry_after, retry_debug_headers: retry_debug_headers) if debug?
|
50
49
|
self.delay = retry_after if resp.headers.key? 'retry-after'
|
51
50
|
|
52
51
|
self.delay += delay_factor
|
@@ -67,6 +66,9 @@ module LabClient
|
|
67
66
|
# Save Client
|
68
67
|
save_client
|
69
68
|
|
69
|
+
# Reset Delay/Retry Factor
|
70
|
+
retry_update if resp.success?
|
71
|
+
|
70
72
|
# Exit on Max Retries
|
71
73
|
raise LabClient::Error.new(resp), resp.friendly_error if retry_max?
|
72
74
|
|
@@ -74,9 +76,6 @@ module LabClient
|
|
74
76
|
|
75
77
|
# Drop in raw path
|
76
78
|
save_path
|
77
|
-
|
78
|
-
# Reset Delay/Retry Factor
|
79
|
-
retry_update
|
80
79
|
end
|
81
80
|
|
82
81
|
# Assume we want LabStruct if @klass is ever nil
|
@@ -85,13 +84,17 @@ module LabClient
|
|
85
84
|
when LabStruct
|
86
85
|
klass ? klass.new(resp.data, resp, self) : resp.data
|
87
86
|
when Array
|
88
|
-
if
|
87
|
+
if klass.nil?
|
89
88
|
resp.data
|
90
89
|
else
|
91
|
-
PaginatedResponse.new(
|
90
|
+
PaginatedResponse.new(klass, resp, self)
|
92
91
|
end
|
92
|
+
# Return Response/Status Object if there is no output otherwise
|
93
|
+
when NilClass
|
94
|
+
resp
|
95
|
+
# Default handler / if klass defined store plain response in data
|
93
96
|
else
|
94
|
-
resp.data
|
97
|
+
klass ? klass.new({ data: resp.data, response: resp }, resp, self) : resp
|
95
98
|
end
|
96
99
|
end
|
97
100
|
end
|
data/lib/labclient/files/show.rb
CHANGED
@@ -3,11 +3,11 @@ module LabClient
|
|
3
3
|
# Specifics
|
4
4
|
class Files < Common
|
5
5
|
doc 'Show' do
|
6
|
-
desc 'Allows you to receive information about file in repository like name, size, content [Project ID, File Path, Ref (
|
6
|
+
desc 'Allows you to receive information about file in repository like name, size, content [Project ID, File Path, Ref (main default), kind]'
|
7
7
|
example 'client.files.show(264, "README.md")'
|
8
8
|
|
9
9
|
markdown <<~DOC
|
10
|
-
Ref will default to `
|
10
|
+
Ref will default to `main`
|
11
11
|
|
12
12
|
Kind can be left empty or set to either :raw or :blame
|
13
13
|
DOC
|
@@ -15,12 +15,12 @@ module LabClient
|
|
15
15
|
|
16
16
|
doc 'Show' do
|
17
17
|
desc 'Raw Content'
|
18
|
-
example 'client.files.show(264, "README.md", :
|
18
|
+
example 'client.files.show(264, "README.md", :main, :raw)'
|
19
19
|
end
|
20
20
|
|
21
21
|
doc 'Show' do
|
22
22
|
desc 'Blame'
|
23
|
-
example 'client.files.show(264, "README.md", :
|
23
|
+
example 'client.files.show(264, "README.md", :main, :blame)'
|
24
24
|
end
|
25
25
|
|
26
26
|
doc 'Show' do
|
@@ -31,7 +31,7 @@ module LabClient
|
|
31
31
|
DOC
|
32
32
|
end
|
33
33
|
|
34
|
-
def show(project_id, file_path, ref = :
|
34
|
+
def show(project_id, file_path, ref = :main, kind = nil)
|
35
35
|
kind = case kind
|
36
36
|
when :raw
|
37
37
|
'/raw'
|
@@ -45,7 +45,7 @@ module LabClient
|
|
45
45
|
# Path Name Encoding
|
46
46
|
file_path = CGI.escape(file_path)
|
47
47
|
|
48
|
-
client.request(:get, "projects/#{project_id}/repository/files/#{file_path}#{kind}",
|
48
|
+
client.request(:get, "projects/#{project_id}/repository/files/#{file_path}#{kind}", LabFile, ref: ref)
|
49
49
|
end
|
50
50
|
end
|
51
51
|
end
|
data/lib/labclient/http.rb
CHANGED
@@ -82,15 +82,25 @@ module Typhoeus
|
|
82
82
|
self
|
83
83
|
end
|
84
84
|
|
85
|
+
# Check if response body can be parsed
|
86
|
+
def json_body?
|
87
|
+
content_type = headers['content-type']
|
88
|
+
|
89
|
+
return false unless content_type
|
90
|
+
return true if content_type.include? 'application/json'
|
91
|
+
|
92
|
+
false
|
93
|
+
end
|
94
|
+
|
85
95
|
def process_body
|
86
|
-
if body.empty?
|
87
|
-
|
88
|
-
|
89
|
-
body
|
90
|
-
else
|
91
|
-
result = Oj.load(body, mode: :compat, object_class: LabClient::LabStruct)
|
96
|
+
return nil if body.empty?
|
97
|
+
|
98
|
+
if json_body?
|
99
|
+
result = Oj.load(body, mode: :compat, symbol_keys: true, object_class: LabClient::LabStruct)
|
92
100
|
result.instance_variable_set(:@response, self) if result.instance_of?(LabClient::LabStruct)
|
93
101
|
result
|
102
|
+
else
|
103
|
+
body
|
94
104
|
end
|
95
105
|
end
|
96
106
|
|
@@ -3,10 +3,10 @@ module LabClient
|
|
3
3
|
# Specifics
|
4
4
|
class Issues < Common
|
5
5
|
doc 'Delete' do
|
6
|
-
desc '
|
6
|
+
desc 'Only for administrators and project owners. Deletes an issue. [Project ID, Issue IID]'
|
7
7
|
example 'client.issues.delete(5, 1)'
|
8
8
|
result <<~DOC
|
9
|
-
=> #<
|
9
|
+
=> #<TyphoeusResponse code: 204>
|
10
10
|
DOC
|
11
11
|
end
|
12
12
|
|
@@ -3,11 +3,15 @@ module LabClient
|
|
3
3
|
# Specifics
|
4
4
|
class Jobs < Common
|
5
5
|
doc 'Artifacts' do
|
6
|
-
desc 'Get the job’s artifacts zipped archive of a project. [Project ID, Job ID,
|
6
|
+
desc 'Get the job’s artifacts zipped archive of a project. [Project ID, Job ID, Job Token, File Path]'
|
7
7
|
example 'client.jobs.artifacts(264, 1)'
|
8
8
|
|
9
9
|
markdown <<~DOC
|
10
|
-
|
10
|
+
---
|
11
|
+
|
12
|
+
Two methods are available. `download_artifacts` will download and write to the local directory (or file path) and `artifacts`/`show_artifacts` which will return a `LabFile` with the key of `data` for the response result.
|
13
|
+
|
14
|
+
File Output will default to the current directory + job id + file extension. 14.zip (Still returning `LabFile`)
|
11
15
|
|
12
16
|
Job Token: To be used with triggers for multi-project pipelines. It should be invoked only inside `.gitlab-ci.yml`. Its value is always `$CI_JOB_TOKEN`.
|
13
17
|
DOC
|
@@ -16,7 +20,7 @@ module LabClient
|
|
16
20
|
doc 'Artifacts' do
|
17
21
|
desc 'Specific output location'
|
18
22
|
example <<~DOC
|
19
|
-
client.jobs.
|
23
|
+
client.jobs.download_artifacts(264, 1, '/tmp/output.zip')
|
20
24
|
DOC
|
21
25
|
end
|
22
26
|
|
@@ -24,6 +28,7 @@ module LabClient
|
|
24
28
|
desc 'via Project'
|
25
29
|
example <<~DOC
|
26
30
|
project = client.projects.show(264)
|
31
|
+
project.job_download_artifacts(7)
|
27
32
|
project.job_artifacts(7)
|
28
33
|
DOC
|
29
34
|
end
|
@@ -32,18 +37,29 @@ module LabClient
|
|
32
37
|
desc 'via Job'
|
33
38
|
example <<~DOC
|
34
39
|
job = client.jobs.show(264, 7)
|
35
|
-
job.
|
40
|
+
job.download_artifacts
|
41
|
+
job.show_artifacts
|
36
42
|
DOC
|
37
43
|
end
|
38
44
|
|
39
|
-
def artifacts(project_id, job_id,
|
45
|
+
def artifacts(project_id, job_id, job_token = nil)
|
40
46
|
job_id = format_id(job_id)
|
41
47
|
project_id = format_id(project_id)
|
42
|
-
file_path ||= "#{Dir.pwd}/#{job_id}.zip"
|
43
48
|
query = { job_token: job_token } if job_token
|
44
|
-
output = client.request(:get, "projects/#{project_id}/jobs/#{job_id}/artifacts", nil, query)
|
45
49
|
|
46
|
-
|
50
|
+
# Don't try to process output
|
51
|
+
client.request(:get, "projects/#{project_id}/jobs/#{job_id}/artifacts", LabFile, query)
|
52
|
+
end
|
53
|
+
|
54
|
+
# Helper to write immediately to a file
|
55
|
+
def download_artifacts(project_id, job_id, file_path = nil, job_token = nil)
|
56
|
+
file_path ||= "#{Dir.pwd}/#{job_id}.zip"
|
57
|
+
output = artifacts(project_id, job_id, job_token)
|
58
|
+
|
59
|
+
File.write(file_path, output.data) if output.success?
|
60
|
+
|
61
|
+
# Return LabFile
|
62
|
+
output
|
47
63
|
end
|
48
64
|
end
|
49
65
|
end
|
data/lib/labclient/jobs/job.rb
CHANGED
@@ -17,9 +17,16 @@ module LabClient
|
|
17
17
|
Pipeline.new(@table[:pipeline], response, client)
|
18
18
|
end
|
19
19
|
|
20
|
-
|
20
|
+
# File Write Response
|
21
|
+
def download_artifacts(file_path = nil, job_token = nil)
|
21
22
|
project_id = collect_project_id
|
22
|
-
client.jobs.
|
23
|
+
client.jobs.download_artifacts(project_id, id, job_token, file_path)
|
24
|
+
end
|
25
|
+
|
26
|
+
# LabFile Response
|
27
|
+
def show_artifacts(job_token = nil)
|
28
|
+
project_id = collect_project_id
|
29
|
+
client.jobs.artifacts(project_id, id, job_token)
|
23
30
|
end
|
24
31
|
|
25
32
|
def artifacts_path(artifacts_path, file_path = nil)
|
@@ -65,7 +72,7 @@ module LabClient
|
|
65
72
|
help do
|
66
73
|
@group_name = 'Jobs'
|
67
74
|
subtitle 'Job'
|
68
|
-
option '
|
75
|
+
option 'download_artifacts', 'Download Job artifacts. [File Path, Job Token]'
|
69
76
|
option 'artifacts_path', 'Download Job artifacts path. [File Path, Output Path]'
|
70
77
|
option 'trace', 'Get Job Output'
|
71
78
|
option 'cancel', 'Cancel Job'
|
data/lib/labclient/klass.rb
CHANGED
@@ -5,7 +5,7 @@ module LabClient
|
|
5
5
|
include LabClient::Logger
|
6
6
|
include CurlHelper
|
7
7
|
|
8
|
-
attr_reader :client
|
8
|
+
attr_reader :client
|
9
9
|
|
10
10
|
extend Docs
|
11
11
|
|
@@ -105,18 +105,13 @@ module LabClient
|
|
105
105
|
client.quiet?
|
106
106
|
end
|
107
107
|
|
108
|
-
|
109
|
-
|
108
|
+
def initialize(table = nil, response = nil, client = nil)
|
109
|
+
# @table = table unless table.nil?
|
110
110
|
@client = client
|
111
111
|
@response = response
|
112
112
|
|
113
|
-
|
114
|
-
hash&.each_pair do |k, v|
|
115
|
-
k = k.to_sym
|
116
|
-
@table[k] = v
|
117
|
-
end
|
113
|
+
super(table)
|
118
114
|
end
|
119
|
-
# rubocop:enable Lint/MissingSuper
|
120
115
|
|
121
116
|
# Forward response success
|
122
117
|
def success?
|
data/lib/labclient/lab_struct.rb
CHANGED
@@ -1,16 +1,28 @@
|
|
1
|
-
# Extensions for
|
1
|
+
# Extensions for LabStruct specific to LabClient
|
2
2
|
module LabClient
|
3
|
-
# Unique inherited class to not override top level
|
4
|
-
class LabStruct
|
3
|
+
# Unique inherited class to not override top level LabStruct
|
4
|
+
class LabStruct
|
5
5
|
include CurlHelper
|
6
|
-
attr_reader :response
|
6
|
+
attr_reader :response, :table
|
7
|
+
|
8
|
+
def initialize(hash = {})
|
9
|
+
@table = if hash.instance_of?(LabClient::LabStruct)
|
10
|
+
hash.to_h
|
11
|
+
else
|
12
|
+
hash
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def to_h
|
17
|
+
@table
|
18
|
+
end
|
7
19
|
|
8
20
|
def keys
|
9
|
-
|
21
|
+
@table.keys.sort
|
10
22
|
end
|
11
23
|
|
12
24
|
def inspect
|
13
|
-
|
25
|
+
@table.inspect
|
14
26
|
end
|
15
27
|
|
16
28
|
def as_json(*args)
|
@@ -18,7 +30,7 @@ module LabClient
|
|
18
30
|
end
|
19
31
|
|
20
32
|
def slice(*opts)
|
21
|
-
|
33
|
+
@table.slice(*opts)
|
22
34
|
end
|
23
35
|
|
24
36
|
def client
|
@@ -29,5 +41,25 @@ module LabClient
|
|
29
41
|
def success?
|
30
42
|
@response.success?
|
31
43
|
end
|
44
|
+
|
45
|
+
def method_missing(method, *_args)
|
46
|
+
@table[method] if @table.keys.include?(method)
|
47
|
+
end
|
48
|
+
|
49
|
+
def respond_to_missing?(method_name, include_private = false)
|
50
|
+
@table.keys.include?(method_name) || super
|
51
|
+
end
|
52
|
+
|
53
|
+
def key?(idx)
|
54
|
+
@table.key? idx
|
55
|
+
end
|
56
|
+
|
57
|
+
def []=(name, value)
|
58
|
+
@table[name] = value
|
59
|
+
end
|
60
|
+
|
61
|
+
def [](name)
|
62
|
+
@table[name.to_sym]
|
63
|
+
end
|
32
64
|
end
|
33
65
|
end
|
@@ -13,13 +13,21 @@ module LabClient
|
|
13
13
|
end
|
14
14
|
|
15
15
|
doc 'Delete' do
|
16
|
-
desc 'Delete
|
16
|
+
desc 'Delete via MergeRequest'
|
17
17
|
example <<~DOC
|
18
|
-
mr = client.merge_requests.
|
18
|
+
mr = client.merge_requests.delete(343,2)
|
19
19
|
mr.delete
|
20
20
|
DOC
|
21
21
|
end
|
22
22
|
|
23
|
+
doc 'Delete' do
|
24
|
+
desc 'Via Project'
|
25
|
+
example <<~DOC
|
26
|
+
project = client.projects.show(1)
|
27
|
+
project.merge_requests_delete(12)
|
28
|
+
DOC
|
29
|
+
end
|
30
|
+
|
23
31
|
# Delete
|
24
32
|
def delete(project_id, merge_request_id)
|
25
33
|
project_id = format_id(project_id)
|
@@ -226,8 +226,12 @@ module LabClient
|
|
226
226
|
client.jobs.show(id, job_id)
|
227
227
|
end
|
228
228
|
|
229
|
-
def
|
230
|
-
client.jobs.
|
229
|
+
def job_download_artifacts(job_id, file_path = nil, job_token = nil)
|
230
|
+
client.jobs.download_artifacts(id, job_id, file_path, job_token)
|
231
|
+
end
|
232
|
+
|
233
|
+
def job_artifacts(job_id, job_token = nil)
|
234
|
+
client.jobs.artifacts(id, job_id, job_token)
|
231
235
|
end
|
232
236
|
|
233
237
|
def job_artifacts_latest(branch_name, job_name, file_path = nil, job_token = nil)
|
@@ -321,7 +325,7 @@ module LabClient
|
|
321
325
|
end
|
322
326
|
|
323
327
|
# Files
|
324
|
-
def file(file_path, ref = :
|
328
|
+
def file(file_path, ref = :main, kind = nil)
|
325
329
|
client.files.show(id, file_path, ref, kind)
|
326
330
|
end
|
327
331
|
|
@@ -647,6 +651,10 @@ module LabClient
|
|
647
651
|
client.merge_requests.create(id, query)
|
648
652
|
end
|
649
653
|
|
654
|
+
def merge_request_delete(merge_request_iid)
|
655
|
+
client.merge_requests.delete(id, merge_request_iid)
|
656
|
+
end
|
657
|
+
|
650
658
|
# Access Requests
|
651
659
|
def request_access
|
652
660
|
client.projects.access_requests.create(id)
|
@@ -29,7 +29,7 @@ module LabClient
|
|
29
29
|
def tree(project_id, query = {})
|
30
30
|
project_id = format_id(project_id)
|
31
31
|
|
32
|
-
client.request(:get, "projects/#{project_id}/repository/tree",
|
32
|
+
client.request(:get, "projects/#{project_id}/repository/tree", RepositoryTree, query)
|
33
33
|
end
|
34
34
|
end
|
35
35
|
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# Top namespace
|
2
|
+
module LabClient
|
3
|
+
# Specifics
|
4
|
+
class Terraform < Common
|
5
|
+
doc 'Create' do
|
6
|
+
desc 'Creates a new State. [Project ID, StateName, LockID, Hash]'
|
7
|
+
example 'client.terraform.create(5, {})'
|
8
|
+
result '#<TerraformState serial: 4>'
|
9
|
+
|
10
|
+
markdown <<~DOC
|
11
|
+
Attributes for Hash
|
12
|
+
|
13
|
+
ID,Operation,Info,Who,Version,Created,Path
|
14
|
+
DOC
|
15
|
+
end
|
16
|
+
|
17
|
+
def create(project_id, name, xid, body)
|
18
|
+
project_id = format_id(project_id)
|
19
|
+
|
20
|
+
client.request(:post, "projects/#{project_id}/terraform/state/#{name}?ID=#{xid}", nil, body)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# Top namespace
|
2
|
+
module LabClient
|
3
|
+
# Specifics
|
4
|
+
class Terraform < Common
|
5
|
+
doc 'Delete' do
|
6
|
+
desc 'Delete Terraform State. [Project ID, StateName]'
|
7
|
+
example 'client.terraform.delete(5, :state_name)'
|
8
|
+
end
|
9
|
+
|
10
|
+
def delete(project_id, name)
|
11
|
+
project_id = format_id(project_id)
|
12
|
+
|
13
|
+
client.request(:delete, "projects/#{project_id}/terraform/state/#{name}")
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# Top namespace
|
2
|
+
module LabClient
|
3
|
+
# Specifics
|
4
|
+
class Terraform < Common
|
5
|
+
doc 'Lock' do
|
6
|
+
desc 'Locks a new State. [Project ID, Hash]'
|
7
|
+
example 'client.wikis.Lock(5, content: "Lots of Stuff", title: "Title!")'
|
8
|
+
result '#<TerraformState slug: Title!>'
|
9
|
+
end
|
10
|
+
|
11
|
+
def lock(project_id, name, query)
|
12
|
+
project_id = format_id(project_id)
|
13
|
+
|
14
|
+
client.request(:post, "projects/#{project_id}/terraform/state/#{name}/lock", nil, query)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# Top namespace
|
2
|
+
module LabClient
|
3
|
+
# Specifics
|
4
|
+
class Terraform < Common
|
5
|
+
doc 'Show' do
|
6
|
+
desc 'Collect Terraform State Information'
|
7
|
+
example 'client.terraform.show(264, "README.md")'
|
8
|
+
|
9
|
+
markdown <<~DOC
|
10
|
+
Ref will default to `main`
|
11
|
+
|
12
|
+
Kind can be left empty or set to either :raw or :blame
|
13
|
+
DOC
|
14
|
+
end
|
15
|
+
|
16
|
+
def show(project_id, name)
|
17
|
+
project_id = format_id(project_id)
|
18
|
+
|
19
|
+
client.request(:get, "projects/#{project_id}/terraform/state/#{name}", TerraformState)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# Top namespace
|
2
|
+
module LabClient
|
3
|
+
# Specifics
|
4
|
+
class Terraform < Common
|
5
|
+
doc 'Lock' do
|
6
|
+
desc 'Unlock State [Project ID, StateName Lock ID]'
|
7
|
+
example 'client.terraform.lock(5, :state_name, 123)'
|
8
|
+
end
|
9
|
+
|
10
|
+
def unlock(project_id, name, xid)
|
11
|
+
project_id = format_id(project_id)
|
12
|
+
|
13
|
+
client.request(:delete, "projects/#{project_id}/terraform/state/#{name}/lock?ID=#{xid}")
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
data/lib/labclient/version.rb
CHANGED
data/lib/labclient.rb
CHANGED
@@ -771,18 +771,13 @@ require 'labclient/pipelines/pipeline'
|
|
771
771
|
# Repository
|
772
772
|
require 'labclient/repository/alias'
|
773
773
|
require 'labclient/repository/tree'
|
774
|
+
require 'labclient/repository/repository_tree'
|
774
775
|
require 'labclient/repository/blob'
|
775
776
|
require 'labclient/repository/archive'
|
776
777
|
require 'labclient/repository/compare'
|
777
778
|
require 'labclient/repository/contributors'
|
778
779
|
require 'labclient/repository/merge_base'
|
779
780
|
|
780
|
-
# Files
|
781
|
-
require 'labclient/files/show'
|
782
|
-
require 'labclient/files/create'
|
783
|
-
require 'labclient/files/update'
|
784
|
-
require 'labclient/files/delete'
|
785
|
-
|
786
781
|
# Branches
|
787
782
|
require 'labclient/branches/list'
|
788
783
|
require 'labclient/branches/show'
|
@@ -865,6 +860,21 @@ require 'labclient/feature_flags/delete'
|
|
865
860
|
require 'labclient/feature_flags/list'
|
866
861
|
require 'labclient/feature_flags/feature_flag'
|
867
862
|
|
863
|
+
# Files
|
864
|
+
require 'labclient/files/file'
|
865
|
+
require 'labclient/files/show'
|
866
|
+
require 'labclient/files/create'
|
867
|
+
require 'labclient/files/update'
|
868
|
+
require 'labclient/files/delete'
|
869
|
+
|
870
|
+
# Terraform
|
871
|
+
require 'labclient/terraform/create'
|
872
|
+
require 'labclient/terraform/lock'
|
873
|
+
require 'labclient/terraform/unlock'
|
874
|
+
require 'labclient/terraform/delete'
|
875
|
+
require 'labclient/terraform/show'
|
876
|
+
require 'labclient/terraform/terraform_state'
|
877
|
+
|
868
878
|
require 'labclient/resource_labels/resource_label'
|
869
879
|
|
870
880
|
# Generators
|
@@ -876,7 +886,7 @@ require 'labclient/generator/generator'
|
|
876
886
|
require 'labclient/generator/wizard'
|
877
887
|
|
878
888
|
# Dynamically Require Templates (Simplify new template creation)
|
879
|
-
Dir["#{File.dirname(__FILE__)}/labclient/generator/templates/*.rb"].
|
889
|
+
Dir["#{File.dirname(__FILE__)}/labclient/generator/templates/*.rb"].each { |file| require file }
|
880
890
|
|
881
891
|
# Load Client Files - I am Very Last!
|
882
892
|
require 'labclient/client/setup'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: labclient
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Davin Walker
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-02-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -224,16 +224,16 @@ dependencies:
|
|
224
224
|
name: rubocop
|
225
225
|
requirement: !ruby/object:Gem::Requirement
|
226
226
|
requirements:
|
227
|
-
- - "
|
227
|
+
- - ">="
|
228
228
|
- !ruby/object:Gem::Version
|
229
|
-
version: '
|
229
|
+
version: '0'
|
230
230
|
type: :development
|
231
231
|
prerelease: false
|
232
232
|
version_requirements: !ruby/object:Gem::Requirement
|
233
233
|
requirements:
|
234
|
-
- - "
|
234
|
+
- - ">="
|
235
235
|
- !ruby/object:Gem::Version
|
236
|
-
version: '
|
236
|
+
version: '0'
|
237
237
|
- !ruby/object:Gem::Dependency
|
238
238
|
name: rubocop-minitest
|
239
239
|
requirement: !ruby/object:Gem::Requirement
|
@@ -449,6 +449,7 @@ files:
|
|
449
449
|
- lib/labclient/feature_flags/list.rb
|
450
450
|
- lib/labclient/files/create.rb
|
451
451
|
- lib/labclient/files/delete.rb
|
452
|
+
- lib/labclient/files/file.rb
|
452
453
|
- lib/labclient/files/show.rb
|
453
454
|
- lib/labclient/files/update.rb
|
454
455
|
- lib/labclient/generator/generator.rb
|
@@ -848,6 +849,7 @@ files:
|
|
848
849
|
- lib/labclient/repository/contributors.rb
|
849
850
|
- lib/labclient/repository/merge_base.rb
|
850
851
|
- lib/labclient/repository/raw_blob.rb
|
852
|
+
- lib/labclient/repository/repository_tree.rb
|
851
853
|
- lib/labclient/repository/tree.rb
|
852
854
|
- lib/labclient/resource_labels/epics/client.rb
|
853
855
|
- lib/labclient/resource_labels/epics/list.rb
|
@@ -891,6 +893,12 @@ files:
|
|
891
893
|
- lib/labclient/tags/show.rb
|
892
894
|
- lib/labclient/tags/tag.rb
|
893
895
|
- lib/labclient/tags/update.rb
|
896
|
+
- lib/labclient/terraform/create.rb
|
897
|
+
- lib/labclient/terraform/delete.rb
|
898
|
+
- lib/labclient/terraform/lock.rb
|
899
|
+
- lib/labclient/terraform/show.rb
|
900
|
+
- lib/labclient/terraform/terraform_state.rb
|
901
|
+
- lib/labclient/terraform/unlock.rb
|
894
902
|
- lib/labclient/todos/list.rb
|
895
903
|
- lib/labclient/todos/mark_all_done.rb
|
896
904
|
- lib/labclient/todos/mark_done.rb
|
@@ -943,7 +951,8 @@ files:
|
|
943
951
|
homepage: https://gitlab.com/labclient/labclient
|
944
952
|
licenses:
|
945
953
|
- MIT
|
946
|
-
metadata:
|
954
|
+
metadata:
|
955
|
+
rubygems_mfa_required: 'true'
|
947
956
|
post_install_message:
|
948
957
|
rdoc_options: []
|
949
958
|
require_paths:
|
@@ -959,7 +968,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
959
968
|
- !ruby/object:Gem::Version
|
960
969
|
version: '0'
|
961
970
|
requirements: []
|
962
|
-
rubygems_version: 3.
|
971
|
+
rubygems_version: 3.2.32
|
963
972
|
signing_key:
|
964
973
|
specification_version: 4
|
965
974
|
summary: Gitlab API Client
|