Rename namespace to docker.tools
I have tested this version in the datoms project.
This commit is contained in:
committed by
James Carnegie
parent
4f77f40fb2
commit
63d3cc2f0a
3
.gitignore
vendored
3
.gitignore
vendored
@@ -5,3 +5,6 @@ babashka-pod-docker
|
|||||||
/.cpcache/
|
/.cpcache/
|
||||||
/.lsp/
|
/.lsp/
|
||||||
/.nrepl-port
|
/.nrepl-port
|
||||||
|
/vendor/
|
||||||
|
/result
|
||||||
|
/.direnv/
|
||||||
|
|||||||
@@ -9,12 +9,12 @@ This is a [babashka pod](https://github.com/babashka/pods) that binds some golan
|
|||||||
|
|
||||||
```clojure
|
```clojure
|
||||||
(require '[babashka.pods :as pods])
|
(require '[babashka.pods :as pods])
|
||||||
(pods/load-pod 'docker/docker-tools "0.1.0")
|
(pods/load-pod 'docker/tools "0.1.0")
|
||||||
; OR use a locally built pod binary
|
; OR use a locally built pod binary
|
||||||
#_(pods/load-pod "./babashka-pod-docker")
|
#_(pods/load-pod "./babashka-pod-docker")
|
||||||
|
|
||||||
;; load-pod will create this namespace with two vars
|
;; load-pod will create this namespace with two vars
|
||||||
(require '[docker.babashka-pod-docker :as docker])
|
(require '[docker.tools :as docker])
|
||||||
|
|
||||||
;; parse image names using github.com/docker/distribution
|
;; parse image names using github.com/docker/distribution
|
||||||
;; turns golang structs into clojure maps
|
;; turns golang structs into clojure maps
|
||||||
@@ -79,11 +79,11 @@ Here is an example of bindings that will resolve at compile-time and go through
|
|||||||
|
|
||||||
;; statically define dispatch functions - this is synchronous
|
;; statically define dispatch functions - this is synchronous
|
||||||
(defn parse [s]
|
(defn parse [s]
|
||||||
(impl/invoke-public "docker.docker-tools" "docker.babashka-pod-docker/parse-dockerfile" [s] {}))
|
(impl/invoke-public "docker.tools" "docker.tools/parse-dockerfile" [s] {}))
|
||||||
|
|
||||||
;; async example
|
;; async example
|
||||||
(defn generate-sbom [s]
|
(defn generate-sbom [s]
|
||||||
(impl/invoke-public "docker.docker-tools" "docker.babashka-pod-docker/generate-sbom"
|
(impl/invoke-public "docker.tools" "docker.tools/generate-sbom"
|
||||||
[s cb]
|
[s cb]
|
||||||
{:handlers {:done (fn [])
|
{:handlers {:done (fn [])
|
||||||
:success cb
|
:success cb
|
||||||
@@ -99,3 +99,4 @@ This method of dispatch does not require any dynamic namespace generation.
|
|||||||
## Contributing
|
## Contributing
|
||||||
|
|
||||||
You can find information about contributing to this project in the CONTRIBUTING.md
|
You can find information about contributing to this project in the CONTRIBUTING.md
|
||||||
|
|
||||||
|
|||||||
12
dev/user.clj
12
dev/user.clj
@@ -23,9 +23,9 @@
|
|||||||
{:pod/id (:pod-id pod)})))
|
{:pod/id (:pod-id pod)})))
|
||||||
|
|
||||||
(comment
|
(comment
|
||||||
(pods/load-pod 'docker.docker-tools "0.1.0")
|
(pods/load-pod 'docker.tools "0.1.0")
|
||||||
|
|
||||||
(require '[docker.babashka-pod-docker :as docker])
|
(require '[docker.tools :as docker])
|
||||||
|
|
||||||
|
|
||||||
;; parse image names using github.com/docker/distribution
|
;; parse image names using github.com/docker/distribution
|
||||||
@@ -55,8 +55,8 @@
|
|||||||
(defn generate-sbom
|
(defn generate-sbom
|
||||||
[image]
|
[image]
|
||||||
(impl/invoke-public
|
(impl/invoke-public
|
||||||
"docker.docker-tools"
|
"docker.tools"
|
||||||
"docker.babashka-pod-docker/generate-sbom"
|
"docker.tools/generate-sbom"
|
||||||
[image "" ""]
|
[image "" ""]
|
||||||
{:handlers {:done (fn [] (println "Done"))
|
{:handlers {:done (fn [] (println "Done"))
|
||||||
:success (fn [msg] (println "msg: " msg))
|
:success (fn [msg] (println "msg: " msg))
|
||||||
@@ -65,8 +65,8 @@
|
|||||||
(comment
|
(comment
|
||||||
(println (load-pod "./babashka-pod-docker"))
|
(println (load-pod "./babashka-pod-docker"))
|
||||||
(impl/invoke-public
|
(impl/invoke-public
|
||||||
"docker.docker-tools"
|
"docker.tools"
|
||||||
"docker.babashka-pod-docker/generate-sbom"
|
"docker.tools/generate-sbom"
|
||||||
["ubuntu:latest" "" ""]
|
["ubuntu:latest" "" ""]
|
||||||
{})
|
{})
|
||||||
(generate-sbom "alpine")
|
(generate-sbom "alpine")
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"dockerfileparse/user/parser/babashka"
|
"babashka-pod-docker/babashka"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Reference struct {
|
type Reference struct {
|
||||||
@@ -111,7 +111,7 @@ func ProcessMessage(message *babashka.Message) (any, error) {
|
|||||||
Namespaces: []babashka.Namespace{
|
Namespaces: []babashka.Namespace{
|
||||||
{
|
{
|
||||||
// this is the pod-id
|
// this is the pod-id
|
||||||
Name: "docker.docker-tools",
|
Name: "docker.tools",
|
||||||
Vars: []babashka.Var{
|
Vars: []babashka.Var{
|
||||||
{
|
{
|
||||||
Name: "parse-image-name",
|
Name: "parse-image-name",
|
||||||
@@ -127,8 +127,8 @@ func ProcessMessage(message *babashka.Message) (any, error) {
|
|||||||
(sbom image cb {}))
|
(sbom image cb {}))
|
||||||
([image cb opts]
|
([image cb opts]
|
||||||
(babashka.pods/invoke
|
(babashka.pods/invoke
|
||||||
"docker.docker-tools"
|
"docker.tools"
|
||||||
'docker.babashka-pod-docker/generate-sbom
|
'docker.tools/generate-sbom
|
||||||
[image]
|
[image]
|
||||||
{:handlers {:success (fn [event]
|
{:handlers {:success (fn [event]
|
||||||
(cb event))
|
(cb event))
|
||||||
@@ -145,8 +145,8 @@ func ProcessMessage(message *babashka.Message) (any, error) {
|
|||||||
(hashes image cb {}))
|
(hashes image cb {}))
|
||||||
([image cb opts]
|
([image cb opts]
|
||||||
(babashka.pods/invoke
|
(babashka.pods/invoke
|
||||||
"docker.docker-tools"
|
"docker.tools"
|
||||||
'docker.babashka-pod-docker/generate-hashes
|
'docker.tools/generate-hashes
|
||||||
[image]
|
[image]
|
||||||
{:handlers {:success (fn [event]
|
{:handlers {:success (fn [event]
|
||||||
(cb event))
|
(cb event))
|
||||||
@@ -161,21 +161,21 @@ func ProcessMessage(message *babashka.Message) (any, error) {
|
|||||||
}, nil
|
}, nil
|
||||||
case "invoke":
|
case "invoke":
|
||||||
switch message.Var {
|
switch message.Var {
|
||||||
case "docker.babashka-pod-docker/parse-image-name":
|
case "docker.tools/parse-image-name":
|
||||||
args := []string{}
|
args := []string{}
|
||||||
if err := json.Unmarshal([]byte(message.Args), &args); err != nil {
|
if err := json.Unmarshal([]byte(message.Args), &args); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return parse_uri(args[0])
|
return parse_uri(args[0])
|
||||||
case "docker.babashka-pod-docker/parse-dockerfile":
|
case "docker.tools/parse-dockerfile":
|
||||||
args := []string{}
|
args := []string{}
|
||||||
if err := json.Unmarshal([]byte(message.Args), &args); err != nil {
|
if err := json.Unmarshal([]byte(message.Args), &args); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
reader := strings.NewReader(args[0])
|
reader := strings.NewReader(args[0])
|
||||||
return parser.Parse(reader)
|
return parser.Parse(reader)
|
||||||
case "docker.babashka-pod-docker/generate-sbom":
|
case "docker.tools/generate-sbom":
|
||||||
args := []string{}
|
args := []string{}
|
||||||
|
|
||||||
if err := json.Unmarshal([]byte(message.Args), &args); err != nil {
|
if err := json.Unmarshal([]byte(message.Args), &args); err != nil {
|
||||||
@@ -194,7 +194,7 @@ func ProcessMessage(message *babashka.Message) (any, error) {
|
|||||||
}
|
}
|
||||||
return "done", nil
|
return "done", nil
|
||||||
|
|
||||||
case "docker.babashka-pod-docker/generate-hashes":
|
case "docker.tools/generate-hashes":
|
||||||
args := []string{}
|
args := []string{}
|
||||||
if err := json.Unmarshal([]byte(message.Args), &args); err != nil {
|
if err := json.Unmarshal([]byte(message.Args), &args); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|||||||
31
flake.nix
31
flake.nix
@@ -11,22 +11,41 @@
|
|||||||
flake-utils.lib.eachDefaultSystem (system:
|
flake-utils.lib.eachDefaultSystem (system:
|
||||||
let
|
let
|
||||||
pkgs = import nixpkgs { inherit system; };
|
pkgs = import nixpkgs { inherit system; };
|
||||||
|
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
devShells.default = pkgs.mkShell {
|
devShells.default = pkgs.mkShell {
|
||||||
packages = with pkgs; [ go gotools golangci-lint gopls gopkgs go-outline ];
|
packages = with pkgs; [ go gotools golangci-lint gopls gopkgs go-outline ];
|
||||||
};
|
};
|
||||||
packages = {
|
packages = rec {
|
||||||
default = pkgs.buildGoModule {
|
default = pkgs.buildGoModule {
|
||||||
pname = "babashka-pod-docker";
|
pname = "babashka-pod-docker";
|
||||||
version = "0.0.1";
|
version = "0.0.1";
|
||||||
src = ./.;
|
src = ./.;
|
||||||
vendorSha256 = "sha256-KUWqddPcv+hLStd7JEzQBUiGLPLYwfmyVoG1BtaHWXY=";
|
# uncomment this and re-run to find the new vendor sha when module deps change
|
||||||
postInstall = ''
|
# note that you'll get inconsistent vendor deps if this gets out of sync because
|
||||||
mv $out/bin/parser $out/bin/babashka-pod-docker
|
# this sha defines the input for the mod deps derivation
|
||||||
'';
|
# vendorSha256 = nixpkgs.lib.fakeSha256;
|
||||||
|
vendorSha256 = "sha256-jCjNhi0eqEBNPts/xmbwugs0T6HUw1ESip/li4/J6YY=";
|
||||||
|
CGO_ENABLED = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
docker = pkgs.dockerTools.buildImage {
|
||||||
|
name = "docker-pod";
|
||||||
|
tag = "latest";
|
||||||
|
config = {
|
||||||
|
Cmd = ["${default}/bin/babashka-pod-docker"];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
default-linux = default.overrideAttrs (old: old // {GOOS = "linux"; GOARCH = "arm64";});
|
||||||
|
docker-arm64 = pkgs.dockerTools.buildImage {
|
||||||
|
name = "docker-pod";
|
||||||
|
tag = "latest";
|
||||||
|
config = {
|
||||||
|
Cmd = ["${default-linux}/bin/linux_arm64/babashka-pod-docker"];
|
||||||
|
};
|
||||||
|
};
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
2
go.mod
2
go.mod
@@ -1,4 +1,4 @@
|
|||||||
module dockerfileparse/user/parser
|
module babashka-pod-docker
|
||||||
|
|
||||||
go 1.19
|
go 1.19
|
||||||
|
|
||||||
|
|||||||
4
main.go
4
main.go
@@ -1,8 +1,8 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"dockerfileparse/user/parser/babashka"
|
"babashka-pod-docker/babashka"
|
||||||
"dockerfileparse/user/parser/docker"
|
"babashka-pod-docker/docker"
|
||||||
|
|
||||||
"github.com/atomist-skills/go-skill"
|
"github.com/atomist-skills/go-skill"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
|
|||||||
Reference in New Issue
Block a user