2022-12-05 17:31:46 -08:00
2022-12-05 17:31:46 -08:00
2022-12-05 17:31:46 -08:00
2022-12-05 17:31:46 -08:00
2022-12-05 17:31:46 -08:00
2022-12-05 17:31:46 -08:00
2022-12-05 17:31:46 -08:00
2022-12-05 17:31:46 -08:00
2022-12-05 17:31:46 -08:00
2022-12-05 17:31:46 -08:00
2022-12-05 17:31:46 -08:00
2022-12-05 17:31:46 -08:00

Background

This is a babashka pod that binds some golang functions into a clojure namespace. Using this pod, clojure programs can parse dockerfiles and docker images names using the "official" docker golang libraries.

Usage

(require '[babashka.pods :as pods])
(pods/load-pod 'atomisthq/docker "0.1.0")
; OR use a locally built pod binary
#_(pods/load-pod "./parser")

;; load-pod will create this namespace with two vars
(require '[pod.babashka.docker :as docker])

;; parse image names using github.com/docker/distribution 
;; turns golang structs into clojure maps
(docker/parse-image-name "gcr.io/whatever:tag") 
;; automatically turns golang errors into Exceptions
(try
  (docker/parse-image-name "gcr.io/whatever/:tag")
  (catch Exception e 
    ;; invalid reference format
    (println (.getMessage e))))

;; parse dockerfiles using github.com/moby/buildkit
;; returns the Result struct transformed to a clojure map
(docker/parse-dockerfile "FROM \\\n    gcr.io/whatever:tag\nCMD [\"run\"]")

Building

To build the golang parser binary locally, run go build.

go build

Contributing

You can find information about contributing to this project in the CONTRIBUTING.md

Description
Mirror of github.com/actions/babashka-pod-docker
Readme 416 KiB
Languages
Go 56.9%
Clojure 26%
Nix 12.7%
Dockerfile 4.4%