xapixctl 1.1.1 → 1.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: eb39c7aace95b6c10168b43e536b404a8d5edcdfc48d12890b296708199dccda
4
- data.tar.gz: 5db98915dd0ac3f1c02b64ceee8ba7497a72fe4ccd65c09c2543aa108a4a1b95
3
+ metadata.gz: 3735380aedfe9b2b343be8035f2d988225e1ab686c8b861343a7872b74856b86
4
+ data.tar.gz: 134e2c3c03e630fddda6dfdc266b51716c6e239989d24a8af4d0e495f8b80ba0
5
5
  SHA512:
6
- metadata.gz: d67fe8ecd7b977fd05c7f8f8fb9b2b0fdbd4b1153405f0419f93bf05eea7dcb77d4314f4a635d77cb8472c50fcdef9c92df5fae1e361a8874b33401968dfaa35
7
- data.tar.gz: e44e46596d4b155a5e3e5c08772de09fdbac68d1b5de23c6377a448f75af35c3701e59cf25498491d57c1c5418b3340ec7098939d168063f0c18bbe929c532d7
6
+ metadata.gz: 5ad8cc281b69dd9a42b9f4b335b36bcde452888cd75896a4841af22957ce6631adccca781192919e16996a4c550def367de43b9b05d70c9fcddf303a436c29ce
7
+ data.tar.gz: 4730232765f508b57a332486a29abb543af26f0592471f1304d4e34a05491497d95ba04d737708cdf10085281293a5dda5a0edaf256fa4fa5d6f0f73052cadd3
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- xapixctl (1.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.3)
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.4)
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.91.0)
58
+ rubocop (0.92.0)
59
59
  parallel (~> 1.10)
60
- parser (>= 2.7.1.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.4.0, < 1.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.4.2)
68
- parser (>= 2.7.1.4)
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)
@@ -13,7 +13,7 @@ module Xapixctl
13
13
  private
14
14
 
15
15
  def warn_api_error(text, err, result)
16
- details = "\n " + result['errors'].map { |k| k['detail'] }.join("\n ") rescue err.to_s
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
- yaml_string = filename == '-' ? $stdin.read : IO.read(filename)
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
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
 
@@ -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 do |resource_ids|
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 'DELETED' }
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
- type = desc['kind']
130
- id = desc.dig('metadata', 'id')
131
- puts "deleting #{type} #{id}"
132
- connection.delete(type, id, org: options[:org], project: options[:project]) do |res|
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"
@@ -80,12 +80,13 @@ module Xapixctl
80
80
  DataSource
81
81
  Pipeline
82
82
  Service
83
+ ServiceInstall
83
84
  EndpointGroup
84
85
  Endpoint
85
86
  StreamGroup
86
87
  Stream
87
- Scheduler
88
88
  StreamProcessor
89
+ Scheduler
89
90
  ApiPublishing
90
91
  ApiPublishingRole
91
92
  ].freeze
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Xapixctl
4
- VERSION = "1.1.1"
4
+ VERSION = "1.1.2"
5
5
  end
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.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-22 00:00:00.000000000 Z
11
+ date: 2020-09-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport