Skip to content

Commit

Permalink
Read repository contents using ConfigurationRepository interface
Browse files Browse the repository at this point in the history
  • Loading branch information
passichenko committed Sep 27, 2024
1 parent 158cf2f commit e6301dd
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions pkg/gen/gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,13 +115,8 @@ func genFormattedGo(ctx context.Context, project *native.Project, repoPath, lekk
return nil
}

// Reads repository contents from a local config repository.
func ReadRepoContents(ctx context.Context, repoPath string) (repoContents *featurev1beta1.RepositoryContents, err error) {
defer err2.Handle(&err)
r, err := repo.NewLocal(repoPath, nil)
if err != nil {
return nil, errors.Wrap(err, "read config repository")
}
// Read repository contents using ConfigurationRepository interface
func ReadRepoContentsFromRepo(ctx context.Context, r repo.ConfigurationRepository) (repoContents *featurev1beta1.RepositoryContents, err error) {
rootMD, nsMDs := try.To2(r.ParseMetadata(ctx))
repoContents = &featurev1beta1.RepositoryContents{}
repoContents.FileDescriptorSet = try.To1(r.GetFileDescriptorSet(ctx, rootMD.ProtoDirectory))
Expand Down Expand Up @@ -150,3 +145,13 @@ func ReadRepoContents(ctx context.Context, repoPath string) (repoContents *featu
}
return repoContents, nil
}

// Reads repository contents from a local config repository.
func ReadRepoContents(ctx context.Context, repoPath string) (repoContents *featurev1beta1.RepositoryContents, err error) {
defer err2.Handle(&err)
r, err := repo.NewLocal(repoPath, nil)
if err != nil {
return nil, errors.Wrap(err, "read config repository")
}
return ReadRepoContentsFromRepo(ctx, r)
}

0 comments on commit e6301dd

Please sign in to comment.