volcano-sdk 0.32.3 → 0.32.4

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: 9d3d0ea5cca245b91aacf3a1df887df87aa5ca81419e1410019f9536fcb640aa
4
- data.tar.gz: 7173bed2407482a5122d11439e2c557764c1ed10463012490c38448e480bfbb8
3
+ metadata.gz: 5ef8f141d5ef4704ebc727b5836e416fb382af153ad9eb7748ef9d77181c947f
4
+ data.tar.gz: 271d7a8647274d6229de1f89fae7521486bc8617c9f4caa9b37d69b859fc9e7f
5
5
  SHA512:
6
- metadata.gz: 7fe8b416c01cf5be74751679b0487e9f5c6031ff35caa039b936b63eb49fdf87ece8f3e65e7afbd28f4acf3ccbddf3892f492d2796aec82f59c840ba82f4c7fe
7
- data.tar.gz: 76844522cca4fbfefb369d9d597079d5b6ae28d385a297f77b43c012c6101b3fbc42bd96f9dee82da7a9f66b318e9446b17524e4803f9f9e83ed9cac4d9a1e64
6
+ metadata.gz: 51b1d9f99ed3b506ae5716c89c29e558d5a7b3cd8b1d324a00c7adc05dc9d4c23753797c0d1d317d0f059a91574e461af32c15b9a37eefe4f43d9820db594b21
7
+ data.tar.gz: 60a608b1b29a3599abdcbc815c37a6f49073921eabdec82926f7f6c51024a1b3ca2f803d72b7c4256722955d5db9e7cc2d3dcba22b6005581bc7581019f54201
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'json'
4
+
3
5
  module Volcano
4
6
  # Validates object metadata and paginated storage responses.
5
7
  module StorageObjectResponse
@@ -69,20 +71,40 @@ module Volcano
69
71
  def storage_json_hash(value)
70
72
  raise Error::TransportError, 'invalid storage JSON object' unless value.is_a?(Hash)
71
73
 
74
+ # @type var active: Hash[Integer, bool]
75
+ active = {}
76
+ copy = storage_json_container(value, active) { storage_json_entries(value, active) }
77
+ JSON.generate(copy)
78
+ copy
79
+ rescue JSON::GeneratorError
80
+ raise Error::TransportError, 'invalid storage JSON value', cause: nil
81
+ end
82
+
83
+ def storage_json_entries(value, active)
72
84
  value.to_h do |key, item|
73
85
  raise Error::TransportError, 'invalid storage JSON key' unless key.is_a?(String)
74
86
 
75
- [key, storage_json_value(item)]
87
+ [key, storage_json_value(item, active)]
76
88
  end
77
89
  end
78
90
 
79
- def storage_json_value(value)
91
+ def storage_json_value(value, active)
80
92
  case value
81
93
  when NilClass, TrueClass, FalseClass, Integer, Float, String then value
82
- when Array then value.map { |item| storage_json_value(item) }
83
- when Hash then storage_json_hash(value)
94
+ when Array then storage_json_container(value, active) { value.map { |item| storage_json_value(item, active) } }
95
+ when Hash then storage_json_container(value, active) { storage_json_entries(value, active) }
84
96
  else raise Error::TransportError, 'invalid storage JSON value'
85
97
  end
86
98
  end
99
+
100
+ def storage_json_container(value, active)
101
+ id = value.object_id
102
+ raise Error::TransportError, 'invalid storage JSON value' if active.key?(id) || active.size >= 100
103
+
104
+ active[id] = true
105
+ copy = yield
106
+ active.delete(id)
107
+ copy
108
+ end
87
109
  end
88
110
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Volcano
4
- VERSION = '0.32.3'
4
+ VERSION = '0.32.4'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: volcano-sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.32.3
4
+ version: 0.32.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kong