Skip to content

Commit

Permalink
fix(manifest): Tidy up use of pullGit and pullArchive with useGit
Browse files Browse the repository at this point in the history
Signed-off-by: Alexander Jung <alex@unikraft.io>
  • Loading branch information
nderjung committed Jan 10, 2025
1 parent 36b424c commit 2462e77
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 38 deletions.
18 changes: 4 additions & 14 deletions manifest/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,33 +197,23 @@ func (gp *GitProvider) Manifests() ([]*Manifest, error) {
}

func (gp *GitProvider) PullChannel(ctx context.Context, manifest *Manifest, channel *ManifestChannel, popts ...pack.PullOption) error {
if useGit {
return pullGit(ctx, manifest, popts...)
}

manifest.mopts = gp.mopts

if err := pullArchive(ctx, manifest, channel.Resource, channel.Sha256, popts...); err != nil {
log.G(ctx).Trace(err)
if useGit {
return pullGit(ctx, manifest, popts...)
}

return nil
return pullArchive(ctx, manifest, channel.Resource, channel.Sha256, popts...)
}

func (gp *GitProvider) PullVersion(ctx context.Context, manifest *Manifest, version *ManifestVersion, popts ...pack.PullOption) error {
if useGit {
return pullGit(ctx, manifest, popts...)
}

manifest.mopts = gp.mopts

if err := pullArchive(ctx, manifest, version.Resource, version.Sha256, popts...); err != nil {
log.G(ctx).Trace(err)
if useGit {
return pullGit(ctx, manifest, popts...)
}

return nil
return pullArchive(ctx, manifest, version.Resource, version.Sha256, popts...)
}

func (gp *GitProvider) DeleteManifest(context.Context) error {
Expand Down
18 changes: 4 additions & 14 deletions manifest/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,33 +130,23 @@ func (ghp GitHubProvider) Manifests() ([]*Manifest, error) {
}

func (ghp GitHubProvider) PullChannel(ctx context.Context, manifest *Manifest, channel *ManifestChannel, popts ...pack.PullOption) error {
if useGit {
return pullGit(ctx, manifest, popts...)
}

manifest.mopts = ghp.mopts

if err := pullArchive(ctx, manifest, channel.Resource, channel.Sha256, popts...); err != nil {
log.G(ctx).Trace(err)
if useGit {
return pullGit(ctx, manifest, popts...)
}

return nil
return pullArchive(ctx, manifest, channel.Resource, channel.Sha256, popts...)
}

func (ghp GitHubProvider) PullVersion(ctx context.Context, manifest *Manifest, version *ManifestVersion, popts ...pack.PullOption) error {
if useGit {
return pullGit(ctx, manifest, popts...)
}

manifest.mopts = ghp.mopts

if err := pullArchive(ctx, manifest, version.Resource, version.Sha256, popts...); err != nil {
log.G(ctx).Trace(err)
if useGit {
return pullGit(ctx, manifest, popts...)
}

return nil
return pullArchive(ctx, manifest, version.Resource, version.Sha256, popts...)
}

func (ghp GitHubProvider) DeleteManifest(context.Context) error {
Expand Down
12 changes: 2 additions & 10 deletions manifest/manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,8 @@ func (mp *ManifestProvider) Manifests() ([]*Manifest, error) {
func (mp *ManifestProvider) PullChannel(ctx context.Context, manifest *Manifest, channel *ManifestChannel, opts ...pack.PullOption) error {
manifest.mopts = mp.manifest.mopts

// If the user has requested to pull the manifest via git, and it passes,
// great, otherwise fall back to archive pull.
if useGit {
if err := pullGit(ctx, manifest, opts...); err == nil {
return nil
}
return pullGit(ctx, manifest, opts...)
}

return pullArchive(ctx, manifest, channel.Resource, channel.Sha256, opts...)
Expand All @@ -117,12 +113,8 @@ func (mp *ManifestProvider) PullChannel(ctx context.Context, manifest *Manifest,
func (mp *ManifestProvider) PullVersion(ctx context.Context, manifest *Manifest, version *ManifestVersion, opts ...pack.PullOption) error {
manifest.mopts = mp.manifest.mopts

// If the user has requested to pull the manifest via git, and it passes,
// great, otherwise fall back to archive pull.
if useGit {
if err := pullGit(ctx, manifest, opts...); err == nil {
return nil
}
return pullGit(ctx, manifest, opts...)
}

return pullArchive(ctx, manifest, version.Resource, version.Sha256, opts...)
Expand Down

0 comments on commit 2462e77

Please sign in to comment.