Skip to content

feat: add domain-zone record list#125

Merged
amstuta merged 1 commit intomainfrom
dev/mjones/list-records
Jan 30, 2026
Merged

feat: add domain-zone record list#125
amstuta merged 1 commit intomainfrom
dev/mjones/list-records

Conversation

@marie-j
Copy link
Contributor

@marie-j marie-j commented Jan 27, 2026

Description

Add ovhcloud domain-zone record list

Fixes #xx (issue)

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Improvement (improvement of existing commands)
  • Breaking change (fix or feature that can break a current behavior)
  • Documentation update

Checklist:

  • My code follows the style guidelines of this project
  • I have commented my code
  • I updated the documentation by running make doc
  • I ran go mod tidy
  • I have added tests that prove my fix is effective or that my feature works

@marie-j marie-j requested a review from a team as a code owner January 27, 2026 16:54
@amstuta amstuta requested a review from Copilot January 27, 2026 16:56
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a new list command to retrieve all DNS records from a domain zone, complementing the existing get command that retrieves a single record by ID.

Changes:

  • Added ListRecords function to fetch and display all DNS records for a specified zone
  • Implemented cell width truncation (50 characters) with ellipsis for long table cell values
  • Added comprehensive test coverage for the new list records functionality

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
internal/services/domainzone/domainzone.go Added ListRecords function and recordColumnsToDisplay variable to support listing DNS records
internal/display/display.go Implemented max cell width truncation (50 chars) with ellipsis for both data tables and config tables
internal/cmd/domainzone_test.go Added test case TestDomainZoneListRecords to verify the list records functionality
internal/cmd/domainzone.go Registered new list subcommand under domain-zone record with filter flag support
doc/ovhcloud_domain-zone_record_list.md Added documentation for the new list command with usage examples and flag descriptions
doc/ovhcloud_domain-zone_record.md Updated parent command documentation to reference the new list subcommand

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

}

// Extract values to display
const maxCellWidth = 50
Copy link

Copilot AI Jan 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The magic number 50 for maxCellWidth is defined twice (lines 119 and 183). Consider defining it once at the package level to avoid duplication and ensure consistency.

Copilot uses AI. Check for mistakes.

// Crop content if it exceeds max width
if len(cellValue) > maxCellWidth {
cellValue = cellValue[:maxCellWidth-3] + "…"
Copy link

Copilot AI Jan 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The magic number 3 for ellipsis length is hardcoded. Consider extracting it as a named constant (e.g., ellipsisLength = 3) to improve code clarity and maintainability.

Copilot uses AI. Check for mistakes.
@marie-j marie-j force-pushed the dev/mjones/list-records branch 2 times, most recently from baddfcd to 0957e3b Compare January 27, 2026 17:23

const (
maxCellWidth = 50
ellipsisLength = 3
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is 1, isn't it?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 char but 3 bytes

}

// Crop content if it exceeds max width
if len(cellValue) > maxCellWidth {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a real truncate function should take into account UTF-8 runes to avoid truncating in the middle of a rune. I don't know if cellValue can contain such rune here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something like:

func truncate(s string, maxLen int) string {
        if len(s) <= maxLen {
                return s
        }

        s = s[:maxLen-len("…")]

        // Be sure we don't truncate in the middle of a UTF-8 rune
        for {
                r, size := utf8.DecodeLastRuneInString(s)
                if r != utf8.RuneError {
                        return s + "…"
                }
                if size == 0 {
                        return "…"
                }
                s = s[:len(s)-size]
        }
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See also github.com/charmbracelet/x/ansi.Truncate as this module is already a dependency.

Signed-off-by: Marie JONES <14836007+marie-j@users.noreply.github.com>
@marie-j marie-j force-pushed the dev/mjones/list-records branch from 0957e3b to 9bf417d Compare January 30, 2026 14:36
@amstuta amstuta merged commit 6057522 into main Jan 30, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants