xapixctl 1.1.2 → 1.2.0

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: 3735380aedfe9b2b343be8035f2d988225e1ab686c8b861343a7872b74856b86
4
- data.tar.gz: 134e2c3c03e630fddda6dfdc266b51716c6e239989d24a8af4d0e495f8b80ba0
3
+ metadata.gz: c745d574b6c72e52ff4a74989ac0b4663c6707e9dbd3c14e69facac3e135a978
4
+ data.tar.gz: 042e00431dc81a64d68d3a3b61af8b54b4319133144a4ba3916d26ad6a32a423
5
5
  SHA512:
6
- metadata.gz: 5ad8cc281b69dd9a42b9f4b335b36bcde452888cd75896a4841af22957ce6631adccca781192919e16996a4c550def367de43b9b05d70c9fcddf303a436c29ce
7
- data.tar.gz: 4730232765f508b57a332486a29abb543af26f0592471f1304d4e34a05491497d95ba04d737708cdf10085281293a5dda5a0edaf256fa4fa5d6f0f73052cadd3
6
+ metadata.gz: 34c8479e26148a0e158f20e9202340dc65dd84a85d624498f9e0b07994b1964257f5ab3d1b8db5fbc7304d4800ccb1672570f1beaffd857f7443c654d986cb63
7
+ data.tar.gz: 7071a6a8a53d41b41eec96af9ba05c58446c56ceb3be73148b619e3c33ac44d6da75b45b4192e0f5d1a4d547903ec98fbd2f87431ab5082cb659e456e827d39b
@@ -0,0 +1,19 @@
1
+ name: CD
2
+ on: push
3
+ jobs:
4
+ test:
5
+ runs-on: ubuntu-latest
6
+ strategy:
7
+ matrix:
8
+ ruby-version: [2.7, 2.6]
9
+ steps:
10
+ - uses: actions/checkout@v2
11
+ - name: Set up Ruby ${{ matrix.ruby-version }}
12
+ uses: ruby/setup-ruby@v1
13
+ with:
14
+ ruby-version: ${{ matrix.ruby-version }}
15
+ bundler-cache: true
16
+ - name: Install dependencies
17
+ run: bundle install
18
+ - name: Run tests
19
+ run: bundle exec rspec
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.6.6
1
+ 2.6.3
data/Gemfile.lock CHANGED
@@ -1,40 +1,45 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- xapixctl (1.1.2)
4
+ xapixctl (1.2.0)
5
5
  activesupport (>= 5.2.3, < 6.0.0)
6
6
  rest-client (>= 2.1.0, < 3.0.0)
7
- thor (>= 1.0.0, < 1.1.0)
7
+ thor (>= 1.0.0, < 1.2.0)
8
8
 
9
9
  GEM
10
10
  remote: https://rubygems.org/
11
11
  specs:
12
- activesupport (5.2.4.4)
12
+ activesupport (5.2.4.5)
13
13
  concurrent-ruby (~> 1.0, >= 1.0.2)
14
14
  i18n (>= 0.7, < 2)
15
15
  minitest (~> 5.1)
16
16
  tzinfo (~> 1.1)
17
- ast (2.4.1)
18
- concurrent-ruby (1.1.7)
17
+ addressable (2.7.0)
18
+ public_suffix (>= 2.0.2, < 5.0)
19
+ ast (2.4.2)
20
+ concurrent-ruby (1.1.8)
21
+ crack (0.4.4)
19
22
  diff-lcs (1.4.4)
20
23
  domain_name (0.5.20190701)
21
24
  unf (>= 0.0.5, < 1.0.0)
25
+ hashdiff (1.0.1)
22
26
  http-accept (1.7.0)
23
27
  http-cookie (1.0.3)
24
28
  domain_name (~> 0.5)
25
- i18n (1.8.5)
29
+ i18n (1.8.9)
26
30
  concurrent-ruby (~> 1.0)
27
31
  mime-types (3.3.1)
28
32
  mime-types-data (~> 3.2015)
29
- mime-types-data (3.2020.0512)
30
- minitest (5.14.2)
33
+ mime-types-data (3.2021.0225)
34
+ minitest (5.14.4)
31
35
  netrc (0.11.0)
32
- parallel (1.19.2)
33
- parser (2.7.1.5)
36
+ parallel (1.20.1)
37
+ parser (3.0.0.0)
34
38
  ast (~> 2.4.1)
