Skip to content

Commit

Permalink
fix: resolverevision endpoint now works correctly for oci
Browse files Browse the repository at this point in the history
Signed-off-by: Blake Pettersson <blake.pettersson@gmail.com>
  • Loading branch information
blakepettersson committed Jun 26, 2024
1 parent acf994e commit 00a0e52
Showing 1 changed file with 22 additions and 10 deletions.
32 changes: 22 additions & 10 deletions reposerver/repository/repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -2584,30 +2584,42 @@ func (s *Service) ResolveRevision(ctx context.Context, q *apiclient.ResolveRevis
ambiguousRevision := q.AmbiguousRevision
var revision string
source := app.Spec.GetSourcePtrByIndex(int(q.SourceIndex))
if source.IsHelm() {
_, revision, err := s.newHelmClientResolveRevision(repo, ambiguousRevision, source.Chart, true)

if source.IsOci() {
_, revision, err := s.newOciClientResolveRevision(ctx, repo, ambiguousRevision, true)
if err != nil {
return &apiclient.ResolveRevisionResponse{Revision: "", AmbiguousRevision: ""}, err
}
return &apiclient.ResolveRevisionResponse{
Revision: revision,
AmbiguousRevision: fmt.Sprintf("%v (%v)", ambiguousRevision, revision),
}, nil
} else {
gitClient, err := git.NewClient(repo.Repo, repo.GetGitCreds(s.gitCredsStore), repo.IsInsecure(), repo.IsLFSEnabled(), repo.Proxy)
if err != nil {
return &apiclient.ResolveRevisionResponse{Revision: "", AmbiguousRevision: ""}, err
}
revision, err = gitClient.LsRemote(ambiguousRevision)
}

if source.IsHelm() {
_, revision, err := s.newHelmClientResolveRevision(repo, ambiguousRevision, source.Chart, true)
if err != nil {
s.metricsServer.IncGitLsRemoteFail(gitClient.Root(), revision)
return &apiclient.ResolveRevisionResponse{Revision: "", AmbiguousRevision: ""}, err
}
return &apiclient.ResolveRevisionResponse{
Revision: revision,
AmbiguousRevision: fmt.Sprintf("%s (%s)", ambiguousRevision, revision),
AmbiguousRevision: fmt.Sprintf("%v (%v)", ambiguousRevision, revision),
}, nil
}

gitClient, err := git.NewClient(repo.Repo, repo.GetGitCreds(s.gitCredsStore), repo.IsInsecure(), repo.IsLFSEnabled(), repo.Proxy)
if err != nil {
return &apiclient.ResolveRevisionResponse{Revision: "", AmbiguousRevision: ""}, err
}
revision, err = gitClient.LsRemote(ambiguousRevision)
if err != nil {
s.metricsServer.IncGitLsRemoteFail(gitClient.Root(), revision)
return &apiclient.ResolveRevisionResponse{Revision: "", AmbiguousRevision: ""}, err
}
return &apiclient.ResolveRevisionResponse{
Revision: revision,
AmbiguousRevision: fmt.Sprintf("%s (%s)", ambiguousRevision, revision),
}, nil
}

func (s *Service) GetGitFiles(_ context.Context, request *apiclient.GitFilesRequest) (*apiclient.GitFilesResponse, error) {
Expand Down

0 comments on commit 00a0e52

Please sign in to comment.