Skip to content

Commit

Permalink
vendor update test fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Cerebrovinny committed Feb 2, 2025
1 parent 32eb1e8 commit 9524836
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 11 deletions.
27 changes: 18 additions & 9 deletions pkg/list/list_vendor.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func processVendorFile(filePath string, atmosConfig schema.AtmosConfiguration) (
for _, source := range vendorConfig.Spec.Sources {
vendorType := "Vendor Manifest"
manifest := filepath.Clean(filePath)
folder := filepath.Join(atmosConfig.BasePath, "components", "terraform", source.Component)
folder := filepath.Join(atmosConfig.BasePath, source.Targets[0])

vendors = append(vendors, VendorInfo{
Component: source.Component,
Expand Down Expand Up @@ -139,16 +139,25 @@ func FilterAndListVendors(listConfig schema.ListConfig, format string, delimiter
allVendors = append(allVendors, vendors...)
}

// Convert vendor info to rows
// Convert vendor info to rows based on header columns
var rows [][]string
for _, vendor := range allVendors {
rows = append(rows, []string{
vendor.Component,
vendor.Type,
vendor.Manifest,
vendor.Folder,
vendor.Version,
})
row := make([]string, len(header))
for i, col := range header {
switch col {
case "Component":
row[i] = vendor.Component
case "Type":
row[i] = vendor.Type
case "Manifest":
row[i] = vendor.Manifest
case "Folder":
row[i] = vendor.Folder
case "Version":
row[i] = vendor.Version
}
}
rows = append(rows, row)
}

// Sort rows for consistent output
Expand Down
11 changes: 9 additions & 2 deletions pkg/list/list_vendor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,15 @@ components:
},
},
{
name: "csv format with multiple vendors",
config: schema.ListConfig{},
name: "csv format with multiple vendors",
config: schema.ListConfig{
Columns: []schema.ListColumnConfig{
{Name: "Component", Value: "{{ .atmos_component }}"},
{Name: "Type", Value: "{{ .atmos_vendor_type }}"},
{Name: "Manifest", Value: "{{ .atmos_vendor_file }}"},
{Name: "Folder", Value: "{{ .atmos_vendor_target }}"},
},
},
format: "csv",
delimiter: ",",
wantErr: false,
Expand Down

0 comments on commit 9524836

Please sign in to comment.