39
+ public_suffix (4.0.6)
35
40
  rainbow (3.0.0)
36
- rake (13.0.1)
37
- regexp_parser (1.8.0)
41
+ rake (13.0.3)
42
+ regexp_parser (2.1.1)
38
43
  relaxed-rubocop (2.5)
39
44
  rest-client (2.1.0)
40
45
  http-accept (>= 1.7.0, < 2.0)
@@ -42,50 +47,62 @@ GEM
42
47
  mime-types (>= 1.16, < 4.0)
43
48
  netrc (~> 0.8)
44
49
  rexml (3.2.4)
45
- rspec (3.9.0)
46
- rspec-core (~> 3.9.0)
47
- rspec-expectations (~> 3.9.0)
48
- rspec-mocks (~> 3.9.0)
49
- rspec-core (3.9.2)
50
- rspec-support (~> 3.9.3)
51
- rspec-expectations (3.9.2)
50
+ rspec (3.10.0)
51
+ rspec-core (~> 3.10.0)
52
+ rspec-expectations (~> 3.10.0)
53
+ rspec-mocks (~> 3.10.0)
54
+ rspec-core (3.10.1)
55
+ rspec-support (~> 3.10.0)
56
+ rspec-expectations (3.10.1)
52
57
  diff-lcs (>= 1.2.0, < 2.0)
53
- rspec-support (~> 3.9.0)
54
- rspec-mocks (3.9.1)
58
+ rspec-support (~> 3.10.0)
59
+ rspec-mocks (3.10.2)
55
60
  diff-lcs (>= 1.2.0, < 2.0)
56
- rspec-support (~> 3.9.0)
57
- rspec-support (3.9.3)
58
- rubocop (0.92.0)
61
+ rspec-support (~> 3.10.0)
62
+ rspec-support (3.10.2)
63
+ rubocop (1.11.0)
59
64
  parallel (~> 1.10)
60
- parser (>= 2.7.1.5)
65
+ parser (>= 3.0.0.0)
61
66
  rainbow (>= 2.2.2, < 4.0)
62
- regexp_parser (>= 1.7)
67
+ regexp_parser (>= 1.8, < 3.0)
63
68
  rexml
64
- rubocop-ast (>= 0.5.0)
69
+ rubocop-ast (>= 1.2.0, < 2.0)
65
70
  ruby-progressbar (~> 1.7)
66
- unicode-display_width (>= 1.4.0, < 2.0)
67
- rubocop-ast (0.5.0)
71
+ unicode-display_width (>= 1.4.0, < 3.0)
72
+ rubocop-ast (1.4.1)
68
73
  parser (>= 2.7.1.5)
69
- ruby-progressbar (1.10.1)
70
- thor (1.0.1)
74
+ rubocop-rake (0.5.1)
75
+ rubocop
76
+ rubocop-rspec (2.2.0)
77
+ rubocop (~> 1.0)
78
+ rubocop-ast (>= 1.1.0)
79
+ ruby-progressbar (1.11.0)
80
+ thor (1.1.0)
71
81
  thread_safe (0.3.6)
72
- tzinfo (1.2.7)
82
+ tzinfo (1.2.9)
73
83
  thread_safe (~> 0.1)
74
84
  unf (0.1.4)
75
85
  unf_ext
76
86
  unf_ext (0.0.7.7)
77
- unicode-display_width (1.7.0)
87
+ unicode-display_width (2.0.0)
88
+ webmock (3.11.0)
89
+ addressable (>= 2.3.6)
90
+ crack (>= 0.3.2)
91
+ hashdiff (>= 0.4.0, < 2.0.0)
78
92
 
79
93
  PLATFORMS
80
94
  ruby
81
95
 
82
96
  DEPENDENCIES
83
- bundler (~> 1.17.3)
97
+ bundler (~> 2.1.4)
84
98
  rake (~> 13.0)
85
99
  relaxed-rubocop (~> 2.5)
86
100
  rspec (~> 3.0)
87
- rubocop (~> 0.89)
101
+ rubocop (~> 1.11)
102
+ rubocop-rake
103
+ rubocop-rspec
104
+ webmock
88
105
  xapixctl!
89
106
 
90
107
  BUNDLED WITH
91
- 1.17.3
108
+ 2.1.4
data/lib/xapixctl.rb CHANGED
@@ -4,9 +4,6 @@ require 'active_support'
4
4
  require 'active_support/core_ext/hash/keys'
5
5
  require 'active_support/core_ext/object/blank'
6
6
  require 'active_support/core_ext/string/inflections'
7
- require 'rest_client'
8
- require 'json'
9
- require 'psych'
10
7
  require 'xapixctl/version'
11
8
  require 'xapixctl/phoenix_client'
12
9
 
@@ -1,20 +1,23 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'thor'
4
+ require 'pathname'
4
5
 
5
6
  module Xapixctl
6
7
  class BaseCli < Thor
7
8
  def self.exit_on_failure?; true; end
8
9
 
9
- class_option :verbose, type: :boolean, aliases: "-v"
10
+ class_option :org, aliases: "-o", desc: "Organization; Fallback: environment variable XAPIX_ORG"
11
+ class_option :project, aliases: "-p", desc: "Project, can be ORG/PROJECT; Fallback: environment variable XAPIX_PROJECT"
12
+ class_option :debug
10
13
  class_option :xapix_url, desc: "Fallback: environment variable XAPIX_URL. URL to Xapix. Default: https://cloud.xapix.io/"
11
14
  class_option :xapix_token, desc: "Fallback: environment variable XAPIX_TOKEN. Your access token."
12
15
 
13
16
  private
14
17
 
15
- def warn_api_error(text, err, result)
18
+ def exit_with_api_error(err, result)
16
19
  details = result['errors'].map { |k| k['detail'] }.unshift('').join("\n ") rescue err.to_s
17
- warn "#{text}: #{details}"
20
+ warn "API error: #{details}"
18
21
  exit 1
19
22
  end
20
23
 
@@ -29,8 +32,8 @@ module Xapixctl
29
32
  end
30
33
 
31
34
  DOCUMENT_STRUCTURE = %w[version kind metadata definition].freeze
32
- def resources_from_file(filename)
33
- load_files(filename) do |yaml_string|
35
+ def resources_from_file(filename, ignore_missing: false)
36
+ load_files(filename, ignore_missing) do |yaml_string|
34
37
  yaml_string.split(/^---\s*\n/).map { |yml| Psych.safe_load(yml) }.compact.each do |doc|
35
38
  unless (DOCUMENT_STRUCTURE - doc.keys.map(&:to_s)).empty?
36
39
  warn "does not look like a correct resource definition:"
@@ -42,24 +45,54 @@ module Xapixctl
42
45
  end
43
46
  end
44
47
 
45
- def load_files(filename)
48
+ def load_files(filename, ignore_missing)
46
49
  if filename == '-'
47
50
  yield $stdin.read
48
51
  else
49
- pn = Pathname.new(filename)
52
+ pn = filename.is_a?(Pathname) ? filename : Pathname.new(filename)
50
53
  if pn.directory?
51
54
  pn.glob(["**/*.yaml", "**/*.yml"]).sort.each { |dpn| yield dpn.read }
52
- else
55
+ elsif pn.exist?
53
56
  yield pn.read
57
+ elsif !ignore_missing
58
+ warn "file not found: #{filename}"
59
+ exit 1
54
60
  end
55
61
  end
56
62
  end
57
63
 
58
64
  def connection
59
- url = options[:xapix_url] || ENV['XAPIX_URL'] || 'https://cloud.xapix.io/'
60
- token = options[:xapix_token] || ENV['XAPIX_TOKEN']
61
- raise Thor::RequiredArgumentMissingError, "no XAPIX_TOKEN given. Either use --xapix_token [TOKEN] or set environment variable XAPIX_TOKEN (recommended)" if !token
62
- PhoenixClient::Connection.new(url, token)
65
+ @connection ||= begin
66
+ url = options[:xapix_url] || ENV['XAPIX_URL'] || 'https://cloud.xapix.io/'
67
+ token = options[:xapix_token] || ENV['XAPIX_TOKEN']
68
+ raise Thor::RequiredArgumentMissingError, "No XAPIX_TOKEN given. Either use --xapix_token [TOKEN] or set environment variable XAPIX_TOKEN (recommended)" if !token
69
+ PhoenixClient.connection(
70
+ url, token,
71
+ default_error_handler: ->(err, result) { exit_with_api_error(err, result) },
72
+ logging: options[:debug] ? 'stdout' : nil
73
+ )
74
+ end
75
+ end
76
+
77
+ def org_or_prj_connection
78
+ options[:project] ? prj_connection : org_connection
79
+ end
80
+
81
+ def org_connection
82
+ org = options[:org] || ENV['XAPIX_ORG']
83
+ raise Thor::RequiredArgumentMissingError, "No organization given. Either use --org [ORG] or set environment variable XAPIX_ORG" if !org
84
+ @org_connection ||= connection.organization(org)
85
+ end
86
+
87
+ def prj_connection
88
+ project = options[:project] || ENV['XAPIX_PROJECT']
89
+ org = options[:org] || ENV['XAPIX_ORG']
90
+ raise Thor::RequiredArgumentMissingError, "No project given. Either use --project [ORG/PROJECT] or set environment variable XAPIX_PROJECT" if !project
91
+ if project.include?('/')
92
+ org, project = project.split('/', 2)
93
+ end
94
+ raise Thor::RequiredArgumentMissingError, "No organization given. Either use --org [ORG] or set environment variable XAPIX_ORG" if !org
95
+ @prj_connection ||= connection.project(org: org, project: project)
63
96
  end
64
97
  end
65
98
  end
data/lib/xapixctl/cli.rb CHANGED
@@ -2,24 +2,26 @@
2
2
 
3
3
  require 'xapixctl/base_cli'
4
4
  require 'xapixctl/preview_cli'
5
+ require 'xapixctl/sync_cli'
5
6
 
6
7
  module Xapixctl
7
8
  class Cli < BaseCli
8
9
  desc "preview SUBCOMMAND ...ARGS", "Request preview for resources"
9
10
  subcommand "preview", Preview
10
11
 
11
- option :org, aliases: "-o", desc: "Organization", required: true
12
- option :project, aliases: "-p", desc: "Project"
12
+ desc "sync SUBCOMMAND ...ARGS", "Sync resources"
13
+ subcommand "sync", Sync
14
+
13
15
  option :format, aliases: "-f", default: 'text', enum: ['text', 'yaml', 'json'], desc: "Output format"
14
16
  desc "get TYPE [ID]", "retrieve either all resources of given TYPE or just the resource of given TYPE and ID"
15
17
  long_desc <<-LONGDESC
16
18
  `xapixctl get TYPE` will retrieve the list of all resources of given type.
17
19
 
18
20
  If requested on an organization (i.e. no project given), the following types are available:
19
- \x5 Project
21
+ \x5Project
20
22
 
21
23
  If requested on an a project (i.e. organization and project are given), the following types are available:
22
- \x5 Ambassador, AuthScheme, CacheConnection, Credential, DataSource, Endpoint, EndpointGroup, Proxy, Schema, Stream, StreamGroup
24
+ \x5#{PhoenixClient::SUPPORTED_RESOURCE_TYPES.sort.join(', ')}
23
25
 
24
26
  Use the format to switch between the different output formats.
25
27
 
@@ -27,24 +29,17 @@ module Xapixctl
27
29
  \x5> $ xapixctl get -o xapix Project
28
30
  \x5> $ xapixctl get -o xapix Project some-project
29
31
  \x5> $ xapixctl get -o xapix -p some-project DataSource
30
- \x5> $ xapixctl get -o xapix -p some-project DataSource get-a-list
32
+ \x5> $ xapixctl get -p xapix/some-project DataSource
33
+ \x5> $ xapixctl get -p xapix/some-project DataSource get-a-list
31
34
  LONGDESC
32
35
  def get(resource_type, resource_id = nil)
33
- if resource_id
34
- connection.resource(resource_type, resource_id, org: options[:org], project: options[:project], format: options[:format].to_sym) do |res|
35
- res.on_success { |resource| puts resource }
36
- res.on_error { |err, result| warn_api_error("could not get", err, result) }
37
- end
38
- else
39
- connection.resource_ids(resource_type, org: options[:org], project: options[:project]) do |res|
40
- res.on_success { |resource_ids| resource_ids.each { |res_id| get(resource_type, res_id) } }
41
- res.on_error { |err, result| warn_api_error("could not get", err, result) }
42
- end
36
+ conn = org_or_prj_connection
37
+ resource_ids = resource_id ? [resource_id] : conn.resource_ids(resource_type)
38
+ resource_ids.each do |res_id|
39
+ puts conn.resource(resource_type, res_id, format: options[:format].to_sym)
43
40
  end
44
41
  end
45
42
 
46
- option :org, aliases: "-o", desc: "Organization", required: true
47
- option :project, aliases: "-p", desc: "Project", required: true
48
43
  option :format, aliases: "-f", default: 'text', enum: ['text', 'yaml', 'json'], desc: "Output format"
49
44
  desc "export", "retrieves all resources within a project"
50
45
  long_desc <<-LONGDESC
@@ -54,19 +49,15 @@ module Xapixctl
54
49
 
55
50
  Examples:
56
51
  \x5> $ xapixctl export -o xapix -p some-project
57
- \x5> $ xapixctl export -o xapix -p some-project -f yaml > some_project.yaml
52
+ \x5> $ xapixctl export -p xapix/some-project
53
+ \x5> $ xapixctl export -p xapix/some-project -f yaml > some_project.yaml
58
54
  LONGDESC
59
55
  def export
60
- connection.resource('Project', options[:project], org: options[:org], format: options[:format].to_sym) do |res|
61
- res.on_success { |resource| puts resource }
62
- res.on_error { |err, result| warn_api_error("could not get", err, result) }
63
- end
64
- (connection.resource_types_for_export - ['Project']).each { |type| get(type) }
56
+ get('Project', prj_connection.project)
57
+ prj_connection.resource_types_for_export.each { |type| get(type) }
65
58
  end
66
59
 
67
- option :org, aliases: "-o", desc: "Organization", required: true
68
- option :project, aliases: "-p", desc: "Project"
69
- option :file, aliases: "-f", required: true
60
+ option :file, aliases: "-f", required: true, desc: 'file or directory from which to load resource descriptions'
70
61
  desc "apply", "Create or update a resource from a file"
71
62
  long_desc <<-LONGDESC
72
63
  `xapixctl apply -f FILE` will apply the given resource description.
@@ -82,7 +73,8 @@ module Xapixctl
82
73
  Examples:
83
74
  \x5> $ xapixctl apply -o xapix -f get_a_list.yaml
84
75
  \x5> $ xapixctl apply -o xapix -p some-project -f get_a_list.yaml
85
- \x5> $ xapixctl apply -o xapix -p some-project -f ./
76
+ \x5> $ xapixctl apply -p xapix/some-project -f get_a_list.yaml
77
+ \x5> $ xapixctl apply -p xapix/some-project -f ./
86
78
 
87
79
  To copy over all data sources from one project to another:
88
80
  \x5> $ xapixctl get -o xapix-old -p some-project DataSource -f yaml | xapixctl apply -o xapix-new -f -
@@ -90,16 +82,11 @@ module Xapixctl
90
82
  def apply
91
83
  resources_from_file(options[:file]) do |desc|
92
84
  puts "applying #{desc['kind']} #{desc.dig('metadata', 'id')}"
93
- connection.apply(desc, org: options[:org], project: options[:project]) do |res|
94
- res.on_success { puts 'OK' }
95
- res.on_error { |err, result| warn_api_error("could not apply changes", err, result); break }
96
- end
85
+ org_or_prj_connection.apply(desc)
97
86
  end
98
87
  end
99
88
 
100
- option :org, aliases: "-o", desc: "Organization", required: true
101
- option :project, aliases: "-p", desc: "Project"
102
- option :file, aliases: "-f"
89
+ option :file, aliases: "-f", desc: 'file or directory from which to load resource descriptions'
103
90
  desc "delete [TYPE ID] [-f FILE]", "delete the resources in the file"
104
91
  long_desc <<-LONGDESC
105
92
  `xapixctl delete -f FILE` will delete all the resources listed in the file.
@@ -110,22 +97,20 @@ module Xapixctl
110
97
  You can also read from stdin by using '-'.
111
98
 
112
99
  Examples:
113
- \x5> $ xapixctl delete -o xapix -p some-project -f get_a_list.yaml
114
- \x5> $ xapixctl delete -o xapix -p some-project -f ./
115
- \x5> $ xapixctl delete -o xapix -p some-project DataSource get-a-list
116
100
  \x5> $ xapixctl delete -o xapix Project some-project
101
+ \x5> $ xapixctl delete -p xapix -p some-project DataSource get-a-list
102
+ \x5> $ xapixctl delete -p xapix/some-project DataSource get-a-list
103
+ \x5> $ xapixctl delete -p xapix/some-project -f get_a_list.yaml
104
+ \x5> $ xapixctl delete -p xapix/some-project -f ./
117
105
  LONGDESC
