Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing data_security_mode enum #51

Merged
merged 3 commits into from
Jul 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions charts/databricks-kube-operator/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
apiVersion: v2
appVersion: 0.8.1
appVersion: 0.8.2
name: databricks-kube-operator
description: A kube-rs operator for managing Databricks API resources
version: 0.9.2
version: 0.9.3

home: https://github.com/mach-kernel/databricks-kube-operator
sources:
Expand Down
2 changes: 1 addition & 1 deletion databricks-kube/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ path = "src/crdgen.rs"
[package]
name = "databricks_kube"
default-run = "databricks_kube"
version = "0.8.1"
version = "0.8.2"
edition = "2021"

[dependencies]
Expand Down
2 changes: 1 addition & 1 deletion databricks-rust-jobs/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "databricks_rust_jobs"
version = "2.1.1"
version = "2.1.2"
authors = ["OpenAPI Generator team and contributors"]
description = "The Jobs API allows you to create, edit, and delete jobs. You should never hard code secrets or store them in plain text. Use the [Secrets API](https://docs.databricks.com/dev-tools/api/latest/secrets.html) to manage secrets in the [Databricks CLI](https://docs.databricks.com/dev-tools/cli/index.html). Use the [Secrets utility](https://docs.databricks.com/dev-tools/databricks-utils.html#dbutils-secrets) to reference secrets in notebooks and jobs."
# Override this license by providing a License Object in the OpenAPI.
Expand Down
2 changes: 2 additions & 0 deletions databricks-rust-jobs/src/models/new_cluster.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ pub enum DataSecurityMode {
LegacyPassthrough,
#[serde(rename = "LEGACY_SINGLE_USER")]
LegacySingleUser,
#[serde(rename = "LEGACY_SINGLE_USER_STANDARD")]
LegacySingleUserStandard,
}

impl Default for DataSecurityMode {
Expand Down
2 changes: 2 additions & 0 deletions databricks-rust-jobs/src/models/new_task_cluster.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ pub enum DataSecurityMode {
LegacyPassthrough,
#[serde(rename = "LEGACY_SINGLE_USER")]
LegacySingleUser,
#[serde(rename = "LEGACY_SINGLE_USER_STANDARD")]
LegacySingleUserStandard,
}

impl Default for DataSecurityMode {
Expand Down
56 changes: 35 additions & 21 deletions openapi/openapi-helper.bb
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,36 @@
:else
form))

(defn emit-components
(defn clean-databricks
[form]
(if (map? form)
(let [to-remove (filter #(str/starts-with? % "x-databricks")
(keys form))]
(apply dissoc form to-remove))
form))

(defn select-refs
"Collect referenced schema/parameter/response refs from OpenAPI components"
[cs components]
(let [filtered-components (->> cs
; #/components/kind/name split /
(map #(str/split % #"/"))
; drop #, components
(map #(map keyword (drop 2 %)))
(map last))]
{:schemas (select-keys (:schemas components) filtered-components)
:parameters (select-keys (:parameters components) filtered-components)
:responses (select-keys (:responses components) filtered-components)}))
(let [component-keys (->> cs
; #/components/kind/name split /
(map #(str/split % #"/"))
; drop #, components
(map #(map keyword (drop 2 %)))
(map last))]
{:schemas (select-keys (:schemas components) component-keys)
:parameters (select-keys (:parameters components) component-keys)
:responses (select-keys (:responses components) component-keys)}))

(defn emit-components-for
([all form]
(emit-components-for all form (set (walk/postwalk collect-refs form))))
([all form refs]
(let [new-form (select-refs refs all)
new-refs (set (walk/postwalk collect-refs new-form))]
(if (> (count new-refs) (count refs))
(emit-components-for all form new-refs)
new-form))))

(defn emit-subspec
"Emit a subset of the larger spec"
Expand All @@ -68,19 +86,12 @@
paths (if f
(into {} (keep #(emit-matching f %)) paths)
paths)
path-component-refs (set (walk/postwalk collect-refs paths))
path-components (emit-components path-component-refs components)

component-refs (set (walk/postwalk collect-refs path-components))
component-components (emit-components component-refs components)

components (merge-with merge path-components component-components)]
components (emit-components-for components paths)]
(-> parsed-spec
(assoc :components components)
(assoc :paths paths)
(dissoc :tags)
(dissoc :x-databricks-groups)
(walk/stringify-keys))))
(dissoc :tags))))

(defn -main
[args]
Expand All @@ -93,8 +104,11 @@
(when-not spec
(println "Usage\n" (cli/format-opts cli-spec))
(System/exit 1))

(let [new-spec (walk/postwalk repascalize (emit-subspec filter spec))]

(let [new-spec (->> (emit-subspec filter spec)
(walk/stringify-keys)
(walk/postwalk repascalize)
(walk/postwalk clean-databricks))]
(println (json/encode new-spec {:pretty true})))))

(-main *command-line-args*)
Loading