xapixctl 1.1.1 → 1.1.2
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 +4 -4
- data/Gemfile.lock +8 -8
- data/lib/xapixctl/base_cli.rb +22 -8
- data/lib/xapixctl/cli.rb +10 -16
- data/lib/xapixctl/phoenix_client.rb +2 -1
- data/lib/xapixctl/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3735380aedfe9b2b343be8035f2d988225e1ab686c8b861343a7872b74856b86
|
4
|
+
data.tar.gz: 134e2c3c03e630fddda6dfdc266b51716c6e239989d24a8af4d0e495f8b80ba0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5ad8cc281b69dd9a42b9f4b335b36bcde452888cd75896a4841af22957ce6631adccca781192919e16996a4c550def367de43b9b05d70c9fcddf303a436c29ce
|
7
|
+
data.tar.gz: 4730232765f508b57a332486a29abb543af26f0592471f1304d4e34a05491497d95ba04d737708cdf10085281293a5dda5a0edaf256fa4fa5d6f0f73052cadd3
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
xapixctl (1.1.
|
4
|
+
xapixctl (1.1.2)
|
5
5
|
activesupport (>= 5.2.3, < 6.0.0)
|
6
6
|
rest-client (>= 2.1.0, < 3.0.0)
|
7
7
|
thor (>= 1.0.0, < 1.1.0)
|
@@ -16,7 +16,7 @@ GEM
|
|
16
16
|
tzinfo (~> 1.1)
|
17
17
|
ast (2.4.1)
|
18
18
|
concurrent-ruby (1.1.7)
|
19
|
-
diff-lcs (1.
|
19
|
+
diff-lcs (1.4.4)
|
20
20
|
domain_name (0.5.20190701)
|
21
21
|
unf (>= 0.0.5, < 1.0.0)
|
22
22
|
http-accept (1.7.0)
|
@@ -30,7 +30,7 @@ GEM
|
|
30
30
|
minitest (5.14.2)
|
31
31
|
netrc (0.11.0)
|
32
32
|
parallel (1.19.2)
|
33
|
-
parser (2.7.1.
|
33
|
+
parser (2.7.1.5)
|
34
34
|
ast (~> 2.4.1)
|
35
35
|
rainbow (3.0.0)
|
36
36
|
rake (13.0.1)
|
@@ -55,17 +55,17 @@ GEM
|
|
55
55
|
diff-lcs (>= 1.2.0, < 2.0)
|
56
56
|
rspec-support (~> 3.9.0)
|
57
57
|
rspec-support (3.9.3)
|
58
|
-
rubocop (0.
|
58
|
+
rubocop (0.92.0)
|
59
59
|
parallel (~> 1.10)
|
60
|
-
parser (>= 2.7.1.
|
60
|
+
parser (>= 2.7.1.5)
|
61
61
|
rainbow (>= 2.2.2, < 4.0)
|
62
62
|
regexp_parser (>= 1.7)
|
63
63
|
rexml
|
64
|
-
rubocop-ast (>= 0.
|
64
|
+
rubocop-ast (>= 0.5.0)
|
65
65
|
ruby-progressbar (~> 1.7)
|
66
66
|
unicode-display_width (>= 1.4.0, < 2.0)
|
67
|
-
rubocop-ast (0.
|
68
|
-
parser (>= 2.7.1.
|
67
|
+
rubocop-ast (0.5.0)
|
68
|
+
parser (>= 2.7.1.5)
|
69
69
|
ruby-progressbar (1.10.1)
|
70
70
|
thor (1.0.1)
|
71
71
|
thread_safe (0.3.6)
|
data/lib/xapixctl/base_cli.rb
CHANGED
@@ -13,7 +13,7 @@ module Xapixctl
|
|
13
13
|
private
|
14
14
|
|
15
15
|
def warn_api_error(text, err, result)
|
16
|
-
details =
|
16
|
+
details = result['errors'].map { |k| k['detail'] }.unshift('').join("\n ") rescue err.to_s
|
17
17
|
warn "#{text}: #{details}"
|
18
18
|
exit 1
|
19
19
|
end
|
@@ -30,14 +30,28 @@ module Xapixctl
|
|
30
30
|
|
31
31
|
DOCUMENT_STRUCTURE = %w[version kind metadata definition].freeze
|
32
32
|
def resources_from_file(filename)
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
33
|
+
load_files(filename) do |yaml_string|
|
34
|
+
yaml_string.split(/^---\s*\n/).map { |yml| Psych.safe_load(yml) }.compact.each do |doc|
|
35
|
+
unless (DOCUMENT_STRUCTURE - doc.keys.map(&:to_s)).empty?
|
36
|
+
warn "does not look like a correct resource definition:"
|
37
|
+
warn doc.inspect
|
38
|
+
exit 1
|
39
|
+
end
|
40
|
+
yield doc
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def load_files(filename)
|
46
|
+
if filename == '-'
|
47
|
+
yield $stdin.read
|
48
|
+
else
|
49
|
+
pn = Pathname.new(filename)
|
50
|
+
if pn.directory?
|
51
|
+
pn.glob(["**/*.yaml", "**/*.yml"]).sort.each { |dpn| yield dpn.read }
|
52
|
+
else
|
53
|
+
yield pn.read
|
39
54
|
end
|
40
|
-
yield doc
|
41
55
|
end
|
42
56
|
end
|
43
57
|
|
data/lib/xapixctl/cli.rb
CHANGED
@@ -37,14 +37,7 @@ module Xapixctl
|
|
37
37
|
end
|
38
38
|
else
|
39
39
|
connection.resource_ids(resource_type, org: options[:org], project: options[:project]) do |res|
|
40
|
-
res.on_success
|
41
|
-
resource_ids.each do |resource_id|
|
42
|
-
connection.resource(resource_type, resource_id, org: options[:org], project: options[:project], format: options[:format].to_sym) do |res|
|
43
|
-
res.on_success { |resource| puts resource }
|
44
|
-
res.on_error { |err, result| warn_api_error("could not get", err, result) }
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
40
|
+
res.on_success { |resource_ids| resource_ids.each { |res_id| get(resource_type, res_id) } }
|
48
41
|
res.on_error { |err, result| warn_api_error("could not get", err, result) }
|
49
42
|
end
|
50
43
|
end
|
@@ -83,11 +76,13 @@ module Xapixctl
|
|
83
76
|
If applied on a project (i.e. organization and project are given), the given project is used.
|
84
77
|
|
85
78
|
The given file should be in YAML format and can contain multiple resource definitions, each as it's own YAML document.
|
79
|
+
You can also provide a directory, in which case all files with yml/yaml extension will get loaded.
|
86
80
|
You can also read from stdin by using '-'.
|
87
81
|
|
88
82
|
Examples:
|
89
83
|
\x5> $ xapixctl apply -o xapix -f get_a_list.yaml
|
90
84
|
\x5> $ xapixctl apply -o xapix -p some-project -f get_a_list.yaml
|
85
|
+
\x5> $ xapixctl apply -o xapix -p some-project -f ./
|
91
86
|
|
92
87
|
To copy over all data sources from one project to another:
|
93
88
|
\x5> $ xapixctl get -o xapix-old -p some-project DataSource -f yaml | xapixctl apply -o xapix-new -f -
|
@@ -111,28 +106,27 @@ module Xapixctl
|
|
111
106
|
\x5`xapixctl delete TYPE ID` will delete the resource by given TYPE and ID.
|
112
107
|
|
113
108
|
The given file should be in YAML format and can contain multiple resource definitions, each as it's own YAML document.
|
109
|
+
You can also provide a directory, in which case all files with yml/yaml extension will get loaded.
|
114
110
|
You can also read from stdin by using '-'.
|
115
111
|
|
116
112
|
Examples:
|
117
113
|
\x5> $ xapixctl delete -o xapix -p some-project -f get_a_list.yaml
|
114
|
+
\x5> $ xapixctl delete -o xapix -p some-project -f ./
|
118
115
|
\x5> $ xapixctl delete -o xapix -p some-project DataSource get-a-list
|
119
116
|
\x5> $ xapixctl delete -o xapix Project some-project
|
120
117
|
LONGDESC
|
121
118
|
def delete(resource_type = nil, resource_id = nil)
|
122
119
|
if resource_type && resource_id
|
123
120
|
connection.delete(resource_type, resource_id, org: options[:org], project: options[:project]) do |res|
|
124
|
-
res.on_success { puts
|
121
|
+
res.on_success { puts "DELETED #{resource_type} #{resource_id}" }
|
125
122
|
res.on_error { |err, result| warn_api_error("could not delete", err, result) }
|
126
123
|
end
|
127
124
|
elsif options[:file]
|
128
125
|
resources_from_file(options[:file]) do |desc|
|
129
|
-
|
130
|
-
|
131
|
-
puts "deleting #{
|
132
|
-
|
133
|
-
res.on_success { puts "DELETED #{type} #{id}" }
|
134
|
-
res.on_error { |err, result| warn_api_error("could not delete", err, result); break }
|
135
|
-
end
|
126
|
+
res_type = desc['kind']
|
127
|
+
res_id = desc.dig('metadata', 'id')
|
128
|
+
puts "deleting #{res_type} #{res_id}"
|
129
|
+
delete(res_type, res_id)
|
136
130
|
end
|
137
131
|
else
|
138
132
|
warn "need TYPE and ID or --file option"
|
data/lib/xapixctl/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: xapixctl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Reinsch
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-09-
|
11
|
+
date: 2020-09-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|