Skip to content

Commit 8eba055

Browse files
authored
Merge branch 'main' into docker-library-behavior
2 parents 0238303 + 6d8a7cc commit 8eba055

54 files changed

Lines changed: 1627 additions & 600 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/tests.yaml

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,20 @@ jobs:
216216
- name: Verify - hauler store copy
217217
run: |
218218
hauler store copy --help
219-
# need more tests here
219+
# verify via registry target
220+
hauler store serve registry --port 5002 --readonly=false &
221+
until curl -sf http://localhost:5002/v2/_catalog; do : ; done
222+
hauler store copy registry://localhost:5002 --plain-http
223+
# verify blobs actually landed in the registry backend
224+
[ $(find registry -type f | wc -l) -gt 0 ]
225+
# verify via --only
226+
hauler store copy registry://localhost:5002 --plain-http --only busybox
227+
pkill -f "hauler store serve registry --port 5002"
228+
rm -rf registry
229+
# verify via directory target (files and charts only; images and cosign artifacts are skipped)
230+
hauler store copy dir://./store-copy-output
231+
test -f ./store-copy-output/hauler-manifest.yaml
232+
rm -rf ./store-copy-output
220233
221234
- name: Verify - hauler store extract
222235
run: |
@@ -354,9 +367,9 @@ jobs:
354367
until curl -sf http://localhost:5001/v2/_catalog; do : ; done
355368
pkill -f "hauler store serve registry --port 5001 --readonly"
356369
# verify via registry with different port with readonly with tls
357-
# hauler store serve registry --port 5001 --readonly --tls-cert testdata/certs/server-cert.crt --tls-key testdata/certs/server-cert.key &
358-
# until curl -sf --cacert testdata/certs/cacerts.pem https://localhost:5001/v2/_catalog; do : ; done
359-
# pkill -f "hauler store serve registry --port 5001 --readonly --tls-cert testdata/certs/server-cert.crt --tls-key testdata/certs/server-cert.key"
370+
hauler store serve registry --port 5001 --readonly --tls-cert testdata/certs/server-cert.crt --tls-key testdata/certs/server-cert.key &
371+
until curl -sf --cacert testdata/certs/cacerts.pem https://localhost:5001/v2/_catalog; do : ; done
372+
pkill -f "hauler store serve registry --port 5001 --readonly --tls-cert testdata/certs/server-cert.crt --tls-key testdata/certs/server-cert.key"
360373
361374
- name: Verify - hauler store serve fileserver
362375
run: |
@@ -374,9 +387,9 @@ jobs:
374387
until curl -sf http://localhost:8000; do : ; done
375388
pkill -f "hauler store serve fileserver --port 8000 --timeout 120"
376389
# verify via fileserver with different port with timeout and tls
377-
# hauler store serve fileserver --port 8000 --timeout 120 --tls-cert testdata/certs/server-cert.crt --tls-key testdata/certs/server-cert.key &
378-
# until curl -sf --cacert testdata/certs/cacerts.pem https://localhost:8000; do : ; done
379-
# pkill -f "hauler store serve fileserver --port 8000 --timeout 120 --tls-cert testdata/certs/server-cert.crt --tls-key testdata/certs/server-cert.key"
390+
hauler store serve fileserver --port 8000 --timeout 120 --tls-cert testdata/certs/server-cert.crt --tls-key testdata/certs/server-cert.key &
391+
until curl -sf --cacert testdata/certs/cacerts.pem https://localhost:8000; do : ; done
392+
pkill -f "hauler store serve fileserver --port 8000 --timeout 120 --tls-cert testdata/certs/server-cert.crt --tls-key testdata/certs/server-cert.key"
380393
381394
- name: Verify Hauler Store Contents
382395
run: |

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,5 @@ vulncheck.out
2020
trivy.out
2121
CLAUDE.md
2222
**/CLAUDE.*
23-
.claude**
23+
.claude**
24+
__debug_bin*

.goreleaser.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ dockers_v2:
6969
"classification": "UNCLASSIFIED"
7070
"org.opencontainers.image.created": "{{.Date}}"
7171
"org.opencontainers.image.description": "Hauler: Airgap Swiss Army Knife"
72-
"org.opencontainers.image.name": "{{.ProjectName}}-debug"
72+
"org.opencontainers.image.name": "{{.ProjectName}}"
7373
"org.opencontainers.image.revision": "{{.FullCommit}}"
7474
"org.opencontainers.image.source": "{{.GitURL}}"
7575
"org.opencontainers.image.version": "{{.Version}}"

Dockerfile

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# builder stage
2-
FROM registry.suse.com/bci/bci-base:15.7 AS builder
2+
FROM registry.suse.com/bci/bci-base:16.1 AS builder
33
ARG TARGETPLATFORM
44

