Skip to content

Commit a5a4c44

Browse files
authored
refactor: move the PullByDragonfly as private method (#204)
Signed-off-by: chlins <[email protected]>
1 parent 776d032 commit a5a4c44

File tree

5 files changed

+9
-61
lines changed

5 files changed

+9
-61
lines changed

cmd/pull.go

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,8 @@ func runPull(ctx context.Context, target string) error {
7373
return fmt.Errorf("target is required")
7474
}
7575

76-
if pullConfig.DragonflyEndpoint != "" {
77-
if err := b.PullByDragonfly(ctx, target, pullConfig); err != nil {
78-
return err
79-
}
80-
} else {
81-
if err := b.Pull(ctx, target, pullConfig); err != nil {
82-
return err
83-
}
76+
if err := b.Pull(ctx, target, pullConfig); err != nil {
77+
return err
8478
}
8579

8680
fmt.Printf("Successfully pulled model artifact: %s\n", target)

pkg/backend/backend.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,6 @@ type Backend interface {
4040
// Pull pulls an artifact from a registry.
4141
Pull(ctx context.Context, target string, cfg *config.Pull) error
4242

43-
// PullByDragonfly pulls an artifact from a registry by Dragonfly.
44-
PullByDragonfly(ctx context.Context, target string, cfg *config.Pull) error
45-
4643
// Fetch fetches partial files to the output.
4744
Fetch(ctx context.Context, target string, cfg *config.Fetch) error
4845

pkg/backend/pull.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ import (
3535

3636
// Pull pulls an artifact from a registry.
3737
func (b *backend) Pull(ctx context.Context, target string, cfg *config.Pull) error {
38+
// pullByDragonfly is called if a Dragonfly endpoint is specified in the configuration.
39+
if cfg.DragonflyEndpoint != "" {
40+
return b.pullByDragonfly(ctx, target, cfg)
41+
}
42+
3843
// parse the repository and tag from the target.
3944
ref, err := ParseReference(target)
4045
if err != nil {

pkg/backend/pull_by_d7y.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ const (
4545
mediaTypeTarSuffix = ".tar"
4646
)
4747

48-
// PullByDragonfly pulls and hardlinks blobs from Dragonfly gRPC service for remote extraction.
49-
func (b *backend) PullByDragonfly(ctx context.Context, target string, cfg *config.Pull) error {
48+
// pullByDragonfly pulls and hardlinks blobs from Dragonfly gRPC service for remote extraction.
49+
func (b *backend) pullByDragonfly(ctx context.Context, target string, cfg *config.Pull) error {
5050
// Parse reference and initialize remote client.
5151
ref, err := ParseReference(target)
5252
if err != nil {

test/mocks/backend/backend.go

Lines changed: 0 additions & 48 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)