kubeclient 4.7.0 → 4.12.0

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.
Files changed (117) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/actions.yml +43 -0
  3. data/.rubocop.yml +111 -14
  4. data/CHANGELOG.md +119 -0
  5. data/README.md +41 -4
  6. data/RELEASING.md +8 -8
  7. data/kubeclient.gemspec +11 -7
  8. data/lib/kubeclient/aws_eks_credentials.rb +17 -8
  9. data/lib/kubeclient/common.rb +55 -21
  10. data/lib/kubeclient/config.rb +33 -13
  11. data/lib/kubeclient/exec_credentials.rb +33 -4
  12. data/lib/kubeclient/version.rb +1 -1
  13. data/lib/kubeclient/watch_stream.rb +1 -0
  14. metadata +46 -222
  15. data/.travis.yml +0 -29
  16. data/test/cassettes/kubernetes_guestbook.yml +0 -879
  17. data/test/config/allinone.kubeconfig +0 -20
  18. data/test/config/execauth.kubeconfig +0 -62
  19. data/test/config/external-ca.pem +0 -18
  20. data/test/config/external-cert.pem +0 -19
  21. data/test/config/external-key.rsa +0 -27
  22. data/test/config/external.kubeconfig +0 -20
  23. data/test/config/gcpauth.kubeconfig +0 -22
  24. data/test/config/gcpcmdauth.kubeconfig +0 -26
  25. data/test/config/nouser.kubeconfig +0 -16
  26. data/test/config/oidcauth.kubeconfig +0 -25
  27. data/test/config/timestamps.kubeconfig +0 -25
  28. data/test/config/userauth.kubeconfig +0 -28
  29. data/test/json/bindings_list.json +0 -10
  30. data/test/json/component_status.json +0 -17
  31. data/test/json/component_status_list.json +0 -52
  32. data/test/json/config.istio.io_api_resource_list.json +0 -679
  33. data/test/json/config_map_list.json +0 -9
  34. data/test/json/core_api_resource_list.json +0 -181
  35. data/test/json/core_api_resource_list_without_kind.json +0 -129
  36. data/test/json/core_oapi_resource_list_without_kind.json +0 -197
  37. data/test/json/created_endpoint.json +0 -28
  38. data/test/json/created_namespace.json +0 -20
  39. data/test/json/created_secret.json +0 -16
  40. data/test/json/created_security_context_constraint.json +0 -65
  41. data/test/json/created_service.json +0 -31
  42. data/test/json/empty_pod_list.json +0 -9
  43. data/test/json/endpoint_list.json +0 -48
  44. data/test/json/entity_list.json +0 -56
  45. data/test/json/event_list.json +0 -35
  46. data/test/json/extensions_v1beta1_api_resource_list.json +0 -217
  47. data/test/json/limit_range.json +0 -23
  48. data/test/json/limit_range_list.json +0 -31
  49. data/test/json/namespace.json +0 -13
  50. data/test/json/namespace_exception.json +0 -8
  51. data/test/json/namespace_list.json +0 -32
  52. data/test/json/node.json +0 -29
  53. data/test/json/node_list.json +0 -37
  54. data/test/json/node_notice.json +0 -160
  55. data/test/json/persistent_volume.json +0 -37
  56. data/test/json/persistent_volume_claim.json +0 -32
  57. data/test/json/persistent_volume_claim_list.json +0 -40
  58. data/test/json/persistent_volume_claims_nil_items.json +0 -8
  59. data/test/json/persistent_volume_list.json +0 -45
  60. data/test/json/pod.json +0 -92
  61. data/test/json/pod_list.json +0 -79
  62. data/test/json/pod_template_list.json +0 -9
  63. data/test/json/pods_1.json +0 -265
  64. data/test/json/pods_2.json +0 -102
  65. data/test/json/pods_410.json +0 -9
  66. data/test/json/processed_template.json +0 -27
  67. data/test/json/replication_controller.json +0 -57
  68. data/test/json/replication_controller_list.json +0 -66
  69. data/test/json/resource_quota.json +0 -46
  70. data/test/json/resource_quota_list.json +0 -54
  71. data/test/json/secret_list.json +0 -44
  72. data/test/json/security.openshift.io_api_resource_list.json +0 -69
  73. data/test/json/security_context_constraint_list.json +0 -375
  74. data/test/json/service.json +0 -33
  75. data/test/json/service_account.json +0 -25
  76. data/test/json/service_account_list.json +0 -82
  77. data/test/json/service_illegal_json_404.json +0 -1
  78. data/test/json/service_json_patch.json +0 -26
  79. data/test/json/service_list.json +0 -97
  80. data/test/json/service_merge_patch.json +0 -26
  81. data/test/json/service_patch.json +0 -25
  82. data/test/json/service_update.json +0 -22
  83. data/test/json/template.json +0 -27
  84. data/test/json/template.openshift.io_api_resource_list.json +0 -75
  85. data/test/json/template_list.json +0 -35
  86. data/test/json/versions_list.json +0 -6
  87. data/test/json/watch_stream.json +0 -3
  88. data/test/test_common.rb +0 -95
  89. data/test/test_component_status.rb +0 -29
  90. data/test/test_config.rb +0 -222
  91. data/test/test_endpoint.rb +0 -54
  92. data/test/test_exec_credentials.rb +0 -125
  93. data/test/test_gcp_command_credentials.rb +0 -27
  94. data/test/test_google_application_default_credentials.rb +0 -15
  95. data/test/test_guestbook_go.rb +0 -235
  96. data/test/test_helper.rb +0 -18
  97. data/test/test_kubeclient.rb +0 -881
  98. data/test/test_limit_range.rb +0 -25
  99. data/test/test_missing_methods.rb +0 -80
  100. data/test/test_namespace.rb +0 -59
  101. data/test/test_node.rb +0 -70
  102. data/test/test_oidc_auth_provider.rb +0 -103
  103. data/test/test_persistent_volume.rb +0 -29
  104. data/test/test_persistent_volume_claim.rb +0 -28
  105. data/test/test_pod.rb +0 -81
  106. data/test/test_pod_log.rb +0 -157
  107. data/test/test_process_template.rb +0 -80
  108. data/test/test_replication_controller.rb +0 -47
  109. data/test/test_resource_list_without_kind.rb +0 -78
  110. data/test/test_resource_quota.rb +0 -23
  111. data/test/test_secret.rb +0 -62
  112. data/test/test_security_context_constraint.rb +0 -62
  113. data/test/test_service.rb +0 -330
  114. data/test/test_service_account.rb +0 -26
  115. data/test/test_watch.rb +0 -195
  116. data/test/txt/pod_log.txt +0 -6
  117. data/test/valid_token_file +0 -1
