-
Notifications
You must be signed in to change notification settings - Fork 46
RTECO-1011 - Implement skill update all #476
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
Draft
udaykb2
wants to merge
8
commits into
main
Choose a base branch
from
RTECO-1011-implement-skills-update-all
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 3 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
bf0fc76
Add prompt to install & update for version
udaykb2 e59d990
Use --all and --slug for skill update
udaykb2 bbc353e
Merge branch 'main' into RTECO-1011-implement-skills-update-all
udaykb2 f837005
Merge branch 'main' into RTECO-1011-implement-skills-update-all
udaykb2 303272e
Answer review comments
udaykb2 c9ffaf6
fix merge conflicts
udaykb2 d8fdc35
Merge branch 'main' into RTECO-1011-implement-skills-update-all
udaykb2 7f095c2
Merge branch 'main' into RTECO-1011-implement-skills-update-all
udaykb2 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| package common | ||
|
|
||
| import ( | ||
| "fmt" | ||
| "strings" | ||
|
|
||
| prompt "github.com/c-bata/go-prompt" | ||
| "github.com/jfrog/jfrog-cli-core/v2/utils/ioutils" | ||
| "github.com/jfrog/jfrog-client-go/utils/log" | ||
| ) | ||
|
|
||
| // SelectPackageVersion resolves "" / "latest" / exact match / interactive prompt for install and update. | ||
| func SelectPackageVersion(available []string, requested, repoKey string, quiet bool) (string, error) { | ||
| if requested == "" || requested == "latest" { | ||
| latest, err := LatestVersion(available) | ||
| if err != nil { | ||
| return "", fmt.Errorf("failed to determine latest version: %w", err) | ||
| } | ||
| log.Info(fmt.Sprintf("Using latest version: %s", latest)) | ||
| return latest, nil | ||
| } | ||
|
|
||
| for _, version := range available { | ||
| if version == requested { | ||
| return requested, nil | ||
| } | ||
| } | ||
|
|
||
| if quiet || IsNonInteractive() { | ||
| return "", fmt.Errorf( | ||
|
udaykb2 marked this conversation as resolved.
|
||
| "version '%s' not found in repository '%s'.\nAvailable versions: %s", | ||
| requested, repoKey, strings.Join(available, ", "), | ||
| ) | ||
| } | ||
|
|
||
| log.Warn(fmt.Sprintf("Version '%s' not found. Please select from the available versions below.", requested)) | ||
|
udaykb2 marked this conversation as resolved.
|
||
|
|
||
| options := make([]prompt.Suggest, len(available)) | ||
| for idx, version := range available { | ||
| options[idx] = prompt.Suggest{Text: version} | ||
| } | ||
| selected := ioutils.AskFromListWithMismatchConfirmation( | ||
| "Select a version:", | ||
| fmt.Sprintf("'%s' is not in the list of available versions.", requested), | ||
| options, | ||
| ) | ||
| return selected, nil | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| package common | ||
|
|
||
| import ( | ||
| "testing" | ||
|
|
||
| "github.com/stretchr/testify/assert" | ||
| "github.com/stretchr/testify/require" | ||
| ) | ||
|
|
||
| func TestSelectPackageVersion_ExactMatchReturnsIt(t *testing.T) { | ||
| available := []string{"1.0.0", "1.1.0", "2.0.0"} | ||
| got, err := SelectPackageVersion(available, "1.1.0", "skills-local", true) | ||
| require.NoError(t, err) | ||
| assert.Equal(t, "1.1.0", got) | ||
| } | ||
|
|
||
| func TestSelectPackageVersion_LatestEmpty(t *testing.T) { | ||
| available := []string{"1.0.0", "1.1.0", "2.0.0"} | ||
| got, err := SelectPackageVersion(available, "", "plugins-local", true) | ||
| require.NoError(t, err) | ||
| assert.Equal(t, "2.0.0", got) | ||
| } | ||
|
|
||
| func TestSelectPackageVersion_LatestKeyword(t *testing.T) { | ||
| available := []string{"1.0.0", "3.0.0", "2.0.0"} | ||
| got, err := SelectPackageVersion(available, "latest", "plugins-local", true) | ||
| require.NoError(t, err) | ||
| assert.Equal(t, "3.0.0", got) | ||
| } | ||
|
|
||
| func TestSelectPackageVersion_NotFoundQuiet(t *testing.T) { | ||
| available := []string{"1.0.0", "1.1.0"} | ||
| _, err := SelectPackageVersion(available, "9.9.9", "plugins-local", true) | ||
| require.Error(t, err) | ||
| assert.Contains(t, err.Error(), "not found") | ||
| } | ||
|
|
||
| func TestSelectPackageVersion_EmptyAvailableList(t *testing.T) { | ||
| _, err := SelectPackageVersion([]string{}, "", "plugins-local", true) | ||
| require.Error(t, err) | ||
| assert.Contains(t, err.Error(), "latest version") | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.