Created
June 16, 2022 12:08
-
-
Save choestelus/ce6d0c31877c230ad397000771c81d6c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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