118
106
  def delete(resource_type = nil, resource_id = nil)
119
107
  if resource_type && resource_id
120
- connection.delete(resource_type, resource_id, org: options[:org], project: options[:project]) do |res|
121
- res.on_success { puts "DELETED #{resource_type} #{resource_id}" }
122
- res.on_error { |err, result| warn_api_error("could not delete", err, result) }
123
- end
108
+ org_or_prj_connection.delete(resource_type, resource_id)
109
+ puts "DELETED #{resource_type} #{resource_id}"
124
110
  elsif options[:file]
125
111
  resources_from_file(options[:file]) do |desc|
126
112
  res_type = desc['kind']
127
113
  res_id = desc.dig('metadata', 'id')
128
- puts "deleting #{res_type} #{res_id}"
129
114
  delete(res_type, res_id)
130
115
  end
131
116
  else
@@ -133,24 +118,21 @@ module Xapixctl
133
118
  end
134
119
  end
135
120
 
136
- option :org, aliases: "-o", desc: "Organization", required: true
137
- option :project, aliases: "-p", desc: "Project", required: true
138
121
  desc "publish", "Publishes the current version of the given project"
139
122
  long_desc <<-LONGDESC
140
123
  `xapixctl publish` will publish the given project.
141
124
 
142
125
  Examples:
143
126
  \x5> $ xapixctl publish -o xapix -p some-project
127
+ \x5> $ xapixctl publish -p xapix/some-project
144
128
  LONGDESC
145
129
  def publish
146
- connection.publish(org: options[:org], project: options[:project]) do |res|
130
+ prj_connection.publish do |res|
147
131
  res.on_success { |result| show_deployment_status(result) }
148
- res.on_error { |err, result| show_deployment_status(result); warn_api_error('errors', err, result) }
132
+ res.on_error { |err, result| show_deployment_status(result); exit_with_api_error(err, result) }
149
133
  end
150
134
  end
151
135
 
152
- option :org, aliases: "-o", desc: "Organization", required: true
153
- option :project, aliases: "-p", desc: "Project", required: true
154
136
  desc "logs CORRELATION_ID", "Retrieves the execution logs for the given correlation ID"
155
137
  long_desc <<-LONGDESC
156
138
  `xapixctl logs CORRELATION_ID` will retrieve execution logs for the given correlation ID.
@@ -159,27 +141,23 @@ module Xapixctl
159
141
 
160
142
  Examples:
161
143
  \x5> $ xapixctl logs be9c8608-e291-460d-bc20-5a394c4079d4 -o xapix -p some-project
144
+ \x5> $ xapixctl logs be9c8608-e291-460d-bc20-5a394c4079d4 -p xapix/some-project
162
145
  LONGDESC
163
146
  def logs(correlation_id)
164
- connection.logs(correlation_id, org: options[:org], project: options[:project]) do |res|
165
- res.on_success { |result| puts result['logs'].to_yaml }
166
- res.on_error { |err, result| warn_api_error('could not get logs', err, result) }
167
- end
147
+ result = prj_connection.logs(correlation_id)
148
+ puts result['logs'].to_yaml
168
149
  end
169
150
 
170
151
  SUPPORTED_CONTEXTS = ['Project', 'Organization'].freeze
152
+
171
153
  desc "api-resources", "retrieves a list of all available resource types"
172
154
  def api_resources
173
- connection.available_resource_types do |res|
174
- res.on_success do |available_types|
175
- format_str = "%20.20s %20.20s"
176
- puts format_str % ['Type', 'Required Context']
177
- available_types.sort_by { |desc| desc['type'] }.each do |desc|
178
- next unless SUPPORTED_CONTEXTS.include?(desc['context'])
179
- puts format_str % [desc['type'], desc['context']]
180
- end
181
- end
182
- res.on_error { |err, result| warn_api_error("could not get", err, result) }
155
+ available_types = connection.available_resource_types
156
+ format_str = "%20.20s %20.20s %26.26s"
157
+ puts format_str % ['Type', 'Required Context', '']
158
+ available_types.sort_by { |desc| desc['type'] }.each do |desc|
159
+ next unless SUPPORTED_CONTEXTS.include?(desc['context'])
160
+ puts format_str % [desc['type'], desc['context'], PhoenixClient.supported_type?(desc['type']) ? '' : '(unsupported, update CLI)']
183
161
  end
184
162
  end
185
163
  end