├── .gitignore ├── CHANGELOG.md ├── LICENSE ├── README.md ├── project.clj ├── resources ├── openapiv2 │ ├── v1.21.14.json │ └── v1.23.17.json └── swagger │ ├── apps_v1.json │ ├── apps_v1beta1.json │ ├── apps_v1beta2.json │ ├── autoscaling_v1.json │ ├── autoscaling_v2beta1.json │ ├── batch_v1beta1.json │ ├── extensions_v1beta1.json │ ├── kedash_v1alpha1.json │ ├── networking_k8s_io_v1.json │ ├── policy_v1beta1.json │ └── v1.json ├── src └── kubernetes │ └── api │ ├── apps_v1.clj │ ├── apps_v1beta1.clj │ ├── apps_v1beta2.clj │ ├── autoscaling_v1.clj │ ├── autoscaling_v2.clj │ ├── autoscaling_v2beta1.clj │ ├── batch_v1.clj │ ├── batch_v1beta1.clj │ ├── extensions_v1beta1.clj │ ├── kedash_v1alpha1.clj │ ├── networking_istio_io_v1beta1.clj │ ├── networking_k8s_io_v1.clj │ ├── openapiv2.clj │ ├── policy_v1.clj │ ├── policy_v1beta1.clj │ ├── security_istio_io_v1.clj │ ├── storage_k8s_io_v1.clj │ ├── swagger.clj │ ├── util.clj │ └── v1.clj └── test └── kubernetes └── api ├── apps_v1_test.clj ├── apps_v1beta1_test.clj ├── apps_v1beta2_test.clj ├── autoscaling_v1_test.clj ├── batch_v1beta1_test.clj ├── common.clj ├── extensions_v1beta1_test.clj ├── policy_v1beta1_test.clj ├── storage_k8s_io_v1_test.clj ├── util_test.clj └── v1_test.clj /.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | /classes 3 | /checkouts 4 | pom.xml 5 | pom.xml.asc 6 | *.jar 7 | *.class 8 | /.lein-* 9 | /.nrepl-port 10 | .hgignore 11 | .hg/ 12 | *.iml 13 | *.swp 14 | .idea/* 15 | 16 | doc 17 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | All notable changes to this project will be documented in this file. This change log follows the conventions of [keepachangelog.com](http://keepachangelog.com/). 3 | 4 | ## [1.14.0] - 2023-11-17 5 | ### Added 6 | - Add batch/v1 namespace 7 | 8 | ## [1.13.0] - 2023-08-01 9 | ### Added 10 | - Add autoscaling/v2 namespace 11 | 12 | ## [1.12.0] - 2023-08-01 13 | ### Added 14 | - Add policy/v1 namespace 15 | 16 | ## [1.11.0] - 2023-08-01 17 | ### Added 18 | - Add `kubernetes.api.storage-k8s-io-v1` namespace 19 | - Add `declare` statement to allow static analysis to know about methods on `kubernetes.api.v1` 20 | 21 | ## [1.10.0] - 2022-07-12 22 | ### Added 23 | - Add security.istio.io namespace 24 | 25 | ## [1.9.0] - 2022-07-06 26 | ### Added 27 | - Add networking.istio.io namespace 28 | 29 | ## [1.8.0] - 2022-12-08 30 | ### Added 31 | - Add networking.k8s.io namespace 32 | - Namespace to support openapiv2 33 | 34 | ## [0.1.1] - 2015-12-02 35 | ### Changed 36 | - Documentation on how to make the widgets. 37 | 38 | ### Removed 39 | - `make-widget-sync` - we're all async, all the time. 40 | 41 | ### Fixed 42 | - Fixed widget maker to keep working when daylight savings switches over. 43 | 44 | ## 0.1.0 - 2015-12-02 45 | ### Added 46 | - Files from the new template. 47 | - Widget maker public API - `make-widget-sync`. 48 | 49 | [unreleased]: https://github.com/your-name/kubernetes.api/compare/0.1.1...HEAD 50 | [0.1.1]: https://github.com/your-name/kubernetes.api/compare/0.1.0...0.1.1 51 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Jon Eisen 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # kubernetes-api 2 | 3 | Kubernetes client API library for Clojure. Functions are generated using macros derived from offical [swagger spec](http://kubernetes.io/swagger-spec/api/v1). 4 | 5 | [![cljdoc documentation](https://cljdoc.org/badge/nubank/kubernetes-api)](https://cljdoc.org/d/nubank/kubernetes-api/) 6 | 7 | ## Installation 8 | 9 | Add the dependency to your `project.clj`. 10 | 11 | [![Clojars Project](https://img.shields.io/clojars/v/nubank/kubernetes-api.svg)](https://clojars.org/nubank/kubernetes-api) 12 | 13 | ## Usage 14 | 15 | First, run a kubernetes proxy with `kubectl proxy --port=8080`. 16 | 17 | Each endpoint function returns a [core.async](https://github.com/clojure/core.async) channel. Under the covers, the [http-kit](https://www.http-kit.org) http client is used. 18 | 19 | ```clojure 20 | (require '[kubernetes.api.v1 :as k8s] 21 | '[clojure.core.async :refer [apis [paths] 19 | (mapv (fn [[path {:keys [parameters] :as operations}]] 20 | {:path (subs (str path) 1) 21 | :operations (mapv (fn [[method operation]] 22 | {:type "" 23 | :consumes (:consumes operation) 24 | :produces (:produces operation) 25 | :summary (:description operation) 26 | :nickname (:operationId operation) 27 | :method (str/upper-case (name method)) 28 | :x-kubernetes-group-version-kind (:x-kubernetes-group-version-kind operation) 29 | :parameters (operation-parameters parameters (:parameters operation))}) 30 | (select-keys operations [:get :patch :delete :put :post :head :options]))}) 31 | paths)) 32 | 33 | (defn openapiv2->swagger [openapiv2] 34 | {:swaggerVersion "1.2" 35 | :apis (paths->apis (:paths openapiv2))}) 36 | 37 | 38 | (defn filter-operations [api-group api-version api] 39 | (update api :operations 40 | (fn [operations] 41 | (vec (filter (fn [{{:keys [group version]} :x-kubernetes-group-version-kind}] 42 | (and (= api-group group) (= api-version version))) 43 | operations))))) 44 | 45 | (defn filter-api-group [swagger-definition api-group version] 46 | (update swagger-definition :apis 47 | (fn [apis] 48 | (->> apis 49 | (map (partial filter-operations api-group version)) 50 | (filter (comp not-empty :operations)))))) 51 | 52 | (defmacro render-api-group [k8s-version api-group version] 53 | (-> (str "openapiv2/" k8s-version ".json") 54 | io/resource 55 | slurp 56 | (json/read-str :key-fn keyword) 57 | openapiv2->swagger 58 | (filter-api-group api-group version) 59 | swagger/render-swagger)) 60 | 61 | (defmacro render-full-api [k8s-version] 62 | (-> (str "openapiv2/" k8s-version ".json") 63 | io/resource 64 | slurp 65 | (json/read-str :key-fn keyword) 66 | openapiv2->swagger 67 | swagger/render-swagger)) 68 | -------------------------------------------------------------------------------- /src/kubernetes/api/policy_v1.clj: -------------------------------------------------------------------------------- 1 | (ns kubernetes.api.policy-v1 2 | (:require [kubernetes.api.openapiv2 :as openapiv2] 3 | [kubernetes.api.util :as util])) 4 | 5 | (def make-context util/make-context) 6 | 7 | (openapiv2/render-api-group "v1.23.17" "policy" "v1") -------------------------------------------------------------------------------- /src/kubernetes/api/policy_v1beta1.clj: -------------------------------------------------------------------------------- 1 | (ns kubernetes.api.policy-v1beta1 2 | (:require [kubernetes.api.swagger :as swagger] 3 | [kubernetes.api.util :as util])) 4 | 5 | (def make-context util/make-context) 6 | 7 | (swagger/render-full-api "policy_v1beta1") 8 | -------------------------------------------------------------------------------- /src/kubernetes/api/security_istio_io_v1.clj: -------------------------------------------------------------------------------- 1 | (ns kubernetes.api.security-istio-io-v1 2 | (:require [kubernetes.api.openapiv2 :as openapiv2] 3 | [kubernetes.api.util :as util])) 4 | 5 | (def make-context util/make-context) 6 | 7 | (openapiv2/render-api-group "v1.23.17" "security.istio.io" "v1") 8 | -------------------------------------------------------------------------------- /src/kubernetes/api/storage_k8s_io_v1.clj: -------------------------------------------------------------------------------- 1 | (ns kubernetes.api.storage-k8s-io-v1 2 | (:require [kubernetes.api.openapiv2 :as openapiv2] 3 | [kubernetes.api.util :as util])) 4 | 5 | (def make-context util/make-context) 6 | 7 | (openapiv2/render-api-group "v1.23.17" "storage.k8s.io" "v1") 8 | 9 | ; expose dynamically generated vars for static analysis 10 | (declare 11 | create-storage-v1csi-driver 12 | create-storage-v1csi-node 13 | create-storage-v1storage-class 14 | create-storage-v1volume-attachment 15 | delete-storage-v1collection-csi-driver 16 | delete-storage-v1collection-csi-node 17 | delete-storage-v1collection-storage-class 18 | delete-storage-v1collection-volume-attachment 19 | delete-storage-v1csi-driver 20 | delete-storage-v1csi-node 21 | delete-storage-v1storage-class 22 | delete-storage-v1volume-attachment 23 | list-storage-v1csi-driver 24 | list-storage-v1csi-node 25 | list-storage-v1storage-class 26 | list-storage-v1volume-attachment 27 | patch-storage-v1csi-driver 28 | patch-storage-v1csi-node 29 | patch-storage-v1storage-class 30 | patch-storage-v1volume-attachment 31 | patch-storage-v1volume-attachment-status 32 | read-storage-v1csi-driver 33 | read-storage-v1csi-node 34 | read-storage-v1storage-class 35 | read-storage-v1volume-attachment 36 | read-storage-v1volume-attachment-status 37 | replace-storage-v1csi-driver 38 | replace-storage-v1csi-node 39 | replace-storage-v1storage-class 40 | replace-storage-v1volume-attachment 41 | replace-storage-v1volume-attachment-status) 42 | -------------------------------------------------------------------------------- /src/kubernetes/api/swagger.clj: -------------------------------------------------------------------------------- 1 | (ns kubernetes.api.swagger 2 | "Render client API functions from swagger doc using macros" 3 | (:require [clojure.string :as str] 4 | [clojure.java.io :as io] 5 | [clojure.data.json :as json] 6 | [kubernetes.api.util :as util])) 7 | 8 | 9 | (defn capital? [c] (let [i (int c)] (and (<= i 90) (>= i 65)))) 10 | 11 | (defn camel->dashed [nickname] 12 | (-> nickname 13 | (str/replace #"([a-z])([A-Z])" "$1-$2") 14 | (str/replace #"([A-Z]+)([A-Z][a-z])" "$1-$2") 15 | str/lower-case)) 16 | 17 | (defn renderable-param? [{:keys [name] :as param}] 18 | (not (#{"watch" "pretty" "timeoutSeconds" "resourceVersion"} name))) 19 | 20 | (defn render-doc-param [{:keys [type name description 21 | required allowMultiple]}] 22 | (str (camel->dashed name) 23 | ": " (if required "required" "optional") 24 | " " (if allowMultiple (str "[" type "]") type) 25 | " " description)) 26 | 27 | (defn body-param-type [params] 28 | (->> params 29 | (filter #(= (:paramType %) "body")) 30 | first 31 | :type)) 32 | 33 | (defn render-doc-str [method path summary ret-type params] 34 | (str "\nCalls " method " on " path 35 | "\n" summary 36 | "\nParameters:" 37 | "\n\t- ctx: required server context" 38 | (if (not= method "GET") 39 | (str "\n\t- body: required " (body-param-type params)) 40 | "") 41 | (if (not-empty params) 42 | (str "\nOptions:\n\t- " (str/join "\n\t- " (map render-doc-param params)))) 43 | "\nReturns " ret-type)) 44 | 45 | (defn renderable-op? 46 | "Return true if op is renderable" 47 | [{:keys [produces nickname] :as op}] 48 | (and (some #{"application/json"} produces) 49 | (not (.startsWith nickname "watch")))) 50 | 51 | (defn param-by-f [params f] 52 | (->> params 53 | (filter f) 54 | (map :name) 55 | (map camel->dashed) 56 | (map keyword) 57 | vec)) 58 | (defn param-by-type [params type] (param-by-f params #(= (:paramType %) type))) 59 | 60 | (defn render-op [{:keys [path] :as api} 61 | {:keys [nickname summary method type] 62 | params :parameters 63 | [{ret-type :responseModel}] :responseMessages 64 | :as op}] 65 | (let [params (filter renderable-param? params) 66 | fn-name (symbol (camel->dashed nickname)) 67 | doc-str (render-doc-str method path summary ret-type params) 68 | method-kw (-> method str/lower-case keyword) 69 | body-param (first (param-by-type params "body"))] 70 | `(defn ~fn-name ~doc-str [ctx# & [body?# opts?#]] 71 | (let [required-body# ~(some? body-param) 72 | [body# opts#] (if required-body# [body?# opts?#] [nil body?#]) 73 | path-params# ~(param-by-type params "path") 74 | req-params# ~(param-by-f params 75 | #(and (:required %) 76 | (not= (:paramType %) "body"))) 77 | query-params# ~(param-by-type params "query")] 78 | (assert (if required-body# (some? body#) (nil? body#)) 79 | (if required-body# "Body is required" "Body is prohibited")) 80 | (assert (every? #(get opts# %) req-params#) 81 | (str "Missing required options: " 82 | (pr-str (filter #(not (get opts# %)) req-params#)))) 83 | (util/request 84 | ctx# 85 | {:method ~method-kw 86 | :path ~path 87 | :params (select-keys opts# path-params#) 88 | :query (select-keys opts# query-params#) 89 | :patch-type (:patch-type opts#) 90 | :body body#}))))) 91 | 92 | (defn render-api [{:keys [operations] :as api}] 93 | `(do ~@(->> operations 94 | (filter renderable-op?) 95 | (map (partial render-op api))))) 96 | 97 | (defn render-swagger [{:keys [apis]}] 98 | `(do ~@(map render-api apis))) 99 | 100 | (defmacro render-full-api [version] 101 | (-> (str "swagger/" version ".json") 102 | io/resource 103 | slurp 104 | (json/read-str :key-fn keyword) 105 | render-swagger)) 106 | -------------------------------------------------------------------------------- /src/kubernetes/api/util.clj: -------------------------------------------------------------------------------- 1 | (ns kubernetes.api.util 2 | (:require [clojure.string :as str] 3 | [clojure.core.async :refer [go ! chan]] 4 | [org.httpkit.client :as http] 5 | [clojure.data.json :as json] 6 | [less.awful.ssl :as ssl])) 7 | 8 | (def patch-types {:json-patch "application/json-patch+json" 9 | :merge-patch "application/merge-patch+json" 10 | :strategic-merge-patch "application/strategic-merge-patch+json" 11 | :apply-patch "application/apply-patch+yaml"}) 12 | 13 | (defn make-context 14 | ([server] (make-context server {})) 15 | ([server opts] (merge {:server server} opts))) 16 | 17 | (defn- parameterize-path [path params] 18 | (reduce-kv (fn [s k v] 19 | (str/replace s (re-pattern (str "\\{" (name k) "\\}")) v)) 20 | path 21 | params)) 22 | 23 | (defn dashed->camel [s] 24 | (str/replace s #"-([a-z])" #(str/upper-case (second %)))) 25 | 26 | (defn- query-str [query] 27 | (->> query 28 | (map (fn [[k v]] (str (dashed->camel (name k)) "=" v))) 29 | (str/join "&"))) 30 | 31 | (defn- url [{:keys [server]} path params query] 32 | (str server 33 | (parameterize-path path params) 34 | (if (empty? query) "" "?") 35 | (query-str query))) 36 | 37 | (defn- new-basic-auth-token [username password] 38 | (str username ":" password)) 39 | 40 | (defn- new-ssl-engine [ca-cert client-cert client-key] 41 | (-> (ssl/ssl-context client-key client-cert ca-cert) 42 | ssl/ssl-context->engine)) 43 | 44 | (defn- content-type 45 | ([method] 46 | (content-type method nil)) 47 | ([method patch-type] 48 | (if (= method :patch) 49 | (or (get patch-types patch-type) (:strategic-merge-patch patch-types)) 50 | "application/json"))) 51 | 52 | (defn parse-response [{:keys [status headers body error]}] 53 | (cond 54 | error {:success false :error error} 55 | :else (try 56 | (json/read-str body :key-fn keyword) 57 | (catch Exception e 58 | body)))) 59 | 60 | (defn- basic-auth? [{:keys [username password]}] 61 | (every? some? [username password])) 62 | 63 | (defn- client-cert? [{:keys [ca-cert client-cert client-key]}] 64 | (every? some? [ca-cert client-cert client-key])) 65 | 66 | (defn- token? [{:keys [token]}] 67 | (some? token)) 68 | 69 | (defn- token-fn? [{:keys [token-fn]}] 70 | (some? token-fn)) 71 | 72 | (defn- default-request-opts [ctx {:keys [method path params query]}] 73 | {:url (url ctx path params query) 74 | :method method 75 | :insecure? (not (client-cert? ctx)) 76 | :as :text}) 77 | 78 | (defn- request-auth-opts [{:keys [username password ca-cert client-cert client-key token token-fn] :as ctx} opts] 79 | (cond 80 | (basic-auth? ctx) 81 | {:basic-auth (new-basic-auth-token username password)} 82 | 83 | (client-cert? ctx) 84 | {:sslengine (new-ssl-engine ca-cert client-cert client-key)} 85 | 86 | (token? ctx) 87 | {:oauth-token token} 88 | 89 | (token-fn? ctx) 90 | {:oauth-token (token-fn ctx opts)})) 91 | 92 | (defn- request-body-opts [{:keys [method body patch-type]}] 93 | (when (some? body) 94 | {:body (json/write-str body) 95 | :headers {"Content-Type" (content-type method patch-type)}})) 96 | 97 | (defn- request-opts [ctx opts] 98 | (merge (default-request-opts ctx opts) 99 | (request-auth-opts ctx opts) 100 | (request-body-opts opts))) 101 | 102 | (defn request [ctx opts] 103 | (let [c (chan)] 104 | (http/request (request-opts ctx opts) #(go (>! c (parse-response %)))) 105 | c)) 106 | -------------------------------------------------------------------------------- /src/kubernetes/api/v1.clj: -------------------------------------------------------------------------------- 1 | (ns kubernetes.api.v1 2 | (:require [kubernetes.api.swagger :as swagger] 3 | [kubernetes.api.util :as util])) 4 | 5 | (def make-context util/make-context) 6 | 7 | (swagger/render-full-api "v1") 8 | 9 | ; expose dynamically generated vars for static analysis 10 | (declare 11 | create-namespace 12 | create-namespaced-binding 13 | create-namespaced-config-map 14 | create-namespaced-endpoints 15 | create-namespaced-event 16 | create-namespaced-limit-range 17 | create-namespaced-persistent-volume-claim 18 | create-namespaced-pod 19 | create-namespaced-pod-binding 20 | create-namespaced-pod-eviction 21 | create-namespaced-pod-template 22 | create-namespaced-replication-controller 23 | create-namespaced-resource-quota 24 | create-namespaced-secret 25 | create-namespaced-service 26 | create-namespaced-service-account 27 | create-node 28 | create-persistent-volume 29 | delete-namespace 30 | delete-namespaced-config-map 31 | delete-namespaced-endpoints 32 | delete-namespaced-event 33 | delete-namespaced-limit-range 34 | delete-namespaced-persistent-volume-claim 35 | delete-namespaced-pod 36 | delete-namespaced-pod-template 37 | delete-namespaced-replication-controller 38 | delete-namespaced-resource-quota 39 | delete-namespaced-secret 40 | delete-namespaced-service 41 | delete-namespaced-service-account 42 | delete-node 43 | delete-persistent-volume 44 | deletecollection-namespaced-config-map 45 | deletecollection-namespaced-endpoints 46 | deletecollection-namespaced-event 47 | deletecollection-namespaced-limit-range 48 | deletecollection-namespaced-persistent-volume-claim 49 | deletecollection-namespaced-pod 50 | deletecollection-namespaced-pod-template 51 | deletecollection-namespaced-replication-controller 52 | deletecollection-namespaced-resource-quota 53 | deletecollection-namespaced-secret 54 | deletecollection-namespaced-service-account 55 | deletecollection-node 56 | deletecollection-persistent-volume 57 | get-api-resources 58 | list-component-status 59 | list-config-map-for-all-namespaces 60 | list-endpoints-for-all-namespaces 61 | list-event-for-all-namespaces 62 | list-limit-range-for-all-namespaces 63 | list-namespace 64 | list-namespaced-config-map 65 | list-namespaced-endpoints 66 | list-namespaced-event 67 | list-namespaced-limit-range 68 | list-namespaced-persistent-volume-claim 69 | list-namespaced-pod 70 | list-namespaced-pod-template 71 | list-namespaced-replication-controller 72 | list-namespaced-resource-quota 73 | list-namespaced-secret 74 | list-namespaced-service 75 | list-namespaced-service-account 76 | list-node 77 | list-persistent-volume 78 | list-persistent-volume-claim-for-all-namespaces 79 | list-pod-for-all-namespaces 80 | list-pod-template-for-all-namespaces 81 | list-replication-controller-for-all-namespaces 82 | list-resource-quota-for-all-namespaces 83 | list-secret-for-all-namespaces 84 | list-service-account-for-all-namespaces 85 | list-service-for-all-namespaces 86 | patch-namespace 87 | patch-namespace-status 88 | patch-namespaced-config-map 89 | patch-namespaced-endpoints 90 | patch-namespaced-event 91 | patch-namespaced-limit-range 92 | patch-namespaced-persistent-volume-claim 93 | patch-namespaced-persistent-volume-claim-status 94 | patch-namespaced-pod 95 | patch-namespaced-pod-status 96 | patch-namespaced-pod-template 97 | patch-namespaced-replication-controller 98 | patch-namespaced-replication-controller-scale 99 | patch-namespaced-replication-controller-status 100 | patch-namespaced-resource-quota 101 | patch-namespaced-resource-quota-status 102 | patch-namespaced-secret 103 | patch-namespaced-service 104 | patch-namespaced-service-account 105 | patch-namespaced-service-status 106 | patch-node 107 | patch-node-status 108 | patch-persistent-volume 109 | patch-persistent-volume-status 110 | read-component-status 111 | read-namespace 112 | read-namespace-status 113 | read-namespaced-config-map 114 | read-namespaced-endpoints 115 | read-namespaced-event 116 | read-namespaced-limit-range 117 | read-namespaced-persistent-volume-claim 118 | read-namespaced-persistent-volume-claim-status 119 | read-namespaced-pod 120 | read-namespaced-pod-log 121 | read-namespaced-pod-status 122 | read-namespaced-pod-template 123 | read-namespaced-replication-controller 124 | read-namespaced-replication-controller-scale 125 | read-namespaced-replication-controller-status 126 | read-namespaced-resource-quota 127 | read-namespaced-resource-quota-status 128 | read-namespaced-secret 129 | read-namespaced-service 130 | read-namespaced-service-account 131 | read-namespaced-service-status 132 | read-node 133 | read-node-status 134 | read-persistent-volume 135 | read-persistent-volume-status 136 | replace-namespace 137 | replace-namespace-finalize 138 | replace-namespace-status 139 | replace-namespaced-config-map 140 | replace-namespaced-endpoints 141 | replace-namespaced-event 142 | replace-namespaced-limit-range 143 | replace-namespaced-persistent-volume-claim 144 | replace-namespaced-persistent-volume-claim-status 145 | replace-namespaced-pod 146 | replace-namespaced-pod-status 147 | replace-namespaced-pod-template 148 | replace-namespaced-replication-controller 149 | replace-namespaced-replication-controller-scale 150 | replace-namespaced-replication-controller-status 151 | replace-namespaced-resource-quota 152 | replace-namespaced-resource-quota-status 153 | replace-namespaced-secret 154 | replace-namespaced-service 155 | replace-namespaced-service-account 156 | replace-namespaced-service-status 157 | replace-node 158 | replace-node-status 159 | replace-persistent-volume 160 | replace-persistent-volume-status) 161 | -------------------------------------------------------------------------------- /test/kubernetes/api/apps_v1_test.clj: -------------------------------------------------------------------------------- 1 | (ns kubernetes.api.apps-v1-test 2 | (:require [clojure.core.async :refer [ stateful-sets :items first :metadata :name))) 38 | (is (= "StatefulSetList" (:kind stateful-sets))))) 39 | 40 | (testing "reading single stateful-set" 41 | (let [{:keys[kind metadata]} ( stateful-sets :items first :metadata :name))) 38 | (is (= "StatefulSetList" (:kind stateful-sets))))) 39 | 40 | (testing "reading single stateful-set" 41 | (let [{:keys[kind metadata]} ( stateful-sets :items first :metadata :name))) 38 | (is (= "StatefulSetList" (:kind stateful-sets))))) 39 | 40 | (testing "reading single stateful-set" 41 | (let [{:keys[kind metadata]} ( hpas :items first :metadata :name))) 54 | (is (= "HorizontalPodAutoscalerList" (:kind hpas))))) 55 | 56 | (testing "reading single hpa" 57 | (let [{:keys[kind metadata]} ( cron-jobs :items first :metadata :name))) 40 | (is (= "CronJobList" (:kind cron-jobs))))) 41 | 42 | (testing "reading single cron-job" 43 | (let [{:keys[kind metadata]} (> (repeatedly 10 #(rand-int 26)) 6 | (map #(nth (char-array "abcdefghijklmnopqrstuvwxyz") %)) 7 | (str/join ""))) 8 | -------------------------------------------------------------------------------- /test/kubernetes/api/extensions_v1beta1_test.clj: -------------------------------------------------------------------------------- 1 | (ns kubernetes.api.extensions-v1beta1-test 2 | (:require [clojure.core.async :refer [> (assoc nsopt :name deployment-name) 39 | (e-v1beta1/patch-namespaced-deployment ctx patch-param) 40 | ( deployments :items first :metadata :name))) 46 | (is (= "DeploymentList" (:kind deployments))))) 47 | 48 | (testing "reading single deployment" 49 | (let [{:keys[kind metadata]} (> items first :spec) {:minAvailable 5 :selector {:matchLabels {:what "nginx-rocks"}}})) 53 | (is (= kind "PodDisruptionBudgetList")))) 54 | 55 | (testing "reading a single pod disruption budget" 56 | (let [{:keys [kind spec]} ( storage-classes :items first :metadata :name))) 39 | (is (= "StorageClassList" (:kind storage-classes))))) 40 | 41 | (testing "reading single storage-class" 42 | (let [{:keys [kind metadata]} (> (repeatedly 10 #(rand-int 26)) 9 | (map #(nth (char-array "abcdefghijklmnopqrstuvwxyz") %)) 10 | (str/join ""))) 11 | (def nsopt {:namespace tns}) 12 | (def pod {:kind "Pod" 13 | :metadata {:name "test" :labels {:test "yes"}} 14 | :spec {:containers [{:name "nginx" 15 | :image "nginx"}]}}) 16 | 17 | (use-fixtures :once 18 | (fn [f] 19 | (