55
# fetched from goreleaser build process
@@ -29,15 +29,13 @@ USER hauler
2929
ENTRYPOINT [ "/hauler" ]
3030

3131
# debug stage
32-
FROM alpine AS debug
32+
FROM registry.suse.com/bci/bci-base:16.1 AS debug
3333

3434
COPY --from=builder /var/lib/ca-certificates/ca-bundle.pem /etc/ssl/certs/ca-certificates.crt
3535
COPY --from=builder /etc/passwd /etc/passwd
3636
COPY --from=builder /etc/group /etc/group
3737
COPY --from=builder --chown=hauler:hauler /home/hauler/. /home/hauler
3838
COPY --from=builder --chown=hauler:hauler /hauler /usr/local/bin/hauler
3939

40-
RUN apk --no-cache add curl
41-
4240
USER hauler
4341
WORKDIR /home/hauler

cmd/hauler/cli/cli.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ func New(ctx context.Context, ro *flags.CliRootOpts) *cobra.Command {
1818
cmd := &cobra.Command{
1919
Use: "hauler",
2020
Short: "Airgap Swiss Army Knife",
21-
Example: " View the Docs: https://docs.hauler.dev\n Environment Variables: " + consts.HaulerDir + " | " + consts.HaulerTempDir + " | " + consts.HaulerStoreDir + " | " + consts.HaulerIgnoreErrors + " | " + consts.HaulerLogLevel + " | " + consts.HaulerAuditLevel + " | " + consts.HaulerConcurrency + " | " + consts.HaulerBlobConcurrency + "\n Warnings: Hauler commands and flags marked with (EXPERIMENTAL) are not yet stable and may change in the future.",
21+
Example: " View the Docs: https://docs.hauler.dev\n Environment Variables: " + consts.HaulerDir + " | " + consts.HaulerTempDir + " | " + consts.HaulerStoreDir + " | " + consts.HaulerIgnoreErrors + " | " + consts.HaulerRetries + " | " + consts.HaulerLogLevel + " | " + consts.HaulerAuditLevel + " | " + consts.HaulerConcurrency + " | " + consts.HaulerBlobConcurrency + "\n Warnings: Hauler commands and flags marked with (EXPERIMENTAL) are not yet stable and may change in the future.",
2222
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
2323
// check for log level env variable or flag
2424
if ro.LogLevel == "" {

cmd/hauler/cli/store.go

Lines changed: 83 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@ package cli
22

33
import (
44
"fmt"
5+
"os"
56

67
"github.com/spf13/cobra"
78
"helm.sh/helm/v4/pkg/action"
89

910
"hauler.dev/go/hauler/v2/cmd/hauler/cli/store"
1011
"hauler.dev/go/hauler/v2/internal/flags"
12+
"hauler.dev/go/hauler/v2/pkg/consts"
1113
"hauler.dev/go/hauler/v2/pkg/log"
1214
)
1315

@@ -71,6 +73,24 @@ func addStoreSync(rso *flags.StoreRootOpts, ro *flags.CliRootOpts) *cobra.Comman
7173
Short: "Sync content to the content store",
7274
Args: cobra.ExactArgs(0),
7375
PreRunE: func(cmd *cobra.Command, args []string) error {
76+
// Check for ca-file & insecure-skip-tls-verify env variables
77+
if o.CaFile == "" {
78+
o.CaFile = os.Getenv(consts.CaFile)
79+
}
80+
81+
// record which precedence-carrying flags the user explicitly set, so
82+
// the resolvers can let an explicit CLI value win over per-item/annotation
83+
o.TlogChanged = cmd.Flags().Changed("use-tlog-verify")
84+
o.ExcludeExtrasChanged = cmd.Flags().Changed("exclude-extras")
85+
o.InsecureChanged = cmd.Flags().Changed("insecure-skip-tls-verify")
86+
o.StoreChanged = cmd.Flags().Changed("store")
87+
o.RetriesChanged = cmd.Flags().Changed("retries")
88+
89+
// env var only applies when the flag wasn't set, so an explicit --insecure-skip-tls-verify=false still wins
90+
if !o.InsecureChanged && os.Getenv(consts.InsecureSkipTLSVerify) == "true" {
91+
o.InsecureSkipTLSVerify = true
92+
}
93+
7494
// --dry-run requires --products
7595
if o.DryRun && len(o.Products) == 0 {
7696
return fmt.Errorf("--dry-run requires --products")
@@ -146,9 +166,8 @@ func addStoreLoad(rso *flags.StoreRootOpts, ro *flags.CliRootOpts) *cobra.Comman
146166
if err != nil {
147167
return err
148168
}
149-
_ = s
150169

151-
return store.LoadCmd(ctx, o, rso, ro)
170+
return store.LoadCmd(ctx, o, s, rso, ro)
152171
},
153172
}
154173
o.AddFlags(cmd)
@@ -232,9 +251,8 @@ func addStoreSave(rso *flags.StoreRootOpts, ro *flags.CliRootOpts) *cobra.Comman
232251
if err != nil {
233252
return err
234253
}
235-
_ = s
236254

237-
return store.SaveCmd(ctx, o, rso, ro)
255+
return store.SaveCmd(ctx, o, s, rso, ro)
238256
},
239257
}
240258
o.AddFlags(cmd)
@@ -292,8 +310,8 @@ func addStoreCopy(rso *flags.StoreRootOpts, ro *flags.CliRootOpts) *cobra.Comman
292310
Use: "copy",
293311
Short: "Copy all store content to another location",
294312
Example: ` # supported copy target prefixes
295-
registry:// | reg:// | oci:// - Pushes the store to an OCI registry
296-
directory:// | dir:// - Extracts the store to a directory`,
313+
registry:// | reg:// | oci:// - Pushes the store to an OCI registry
314+
directory:// | dir:// - Extracts the store to a directory`,
297315
Args: cobra.ExactArgs(1),
298316
RunE: func(cmd *cobra.Command, args []string) error {
299317
ctx := cmd.Context()
@@ -336,13 +354,13 @@ func addStoreAddFile(rso *flags.StoreRootOpts, ro *flags.CliRootOpts) *cobra.Com
336354
Use: "file",
337355
Short: "Add a file to the store",
338356
Example: ` # fetch local file
339-
hauler store add file file.txt
357+
hauler store add file file.txt
340358
341-
# fetch remote file
342-
hauler store add file https://get.rke2.io/install.sh
359+
# fetch remote file
360+
hauler store add file https://get.rke2.io/install.sh
343361
344-
# fetch remote file and assign new name
345-
hauler store add file https://get.hauler.dev --name hauler-install.sh`,
362+
# fetch remote file and assign new name
363+
hauler store add file https://get.hauler.dev --name hauler-install.sh`,
346364
Args: cobra.ExactArgs(1),
347365
RunE: func(cmd *cobra.Command, args []string) error {
348366
ctx := cmd.Context()
@@ -366,28 +384,39 @@ func addStoreAddImage(rso *flags.StoreRootOpts, ro *flags.CliRootOpts) *cobra.Co
366384
cmd := &cobra.Command{
367385
Use: "image",
368386
Short: "Add a image to the store",
369-
Example: ` # fetch image
370-
hauler store add image busybox
387+
Example: ` # fetch image
388+
hauler store add image busybox
371389
372-
# fetch image with repository and tag
373-
hauler store add image library/busybox:stable
390+
# fetch image with repository and tag
391+
hauler store add image library/busybox:stable
374392
375-
# fetch image with full image reference and specific platform
376-
hauler store add image ghcr.io/hauler-dev/hauler-debug:v1.2.0 --platform linux/amd64
393+
# fetch image with full image reference and specific platform
394+
hauler store add image ghcr.io/hauler-dev/hauler-debug:v1.2.0 --platform linux/amd64
377395
378-
# fetch image with full image reference via digest
379-
hauler store add image gcr.io/distroless/base@sha256:7fa7445dfbebae4f4b7ab0e6ef99276e96075ae42584af6286ba080750d6dfe5
396+
# fetch image with full image reference via digest
397+
hauler store add image gcr.io/distroless/base@sha256:7fa7445dfbebae4f4b7ab0e6ef99276e96075ae42584af6286ba080750d6dfe5
380398
381-
# fetch image with full image reference, specific platform, and signature verification
382-
curl -sfOL https://raw.githubusercontent.com/rancherfederal/carbide-releases/main/carbide-key.pub
383-
hauler store add image rgcrprod.azurecr.us/rancher/rke2-runtime:v1.31.5-rke2r1 --platform linux/amd64 --key carbide-key.pub
399+
# fetch image with full image reference, specific platform, and signature verification
400+
curl -sfOL https://raw.githubusercontent.com/rancherfederal/carbide-releases/main/carbide-key.pub
401+
hauler store add image rgcrprod.azurecr.us/rancher/rke2-runtime:v1.31.5-rke2r1 --platform linux/amd64 --key carbide-key.pub
384402
385-
# fetch image and rewrite path
386-
hauler store add image busybox --rewrite custom-path/busybox:latest
403+
# fetch image and rewrite path
404+
hauler store add image busybox --rewrite custom-path/busybox:latest
387405
388-
# add image from local Docker daemon
389-
hauler store add image my-local-app:latest --local`,
406+
# add image from local Docker daemon
407+
hauler store add image my-local-app:latest --local`,
390408
Args: cobra.ExactArgs(1),
409+
PreRunE: func(cmd *cobra.Command, args []string) error {
410+
// Check for ca-file & insecure-skip-tls-verify env variables
411+
if o.CaFile == "" {
412+
o.CaFile = os.Getenv(consts.CaFile)
413+
}
414+
// env var only applies when the flag wasn't set, so an explicit --insecure-skip-tls-verify=false still wins
415+
if !cmd.Flags().Changed("insecure-skip-tls-verify") && os.Getenv(consts.InsecureSkipTLSVerify) == "true" {
416+
o.InsecureSkipTLSVerify = true
417+
}
418+
return nil
419+
},
391420
RunE: func(cmd *cobra.Command, args []string) error {
392421
ctx := cmd.Context()
393422

@@ -410,26 +439,26 @@ func addStoreAddChart(rso *flags.StoreRootOpts, ro *flags.CliRootOpts) *cobra.Co
410439
cmd := &cobra.Command{
411440
Use: "chart",
412441
Short: "Add a helm chart to the store",
413-
Example: ` # fetch local helm chart
414-
hauler store add chart path/to/chart/directory --repo .
442+
Example: ` # fetch local helm chart
443+
hauler store add chart path/to/chart/directory --repo .
415444
416-
# fetch local compressed helm chart
417-
hauler store add chart path/to/chart.tar.gz --repo .
445+
# fetch local compressed helm chart
446+
hauler store add chart path/to/chart.tar.gz --repo .
418447
419-
# fetch remote oci helm chart
420-
hauler store add chart hauler-helm --repo oci://ghcr.io/hauler-dev
448+
# fetch remote oci helm chart
449+
hauler store add chart hauler-helm --repo oci://ghcr.io/hauler-dev
421450
422-
# fetch remote oci helm chart with version
423-
hauler store add chart hauler-helm --repo oci://ghcr.io/hauler-dev --version 1.2.0
451+
# fetch remote oci helm chart with version
452+
hauler store add chart hauler-helm --repo oci://ghcr.io/hauler-dev --version 1.2.0
424453
425-
# fetch remote helm chart
426-
hauler store add chart rancher --repo https://releases.rancher.com/server-charts/stable
454+
# fetch remote helm chart
455+
hauler store add chart rancher --repo https://releases.rancher.com/server-charts/stable
427456
428-
# fetch remote helm chart with specific version
429-
hauler store add chart rancher --repo https://releases.rancher.com/server-charts/latest --version 2.10.1
457+
# fetch remote helm chart with specific version
458+
hauler store add chart rancher --repo https://releases.rancher.com/server-charts/latest --version 2.10.1
430459
431-
# fetch remote helm chart and rewrite path
432-
hauler store add chart hauler-helm --repo oci://ghcr.io/hauler-dev --rewrite custom-path/hauler-chart:latest`,
460+
# fetch remote helm chart and rewrite path
461+
hauler store add chart hauler-helm --repo oci://ghcr.io/hauler-dev --rewrite custom-path/hauler-chart:latest`,
433462
Args: cobra.ExactArgs(1),
434463
PreRunE: func(cmd *cobra.Command, args []string) error {
435464
n, err := flags.ResolveConcurrency(cmd.Flags().Changed("concurrency"), o.Concurrency)
@@ -471,25 +500,25 @@ func addStoreRemove(rso *flags.StoreRootOpts, ro *flags.CliRootOpts) *cobra.Comm
471500
Use: "remove <artifact-ref>",
472501
Short: "Remove an artifact from the content store",
473502
Example: ` # remove an image using full store reference
474-
hauler store info
475-
hauler store remove index.docker.io/library/busybox:stable
503+
hauler store info
504+
hauler store remove index.docker.io/library/busybox:stable
476505
477-
# remove a chart using full store reference
478-
hauler store info
479-
hauler store remove hauler/rancher:2.8.4
506+
# remove a chart using full store reference
507+
hauler store info
508+
hauler store remove hauler/rancher:2.8.4
480509
481-
# remove a file using full store reference
482-
hauler store info
483-
hauler store remove hauler/rke2-install.sh
510+
# remove a file using full store reference
511+
hauler store info
512+
hauler store remove hauler/rke2-install.sh
484513
485-
# remove any artifact with the latest tag
486-
hauler store remove :latest
514+
# remove any artifact with the latest tag
515+
hauler store remove :latest
487516
488-
# remove any artifact with 'busybox' in the reference
489-
hauler store remove busybox
517+
# remove any artifact with 'busybox' in the reference
518+
hauler store remove busybox
490519
491-
# force remove without verification
492-
hauler store remove busybox:latest --force`,
520+
# force remove without verification
521+
hauler store remove busybox:latest --force`,
493522
Args: cobra.ExactArgs(1),
494523
RunE: func(cmd *cobra.Command, args []string) error {
495524
ctx := cmd.Context()

0 commit comments

Comments
 (0)