From 33bd6e1451f64035570485d53cea4cd69286471a Mon Sep 17 00:00:00 2001 From: Quentin Dufour Date: Fri, 28 Apr 2023 12:05:22 +0200 Subject: [PATCH] fix flake + container subcommand --- cmd/container.go | 38 ++++++++++++++++++++++++++++++++++++++ flake.nix | 4 ++-- 2 files changed, 40 insertions(+), 2 deletions(-) create mode 100644 cmd/container.go diff --git a/cmd/container.go b/cmd/container.go new file mode 100644 index 0000000..2b2edf5 --- /dev/null +++ b/cmd/container.go @@ -0,0 +1,38 @@ +package cmd + +import ( + "fmt" + "github.com/spf13/cobra" +) + +const distributionPrefix = "v2" + +//--- +//--- Command logic + +var containerCmd = &cobra.Command{ + Use: "container", + Short: "Manage container images", + Long: "Publish software on an S3 target following the OCI specification", +} + +var containerTag string +var containerPublishCmd = &cobra.Command{ + Use: "push [folder] [remote]", // https://gocloud.dev/howto/blob/#s3-compatible + Short: "Publish a container image", + Long: "Copy .tar.gz files in the specified folder on the S3 target so that they match the OCI distribution specification", + Args: cobra.ExactArgs(2), + Run: func(cmd *cobra.Command, args []string) { + + + fmt.Printf("✅ push succeeded\n") + }, +} + +func init() { + containerPublishCmd.Flags().StringVarP(&containerTag, "tag", "t", "", "Tag of the project, eg. albatros:0.9") + containerPublishCmd.MarkFlagRequired("tag") + + containerCmd.AddCommand(containerPublishCmd) + RootCmd.AddCommand(containerCmd) +} diff --git a/flake.nix b/flake.nix index 8cccd76..ab3bf23 100644 --- a/flake.nix +++ b/flake.nix @@ -39,7 +39,7 @@ }).overrideAttrs (old: old // { GOOS = "linux"; GOARCH = arch; }); # logic to build docker containers - docker = staticBin: arch: pkgs.dockerTools.buildImage { + dockerImg = staticBin: arch: pkgs.dockerTools.buildImage { name = "dxflrs/albatros"; architecture = arch; config = { @@ -58,7 +58,7 @@ # generate packages for each architecture packages = builtins.mapAttrs (name: value: rec { albatros = (albatrosStaticBin value); - docker.albatros = (docker albatros value); + docker.albatros = (dockerImg albatros value); default = albatros; }) archmap; in