@@ -1,26 +0,0 @@
1
- require_relative 'test_helper'
2
-
3
- # ServiceAccount tests
4
- class TestServiceAccount < MiniTest::Test
5
- def test_get_from_json_v1
6
- stub_core_api_list
7
- stub_request(:get, %r{/serviceaccounts})
8
- .to_return(body: open_test_file('service_account.json'),
9
- status: 200)
10
-
11
- client = Kubeclient::Client.new('http://localhost:8080/api/', 'v1')
12
- account = client.get_service_account('default')
13
-
14
- assert_instance_of(Kubeclient::Resource, account)
15
- assert_equal('default', account.metadata.name)
16
- assert_equal('default-token-6s23q', account.secrets[0].name)
17
- assert_equal('default-dockercfg-62tf3', account.secrets[1].name)
18
-
19
- assert_requested(:get,
20
- 'http://localhost:8080/api/v1/serviceaccounts/default',
21
- times: 1)
22
- assert_requested(:get,
23
- 'http://localhost:8080/api/v1',
24
- times: 1)
25
- end
26
- end
data/test/test_watch.rb DELETED
@@ -1,195 +0,0 @@
1
- require_relative 'test_helper'
2
-
3
- # Watch entity tests
4
- class TestWatch < MiniTest::Test
5
- def test_watch_pod_success
6
- stub_core_api_list
7
-
8
- expected = [
9
- { 'type' => 'ADDED', 'resourceVersion' => '1389' },
10
- { 'type' => 'MODIFIED', 'resourceVersion' => '1390' },
11
- { 'type' => 'DELETED', 'resourceVersion' => '1398' }
12
- ]
13
-
14
- stub_request(:get, %r{/watch/pods})
15
- .to_return(body: open_test_file('watch_stream.json'),
16
- status: 200)
17
-
18
- client = Kubeclient::Client.new('http://localhost:8080/api/', 'v1')
19
-
20
- client.watch_pods.to_enum.with_index do |notice, index|
21
- assert_instance_of(Kubeclient::Resource, notice)
22
- assert_equal(expected[index]['type'], notice.type)
23
- assert_equal('Pod', notice.object.kind)
24
- assert_equal('php', notice.object.metadata.name)
25
- assert_equal(expected[index]['resourceVersion'],
26
- notice.object.metadata.resourceVersion)
27
- end
28
- end
29
-
30
- def test_watch_pod_block
31
- stub_core_api_list
32
- stub_request(:get, %r{/watch/pods})
33
- .to_return(body: open_test_file('watch_stream.json'),
34
- status: 200)
35
-
36
- client = Kubeclient::Client.new('http://localhost:8080/api/', 'v1')
37
- yielded = []
38
- client.watch_pods { |notice| yielded << notice.type }
39
-
40
- assert_equal %w[ADDED MODIFIED DELETED], yielded
41
- end
42
-
43
- def test_watch_pod_raw
44
- stub_core_api_list
45
-
46
- stub_request(:get, %r{/watch/pods}).to_return(
47
- body: open_test_file('watch_stream.json'),
48
- status: 200
49
- )
50
-
51
- client = Kubeclient::Client.new('http://localhost:8080/api/', 'v1')
52
-
53
- got = nil
54
- client.watch_pods(as: :raw).each { |notice| got = notice }
55
- assert_match(/\A{"type":"DELETED"/, got)
56
- end
57
-
58
- def test_watch_pod_failure
59
- stub_core_api_list
60
- stub_request(:get, %r{/watch/pods}).to_return(status: 404)
61
-
62
- client = Kubeclient::Client.new('http://localhost:8080/api/', 'v1')
63
- assert_raises(Kubeclient::HttpError) do
64
- client.watch_pods.each do
65
- end
66
- end
67
- end
68
-
69
- def test_watch_pod_follow_redirect
70
- stub_core_api_list
71
-
72
- redirect = 'http://localhost:1234/api/v1/watch/pods'
73
- stub_request(:get, %r{/watch/pods})
74
- .to_return(status: 302, headers: { location: redirect })
75
-
76
- stub_request(:get, redirect).to_return(
77
- body: open_test_file('watch_stream.json'),
78
- status: 200
79
- )
80
-
81
- client = Kubeclient::Client.new('http://localhost:8080/api/', 'v1')
82
-
83
- got = nil
84
- client.watch_pods.each { |notice| got = notice }
85
- assert_equal('DELETED', got.type)
86
- end
87
-
88
- def test_watch_pod_max_redirect
89
- stub_core_api_list
90
-
91
- redirect = 'http://localhost:1234/api/v1/watcher/pods'
92
- stub_request(:get, %r{/watch/pods})
93
- .to_return(status: 302, headers: { location: redirect })
94
-
95
- stub_request(:get, redirect).to_return(
96
- body: open_test_file('watch_stream.json'),
97
- status: 200
98
- )
99
-
100
- client = Kubeclient::Client.new('http://localhost:8080/api/', 'v1', http_max_redirects: 0)
101
-
102
- assert_raises(Kubeclient::HttpError) do
103
- client.watch_pods.each do
104
- end
105
- end
106
- end
107
-
108
- # Ensure that WatchStream respects a format that's not JSON
109
- def test_watch_stream_text
110
- url = 'http://www.example.com/foobar'
111
- expected_lines = open_test_file('pod_log.txt').read.split("\n")
112
-
113
- stub_request(:get, url)
114
- .to_return(body: open_test_file('pod_log.txt'),
115
- status: 200)
116
-
117
- stream = Kubeclient::Common::WatchStream.new(URI.parse(url), {}, formatter: ->(v) { v })
118
- stream.to_enum.with_index do |line, index|
119
- assert_instance_of(String, line)
120
- assert_equal(expected_lines[index], line)
121
- end
122
- end
123
-
124
- def test_watch_with_resource_version
125
- api_host = 'http://localhost:8080/api'
126
- version = '1995'
127
- stub_core_api_list
128
- stub_request(:get, %r{.*\/watch/events})
129
- .to_return(body: open_test_file('watch_stream.json'),
130
- status: 200)
131
-
132
- client = Kubeclient::Client.new(api_host, 'v1')
133
- results = client.watch_events(version).to_enum
134
-
135
- assert_equal(3, results.count)
136
- assert_requested(:get,
137
- "#{api_host}/v1/watch/events?resourceVersion=#{version}",
138
- times: 1)
139
- end
140
-
141
- def test_watch_with_label_selector
142
- api_host = 'http://localhost:8080/api'
143
- selector = 'name=redis-master'
144
-
145
- stub_core_api_list
146
- stub_request(:get, %r{.*\/watch/events})
147
- .to_return(body: open_test_file('watch_stream.json'),
148
- status: 200)
149
-
150
- client = Kubeclient::Client.new(api_host, 'v1')
151
- results = client.watch_events(label_selector: selector).to_enum
152
-
153
- assert_equal(3, results.count)
154
- assert_requested(:get,
155
- "#{api_host}/v1/watch/events?labelSelector=#{selector}",
156
- times: 1)
157
- end
158
-
159
- def test_watch_with_field_selector
160
- api_host = 'http://localhost:8080/api'
161
- selector = 'involvedObject.kind=Pod'
162
-
163
- stub_core_api_list
164
- stub_request(:get, %r{.*\/watch/events})
165
- .to_return(body: open_test_file('watch_stream.json'),
166
- status: 200)
167
-
168
- client = Kubeclient::Client.new(api_host, 'v1')
169
- results = client.watch_events(field_selector: selector).to_enum
170
-
171
- assert_equal(3, results.count)
172
- assert_requested(:get,
173
- "#{api_host}/v1/watch/events?fieldSelector=#{selector}",
174
- times: 1)
175
- end
176
-
177
- def test_watch_with_finish_and_ebadf
178
- api_host = 'http://localhost:8080/api'
179
-
180
- stub_core_api_list
181
- stub_request(:get, %r{.*\/watch/events})
182
- .to_return(body: open_test_file('watch_stream.json'), status: 200)
183
-
184
- client = Kubeclient::Client.new(api_host, 'v1')
185
- watcher = client.watch_events
186
-
187
- # explodes when StandardError is not caught
188
- watcher.each do
189
- watcher.finish
190
- raise StandardError
191
- end
192
-
193
- assert_requested(:get, "#{api_host}/v1/watch/events", times: 1)
194
- end
195
- end
data/test/txt/pod_log.txt DELETED
@@ -1,6 +0,0 @@
1
- Initializing server...
2
- ...loaded configuration
3
- ...updated settings
4
- ...discovered local servers
5
- ...frobinated disks
6
- Complete!
@@ -1 +0,0 @@
1
- valid_token