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
1 change: 1 addition & 0 deletions cmd/inspect.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ func init() {
flags.BoolVar(&inspectConfig.Remote, "remote", false, "inspect model artifact from remote registry")
flags.BoolVar(&inspectConfig.PlainHTTP, "plain-http", false, "use plain HTTP instead of HTTPS")
flags.BoolVar(&inspectConfig.Insecure, "insecure", false, "allow insecure connections")
flags.BoolVar(&inspectConfig.Config, "config", false, "inspect the config of the model artifact")

if err := viper.BindPFlags(flags); err != nil {
panic(fmt.Errorf("bind cache inspect flags to viper: %w", err))
Expand Down
2 changes: 1 addition & 1 deletion pkg/backend/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ type Backend interface {
Prune(ctx context.Context, dryRun, removeUntagged bool) error

// Inspect inspects the model artifact.
Inspect(ctx context.Context, target string, cfg *config.Inspect) (*InspectedModelArtifact, error)
Inspect(ctx context.Context, target string, cfg *config.Inspect) (any, error)
Comment thread
chlins marked this conversation as resolved.

// Extract extracts the model artifact.
Extract(ctx context.Context, target string, cfg *config.Extract) error
Expand Down
6 changes: 5 additions & 1 deletion pkg/backend/inspect.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ type InspectedModelArtifactLayer struct {
}

// Inspect inspects the target from the storage.
func (b *backend) Inspect(ctx context.Context, target string, cfg *config.Inspect) (*InspectedModelArtifact, error) {
func (b *backend) Inspect(ctx context.Context, target string, cfg *config.Inspect) (any, error) {
Comment thread
chlins marked this conversation as resolved.
logrus.Infof("inspect: starting inspect operation for target %s [config: %+v]", target, cfg)
_, err := ParseReference(target)
if err != nil {
Expand All @@ -92,6 +92,10 @@ func (b *backend) Inspect(ctx context.Context, target string, cfg *config.Inspec

logrus.Debugf("inspect: loaded model config for target %s [family: %s, name: %s]", target, config.Descriptor.Family, config.Descriptor.Name)

if cfg.Config {
return config, nil
}

inspectedModelArtifact := &InspectedModelArtifact{
ID: manifest.Config.Digest.String(),
Digest: godigest.FromBytes(manifestRaw).String(),
Expand Down
3 changes: 2 additions & 1 deletion pkg/backend/inspect_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,8 @@ func TestInspect(t *testing.T) {
mockStore.On("PullManifest", ctx, "example.com/repo", "tag").Return([]byte(manifest), "sha256:9ca701e8784e5656e2c36f10f82410a0af4c44f859590a28a3d1519ee1eea89d", nil)
mockStore.On("PullBlob", ctx, "example.com/repo", "sha256:e31b55920173ba79526491fbd01efe609c1d0d72c3a83df85b2c4fe74df2eea2").Return(io.NopCloser(bytes.NewReader([]byte(config))), nil)

inspected, err := b.Inspect(ctx, target, &pkgconfig.Inspect{})
inspectedAny, err := b.Inspect(ctx, target, &pkgconfig.Inspect{})
inspected := inspectedAny.(*InspectedModelArtifact)
assert.NoError(t, err)
assert.Equal(t, "sha256:e31b55920173ba79526491fbd01efe609c1d0d72c3a83df85b2c4fe74df2eea2", inspected.ID)
assert.Equal(t, "sha256:9ca701e8784e5656e2c36f10f82410a0af4c44f859590a28a3d1519ee1eea89d", inspected.Digest)
Expand Down
2 changes: 2 additions & 0 deletions pkg/config/inspect.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,14 @@ type Inspect struct {
Remote bool
PlainHTTP bool
Insecure bool
Config bool
}

func NewInspect() *Inspect {
return &Inspect{
Remote: false,
PlainHTTP: false,
Insecure: false,
Config: false,
}
}
62 changes: 55 additions & 7 deletions test/mocks/backend/backend.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.