Skip to content

Commit

Permalink
Merge pull request #292 from Bedrock-OSS/fix-profile-export-data
Browse files Browse the repository at this point in the history
Fixed exporting files to the data folder using nested profiles.
  • Loading branch information
Nusiq authored Aug 27, 2024
2 parents 12491c0 + 09a6be3 commit fd8b410
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 4 deletions.
2 changes: 1 addition & 1 deletion regolith/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ func ExportProject(ctx RunContext) error {
var exportedFilterNames []string
for filter := range profile.Filters {
filter := profile.Filters[filter]
usingDataPath, err := filter.IsUsingDataExport(dotRegolithPath)
usingDataPath, err := filter.IsUsingDataExport(dotRegolithPath, ctx)
if err != nil {
return burrito.WrapErrorf(
err,
Expand Down
4 changes: 2 additions & 2 deletions regolith/filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ type FilterRunner interface {

// IsUsingDataExport returns whether the filter wants its data to be
// exported back to the data folder after running the profile.
IsUsingDataExport(dotRegolithPath string) (bool, error)
IsUsingDataExport(dotRegolithPath string, ctx RunContext) (bool, error)
}

func (f *Filter) CopyArguments(parent *RemoteFilter) {
Expand Down Expand Up @@ -256,7 +256,7 @@ func (f *Filter) IsDisabled(ctx RunContext) (bool, error) {
return false, nil
}

func (f *Filter) IsUsingDataExport(_ string) (bool, error) {
func (f *Filter) IsUsingDataExport(_ string, _ RunContext) (bool, error) {
return false, nil
}

Expand Down
18 changes: 18 additions & 0 deletions regolith/filter_profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,21 @@ func (f *ProfileFilter) Check(context RunContext) error {
profile, f.Profile, *context.Config, &context,
context.DotRegolithPath)
}

func (f *ProfileFilter) IsUsingDataExport(dotRegolithPath string, ctx RunContext) (bool, error) {
profile := ctx.Config.Profiles[f.Profile]
for filter := range profile.Filters {
filter := profile.Filters[filter]
usingDataPath, err := filter.IsUsingDataExport(dotRegolithPath, ctx)
if err != nil {
return false, burrito.WrapErrorf(
err,
"Failed to check if profile is using data export.\n"+
"Profile: %s", f.Profile)
}
if usingDataPath {
return true, nil
}
}
return false, nil
}
2 changes: 1 addition & 1 deletion regolith/filter_remote.go
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ func (f *RemoteFilter) GetCachedVersion(dotRegolithPath string) (*string, error)
return &version, nil
}

func (f *RemoteFilter) IsUsingDataExport(dotRegolithPath string) (bool, error) {
func (f *RemoteFilter) IsUsingDataExport(dotRegolithPath string, _ RunContext) (bool, error) {
// Load the filter.json file
filterJsonPath := filepath.Join(f.GetDownloadPath(dotRegolithPath), "filter.json")
file, err := os.ReadFile(filterJsonPath)
Expand Down

0 comments on commit fd8b410

Please sign in to comment.