Skip to content

CDTOOL-1328 list version refactor#1774

Draft
anthony-gomez-fastly wants to merge 5 commits intomainfrom
rcaril/CDTOOL-1328-list-version-refactor
Draft

CDTOOL-1328 list version refactor#1774
anthony-gomez-fastly wants to merge 5 commits intomainfrom
rcaril/CDTOOL-1328-list-version-refactor

Conversation

@anthony-gomez-fastly
Copy link
Copy Markdown
Member

Change summary

Performance Optimization - Skip ListVersions API call for numeric versions

Changes to pkg/argparser/flags.go:

  1. OptionalServiceVersion.Parse() - Skip API call for numeric versions
    - Added early return when user provides numeric version (e.g., --version 1)
    - Returns &fastly.Version{Number: n} directly without calling ListVersions API
    - Saves 1 API call per command when numeric version is used
    - Non-numeric versions (e.g., "latest", "active") still call API as before
  2. OptionalAutoClone.Parse() - Handle unknown version state
    - Added stateUnknown check: v.Active == nil && v.Locked == nil
    - Updated autoclone condition to include stateUnknown case
    - Effect: When --autoclone is provided with numeric version, always clones (defensive behavior) since state is unknown
    - Maintains safety while benefiting from optimization

Changes to pkg/argparser/flags_test.go:

  • Updated test "specific version not in list" - now expects success (version 5) instead of error
  • Added explicit Active/Locked fields to "version is editable" test

All Submissions:

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same update/change?

New Feature Submissions:

  • Does your submission pass tests?

Changes to Core Features:

  • Have you written new tests for your core changes, as applicable?
  • Have you successfully run tests with your changes locally?

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.

2 participants