kubeclient 4.9.1 → 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 +100 -0
  5. data/README.md +14 -4
  6. data/RELEASING.md +8 -8
  7. data/kubeclient.gemspec +10 -6
  8. data/lib/kubeclient/aws_eks_credentials.rb +17 -8
  9. data/lib/kubeclient/common.rb +24 -19
  10. data/lib/kubeclient/config.rb +22 -10
  11. data/lib/kubeclient/version.rb +1 -1
  12. data/lib/kubeclient/watch_stream.rb +1 -0
  13. metadata +45 -223
  14. data/.travis.yml +0 -29
  15. data/test/cassettes/kubernetes_guestbook.yml +0 -879
  16. data/test/config/allinone.kubeconfig +0 -20
  17. data/test/config/execauth.kubeconfig +0 -62
  18. data/test/config/external-ca.pem +0 -18
  19. data/test/config/external-cert.pem +0 -19
  20. data/test/config/external-key.rsa +0 -27
  21. data/test/config/external.kubeconfig +0 -20
  22. data/test/config/gcpauth.kubeconfig +0 -22
  23. data/test/config/gcpcmdauth.kubeconfig +0 -26
  24. data/test/config/nouser.kubeconfig +0 -16
  25. data/test/config/oidcauth.kubeconfig +0 -25
  26. data/test/config/timestamps.kubeconfig +0 -25
  27. data/test/config/userauth.kubeconfig +0 -28
  28. data/test/json/bindings_list.json +0 -10
  29. data/test/json/component_status.json +0 -17
  30. data/test/json/component_status_list.json +0 -52
  31. data/test/json/config.istio.io_api_resource_list.json +0 -679
  32. data/test/json/config_map_list.json +0 -9
  33. data/test/json/core_api_resource_list.json +0 -181
  34. data/test/json/core_api_resource_list_without_kind.json +0 -129
  35. data/test/json/core_oapi_resource_list_without_kind.json +0 -197
  36. data/test/json/created_endpoint.json +0 -28
  37. data/test/json/created_namespace.json +0 -20
  38. data/test/json/created_secret.json +0 -16
  39. data/test/json/created_security_context_constraint.json +0 -65
  40. data/test/json/created_service.json +0 -31
  41. data/test/json/empty_pod_list.json +0 -9
  42. data/test/json/endpoint_list.json +0 -48
  43. data/test/json/entity_list.json +0 -56
  44. data/test/json/event_list.json +0 -35
  45. data/test/json/extensions_v1beta1_api_resource_list.json +0 -217
  46. data/test/json/limit_range.json +0 -23
  47. data/test/json/limit_range_list.json +0 -31
  48. data/test/json/namespace.json +0 -13
  49. data/test/json/namespace_exception.json +0 -8
  50. data/test/json/namespace_list.json +0 -32
  51. data/test/json/node.json +0 -29
  52. data/test/json/node_list.json +0 -37
  53. data/test/json/node_notice.json +0 -160
  54. data/test/json/persistent_volume.json +0 -37
  55. data/test/json/persistent_volume_claim.json +0 -32
  56. data/test/json/persistent_volume_claim_list.json +0 -40
  57. data/test/json/persistent_volume_claims_nil_items.json +0 -8
  58. data/test/json/persistent_volume_list.json +0 -45
  59. data/test/json/pod.json +0 -92
  60. data/test/json/pod_list.json +0 -79
  61. data/test/json/pod_template_list.json +0 -9
  62. data/test/json/pods_1.json +0 -265
  63. data/test/json/pods_2.json +0 -102
  64. data/test/json/pods_410.json +0 -9
  65. data/test/json/processed_template.json +0 -27
  66. data/test/json/replication_controller.json +0 -57
  67. data/test/json/replication_controller_list.json +0 -66
  68. data/test/json/resource_quota.json +0 -46
  69. data/test/json/resource_quota_list.json +0 -54
  70. data/test/json/secret_list.json +0 -44
  71. data/test/json/security.openshift.io_api_resource_list.json +0 -69
  72. data/test/json/security_context_constraint_list.json +0 -375
  73. data/test/json/service.json +0 -33
  74. data/test/json/service_account.json +0 -25
  75. data/test/json/service_account_list.json +0 -82
  76. data/test/json/service_illegal_json_404.json +0 -1
  77. data/test/json/service_json_patch.json +0 -26
  78. data/test/json/service_list.json +0 -97
  79. data/test/json/service_merge_patch.json +0 -26
  80. data/test/json/service_patch.json +0 -25
  81. data/test/json/service_update.json +0 -22
  82. data/test/json/template.json +0 -27
  83. data/test/json/template.openshift.io_api_resource_list.json +0 -75
  84. data/test/json/template_list.json +0 -35
  85. data/test/json/versions_list.json +0 -6
  86. data/test/json/watch_stream.json +0 -3
  87. data/test/test_common.rb +0 -95
  88. data/test/test_common_url_handling.rb +0 -160
  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 -225
  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 -357
  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,97 +0,0 @@
