-
-
Notifications
You must be signed in to change notification settings - Fork 111
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement: atmos list vendor #994
base: main
Are you sure you want to change the base?
Conversation
📝 WalkthroughWalkthroughThis pull request introduces a new CLI command ( Changes
Assessment against linked issues
Possibly related PRs
Suggested labels
Suggested reviewers
Tip 🌐 Web search-backed reviews and chat
✨ Finishing Touches
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (2)
pkg/list/list_vendor.go (1)
142-144
: Sorting strategy could be refined.
Usingstrings.Join
on row columns might not match expected sorting on individual fields.cmd/list_vendor.go (1)
55-59
: Consider direct test coverage.
You may add an integration or CLI test for this command’s flow to ensure consistency.
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
cmd/list_vendor.go
(1 hunks)pkg/list/list_vendor.go
(1 hunks)pkg/list/list_vendor_test.go
(1 hunks)pkg/schema/schema.go
(1 hunks)
🧰 Additional context used
🪛 golangci-lint (1.62.2)
pkg/list/list_vendor_test.go
111-111: Error return value of os.Chdir
is not checked
(errcheck)
⏰ Context from checks skipped due to timeout of 90000ms (4)
- GitHub Check: Acceptance Tests (macos-latest, macos)
- GitHub Check: Acceptance Tests (windows-latest, windows)
- GitHub Check: Acceptance Tests (ubuntu-latest, linux)
- GitHub Check: Summary
🔇 Additional comments (6)
pkg/list/list_vendor.go (2)
21-27
: Struct layout looks congruent.
No apparent issues with theVendorInfo
fields or JSON annotations.
44-55
: Validate source component references.
Consider verifyingsource.Component
is non-empty to avoid potential folder creation issues.cmd/list_vendor.go (1)
15-23
: Command usage is concise.
Arguments and examples are clear, supporting multiple formats.pkg/list/list_vendor_test.go (2)
18-240
: Test coverage is thorough.
Your table-driven tests ensure multiple vendor formats are well-exercised.🧰 Tools
🪛 golangci-lint (1.62.2)
111-111: Error return value of
os.Chdir
is not checked(errcheck)
111-111
: Defer’s error return is unchecked.
It might be prudent to catchos.Chdir(currentDir)
errors in a deferred function.Proposed fix:
- defer os.Chdir(currentDir) + defer func() { + if err := os.Chdir(currentDir); err != nil { + t.Logf("Error returning to original directory: %v", err) + } +}()🧰 Tools
🪛 golangci-lint (1.62.2)
111-111: Error return value of
os.Chdir
is not checked(errcheck)
pkg/schema/schema.go (1)
637-638
: LGTM! Clean addition of vendor list configuration.The addition of the
List
field to theVendor
struct is well-structured and consistent with the existing codebase pattern, reusing theListConfig
type that's already used by theWorkflows
struct. The field is properly tagged for YAML, JSON, and mapstructure serialization.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (2)
pkg/list/list_vendor_test.go (2)
18-28
: Consider extracting test setup into a helper function.The test setup code is well-structured, but extracting it into a helper function would improve reusability for future test cases.
+func setupTestEnvironment(t *testing.T) (string, func()) { + tmpDir, err := os.MkdirTemp("", "vendor_test") + require.NoError(t, err) + + // Create vendor directory structure + vendorDir := filepath.Join(tmpDir, "vendor.d") + err = os.MkdirAll(vendorDir, 0o755) + require.NoError(t, err) + + return tmpDir, func() { + os.RemoveAll(tmpDir) + } +} + func TestListVendors(t *testing.T) { - // Create a temporary directory for test files - tmpDir, err := os.MkdirTemp("", "vendor_test") - require.NoError(t, err) - defer os.RemoveAll(tmpDir) - - // Create vendor directory structure - vendorDir := filepath.Join(tmpDir, "vendor.d") - err = os.MkdirAll(vendorDir, 0o755) - require.NoError(t, err) + tmpDir, cleanup := setupTestEnvironment(t) + defer cleanup()
136-235
: Consider adding edge cases to the test suite.The test cases are well-structured, but consider adding these scenarios:
- Empty vendor configuration
- Invalid format string
- Missing required columns
- Special characters in component names
I can help generate the additional test cases if you'd like.
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
pkg/list/list_vendor_test.go
(1 hunks)
🧰 Additional context used
🪛 golangci-lint (1.62.2)
pkg/list/list_vendor_test.go
134-134: Error return value of os.Chdir
is not checked
(errcheck)
⏰ Context from checks skipped due to timeout of 90000ms (21)
- GitHub Check: [mock-macos] tests/fixtures/scenarios/complete
- GitHub Check: [mock-macos] examples/demo-vendoring
- GitHub Check: [mock-macos] examples/demo-context
- GitHub Check: [mock-macos] examples/demo-component-versions
- GitHub Check: [mock-macos] examples/demo-atlantis
- GitHub Check: [mock-windows] tests/fixtures/scenarios/complete
- GitHub Check: [mock-windows] examples/demo-vendoring
- GitHub Check: [mock-windows] examples/demo-context
- GitHub Check: [mock-windows] examples/demo-component-versions
- GitHub Check: [mock-windows] examples/demo-atlantis
- GitHub Check: [mock-linux] tests/fixtures/scenarios/complete
- GitHub Check: [mock-linux] examples/demo-vendoring
- GitHub Check: [mock-linux] examples/demo-context
- GitHub Check: Acceptance Tests (macos-latest, macos)
- GitHub Check: [mock-linux] examples/demo-component-versions
- GitHub Check: Acceptance Tests (windows-latest, windows)
- GitHub Check: Acceptance Tests (ubuntu-latest, linux)
- GitHub Check: [k3s] demo-helmfile
- GitHub Check: [localstack] demo-localstack
- GitHub Check: Docker Lint
- GitHub Check: Summary
🔇 Additional comments (2)
pkg/list/list_vendor_test.go (2)
1-16
: LGTM! Well-organized imports.The imports are properly organized and include all necessary packages for testing, including JSON handling, file operations, and testing utilities.
237-263
: LGTM! Robust test execution.The test execution follows Go's table-driven test pattern with proper error handling and validation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🧹 Nitpick comments (3)
pkg/list/list_vendor.go (3)
21-28
: Add field documentation for better code maintainability.While the struct itself is documented, adding documentation for each field would improve code maintainability.
// VendorInfo represents a vendor configuration entry type VendorInfo struct { + // Component is the name of the vendor component Component string `json:"component"` + // Type indicates the type of vendor configuration Type string `json:"type"` + // Manifest is the path to the vendor manifest file Manifest string `json:"manifest"` + // Folder is the path to the component folder Folder string `json:"folder"` + // Version specifies the version of the vendor component Version string `json:"version"` }
144-147
: Improve sort function reliability.The current sort implementation could produce unexpected results when the delimiter appears in the data.
- sort.Slice(rows, func(i, j int) bool { - return strings.Join(rows[i], delimiter) < strings.Join(rows[j], delimiter) - }) + sort.Slice(rows, func(i, j int) bool { + // Compare by component first, then by type + if rows[i][0] != rows[j][0] { + return rows[i][0] < rows[j][0] + } + return rows[i][1] < rows[j][1] + })
171-188
: Extract table styling logic for better maintainability.The table styling code should be extracted into a separate function for better organization.
+func createStyledTable(header []string, rows [][]string) string { + t := table.New(). + Border(lipgloss.ThickBorder()). + BorderStyle(lipgloss.NewStyle().Foreground(lipgloss.Color(theme.ColorBorder))). + StyleFunc(func(row, col int) lipgloss.Style { + style := lipgloss.NewStyle().PaddingLeft(1).PaddingRight(1) + if row == 0 { + return style.Inherit(theme.Styles.CommandName).Align(lipgloss.Center) + } + return style.Inherit(theme.Styles.Description) + }). + Headers(header...). + Rows(rows...) + return t.String() + utils.GetLineEnding() +} + // In FilterAndListVendors: if format == "" && exec.CheckTTYSupport() { - // Create a styled table for TTY - t := table.New(). - Border(lipgloss.ThickBorder()). - // ... rest of the table styling code ... - return t.String() + utils.GetLineEnding(), nil + return createStyledTable(header, rows), nil }
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
pkg/list/list_vendor.go
(1 hunks)pkg/list/list_vendor_test.go
(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- pkg/list/list_vendor_test.go
⏰ Context from checks skipped due to timeout of 90000ms (2)
- GitHub Check: Build (windows-latest, windows)
- GitHub Check: Summary
🔇 Additional comments (1)
pkg/list/list_vendor.go (1)
1-19
: LGTM! Well-organized imports.The imports are properly organized and all are being used in the code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (2)
pkg/list/list_workflows.go (2)
26-26
: Consider enhancing format-specific delimiter handling.The addition of
FormatTSV
is a good step, but we should ensure consistent delimiter handling between CSV and TSV formats.Consider defining format-specific delimiters as constants and using them in the format handling logic:
const ( FormatTable = "table" FormatJSON = "json" FormatCSV = "csv" FormatTSV = "tsv" + DelimiterCSV = "," + DelimiterTSV = "\t" )Also applies to: 34-34
192-199
: Enhance format-specific output handling.The current implementation uses the same logic for both CSV and TSV formats. Consider separating these cases to handle format-specific requirements.
Consider updating the format handling:
switch format { case "json": // ... existing JSON handling ... case "csv": - // Use the provided delimiter for CSV output + // Use comma delimiter for CSV unless custom delimiter provided + csvDelimiter := DelimiterCSV + if delimiter != "" { + csvDelimiter = delimiter + } var output strings.Builder - output.WriteString(strings.Join(header, delimiter) + utils.GetLineEnding()) + output.WriteString(strings.Join(header, csvDelimiter) + utils.GetLineEnding()) for _, row := range rows { - output.WriteString(strings.Join(row, delimiter) + utils.GetLineEnding()) + output.WriteString(strings.Join(row, csvDelimiter) + utils.GetLineEnding()) } return output.String(), nil + case "tsv": + // Use tab delimiter for TSV unless custom delimiter provided + tsvDelimiter := DelimiterTSV + if delimiter != "" { + tsvDelimiter = delimiter + } + var output strings.Builder + output.WriteString(strings.Join(header, tsvDelimiter) + utils.GetLineEnding()) + for _, row := range rows { + output.WriteString(strings.Join(row, tsvDelimiter) + utils.GetLineEnding()) + } + return output.String(), nil
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
cmd/list_vendor.go
(1 hunks)pkg/list/list_vendor.go
(1 hunks)pkg/list/list_workflows.go
(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
- pkg/list/list_vendor.go
- cmd/list_vendor.go
⏰ Context from checks skipped due to timeout of 90000ms (2)
- GitHub Check: Build (windows-latest, windows)
- GitHub Check: Summary
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (2)
pkg/list/list_vendor.go (1)
94-254
: LGTM! Consider enhancing error messages.The implementation handles output formats and delimiters well, aligning with the PR objectives.
Consider enhancing error messages with more context:
- return "", fmt.Errorf("error initializing CLI config: %w", err) + return "", fmt.Errorf("failed to initialize CLI config while listing vendors: %w", err)website/docs/cli/commands/list/list-vendor.mdx (1)
1-108
: Enhance documentation readability with consistent typography.The documentation is comprehensive and well-structured.
Apply these typographical improvements:
-The type of the vendor manifest (always "Vendor Manifest") +The type of the vendor manifest (always "Vendor Manifest") -[atmos vendor pull](/cli/commands/vendor/usage) - Pull vendored components +[atmos vendor pull](/cli/commands/vendor/usage) — Pull vendored components -[atmos vendor push](/cli/commands/vendor/usage) - Push vendored components +[atmos vendor push](/cli/commands/vendor/usage) — Push vendored components -[atmos list components](/cli/commands/list/components) - List available components +[atmos list components](/cli/commands/list/components) — List available components🧰 Tools
🪛 LanguageTool
[typographical] ~61-~61: Consider using typographic quotation marks here.
Context: ...The type of the vendor manifest (always "Vendor Manifest") -Manifest
: The path to the vendor m...(EN_QUOTES)
[typographical] ~106-~106: To join two clauses or introduce examples, consider using an em dash.
Context: ...vendor pull](/cli/commands/vendor/usage) - Pull vendored components - [atmos vendor...(DASH_RULE)
[typographical] ~107-~107: To join two clauses or introduce examples, consider using an em dash.
Context: ...vendor push](/cli/commands/vendor/usage) - Push vendored components - [atmos list c...(DASH_RULE)
[typographical] ~108-~108: To join two clauses or introduce examples, consider using an em dash.
Context: ...mponents](/cli/commands/list/components) - List available components(DASH_RULE)
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
internal/exec/vendor_utils.go
(3 hunks)pkg/list/list_vendor.go
(1 hunks)website/docs/cli/commands/list/list-vendor.mdx
(1 hunks)
🧰 Additional context used
🪛 LanguageTool
website/docs/cli/commands/list/list-vendor.mdx
[typographical] ~61-~61: Consider using typographic quotation marks here.
Context: ...The type of the vendor manifest (always "Vendor Manifest") - Manifest
: The path to the vendor m...
(EN_QUOTES)
[typographical] ~106-~106: To join two clauses or introduce examples, consider using an em dash.
Context: ...vendor pull](/cli/commands/vendor/usage) - Pull vendored components - [atmos vendor...
(DASH_RULE)
[typographical] ~107-~107: To join two clauses or introduce examples, consider using an em dash.
Context: ...vendor push](/cli/commands/vendor/usage) - Push vendored components - [atmos list c...
(DASH_RULE)
[typographical] ~108-~108: To join two clauses or introduce examples, consider using an em dash.
Context: ...mponents](/cli/commands/list/components) - List available components
(DASH_RULE)
⏰ Context from checks skipped due to timeout of 90000ms (2)
- GitHub Check: Build (windows-latest, windows)
- GitHub Check: Summary
🔇 Additional comments (3)
pkg/list/list_vendor.go (2)
1-23
: LGTM! Well-organized imports and constants.The imports are properly organized and the delimiter constants are appropriately defined.
25-92
: Verify template processing for edge cases.The template processing for targets and sources looks good, but let's ensure it handles all edge cases correctly.
Run this script to check template processing with various inputs:
✅ Verification successful
I'm not getting enough output with the previous regex command. Let's re-verify the usage of the template processing logic directly in the vendor file. We'll run a simpler search for the
exec.ProcessTmpl(
invocations within the file.
Template processing invocations verified in vendor logic.
The invocations for processing both target and source templates using
exec.ProcessTmpl
are present as expected in the file. This confirms that the template processing logic is correctly integrated.🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Test template processing with various inputs including special characters and empty values # Test: Search for template processing patterns rg -A 5 'ProcessTmpl.*"target"|ProcessTmpl.*"source"'Length of output: 55
Script:
#!/bin/bash # Verify ProcessTmpl invocations in pkg/list/list_vendor.go grep -R "exec.ProcessTmpl(" pkg/list/list_vendor.goLength of output: 142
internal/exec/vendor_utils.go (1)
440-495
: LGTM! Good addition of recursion depth limit.The implementation of depth limiting for vendor imports is a solid defensive programming practice.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (1)
website/docs/cli/commands/list/list-vendor.mdx (1)
104-108
: Related Commands – Minor Stylistic Suggestion
The related commands section is useful; however, consider using an em dash (—) instead of a hyphen for joining the descriptive text, per the static analysis recommendations.🧰 Tools
🪛 LanguageTool
[typographical] ~106-~106: To join two clauses or introduce examples, consider using an em dash.
Context: ...vendor pull](/cli/commands/vendor/usage) - Pull vendored components - [atmos vendor...(DASH_RULE)
[typographical] ~107-~107: To join two clauses or introduce examples, consider using an em dash.
Context: ...vendor push](/cli/commands/vendor/usage) - Push vendored components - [atmos list c...(DASH_RULE)
[typographical] ~108-~108: To join two clauses or introduce examples, consider using an em dash.
Context: ...omponents](/cli/commands/list/component) - List available components(DASH_RULE)
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
website/docs/cli/commands/list/list-vendor.mdx
(1 hunks)
🧰 Additional context used
🪛 LanguageTool
website/docs/cli/commands/list/list-vendor.mdx
[typographical] ~61-~61: Consider using typographic quotation marks here.
Context: ...The type of the vendor manifest (always "Vendor Manifest") - Manifest
: The path to the vendor m...
(EN_QUOTES)
[typographical] ~106-~106: To join two clauses or introduce examples, consider using an em dash.
Context: ...vendor pull](/cli/commands/vendor/usage) - Pull vendored components - [atmos vendor...
(DASH_RULE)
[typographical] ~107-~107: To join two clauses or introduce examples, consider using an em dash.
Context: ...vendor push](/cli/commands/vendor/usage) - Push vendored components - [atmos list c...
(DASH_RULE)
[typographical] ~108-~108: To join two clauses or introduce examples, consider using an em dash.
Context: ...omponents](/cli/commands/list/component) - List available components
(DASH_RULE)
⏰ Context from checks skipped due to timeout of 90000ms (5)
- GitHub Check: Build (macos-latest, macos)
- GitHub Check: Build (windows-latest, windows)
- GitHub Check: website-deploy-preview
- GitHub Check: Analyze (go)
- GitHub Check: Summary
🔇 Additional comments (8)
website/docs/cli/commands/list/list-vendor.mdx (8)
1-4
: YAML Header is Well-Formatted
The front matter correctly sets the title and ID for the documentation page.
6-9
: Command Heading and Introduction Clarity
The title and introductory text clearly explain the purpose of theatmos list vendor
command.
10-14
: Usage Section Readability
The usage example is concise and easy to follow. It provides a simple guide on how to invoke the command with flags.
16-24
: Detailed Command Description
This section effectively outlines what the command does and highlights the key pieces of information—such as component names, versions, folders, and source repositories—that users can expect.
25-30
: Default Columns Information
The list of default columns is clearly presented. The information is helpful for users to understand the standard output layout.
56-63
: Available Columns List is Clear
The list of available columns is comprehensive and effectively mirrors the configuration options provided above.🧰 Tools
🪛 LanguageTool
[typographical] ~61-~61: Consider using typographic quotation marks here.
Context: ...The type of the vendor manifest (always "Vendor Manifest") -Manifest
: The path to the vendor m...(EN_QUOTES)
66-76
: Flags Section is Well Documented
The flags are clearly described, including support for bothcsv
andtsv
output formats as well as the--delimiter
option. This directly addresses prior feedback and enhances usability.
77-103
: Examples Section Effectiveness
The examples are illustrative and cover different output formats and the use of custom delimiters. They provide practical guidance that users can follow without ambiguity.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
website/docs/cli/commands/list/list-vendor.mdx (1)
1-108
: Enhance documentation readability with consistent formatting.The documentation is comprehensive but could benefit from some formatting improvements:
- Use typographic quotation marks consistently
- Use em dashes (—) instead of hyphens for separating related commands
- Consider adding "of" in list descriptions:
- "List of vendored components in JSON format"
- "List of vendored components in TSV format"
-The type of the vendor manifest (always "Vendor Manifest") +The type of the vendor manifest (always "Vendor Manifest") -[atmos vendor pull](/cli/commands/vendor/usage) - Pull vendored components +[atmos vendor pull](/cli/commands/vendor/usage) — Pull vendored components -List vendored components in JSON format: +List of vendored components in JSON format:🧰 Tools
🪛 LanguageTool
[typographical] ~61-~61: Consider using typographic quotation marks here.
Context: ...The type of the vendor manifest (always "Vendor Manifest") -Manifest
: The path to the vendor m...(EN_QUOTES)
[uncategorized] ~84-~84: Possible missing preposition found.
Context: ...):shell atmos list vendor
List vendored components in JSON format: ```shell atm...(AI_HYDRA_LEO_MISSING_OF)
[uncategorized] ~94-~94: Possible missing preposition found.
Context: ...tmos list vendor --format csvList vendored components in TSV format:
shell atmo...(AI_HYDRA_LEO_MISSING_OF)
[typographical] ~106-~106: To join two clauses or introduce examples, consider using an em dash.
Context: ...vendor pull](/cli/commands/vendor/usage) - Pull vendored components - [atmos vendor...(DASH_RULE)
[typographical] ~107-~107: To join two clauses or introduce examples, consider using an em dash.
Context: ...vendor push](/cli/commands/vendor/usage) - Push vendored components - [atmos list c...(DASH_RULE)
[typographical] ~108-~108: To join two clauses or introduce examples, consider using an em dash.
Context: ...omponents](/cli/commands/list/component) - List available components(DASH_RULE)
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
internal/exec/vendor_utils.go
(3 hunks)pkg/list/list_vendor.go
(1 hunks)website/docs/cli/commands/list/list-vendor.mdx
(1 hunks)
🧰 Additional context used
🪛 LanguageTool
website/docs/cli/commands/list/list-vendor.mdx
[typographical] ~61-~61: Consider using typographic quotation marks here.
Context: ...The type of the vendor manifest (always "Vendor Manifest") - Manifest
: The path to the vendor m...
(EN_QUOTES)
[uncategorized] ~84-~84: Possible missing preposition found.
Context: ...): shell atmos list vendor
List vendored components in JSON format: ```shell atm...
(AI_HYDRA_LEO_MISSING_OF)
[uncategorized] ~94-~94: Possible missing preposition found.
Context: ...tmos list vendor --format csv List vendored components in TSV format:
shell atmo...
(AI_HYDRA_LEO_MISSING_OF)
[typographical] ~106-~106: To join two clauses or introduce examples, consider using an em dash.
Context: ...vendor pull](/cli/commands/vendor/usage) - Pull vendored components - [atmos vendor...
(DASH_RULE)
[typographical] ~107-~107: To join two clauses or introduce examples, consider using an em dash.
Context: ...vendor push](/cli/commands/vendor/usage) - Push vendored components - [atmos list c...
(DASH_RULE)
[typographical] ~108-~108: To join two clauses or introduce examples, consider using an em dash.
Context: ...omponents](/cli/commands/list/component) - List available components
(DASH_RULE)
⏰ Context from checks skipped due to timeout of 90000ms (2)
- GitHub Check: Build (windows-latest, windows)
- GitHub Check: Summary
🔇 Additional comments (5)
pkg/list/list_vendor.go (4)
94-140
: LGTM! Well-structured initialization.The function properly validates formats, handles delimiters, and sets up default columns with good error handling.
142-181
: LGTM! Robust file handling implementation.The code properly handles both file and directory cases with appropriate error messages and path processing.
25-92
: 🛠️ Refactor suggestionAdd input validation and improve path handling.
The function should validate inputs and ensure consistent path handling across different platforms.
func processVendorFile(filePath string, atmosConfig schema.AtmosConfiguration) ([]schema.AtmosVendorSource, error) { + if filePath == "" { + return nil, fmt.Errorf("filePath cannot be empty") + } + if atmosConfig.BasePath == "" { + return nil, fmt.Errorf("atmosConfig.BasePath cannot be empty") + } + + // Ensure consistent path format + filePath = filepath.Clean(filepath.ToSlash(filePath)) var vendors []schema.AtmosVendorSourceLikely invalid or redundant comment.
183-302
: 🛠️ Refactor suggestionImplement separate CSV and TSV formats with configurable delimiters.
Based on the PR feedback, we should distinguish between CSV and TSV formats and allow custom delimiters.
switch format { case FormatJSON: // ... existing JSON handling ... case FormatCSV: + if delimiter == "" { + delimiter = DefaultCSVDelimiter + } + var output strings.Builder + output.WriteString(strings.Join(header, delimiter) + utils.GetLineEnding()) + for _, row := range rows { + output.WriteString(strings.Join(row, delimiter) + utils.GetLineEnding()) + } + return output.String(), nil +case FormatTSV: + if delimiter == "" { + delimiter = DefaultTSVDelimiter + } var output strings.Builder output.WriteString(strings.Join(header, delimiter) + utils.GetLineEnding()) for _, row := range rows { output.WriteString(strings.Join(row, delimiter) + utils.GetLineEnding()) } return output.String(), nilLikely invalid or redundant comment.
internal/exec/vendor_utils.go (1)
440-454
: LGTM! Good protection against deeply nested imports.The addition of depth checking prevents stack overflow issues while processing vendor imports.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (3)
pkg/list/list_vendor.go (3)
1-2
: Add package documentation.Consider adding a package-level documentation comment to describe the purpose and functionality of the
list
package.Add this documentation above the package declaration:
+// Package list provides functionality for listing and formatting Atmos configurations, +// including vendor configurations, in various output formats (table, JSON, CSV, TSV). package list
217-229
: Optimize template data map creation.Consider extracting the data map creation to a separate function to improve readability and reusability.
+func createVendorTemplateData(vendor schema.AtmosVendorSource, atmosConfig schema.AtmosConfiguration) map[string]interface{} { + data := map[string]interface{}{ + "Component": vendor.Component, + "Version": vendor.Version, + "Type": "Vendor Manifest", + "File": vendor.File, + "Source": vendor.Source, + "Target": "", + "Tags": vendor.Tags, + "atmos_component": vendor.Component, + "atmos_vendor_type": "Vendor Manifest", + "atmos_vendor_file": vendor.File, + "atmos_vendor_target": "", + } + + if len(vendor.Targets) > 0 { + target := filepath.Join(atmosConfig.BasePath, vendor.Targets[0]) + data["Target"] = target + data["atmos_vendor_target"] = target + } + + return data +}
249-258
: Consider using sort.Slice with a more efficient comparison.The current sorting implementation compares all columns for each row. Consider implementing a more efficient comparison that stops at the first difference.
-sort.Slice(rows, func(i, j int) bool { - for col := 0; col < len(rows[i]); col++ { - if rows[i][col] != rows[j][col] { - return rows[i][col] < rows[j][col] - } - } - return false -}) +sort.Slice(rows, func(i, j int) bool { + // Compare only the first column (usually Component) for better performance + if rows[i][0] != rows[j][0] { + return rows[i][0] < rows[j][0] + } + // If first column is equal, compare second column + if len(rows[i]) > 1 && rows[i][1] != rows[j][1] { + return rows[i][1] < rows[j][1] + } + return false +})
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
pkg/list/list_vendor.go
(1 hunks)pkg/list/list_vendor_test.go
(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- pkg/list/list_vendor_test.go
⏰ Context from checks skipped due to timeout of 90000ms (13)
- GitHub Check: [mock-macos] tests/fixtures/scenarios/complete
- GitHub Check: [mock-macos] examples/demo-vendoring
- GitHub Check: [mock-windows] tests/fixtures/scenarios/complete
- GitHub Check: [mock-windows] examples/demo-vendoring
- GitHub Check: [mock-windows] examples/demo-context
- GitHub Check: [mock-windows] examples/demo-component-versions
- GitHub Check: [mock-linux] tests/fixtures/scenarios/complete
- GitHub Check: Acceptance Tests (macos-latest, macos)
- GitHub Check: Acceptance Tests (windows-latest, windows)
- GitHub Check: Acceptance Tests (ubuntu-latest, linux)
- GitHub Check: [localstack] demo-localstack
- GitHub Check: [k3s] demo-helmfile
- GitHub Check: Summary
🔇 Additional comments (1)
pkg/list/list_vendor.go (1)
25-92
: LGTM! Proper use of existing vendoring logic.The implementation correctly utilizes the existing vendoring infrastructure through
exec.ReadAndProcessVendorConfigFile
andexec.ProcessVendorImports
, maintaining consistency with the established vendoring system.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
internal/exec/vendor_utils.go (1)
440-454
: Consider making maxDepth configurable.While the implementation of depth limit is a good safeguard against stack overflow, consider making the maxDepth configurable through CLI flags or configuration file to accommodate different use cases.
func ProcessVendorImports( atmosConfig schema.AtmosConfiguration, vendorConfigFile string, imports []string, sources []schema.AtmosVendorSource, allImports []string, depth int, - maxDepth int, + maxDepth int, // TODO: Make this configurable via CLI flags or config file ) ([]schema.AtmosVendorSource, []string, error) {
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
internal/exec/vendor_utils.go
(3 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
- GitHub Check: Build (windows-latest, windows)
- GitHub Check: Summary
🔇 Additional comments (2)
internal/exec/vendor_utils.go (2)
279-287
: LGTM! Good defensive programming with depth limits.The addition of depth parameters (0 for initial depth, 50 for max depth) helps prevent stack overflow from deeply nested imports.
481-482
: LGTM! Proper depth tracking in recursive call.The recursive call correctly increments the depth counter and passes the maxDepth parameter.
what
Listing all vendor config in tabular way
why
Evidence:
references
Summary by CodeRabbit
Summary by CodeRabbit
New Features
atmos list vendor
command, including usage examples and output options.Tests
Refactor
ProcessVendorImports
function for better accessibility across packages.