jcf 0.0.10 → 0.0.11

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f9477e6264cb699c3505cfe016acb802bff09e9c71fe98072ea9a1598a021119
4
- data.tar.gz: 05a70e89d7593faa6308a6d0b78d03a3990466dae549a8343625288bf104a4ea
3
+ metadata.gz: 9479fc4468d9132f60c15f22782820798f35ae649d5bb09d575e7b051d77ddda
4
+ data.tar.gz: 4090a17eb90884a706b11ea865805a4a99ada9b8bfbbfc1206fd6ddbf21e4af6
5
5
  SHA512:
6
- metadata.gz: ec4fa652bb3341babc362145fe150e9418944e3b5c2d5aeb2b798c7d82af39849a3c467b1432941638a9c4b0650f468b56c537e927c4ab5b7793884faf31e491
7
- data.tar.gz: 25bad72e4df60a12ef1df353abb6472e9db88623f9a4c7ebcd1e4150222bb92c4a2a63684582c9b5758eec353bdcab263b59cfdd67e259aeb42be071f9691827
6
+ metadata.gz: 06fc37725e7ae5ad94b16e5e4a365ecd69760c45ca7e21922d81ca57e24e826cd43328d67d50e3b7bce5366a5421d09e99eb4fe03529d05562b9a6d4463ca546
7
+ data.tar.gz: 2b508ca2c6441a640f13aa03fa05fb19438467f0bfa053e5cd23f37b8b861176f9648f22746cc2576a73c371e641e50684e02c0960da1e39401bfc89b676a1fc
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## [0.0.11] - 2023-10-12
2
+
3
+ - Add a tree output for a new command `jcf services NAME` that will show all the offerings and instances for that broker. In a tree. Because trees are cool.
4
+
1
5
  ## [0.0.10] - 2023-10-03
2
6
 
3
7
  - Added the template parsing options to metrics command