1
- {
2
- "kind": "ServiceList",
3
- "apiVersion": "v1",
4
- "metadata": {
5
- "selfLink": "/api/v1/services",
6
- "resourceVersion": "36727"
7
- },
8
- "items": [
9
- {
10
- "metadata": {
11
- "name": "kubernetes",
12
- "namespace": "default",
13
- "selfLink": "/api/v1/namespaces/default/services/kubernetes",
14
- "uid": "b6606490-db86-11e4-b293-f8b156af4ae1",
15
- "resourceVersion": "6",
16
- "creationTimestamp": "2015-04-05T11:27:15Z",
17
- "labels": {
18
- "component": "apiserver",
19
- "provider": "kubernetes"
20
- }
21
- },
22
- "spec": {
23
- "ports": [
24
- {
25
- "name": "",
26
- "protocol": "TCP",
27
- "port": 443,
28
- "targetPort": 443
29
- }
30
- ],
31
- "selector": null,
32
- "clusterIP": "10.0.0.2",
33
- "sessionAffinity": "None"
34
- },
35
- "status": {}
36
- },
37
- {
38
- "metadata": {
39
- "name": "kubernetes-ro",
40
- "namespace": "default",
41
- "selfLink": "/api/v1/namespaces/default/services/kubernetes-ro",
42
- "uid": "b6606694-db86-11e4-b293-f8b156af4ae1",
43
- "resourceVersion": "5",
44
- "creationTimestamp": "2015-04-05T11:27:15Z",
45
- "labels": {
46
- "component": "apiserver",
47
- "provider": "kubernetes"
48
- }
49
- },
50
- "spec": {
51
- "ports": [
52
- {
53
- "name": "",
54
- "protocol": "TCP",
55
- "port": 80,
56
- "targetPort": 80
57
- }
58
- ],
59
- "selector": null,
60
- "clusterIP": "10.0.0.1",
61
- "sessionAffinity": "None"
62
- },
63
- "status": {}
64
- },
65
- {
66
- "metadata": {
67
- "name": "redis-slave",
68
- "namespace": "development",
69
- "selfLink": "/api/v1/namespaces/development/services/redis-slave",
70
- "uid": "bdb80a8f-db93-11e4-b293-f8b156af4ae1",
71
- "resourceVersion": "2815",
72
- "creationTimestamp": "2015-04-05T13:00:31Z",
73
- "labels": {
74
- "name": "redis",
75
- "role": "slave"
76
- }
77
- },
78
- "spec": {
79
- "ports": [
80
- {
81
- "name": "",
82
- "protocol": "TCP",
83
- "port": 6379,
84
- "targetPort": "redis-server"
85
- }
86
- ],
87
- "selector": {
88
- "name": "redis",
89
- "role": "slave"
90
- },
91
- "clusterIP": "10.0.0.140",
92
- "sessionAffinity": "None"
93
- },
94
- "status": {}
95
- }
96
- ]
97
- }
@@ -1,26 +0,0 @@
1
- {
2
- "status" : {},
3
- "kind" : "Service",
4
- "apiVersion" : "v1",
5
- "spec" : {
6
- "ports" : [
7
- {
8
- "targetPort" : 80,
9
- "nodePort" : 0,
10
- "port" : 80,
11
- "protocol" : "TCP"
12
- }
13
- ],
14
- "clusterIP" : "1.2.3.4",
15
- "type": "NodePort"
16
- },
17
- "metadata" : {
18
- "name" : "my-service",
19
- "creationTimestamp" : null,
20
- "namespace" : "development",
21
- "resourceVersion" : "2",
22
- "annotations" : {
23
- "key" : "value"
24
- }
25
- }
26
- }
@@ -1,25 +0,0 @@
1
- {
2
- "status" : {},
3
- "kind" : "Service",
4
- "apiVersion" : "v1",
5
- "spec" : {
6
- "ports" : [
7
- {
8
- "targetPort" : 80,
9
- "nodePort" : 0,
10
- "port" : 80,
11
- "protocol" : "TCP"
12
- }
13
- ],
14
- "clusterIP" : "1.2.3.4"
15
- },
16
- "metadata" : {
17
- "name" : "my_service",
18
- "creationTimestamp" : null,
19
- "namespace" : "development",
20
- "resourceVersion" : "2",
21
- "annotations" : {
22
- "key" : "value"
23
- }
24
- }
25
- }
@@ -1,22 +0,0 @@
1
- {
2
- "status" : {},
3
- "kind" : "Service",
4
- "apiVersion" : "v1",
5
- "spec" : {
6
- "ports" : [
7
- {
8
- "targetPort" : 80,
9
- "nodePort" : 0,
10
- "port" : 80,
11
- "protocol" : "TCP"
12
- }
13
- ],
14
- "clusterIP" : "1.2.3.4"
15
- },
16
- "metadata" : {
17
- "name" : "my_service",
18
- "creationTimestamp" : null,
19
- "namespace" : "default",
20
- "resourceVersion" : "2"
21
- }
22
- }
@@ -1,27 +0,0 @@
1
- {
2
- "apiVersion": "template.openshift.io/v1",
3
- "kind": "Template",
4
- "metadata": {
5
- "creationTimestamp": "2018-12-17T16:11:36Z",
6
- "name": "my-template",
7
- "namespace": "default",
8
- "resourceVersion": "21954",
9
- "selfLink": "/apis/template.openshift.io/v1/namespaces/default/templates/my-template",
10
- "uid": "6e03e3e6-0216-11e9-b1e0-68f728fac3ab"
11
- },
12
- "objects": [
13
- {
14
- "apiVersion": "v1",
15
- "kind": "Service",
16
- "metadata": {
17
- "name": "${NAME_PREFIX}my-service"
18
- }
19
- }
20
- ],
21
- "parameters": [
22
- {
23
- "description": "Prefix for names",
24
- "name": "NAME_PREFIX"
25
- }
26
- ]
27
- }
@@ -1,75 +0,0 @@
1
- {
2
- "kind": "APIResourceList",
3
- "apiVersion": "v1",
4
- "groupVersion": "template.openshift.io/v1",
5
- "resources": [
6
- {
7
- "name": "brokertemplateinstances",
8
- "singularName": "",
9
- "namespaced": false,
10
- "kind": "BrokerTemplateInstance",
11
- "verbs": [
12
- "create",
13
- "delete",
14
- "deletecollection",
15
- "get",
16
- "list",
17
- "patch",
18
- "update",
19
- "watch"
20
- ]
21
- },
22
- {
23
- "name": "processedtemplates",
24
- "singularName": "",
25
- "namespaced": true,
26
- "kind": "Template",
27
- "verbs": [
28
- "create"
29
- ]
30
- },
31
- {
32
- "name": "templateinstances",
33
- "singularName": "",
34
- "namespaced": true,
35
- "kind": "TemplateInstance",
36
- "verbs": [
37
- "create",
38
- "delete",
39
- "deletecollection",
40
- "get",
41
- "list",
42
- "patch",
43
- "update",
44
- "watch"
45
- ]
46
- },
47
- {
48
- "name": "templateinstances/status",
49
- "singularName": "",
50
- "namespaced": true,
51
- "kind": "TemplateInstance",
52
- "verbs": [
53
- "get",
54
- "patch",
55
- "update"
56
- ]
57
- },
58
- {
59
- "name": "templates",
60
- "singularName": "",
61
- "namespaced": true,
62
- "kind": "Template",
63
- "verbs": [
64
- "create",
65
- "delete",
66
- "deletecollection",
67
- "get",
68
- "list",
69
- "patch",
70
- "update",
71
- "watch"
72
- ]
73
- }
74
- ]
75
- }
@@ -1,35 +0,0 @@
1
- {
2
- "kind": "TemplateList",
3
- "apiVersion": "template.openshift.io/v1",
4
- "metadata": {
5
- "selfLink": "/apis/template.openshift.io/v1/namespaces/default/templates",
6
- "resourceVersion": "22758"
7
- },
8
- "items": [
9
- {
10
- "metadata": {
11
- "name": "my-template",
12
- "namespace": "default",
13
- "selfLink": "/apis/template.openshift.io/v1/namespaces/default/templates/my-template",
14
- "uid": "6e03e3e6-0216-11e9-b1e0-68f728fac3ab",
15
- "resourceVersion": "21954",
16
- "creationTimestamp": "2018-12-17T16:11:36Z"
17
- },
18
- "objects": [
19
- {
20
- "apiVersion": "v1",
21
- "kind": "Service",
22
- "metadata": {
23
- "name": "${NAME_PREFIX}my-service"
24
- }
25
- }
26
- ],
27
- "parameters": [
28
- {
29
- "name": "NAME_PREFIX",
30
- "description": "Prefix for names"
31
- }
32
- ]
33
- }
34
- ]
35
- }
@@ -1,6 +0,0 @@
1
- {
2
- "versions": [
3
- "v1beta3",
4
- "v1"
5
- ]
6
- }
@@ -1,3 +0,0 @@
1
- {"type":"ADDED","object":{"kind":"Pod","apiVersion":"v1","metadata":{"name":"php","namespace":"default","selfLink":"/api/v1/pods/php","uid":"e75f2c07-b047-11e4-89e4-525400c903c1","resourceVersion":"1389","creationTimestamp":"2015-02-09T05:39:19-05:00","labels":{"name":"foo"}},"spec":{"volumes":null,"containers":[{"name":"nginx","image":"dockerfile/nginx","ports":[{"hostPort":9090,"containerPort":80,"protocol":"TCP"}],"resources":{},"livenessProbe":{"httpGet":{"path":"/index.html","port":"9090"},"initialDelaySeconds":30},"terminationMessagePath":"/dev/termination-log","imagePullPolicy":"IfNotPresent","securityContext":{"capabilities":{}}}],"restartPolicy":{"always":{}},"dnsPolicy":"ClusterFirst"},"status":{"phase":"Pending"}}}
2
- {"type":"MODIFIED","object":{"kind":"Pod","apiVersion":"v1","metadata":{"name":"php","namespace":"default","selfLink":"/api/v1/pods/php","uid":"e75f2c07-b047-11e4-89e4-525400c903c1","resourceVersion":"1390","creationTimestamp":"2015-02-09T05:39:19-05:00","labels":{"name":"foo"}},"spec":{"volumes":null,"containers":[{"name":"nginx","image":"dockerfile/nginx","ports":[{"hostPort":9090,"containerPort":80,"protocol":"TCP"}],"resources":{},"livenessProbe":{"httpGet":{"path":"/index.html","port":"9090"},"initialDelaySeconds":30},"terminationMessagePath":"/dev/termination-log","imagePullPolicy":"IfNotPresent","securityContext":{"capabilities":{}}}],"restartPolicy":{"always":{}},"dnsPolicy":"ClusterFirst"},"status":{"phase":"Pending","host":"127.0.0.1"}}}
3
- {"type":"DELETED","object":{"kind":"Pod","apiVersion":"v1","metadata":{"name":"php","namespace":"default","selfLink":"/api/v1/pods/php","uid":"e75f2c07-b047-11e4-89e4-525400c903c1","resourceVersion":"1398","creationTimestamp":"2015-02-09T05:39:19-05:00","labels":{"name":"foo"}},"spec":{"volumes":null,"containers":[{"name":"nginx","image":"dockerfile/nginx","ports":[{"hostPort":9090,"containerPort":80,"protocol":"TCP"}],"resources":{},"livenessProbe":{"httpGet":{"path":"/index.html","port":"9090"},"initialDelaySeconds":30},"terminationMessagePath":"/dev/termination-log","imagePullPolicy":"IfNotPresent","securityContext":{"capabilities":{}}}],"restartPolicy":{"always":{}},"dnsPolicy":"ClusterFirst"},"status":{"phase":"Pending","host":"127.0.0.1"}}}
data/test/test_common.rb DELETED
@@ -1,95 +0,0 @@
1
-
2
- require_relative 'test_helper'
3
-
4
- # Unit tests for the common module
5
- class CommonTest < MiniTest::Test
6
- class ClientStub
7
- include Kubeclient::ClientMixin
8
- end
9
-
10
- def client
11
- @client ||= ClientStub.new
12
- end
13
-
14
- def test_underscore_entity
15
- %w[
16
- Pod pod
17
- Service service
18
- ReplicationController replication_controller
19
- Node node
20
- Event event
21
- Endpoint endpoint
22
- Namespace namespace
23
- Secret secret
24
- ResourceQuota resource_quota
25
- LimitRange limit_range
26
- PersistentVolume persistent_volume
27
- PersistentVolumeClaim persistent_volume_claim
28
- ComponentStatus component_status
29
- ServiceAccount service_account
30
- Project project
31
- Route route
32
- ClusterRoleBinding cluster_role_binding
33
- Build build
34
- BuildConfig build_config
35
- Image image
36
- ImageStream image_stream
37
- dogstatsd dogstatsd
38
- lowerCamelUPPERCase lower_camel_uppercase
39
- HTTPAPISpecBinding httpapispec_binding
40
- APIGroup apigroup
41
- APIGroupList apigroup_list
42
- APIResourceList apiresource_list
43
- APIService apiservice
44
- APIServiceList apiservice_list
45
- APIVersions apiversions
46
- OAuthAccessToken oauth_access_token
47
- OAuthAccessTokenList oauth_access_token_list
48
- OAuthAuthorizeToken oauth_authorize_token
49
- OAuthAuthorizeTokenList oauth_authorize_token_list
50
- OAuthClient oauth_client
51
- OAuthClientAuthorization oauth_client_authorization
52
- OAuthClientAuthorizationList oauth_client_authorization_list
53
- OAuthClientList oauth_client_list
54
- ].each_slice(2) do |kind, expected_underscore|
55
- underscore = Kubeclient::ClientMixin.underscore_entity(kind)
56
- assert_equal(underscore, expected_underscore)
57
- end
58
- end
59
-
60
- def test_format_datetime_with_string
61
- value = '2018-04-27T18:30:17.480321984Z'
62
- formatted = client.send(:format_datetime, value)
63
- assert_equal(formatted, value)
64
- end
65
-
66
- def test_format_datetime_with_datetime
67
- value = DateTime.new(2018, 4, 30, 19, 20, 33)
68
- formatted = client.send(:format_datetime, value)
69
- assert_equal(formatted, '2018-04-30T19:20:33.000000000+00:00')
70
- end
71
-
72
- def test_format_datetime_with_time
73
- value = Time.new(2018, 4, 30, 19, 20, 33, 0)
74
- formatted = client.send(:format_datetime, value)
75
- assert_equal(formatted, '2018-04-30T19:20:33.000000000+00:00')
76
- end
77
-
78
- def test_parse_definition_with_unconventional_names
79
- %w[
80
- PluralPolicy pluralpolicies plural_policy plural_policies
81
- LatinDatum latindata latin_datum latin_data
82
- Noseparator noseparators noseparator noseparators
83
- lowercase lowercases lowercase lowercases
84
- TestWithDash test-with-dashes test_with_dash test_with_dashes
85
- TestUnderscore test_underscores test_underscore test_underscores
86
- TestMismatch other-odd-name testmismatch otheroddname
87
- MixedDashMinus mixed-dash_minuses mixed_dash_minus mixed_dash_minuses
88
- SameUptoWordboundary sameup-toword-boundarys sameuptowordboundary sameuptowordboundarys
89
- ].each_slice(4) do |kind, plural, expected_single, expected_plural|
90
- method_names = Kubeclient::ClientMixin.parse_definition(kind, plural).method_names
91
- assert_equal(method_names[0], expected_single)
92
- assert_equal(method_names[1], expected_plural)
93
- end
94
- end
95
- end
@@ -1,160 +0,0 @@
1
- require_relative 'test_helper'
2
-
3
- # URLHandling tests
4
- class TestCommonUrlHandling < MiniTest::Test
5
- def test_no_path_in_uri
6
- client = Kubeclient::Client.new('http://localhost:8080', 'v1')
7
- rest_client = client.rest_client
8
- assert_equal('v1', client.instance_variable_get(:@api_version))
9
- assert_equal('', client.instance_variable_get(:@api_group))
10
- assert_equal('http://localhost:8080/api/v1', rest_client.url.to_s)
11
- end
12
-
13
- def test_with_api_path_in_uri
14
- client = Kubeclient::Client.new('http://localhost:8080/api', 'v1')
15
- rest_client = client.rest_client
16
- assert_equal('v1', client.instance_variable_get(:@api_version))
17
- assert_equal('', client.instance_variable_get(:@api_group))
18
- assert_equal('http://localhost:8080/api/v1', rest_client.url.to_s)
19
- end
20
-
21
- def test_with_api_path_in_uri_other_version
22
- client = Kubeclient::Client.new('http://localhost:8080/api', 'v2')
23
- rest_client = client.rest_client
24
- assert_equal('v2', client.instance_variable_get(:@api_version))
25
- assert_equal('', client.instance_variable_get(:@api_group))
26
- assert_equal('http://localhost:8080/api/v2', rest_client.url.to_s)
27
- end
28
-
29
- def test_with_api_group_path_in_uri
30
- client = Kubeclient::Client.new('http://localhost:8080/apis/this_is_the_group', 'v1')
31
- rest_client = client.rest_client
32
- assert_equal('v1', client.instance_variable_get(:@api_version))
33
- assert_equal('this_is_the_group/', client.instance_variable_get(:@api_group))
34
- assert_equal('http://localhost:8080/apis/this_is_the_group/v1', rest_client.url.to_s)
35
- end
36
-
37
- def test_with_api_group_path_in_uri_other_version
38
- client = Kubeclient::Client.new('http://localhost:8080/apis/this_is_the_group', 'v2')
39
- rest_client = client.rest_client
40
- assert_equal('v2', client.instance_variable_get(:@api_version))
41
- assert_equal('this_is_the_group/', client.instance_variable_get(:@api_group))
42
- assert_equal('http://localhost:8080/apis/this_is_the_group/v2', rest_client.url.to_s)
43
- end
44
-
45
- def test_with_api_path_in_uri_trailing_slash
46
- client = Kubeclient::Client.new('http://localhost:8080/api/', 'v1')
47
- rest_client = client.rest_client
48
- assert_equal('v1', client.instance_variable_get(:@api_version))
49
- assert_equal('', client.instance_variable_get(:@api_group))
50
- assert_equal('http://localhost:8080/api/v1', rest_client.url.to_s)
51
- end
52
-
53
- def test_with_api_path_in_api
54
- client = Kubeclient::Client.new('http://localhost:8080/api/but/I/want/a/hidden/k8s/api', 'v1')
55
- rest_client = client.rest_client
56
- assert_equal('v1', client.instance_variable_get(:@api_version))
57
- assert_equal('', client.instance_variable_get(:@api_group))
58
- assert_equal('http://localhost:8080/api/but/I/want/a/hidden/k8s/api/v1', rest_client.url.to_s)
59
- end
60
-
61
- def test_with_api_group_path_in_api
62
- client = Kubeclient::Client.new(
63
- 'http://localhost:8080/api/but/I/want/a/hidden/k8s/apis/this_is_the_group',
64
- 'v1'
65
- )
66
- rest_client = client.rest_client
67
- assert_equal('v1', client.instance_variable_get(:@api_version))
68
- assert_equal('this_is_the_group/', client.instance_variable_get(:@api_group))
69
- assert_equal(
70
- 'http://localhost:8080/api/but/I/want/a/hidden/k8s/apis/this_is_the_group/v1',
71
- rest_client.url.to_s
72
- )
73
- end
74
-
75
- def test_rancher_with_api_path_in_uri
76
- client = Kubeclient::Client.new('http://localhost:8080/k8s/clusters/c-somerancherID/api', 'v1')
77
- rest_client = client.rest_client
78
- assert_equal('v1', client.instance_variable_get(:@api_version))
79
- assert_equal('', client.instance_variable_get(:@api_group))
80
- assert_equal('http://localhost:8080/k8s/clusters/c-somerancherID/api/v1', rest_client.url.to_s)
81
- end
82
-
83
- def test_rancher_no_api_path_in_uri
84
- client = Kubeclient::Client.new('http://localhost:8080/k8s/clusters/c-somerancherID', 'v1')
85
- rest_client = client.rest_client
86
- assert_equal('v1', client.instance_variable_get(:@api_version))
87
- assert_equal('', client.instance_variable_get(:@api_group))
88
- assert_equal('http://localhost:8080/k8s/clusters/c-somerancherID/api/v1', rest_client.url.to_s)
89
- end
90
-
91
- def test_rancher_no_api_path_in_uri_trailing_slash
92
- client = Kubeclient::Client.new('http://localhost:8080/k8s/clusters/c-somerancherID/', 'v1')
93
- rest_client = client.rest_client
94
- assert_equal('v1', client.instance_variable_get(:@api_version))
95
- assert_equal('', client.instance_variable_get(:@api_group))
96
- assert_equal('http://localhost:8080/k8s/clusters/c-somerancherID/api/v1', rest_client.url.to_s)
97
- end
98
-
99
- def test_rancher_with_api_path_in_uri_trailing_slash
100
- client = Kubeclient::Client.new('http://localhost:8080/k8s/clusters/c-somerancherID/api/', 'v1')
101
- rest_client = client.rest_client
102
- assert_equal('v1', client.instance_variable_get(:@api_version))
103
- assert_equal('', client.instance_variable_get(:@api_group))
104
- assert_equal('http://localhost:8080/k8s/clusters/c-somerancherID/api/v1', rest_client.url.to_s)
105
- end
106
-
107
- def test_rancher_with_api_group_in_uri_trailing_slash
108
- client = Kubeclient::Client.new(
109
- 'http://localhost:8080/k8s/clusters/c-somerancherID/apis/this_is_the_group',
110
- 'v1'
111
- )
112
- rest_client = client.rest_client
113
- assert_equal('v1', client.instance_variable_get(:@api_version))
114
- assert_equal('this_is_the_group/', client.instance_variable_get(:@api_group))
115
- assert_equal(
116
- 'http://localhost:8080/k8s/clusters/c-somerancherID/apis/this_is_the_group/v1',
117
- rest_client.url.to_s
118
- )
119
- end
120
-
121
- def test_with_openshift_api_path_in_uri
122
- client = Kubeclient::Client.new('http://localhost:8080/oapi', 'v1')
123
- rest_client = client.rest_client
124
- assert_equal('v1', client.instance_variable_get(:@api_version))
125
- assert_equal('', client.instance_variable_get(:@api_group))
126
- assert_equal('http://localhost:8080/oapi/v1', rest_client.url.to_s)
127
- end
128
-
129
- def test_arbitrary_path_with_openshift_api_path_in_uri
130
- client = Kubeclient::Client.new('http://localhost:8080/foobarbaz/oapi', 'v1')
131
- rest_client = client.rest_client
132
- assert_equal('v1', client.instance_variable_get(:@api_version))
133
- assert_equal('', client.instance_variable_get(:@api_group))
134
- assert_equal('http://localhost:8080/foobarbaz/oapi/v1', rest_client.url.to_s)
135
- end
136
-
137
- def test_with_openshift_api_path_in_uri_trailing_slash
138
- client = Kubeclient::Client.new('http://localhost:8080/oapi/', 'v1')
139
- rest_client = client.rest_client
140
- assert_equal('v1', client.instance_variable_get(:@api_version))
141
- assert_equal('', client.instance_variable_get(:@api_group))
142
- assert_equal('http://localhost:8080/oapi/v1', rest_client.url.to_s)
143
- end
144
-
145
- def test_with_arbitrary_path_in_uri
146
- client = Kubeclient::Client.new('http://localhost:8080/foobarbaz', 'v1')
147
- rest_client = client.rest_client
148
- assert_equal('v1', client.instance_variable_get(:@api_version))
149
- assert_equal('', client.instance_variable_get(:@api_group))
150
- assert_equal('http://localhost:8080/foobarbaz/api/v1', rest_client.url.to_s)
151
- end
152
-
153
- def test_with_arbitrary_and_api_path_in_uri
154
- client = Kubeclient::Client.new('http://localhost:8080/foobarbaz/api', 'v1')
155
- rest_client = client.rest_client
156
- assert_equal('v1', client.instance_variable_get(:@api_version))
157
- assert_equal('', client.instance_variable_get(:@api_group))
158
- assert_equal('http://localhost:8080/foobarbaz/api/v1', rest_client.url.to_s)
159
- end
160
- end
@@ -1,29 +0,0 @@
1
- require_relative 'test_helper'
2
-
3
- # ComponentStatus tests
4
- class TestComponentStatus < MiniTest::Test
5
- def test_get_from_json_v3
6
- stub_core_api_list
7
- stub_request(:get, %r{/componentstatuses})
8
- .to_return(body: open_test_file('component_status.json'), status: 200)
9
-
10
- client = Kubeclient::Client.new('http://localhost:8080/api/', 'v1')
11
- component_status = client.get_component_status('etcd-0', 'default')
12
-
13
- assert_instance_of(Kubeclient::Resource, component_status)
14
- assert_equal('etcd-0', component_status.metadata.name)
15
- assert_equal('Healthy', component_status.conditions[0].type)
16
- assert_equal('True', component_status.conditions[0].status)
17
-
18
- assert_requested(
19
- :get,
20
- 'http://localhost:8080/api/v1',
21
- times: 1
22
- )
23
- assert_requested(
24
- :get,
25
- 'http://localhost:8080/api/v1/namespaces/default/componentstatuses/etcd-0',
26
- times: 1
27
- )
28
- end
29
- end