Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Integration Tests

on:
push:
branches: [master]
pull_request:
branches: [master]

permissions:
contents: read

env:
# Disable Ryuk - GitHub Actions cleans up containers automatically
TESTCONTAINERS_RYUK_DISABLED: true

jobs:
integration:
name: Integration Tests
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1

- name: Setup Go
uses: actions/setup-go@7a3fe6cf4cb3a834922a1244abfce67bcef6a0c5 # v6.2.0
with:
go-version-file: go.mod
cache: true

- name: Run integration tests
run: go test -v -tags=integration -race -timeout=10m ./integration/...
2 changes: 1 addition & 1 deletion cmd/cat.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func runCat(cmd *cobra.Command, args []string) error {
resolvedRef := cfg.ResolveAlias(inputRef)

// 4. Create client (lazy - only downloads manifest + index)
client, err := blob.NewClient(blob.WithDockerConfig())
client, err := newClient(cfg)
if err != nil {
return fmt.Errorf("creating client: %w", err)
}
Expand Down
23 changes: 23 additions & 0 deletions cmd/client.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package cmd

import (
"github.com/meigma/blob"

internalcfg "github.com/meigma/blob-cli/internal/config"
)

// newClient creates a new blob client with options from config.
func newClient(cfg *internalcfg.Config, opts ...blob.Option) (*blob.Client, error) {
allOpts := append(clientOpts(cfg), opts...)
return blob.NewClient(allOpts...)
}

// clientOpts returns the base client options from config.
// This is useful when passing options to functions that create their own client.
func clientOpts(cfg *internalcfg.Config) []blob.Option {
opts := []blob.Option{blob.WithDockerConfig()}
if cfg.PlainHTTP {
opts = append(opts, blob.WithPlainHTTP(true))
}
return opts
}
6 changes: 3 additions & 3 deletions cmd/cp.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ func runCp(cmd *cobra.Command, args []string) error {
resolvedSources := make([]cpResolvedSource, 0, len(sources))

for _, src := range sources {
rsrc, resolveErr := resolveSource(ctx, src, archiveCache)
rsrc, resolveErr := resolveSource(ctx, cfg, src, archiveCache)
if resolveErr != nil {
return resolveErr
}
Expand Down Expand Up @@ -148,11 +148,11 @@ func runCp(cmd *cobra.Command, args []string) error {
}

// resolveSource pulls the archive (if not cached) and detects if the source is a file or directory.
func resolveSource(ctx context.Context, src cpSource, cache map[string]*blob.Archive) (cpResolvedSource, error) {
func resolveSource(ctx context.Context, cfg *internalcfg.Config, src cpSource, cache map[string]*blob.Archive) (cpResolvedSource, error) {
// Get or create archive for this ref
blobArchive, ok := cache[src.ref]
if !ok {
client, clientErr := blob.NewClient(blob.WithDockerConfig())
client, clientErr := newClient(cfg)
if clientErr != nil {
return cpResolvedSource{}, fmt.Errorf("creating client: %w", clientErr)
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/inspect.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func runInspect(cmd *cobra.Command, args []string) error {
inputRef := args[0]
resolvedRef := cfg.ResolveAlias(inputRef)

result, err := archive.Inspect(cmd.Context(), resolvedRef)
result, err := archive.Inspect(cmd.Context(), resolvedRef, clientOpts(cfg)...)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/ls.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func runLs(cmd *cobra.Command, args []string) error {
return err
}

result, err := archive.Inspect(cmd.Context(), ref)
result, err := archive.Inspect(cmd.Context(), ref, clientOpts(cfg)...)
if err != nil {
return err
}
Expand Down
6 changes: 3 additions & 3 deletions cmd/pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,11 @@ func runPull(cmd *cobra.Command, args []string) error {
}

// 6. Create client with policies
clientOpts := []blob.Option{blob.WithDockerConfig()}
policyOpts := make([]blob.Option, 0, len(policies))
for _, p := range policies {
clientOpts = append(clientOpts, blob.WithPolicy(p))
policyOpts = append(policyOpts, blob.WithPolicy(p))
}
client, err := blob.NewClient(clientOpts...)
client, err := newClient(cfg, policyOpts...)
if err != nil {
return fmt.Errorf("creating client: %w", err)
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/push.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func runPush(cmd *cobra.Command, args []string) error {
return err
}

client, err := blob.NewClient(blob.WithDockerConfig())
client, err := newClient(cfg)
if err != nil {
return fmt.Errorf("creating client: %w", err)
}
Expand Down
2 changes: 2 additions & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ func init() {
rootCmd.PersistentFlags().CountP("verbose", "v", "increase verbosity (can be repeated: -vv, -vvv)")
rootCmd.PersistentFlags().BoolP("quiet", "q", false, "suppress non-error output")
rootCmd.PersistentFlags().Bool("no-color", false, "disable colored output")
rootCmd.PersistentFlags().Bool("plain-http", false, "use plain HTTP instead of HTTPS for registries")

// Bind flags to Viper
// Note: "config" is NOT bound to Viper to avoid BLOB_CONFIG env var affecting
Expand All @@ -64,6 +65,7 @@ func init() {
viper.BindPFlag("verbose", rootCmd.PersistentFlags().Lookup("verbose"))
viper.BindPFlag("quiet", rootCmd.PersistentFlags().Lookup("quiet"))
viper.BindPFlag("no-color", rootCmd.PersistentFlags().Lookup("no-color"))
viper.BindPFlag("plain-http", rootCmd.PersistentFlags().Lookup("plain-http"))

// Add core commands
rootCmd.AddCommand(pushCmd)
Expand Down
3 changes: 1 addition & 2 deletions cmd/sign.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"os"
"strings"

"github.com/meigma/blob"
"github.com/meigma/blob/policy/sigstore"
"github.com/meigma/blob/registry/oras"
"github.com/spf13/cobra"
Expand Down Expand Up @@ -90,7 +89,7 @@ func runSign(cmd *cobra.Command, args []string) error {
}

// Normal mode: sign and upload
client, err := blob.NewClient(blob.WithDockerConfig())
client, err := newClient(cfg)
if err != nil {
return fmt.Errorf("creating client: %w", err)
}
Expand Down
3 changes: 1 addition & 2 deletions cmd/tag.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"fmt"
"os"

"github.com/meigma/blob"
"github.com/spf13/cobra"
"github.com/spf13/viper"

Expand Down Expand Up @@ -49,7 +48,7 @@ func runTag(cmd *cobra.Command, args []string) error {
resolvedSrcRef := cfg.ResolveAlias(srcRef)
resolvedDstRef := cfg.ResolveAlias(dstRef)

client, err := blob.NewClient(blob.WithDockerConfig())
client, err := newClient(cfg)
if err != nil {
return fmt.Errorf("creating client: %w", err)
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func runTree(cmd *cobra.Command, args []string) error {
return err
}

result, err := archive.Inspect(cmd.Context(), ref)
result, err := archive.Inspect(cmd.Context(), ref, clientOpts(cfg)...)
if err != nil {
return err
}
Expand Down
8 changes: 4 additions & 4 deletions cmd/verify.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ func runVerify(cmd *cobra.Command, args []string) error {
// 7. Handle no-policies case
if len(policies) == 0 {
// No policies - vacuous success with warning
inspectResult, inspectErr := archive.Inspect(cmd.Context(), resolvedRef)
inspectResult, inspectErr := archive.Inspect(cmd.Context(), resolvedRef, clientOpts(cfg)...)
if inspectErr != nil {
return fmt.Errorf("inspecting archive: %w", inspectErr)
}
Expand All @@ -129,11 +129,11 @@ func runVerify(cmd *cobra.Command, args []string) error {
}

// 8. Create client with policies for verification
clientOpts := []blob.Option{blob.WithDockerConfig()}
policyOpts := make([]blob.Option, 0, len(policies))
for _, p := range policies {
clientOpts = append(clientOpts, blob.WithPolicy(p))
policyOpts = append(policyOpts, blob.WithPolicy(p))
}
client, err := blob.NewClient(clientOpts...)
client, err := newClient(cfg, policyOpts...)
if err != nil {
return fmt.Errorf("creating client: %w", err)
}
Expand Down
54 changes: 54 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,62 @@ module github.com/meigma/blob-cli
go 1.25.5

require (
github.com/charmbracelet/bubbles v0.21.0
github.com/charmbracelet/bubbletea v1.3.10
github.com/charmbracelet/lipgloss v1.1.0
github.com/meigma/blob v1.1.0
github.com/meigma/blob/policy/opa v0.0.0-20260121212824-972ce5f91c94
github.com/meigma/blob/policy/sigstore v0.0.0-20260121212824-972ce5f91c94
github.com/meigma/blob/policy/slsa v0.0.0-20260121212824-972ce5f91c94
github.com/rogpeppe/go-internal v1.14.1
github.com/spf13/cobra v1.10.2
github.com/spf13/viper v1.21.0
github.com/stretchr/testify v1.11.1
github.com/testcontainers/testcontainers-go v0.40.0
gopkg.in/yaml.v3 v3.0.1
)

require (
dario.cat/mergo v1.0.2 // indirect
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect
github.com/Microsoft/go-winio v0.6.2 // indirect
github.com/agnivade/levenshtein v1.2.1 // indirect
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 // indirect
github.com/atotto/clipboard v0.1.4 // indirect
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/blang/semver v3.5.1+incompatible // indirect
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
github.com/cenkalti/backoff/v5 v5.0.3 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/charmbracelet/colorprofile v0.2.3-0.20250311203215-f60798e515dc // indirect
github.com/charmbracelet/x/ansi v0.10.1 // indirect
github.com/charmbracelet/x/cellbuf v0.0.13-0.20250311204145-2c3ea96c31dd // indirect
github.com/charmbracelet/x/term v0.2.1 // indirect
github.com/containerd/errdefs v1.0.0 // indirect
github.com/containerd/errdefs/pkg v0.3.0 // indirect
github.com/containerd/log v0.1.0 // indirect
github.com/containerd/platforms v1.0.0-rc.2 // indirect
github.com/coreos/go-oidc/v3 v3.17.0 // indirect
github.com/cpuguy83/dockercfg v0.3.2 // indirect
github.com/cyberphone/json-canonicalization v0.0.0-20241213102144-19d51d7fe467 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.4.0 // indirect
github.com/digitorus/pkcs7 v0.0.0-20230818184609-3a137a874352 // indirect
github.com/digitorus/timestamp v0.0.0-20231217203849-220c5c2851b7 // indirect
github.com/distribution/reference v0.6.0 // indirect
github.com/docker/docker v28.5.2+incompatible // indirect
github.com/docker/go-connections v0.6.0 // indirect
github.com/docker/go-units v0.5.0 // indirect
github.com/ebitengine/purego v0.8.4 // indirect
github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/fsnotify/fsnotify v1.9.0 // indirect
github.com/go-ini/ini v1.67.0 // indirect
github.com/go-jose/go-jose/v4 v4.1.3 // indirect
github.com/go-logr/logr v1.4.3 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-ole/go-ole v1.2.6 // indirect
github.com/go-openapi/analysis v0.24.1 // indirect
github.com/go-openapi/errors v0.22.6 // indirect
github.com/go-openapi/jsonpointer v0.22.4 // indirect
Expand Down Expand Up @@ -75,6 +103,23 @@ require (
github.com/lestrrat-go/jwx/v3 v3.0.12 // indirect
github.com/lestrrat-go/option v1.0.1 // indirect
github.com/lestrrat-go/option/v2 v2.0.0 // indirect
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect
github.com/magiconair/properties v1.8.10 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mattn/go-localereader v0.0.1 // indirect
github.com/mattn/go-runewidth v0.0.16 // indirect
github.com/moby/docker-image-spec v1.3.1 // indirect
github.com/moby/go-archive v0.1.0 // indirect
github.com/moby/patternmatcher v0.6.0 // indirect
github.com/moby/sys/sequential v0.6.0 // indirect
github.com/moby/sys/user v0.4.0 // indirect
github.com/moby/sys/userns v0.1.0 // indirect
github.com/moby/term v0.5.0 // indirect
github.com/morikuni/aec v1.0.0 // indirect
github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 // indirect
github.com/muesli/cancelreader v0.2.2 // indirect
github.com/muesli/termenv v0.16.0 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/oklog/ulid v1.3.1 // indirect
github.com/open-policy-agent/opa v1.12.3 // indirect
Expand All @@ -84,16 +129,19 @@ require (
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c // indirect
github.com/prometheus/client_golang v1.23.2 // indirect
github.com/prometheus/client_model v0.6.2 // indirect
github.com/prometheus/common v0.66.1 // indirect
github.com/prometheus/procfs v0.17.0 // indirect
github.com/rcrowley/go-metrics v0.0.0-20250401214520-65e299d6c5c9 // indirect
github.com/rivo/uniseg v0.4.7 // indirect
github.com/sagikazarmark/locafero v0.11.0 // indirect
github.com/sassoftware/relic v7.2.1+incompatible // indirect
github.com/secure-systems-lab/go-securesystemslib v0.10.0 // indirect
github.com/segmentio/asm v1.2.1 // indirect
github.com/shibumi/go-pathspec v1.3.0 // indirect
github.com/shirou/gopsutil/v4 v4.25.6 // indirect
github.com/sigstore/protobuf-specs v0.5.0 // indirect
github.com/sigstore/rekor v1.5.0 // indirect
github.com/sigstore/rekor-tiles/v2 v2.0.1 // indirect
Expand All @@ -109,15 +157,20 @@ require (
github.com/tchap/go-patricia/v2 v2.3.3 // indirect
github.com/theupdateframework/go-tuf v0.7.0 // indirect
github.com/theupdateframework/go-tuf/v2 v2.3.1 // indirect
github.com/tklauser/go-sysconf v0.3.12 // indirect
github.com/tklauser/numcpus v0.6.1 // indirect
github.com/transparency-dev/formats v0.0.0-20251017110053-404c0d5b696c // indirect
github.com/transparency-dev/merkle v0.0.2 // indirect
github.com/valyala/fastjson v1.6.4 // indirect
github.com/vektah/gqlparser/v2 v2.5.31 // indirect
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect
github.com/yashtewari/glob-intersection v0.2.0 // indirect
github.com/yusufpapurcu/wmi v1.2.4 // indirect
go.mongodb.org/mongo-driver v1.17.6 // indirect
go.opentelemetry.io/auto/sdk v1.2.1 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.63.0 // indirect
go.opentelemetry.io/otel v1.39.0 // indirect
go.opentelemetry.io/otel/metric v1.39.0 // indirect
go.opentelemetry.io/otel/sdk v1.39.0 // indirect
Expand All @@ -132,6 +185,7 @@ require (
golang.org/x/sys v0.39.0 // indirect
golang.org/x/term v0.38.0 // indirect
golang.org/x/text v0.32.0 // indirect
golang.org/x/tools v0.39.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20251202230838-ff82c1b0f217 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20251222181119-0a764e51fe1b // indirect
google.golang.org/grpc v1.78.0 // indirect
Expand Down
Loading