data/README.md CHANGED
@@ -1,8 +1,25 @@
1
- ![tests](https://github.com/fearoffish/paas-org-metric-gathering-gem/actions/workflows/main.yml/badge.svg)
1
+ [![tests](https://github.com/fearoffish/paas-org-metric-gathering-gem/actions/workflows/main.yml/badge.svg)](https://github.com/fearoffish/paas-org-metric-gathering-gem/actions)
2
2
  [![Gem Version](https://badge.fury.io/rb/jcf.svg)](https://badge.fury.io/rb/jcf)
3
3
 
4
4
  # Jcf
5
5
 
6
+ ## What is it?
7
+
8
+ If you use CloudFoundry you'll know that some commands/queries require you to use `cf curl` and that can get a little tedious. This gem is a wrapper around `cf curl` to make it easier to query the CloudFoundry API, as well as being able to query the CloudWatch metrics for the AWS services that are used by the CF services.
9
+
10
+ Some handy features:
11
+
12
+ ```
13
+ jcf u jamie # find all users with a partial username of jamie
14
+ jcf o foo # find all orgs with a partial name of foo
15
+ jcf sb s3 # find all service brokers with a partial name of s3
16
+ jcf so bucket # find all service offerings with a partial name of bucket
17
+ jcf sp medium # find all service plans with a partial name of medium
18
+
19
+ # find all metrics for the rds-broker service, postgres offering, output it to a csv file
20
+ jcf m postgres -t 'rdsbroker-{guid}' -o admin -f csv --ouput postgres-metrics.csv
21
+ ```
22
+
6
23
  ## Installation
7
24
 
8
25
  ```sh
@@ -134,3 +151,8 @@ The gem is available as open source under the terms of the [MIT License](https:/
134
151
  ## Code of Conduct
135
152
 
136
153
  Everyone interacting in the Jcf project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/fearoffish/paas-org-metric-gathering-gem/blob/main/CODE_OF_CONDUCT.md).
154
+
155
+ ## Credits
156
+
157
+ - Hanami for the [CLI framework](https://hanamirb.org/guides/1.3/cli/overview/)
158
+ I borrowed some ideas from there. Thanks!
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "base"
4
+
5
+ module JCF
6
+ module CF
7
+ class Services
8
+ def self.first(name:)
9
+ # Find the broker, then find all offerings for that broker, then all plans
10
+ # { broker: { offerings: { plans: [] } }
11
+ # e.g. { "p-mysql (guid)": { "10mb (guid)": [], "100mb (guid)": [] } }
12
+ broker = ServiceBroker.first(name: name)
13
+ offerings = ServiceOffering.all(service_broker_guids: broker.guid).map do |offering|
14
+ plans = ServicePlan.all(service_offering_guids: offering.guid)
15
+ { offering.to_s => plans }
16
+ end
17
+ { broker.to_s => offerings }
18
+ end
19
+ end
20
+ end
21
+ end
@@ -14,7 +14,7 @@ module JCF
14
14
  module Commands
15
15
  module CF
16
16
  class Metrics < Command
17
- argument :offering, required: true, values: %w[postgres aws-s3-bucket],
17
+ argument :offering, required: true, values: %w[postgres mysql aws-s3-bucket],
18
18
  desc: "Choose a service instance offering to query"
19
19
 
20
20
  option :template, aliases: ["-t"], required: true, type: :string,
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "shellwords"
4
+ require_relative "../../errors"
5
+ require "tty-tree"
6
+
7
+ module JCF
8
+ module CLI
9
+ module Commands
10
+ module CF
11
+ class Services < Command
12
+ argument :broker, required: false, desc: "Broker name"
13
+
14
+ def call(broker: nil, **)
15
+ # gather all service offerings and plans for a single broker
16
+ if broker
17
+ out.puts formatter.format(JCF::CF::Services.first(name: broker), tree: true)
18
+ else
19
+ # TODO: this is a stub, it should be a list of all brokers
20
+ # out.puts formatter.format(JCF::CF::Organization.all)
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -12,6 +12,7 @@ module JCF
12
12
  register "organizations", Commands::CF::Organizations, aliases: %w[o orgs organization]
13
13
  register "spaces", Commands::CF::Spaces, aliases: %w[s space]
14
14
  register "users", Commands::CF::Users, aliases: %w[u user]
15
+ register "services", Commands::CF::Services
15
16
  register "service_brokers", Commands::CF::ServiceBrokers, aliases: %w[sb service_broker]
16
17
  register "service_offerings", Commands::CF::ServiceOfferings, aliases: %w[so service_offering]
17
18
  register "service_instances", Commands::CF::ServiceInstances, aliases: %w[si service_instance]
@@ -7,9 +7,17 @@ module JCF
7
7
  module OutputFormatters
8
8
  class Text
9
9
  class << self
10
- def format(data)
10
+ def format(data, tree: false)
11
11
  return "" if data.nil?
12
12
 
13
+ if tree
14
+ render_tree(data)
15
+ else
16
+ render_data(data)
17
+ end
18
+ end
19
+
20
+ def render_data(data)
13
21
  keys = collect_keys(data)
14
22
  values = collect_values(data)
15
23
 
@@ -17,6 +25,10 @@ module JCF
17
25
  table.render(:unicode, resize: true)
18
26
  end
19
27
 
28
+ def render_tree(data)
29
+ TTY::Tree.new(data).render
30
+ end
31
+
20
32
  def collect_values(data)
21
33
  if data.is_a?(Array)
22
34
  data.map { |d| d.attributes.values.collect(&:to_s) }
data/lib/jcf/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module JCF
4
- VERSION = "0.0.10"
4
+ VERSION = "0.0.11"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jcf
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.10
4
+ version: 0.0.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jamie van Dyke
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-10-03 00:00:00.000000000 Z
11
+ date: 2023-10-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -240,6 +240,20 @@ dependencies:
240
240
  - - "~>"
241
241
  - !ruby/object:Gem::Version
242
242
  version: 0.12.0
243
+ - !ruby/object:Gem::Dependency
244
+ name: tty-tree
245
+ requirement: !ruby/object:Gem::Requirement
246
+ requirements:
247
+ - - "~>"
248
+ - !ruby/object:Gem::Version
249
+ version: 0.4.0
250
+ type: :runtime
251
+ prerelease: false
252
+ version_requirements: !ruby/object:Gem::Requirement
253
+ requirements:
254
+ - - "~>"
255
+ - !ruby/object:Gem::Version
256
+ version: 0.4.0
243
257
  description:
244
258
  email:
245
259
  - me@fearof.fish
@@ -273,6 +287,7 @@ files:
273
287
  - lib/jcf/cf/service_instance.rb
274
288
  - lib/jcf/cf/service_offering.rb
275
289
  - lib/jcf/cf/service_plan.rb
290
+ - lib/jcf/cf/services.rb
276
291
  - lib/jcf/cf/space.rb
277
292
  - lib/jcf/cf/user.rb
278
293
  - lib/jcf/cli.rb
@@ -286,6 +301,7 @@ files:
286
301
  - lib/jcf/cli/commands/cf/service_instances.rb
287
302
  - lib/jcf/cli/commands/cf/service_offerings.rb
288
303
  - lib/jcf/cli/commands/cf/service_plans.rb
304
+ - lib/jcf/cli/commands/cf/services.rb
289
305
  - lib/jcf/cli/commands/cf/spaces.rb
290
306
  - lib/jcf/cli/commands/cf/users.rb
291
307
  - lib/jcf/cli/commands/version.rb