Skip to content

Instantly share code, notes, and snippets.

@choestelus
Created June 16, 2022 12:08
Show Gist options
  • Save choestelus/ce6d0c31877c230ad397000771c81d6c to your computer and use it in GitHub Desktop.
Save choestelus/ce6d0c31877c230ad397000771c81d6c to your computer and use it in GitHub Desktop.
#!/usr/bin/env bb
; failed attempt at yaml manipulation
(def manifest (yaml/parse-string (slurp *in*)))
(defn get-containers [deployment-manifest]
(->
deployment-manifest
:spec
:template
:spec
:containers))
(defn reformat-image-name [containers]
(let [container (into {} containers)
service-name (get container :name)]
(assoc-in container :image (str service-name "-image"))))
(defn reformat-image-name-manifest [manifest]
(let [container (into {} (get-containers manifest))
service-name (get container :name)]
(println service-name)
(update-in manifest [:spec :template :spec :containers] (clojure.string/replace str service-name "-image"))
)
)
(print (get-containers manifest))
(println "----------------------------------------")
(pprint (->
manifest
reformat-image-name-manifest
))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment